diff --git a/demos/gtk-demo/panes.c b/demos/gtk-demo/panes.c index 675bc5d9ea..e023cd22ba 100644 --- a/demos/gtk-demo/panes.c +++ b/demos/gtk-demo/panes.c @@ -27,10 +27,16 @@ toggle_resize (GtkWidget *widget, is_child1 = (child == gtk_paned_get_child1 (paned)); - gtk_container_child_get (GTK_CONTAINER (paned), child, - "resize", &resize, - "shrink", &shrink, - NULL); + if (is_child1) + g_object_get (paned, + "resize-child1", &resize, + "shrink-child1", &shrink, + NULL); + else + g_object_get (paned, + "resize-child2", &resize, + "shrink-child2", &shrink, + NULL); g_object_ref (child); gtk_container_remove (GTK_CONTAINER (parent), child); @@ -55,10 +61,16 @@ toggle_shrink (GtkWidget *widget, is_child1 = (child == gtk_paned_get_child1 (paned)); - gtk_container_child_get (GTK_CONTAINER (paned), child, - "resize", &resize, - "shrink", &shrink, - NULL); + if (is_child1) + g_object_get (paned, + "resize-child1", &resize, + "shrink-child1", &shrink, + NULL); + else + g_object_get (paned, + "resize-child2", &resize, + "shrink-child2", &shrink, + NULL); g_object_ref (child); gtk_container_remove (GTK_CONTAINER (parent), child); diff --git a/demos/gtk-demo/sliding_puzzle.c b/demos/gtk-demo/sliding_puzzle.c index 60762342c9..dd1bc65151 100644 --- a/demos/gtk-demo/sliding_puzzle.c +++ b/demos/gtk-demo/sliding_puzzle.c @@ -236,10 +236,7 @@ puzzle_button_pressed (GtkGestureMultiPress *gesture, return; } - gtk_container_child_get (GTK_CONTAINER (grid), child, - "left-attach", &l, - "top-attach", &t, - NULL); + gtk_grid_query_child (GTK_GRID (grid), child, &l, &t, NULL, NULL); if (l == pos_x && t == pos_y) { diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index 6083aaee1b..a7e624f154 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -744,10 +744,8 @@ gtk_combo_box_text_get_type GtkContainer GtkContainer GtkContainerClass -GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID gtk_container_add gtk_container_remove -gtk_container_add_with_properties gtk_container_foreach gtk_container_get_children gtk_container_get_path_for_child @@ -756,19 +754,7 @@ gtk_container_set_focus_vadjustment gtk_container_get_focus_hadjustment gtk_container_set_focus_hadjustment gtk_container_child_type -gtk_container_child_get -gtk_container_child_set -gtk_container_child_get_property -gtk_container_child_set_property -gtk_container_child_get_valist -gtk_container_child_set_valist -gtk_container_child_notify -gtk_container_child_notify_by_pspec gtk_container_forall -gtk_container_class_find_child_property -gtk_container_class_install_child_property -gtk_container_class_install_child_properties -gtk_container_class_list_child_properties GTK_CONTAINER @@ -4485,8 +4471,6 @@ gtk_widget_class_set_accessible_type gtk_widget_class_set_accessible_role gtk_widget_get_accessible gtk_widget_child_focus -gtk_widget_child_notify -gtk_widget_freeze_child_notify gtk_widget_get_child_visible gtk_widget_get_parent gtk_widget_get_settings @@ -4496,7 +4480,6 @@ gtk_widget_get_display gtk_widget_get_size_request gtk_widget_set_child_visible gtk_widget_set_size_request -gtk_widget_thaw_child_notify gtk_widget_list_mnemonic_labels gtk_widget_add_mnemonic_label gtk_widget_remove_mnemonic_label diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index 9fb6d81d9e..bbc6968bdf 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -27,18 +27,16 @@ #include "gtkcontainerprivate.h" #include "gtkadjustment.h" -#include "gtkassistant.h" #include "gtkbuildable.h" #include "gtkbuilderprivate.h" #include "gtkintl.h" -#include "gtkpopovermenu.h" #include "gtkprivate.h" #include "gtkmarshalers.h" #include "gtksizerequest.h" #include "gtkstylecontextprivate.h" #include "gtktypebuiltins.h" #include "gtkwidgetprivate.h" -#include "gtkwindowprivate.h" +//#include "gtkwindowprivate.h" #include "a11y/gtkcontaineraccessibleprivate.h" @@ -53,14 +51,14 @@ * @Short_description: Base class for widgets which contain other widgets * @Title: GtkContainer * - * A GTK+ user interface is constructed by nesting widgets inside widgets. + * A GTK user interface is constructed by nesting widgets inside widgets. * Container widgets are the inner nodes in the resulting tree of widgets: * they contain other widgets. So, for example, you might have a #GtkWindow * containing a #GtkFrame containing a #GtkLabel. If you wanted an image instead * of a textual label inside the frame, you might replace the #GtkLabel widget * with a #GtkImage widget. * - * There are two major kinds of container widgets in GTK+. Both are subclasses + * There are two major kinds of container widgets in GTK. Both are subclasses * of the abstract GtkContainer base class. * * The first type of container widget has a single child widget and derives @@ -83,38 +81,8 @@ * If the GtkContainer implementation has internal children, they should be added * with gtk_widget_set_parent() on init() and removed with gtk_widget_unparent() * in the #GtkWidgetClass.destroy() implementation. + * * See more about implementing custom widgets at https://wiki.gnome.org/HowDoI/CustomWidgets - * - * # Child properties - * - * GtkContainer introduces child properties. - * These are object properties that are not specific - * to either the container or the contained widget, but rather to their relation. - * Typical examples of child properties are the position or pack-type of a widget - * which is contained in a #GtkBox. - * - * Use gtk_container_class_install_child_property() to install child properties - * for a container class and gtk_container_class_find_child_property() or - * gtk_container_class_list_child_properties() to get information about existing - * child properties. - * - * To set the value of a child property, use gtk_container_child_set_property(), - * gtk_container_child_set() or gtk_container_child_set_valist(). - * To obtain the value of a child property, use - * gtk_container_child_get_property(), gtk_container_child_get() or - * gtk_container_child_get_valist(). To emit notification about child property - * changes, use gtk_widget_child_notify(). - * - * # GtkContainer as GtkBuildable - * - * The GtkContainer implementation of the GtkBuildable interface supports - * a element for children, which can contain multiple - * elements that specify child properties for the child. - * - * Child properties can also be marked as translatable using - * the same “translatable”, “comments” and “context” attributes that are used - * for regular properties. - * */ @@ -131,15 +99,7 @@ enum { LAST_SIGNAL }; -#define PARAM_SPEC_PARAM_ID(pspec) ((pspec)->param_id) -#define PARAM_SPEC_SET_PARAM_ID(pspec, id) ((pspec)->param_id = (id)) - - /* --- prototypes --- */ -static void gtk_container_base_class_init (GtkContainerClass *klass); -static void gtk_container_base_class_finalize (GtkContainerClass *klass); -static void gtk_container_class_init (GtkContainerClass *klass); -static void gtk_container_init (GtkContainer *container); static void gtk_container_destroy (GtkWidget *widget); static void gtk_container_add_unimplemented (GtkContainer *container, GtkWidget *widget); @@ -150,7 +110,6 @@ static void gtk_container_compute_expand (GtkWidget *widget, gboolean *vexpand_p); static void gtk_container_real_set_focus_child (GtkContainer *container, GtkWidget *widget); - static void gtk_container_children_callback (GtkWidget *widget, gpointer client_data); static GtkSizeRequestMode gtk_container_get_request_mode (GtkWidget *widget); @@ -160,108 +119,16 @@ static GtkWidgetPath * gtk_container_real_get_path_for_child (GtkContainer *cont /* GtkBuildable */ static void gtk_container_buildable_init (GtkBuildableIface *iface); -static void gtk_container_buildable_add_child (GtkBuildable *buildable, - GtkBuilder *builder, - GObject *child, - const gchar *type); -static gboolean gtk_container_buildable_custom_tag_start (GtkBuildable *buildable, - GtkBuilder *builder, - GObject *child, - const gchar *tagname, - GMarkupParser *parser, - gpointer *data); -static void gtk_container_buildable_custom_tag_end (GtkBuildable *buildable, - GtkBuilder *builder, - GObject *child, - const gchar *tagname, - gpointer data); +static GtkBuildableIface *parent_buildable_iface; -/* --- variables --- */ static GQuark vadjustment_key_id; static GQuark hadjustment_key_id; static guint container_signals[LAST_SIGNAL] = { 0 }; -static gint GtkContainer_private_offset; -static GtkWidgetClass *gtk_container_parent_class = NULL; -extern GParamSpecPool *_gtk_widget_child_property_pool; -extern GObjectNotifyContext *_gtk_widget_child_property_notify_context; -static GtkBuildableIface *parent_buildable_iface; - -/* --- functions --- */ -static inline gpointer -gtk_container_get_instance_private (GtkContainer *self) -{ - return G_STRUCT_MEMBER_P (self, GtkContainer_private_offset); -} - -GType -gtk_container_get_type (void) -{ - static GType container_type = 0; - - if (!container_type) - { - const GTypeInfo container_info = - { - sizeof (GtkContainerClass), - (GBaseInitFunc) gtk_container_base_class_init, - (GBaseFinalizeFunc) gtk_container_base_class_finalize, - (GClassInitFunc) gtk_container_class_init, - NULL /* class_finalize */, - NULL /* class_data */, - sizeof (GtkContainer), - 0 /* n_preallocs */, - (GInstanceInitFunc) gtk_container_init, - NULL, /* value_table */ - }; - - const GInterfaceInfo buildable_info = - { - (GInterfaceInitFunc) gtk_container_buildable_init, - NULL, - NULL - }; - - container_type = - g_type_register_static (GTK_TYPE_WIDGET, I_("GtkContainer"), - &container_info, G_TYPE_FLAG_ABSTRACT); - - GtkContainer_private_offset = - g_type_add_instance_private (container_type, sizeof (GtkContainerPrivate)); - - g_type_add_interface_static (container_type, - GTK_TYPE_BUILDABLE, - &buildable_info); - - } - - return container_type; -} - -static void -gtk_container_base_class_init (GtkContainerClass *class) -{ - /* reset instance specifc class fields that don't get inherited */ - class->set_child_property = NULL; - class->get_child_property = NULL; -} - -static void -gtk_container_base_class_finalize (GtkContainerClass *class) -{ - GList *list, *node; - - list = g_param_spec_pool_list_owned (_gtk_widget_child_property_pool, G_OBJECT_CLASS_TYPE (class)); - for (node = list; node; node = node->next) - { - GParamSpec *pspec = node->data; - - g_param_spec_pool_remove (_gtk_widget_child_property_pool, pspec); - PARAM_SPEC_SET_PARAM_ID (pspec, 0); - g_param_spec_unref (pspec); - } - g_list_free (list); -} +G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GtkContainer, gtk_container, GTK_TYPE_WIDGET, + G_ADD_PRIVATE (GtkContainer) + G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, + gtk_container_buildable_init)) static void gtk_container_class_init (GtkContainerClass *class) @@ -269,8 +136,6 @@ gtk_container_class_init (GtkContainerClass *class) GObjectClass *gobject_class = G_OBJECT_CLASS (class); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); - gtk_container_parent_class = g_type_class_peek_parent (class); - vadjustment_key_id = g_quark_from_static_string ("gtk-vadjustment"); hadjustment_key_id = g_quark_from_static_string ("gtk-hadjustment"); @@ -304,21 +169,9 @@ gtk_container_class_init (GtkContainerClass *class) G_TYPE_NONE, 1, GTK_TYPE_WIDGET); - if (GtkContainer_private_offset != 0) - g_type_class_adjust_private_offset (class, &GtkContainer_private_offset); - gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_CONTAINER_ACCESSIBLE); } -static void -gtk_container_buildable_init (GtkBuildableIface *iface) -{ - parent_buildable_iface = g_type_interface_peek_parent (iface); - iface->add_child = gtk_container_buildable_add_child; - iface->custom_tag_start = gtk_container_buildable_custom_tag_start; - iface->custom_tag_end = gtk_container_buildable_custom_tag_end; -} - static void gtk_container_buildable_add_child (GtkBuildable *buildable, GtkBuilder *builder, @@ -329,13 +182,9 @@ gtk_container_buildable_add_child (GtkBuildable *buildable, _gtk_widget_get_parent (GTK_WIDGET (child)) == NULL) { if (type) - { - GTK_BUILDER_WARN_INVALID_CHILD_TYPE (buildable, type); - } + GTK_BUILDER_WARN_INVALID_CHILD_TYPE (buildable, type); else - { - gtk_container_add (GTK_CONTAINER (buildable), GTK_WIDGET (child)); - } + gtk_container_add (GTK_CONTAINER (buildable), GTK_WIDGET (child)); } else { @@ -343,259 +192,11 @@ gtk_container_buildable_add_child (GtkBuildable *buildable, } } -static inline void -container_set_child_property (GtkContainer *container, - GtkWidget *child, - GParamSpec *pspec, - const GValue *value, - GObjectNotifyQueue *nqueue) -{ - GValue tmp_value = G_VALUE_INIT; - GtkContainerClass *class = g_type_class_peek (pspec->owner_type); - - /* provide a copy to work from, convert (if necessary) and validate */ - g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec)); - if (!g_value_transform (value, &tmp_value)) - g_warning ("unable to set child property '%s' of type '%s' from value of type '%s'", - pspec->name, - g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)), - G_VALUE_TYPE_NAME (value)); - else if (g_param_value_validate (pspec, &tmp_value) && !(pspec->flags & G_PARAM_LAX_VALIDATION)) - { - gchar *contents = g_strdup_value_contents (value); - - g_warning ("value \"%s\" of type '%s' is invalid for property '%s' of type '%s'", - contents, - G_VALUE_TYPE_NAME (value), - pspec->name, - g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec))); - g_free (contents); - } - else - { - class->set_child_property (container, child, PARAM_SPEC_PARAM_ID (pspec), &tmp_value, pspec); - g_object_notify_queue_add (G_OBJECT (child), nqueue, pspec); - } - g_value_unset (&tmp_value); -} - static void -gtk_container_buildable_set_child_property (GtkContainer *container, - GtkBuilder *builder, - GtkWidget *child, - gchar *name, - const gchar *value) +gtk_container_buildable_init (GtkBuildableIface *iface) { - GParamSpec *pspec; - GValue gvalue = G_VALUE_INIT; - GError *error = NULL; - GObjectNotifyQueue *nqueue; - - pspec = gtk_container_class_find_child_property (G_OBJECT_GET_CLASS (container), name); - if (!pspec) - { - g_warning ("%s does not have a child property called %s", - G_OBJECT_TYPE_NAME (container), name); - return; - } - else if (!(pspec->flags & G_PARAM_WRITABLE)) - { - g_warning ("Child property '%s' of container class '%s' is not writable", - name, G_OBJECT_TYPE_NAME (container)); - return; - } - - if (!gtk_builder_value_from_string (builder, pspec, value, &gvalue, &error)) - { - g_warning ("Could not read property %s:%s with value %s of type %s: %s", - g_type_name (G_OBJECT_TYPE (container)), - name, - value, - g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)), - error->message); - g_error_free (error); - return; - } - - g_object_ref (container); - g_object_ref (child); - nqueue = g_object_notify_queue_freeze (G_OBJECT (child), _gtk_widget_child_property_notify_context); - container_set_child_property (container, child, pspec, &gvalue, nqueue); - g_object_notify_queue_thaw (G_OBJECT (child), nqueue); - g_object_unref (container); - g_object_unref (child); - g_value_unset (&gvalue); -} - -typedef struct { - GtkBuilder *builder; - GtkContainer *container; - GtkWidget *child; - GString *string; - gchar *child_prop_name; - gchar *context; - gboolean translatable; -} PackingData; - -static void -packing_start_element (GMarkupParseContext *context, - const gchar *element_name, - const gchar **names, - const gchar **values, - gpointer user_data, - GError **error) -{ - PackingData *data = (PackingData*)user_data; - - if (strcmp (element_name, "property") == 0) - { - const gchar *name; - gboolean translatable = FALSE; - const gchar *ctx = NULL; - - if (!_gtk_builder_check_parent (data->builder, context, "packing", error)) - return; - - if (!g_markup_collect_attributes (element_name, names, values, error, - G_MARKUP_COLLECT_STRING, "name", &name, - G_MARKUP_COLLECT_BOOLEAN|G_MARKUP_COLLECT_OPTIONAL, "translatable", &translatable, - G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "comments", NULL, - G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "context", &ctx, - G_MARKUP_COLLECT_INVALID)) - { - _gtk_builder_prefix_error (data->builder, context, error); - return; - } - - data->child_prop_name = g_strdup (name); - data->translatable = translatable; - data->context = g_strdup (ctx); - } - else if (strcmp (element_name, "packing") == 0) - { - if (!_gtk_builder_check_parent (data->builder, context, "child", error)) - return; - - if (!g_markup_collect_attributes (element_name, names, values, error, - G_MARKUP_COLLECT_INVALID, NULL, NULL, - G_MARKUP_COLLECT_INVALID)) - _gtk_builder_prefix_error (data->builder, context, error); - } - else - { - _gtk_builder_error_unhandled_tag (data->builder, context, - "GtkContainer", element_name, - error); - } -} - -static void -packing_text_element (GMarkupParseContext *context, - const gchar *text, - gsize text_len, - gpointer user_data, - GError **error) -{ - PackingData *data = (PackingData*)user_data; - - if (data->child_prop_name) - g_string_append_len (data->string, text, text_len); -} - -static void -packing_end_element (GMarkupParseContext *context, - const gchar *element_name, - gpointer user_data, - GError **error) -{ - PackingData *data = (PackingData*)user_data; - - /* translate the string */ - if (data->string->len && data->translatable) - { - const gchar *translated; - const gchar *domain; - - domain = gtk_builder_get_translation_domain (data->builder); - - translated = _gtk_builder_parser_translate (domain, - data->context, - data->string->str); - g_string_assign (data->string, translated); - } - - if (data->child_prop_name) - gtk_container_buildable_set_child_property (data->container, - data->builder, - data->child, - data->child_prop_name, - data->string->str); - - g_string_set_size (data->string, 0); - g_clear_pointer (&data->child_prop_name, g_free); - g_clear_pointer (&data->context, g_free); - data->translatable = FALSE; -} - -static const GMarkupParser packing_parser = - { - packing_start_element, - packing_end_element, - packing_text_element, - }; - -static gboolean -gtk_container_buildable_custom_tag_start (GtkBuildable *buildable, - GtkBuilder *builder, - GObject *child, - const gchar *tagname, - GMarkupParser *parser, - gpointer *parser_data) -{ - if (parent_buildable_iface->custom_tag_start (buildable, builder, child, - tagname, parser, parser_data)) - return TRUE; - - if (child && strcmp (tagname, "packing") == 0) - { - PackingData *data; - - data = g_slice_new0 (PackingData); - data->string = g_string_new (""); - data->builder = builder; - data->container = GTK_CONTAINER (buildable); - data->child = GTK_WIDGET (child); - data->child_prop_name = NULL; - - *parser = packing_parser; - *parser_data = data; - - return TRUE; - } - - return FALSE; -} - -static void -gtk_container_buildable_custom_tag_end (GtkBuildable *buildable, - GtkBuilder *builder, - GObject *child, - const gchar *tagname, - gpointer parser_data) -{ - if (strcmp (tagname, "packing") == 0) - { - PackingData *data = (PackingData*)parser_data; - - g_string_free (data->string, TRUE); - g_slice_free (PackingData, data); - - return; - } - - if (parent_buildable_iface->custom_tag_end) - parent_buildable_iface->custom_tag_end (buildable, builder, - child, tagname, parser_data); + parent_buildable_iface = g_type_interface_peek_parent (iface); + iface->add_child = gtk_container_buildable_add_child; } /** @@ -608,633 +209,31 @@ gtk_container_buildable_custom_tag_end (GtkBuildable *buildable, * children can be added, e.g. for a #GtkPaned which already has two * children. * - * Returns: a #GType. + * Returns: a #GType **/ GType gtk_container_child_type (GtkContainer *container) { - GType slot; - GtkContainerClass *class; - g_return_val_if_fail (GTK_IS_CONTAINER (container), 0); - class = GTK_CONTAINER_GET_CLASS (container); - if (class->child_type) - slot = class->child_type (container); + if (GTK_CONTAINER_GET_CLASS (container)->child_type) + return GTK_CONTAINER_GET_CLASS (container)->child_type (container); else - slot = G_TYPE_NONE; - - return slot; -} - -/* --- GtkContainer child property mechanism --- */ - -/** - * gtk_container_child_notify: - * @container: the #GtkContainer - * @child: the child widget - * @child_property: the name of a child property installed on - * the class of @container - * - * Emits a #GtkWidget::child-notify signal for the - * [child property][child-properties] - * @child_property on the child. - * - * This is an analogue of g_object_notify() for child properties. - * - * Also see gtk_widget_child_notify(). - */ -void -gtk_container_child_notify (GtkContainer *container, - GtkWidget *child, - const gchar *child_property) -{ - GObject *obj; - GParamSpec *pspec; - - g_return_if_fail (GTK_IS_CONTAINER (container)); - g_return_if_fail (GTK_IS_WIDGET (child)); - g_return_if_fail (child_property != NULL); - - obj = G_OBJECT (child); - - if (obj->ref_count == 0) - return; - - g_object_ref (obj); - - pspec = g_param_spec_pool_lookup (_gtk_widget_child_property_pool, - child_property, - G_OBJECT_TYPE (container), - TRUE); - - if (pspec == NULL) - { - g_warning ("%s: container class '%s' has no child property named '%s'", - G_STRLOC, - G_OBJECT_TYPE_NAME (container), - child_property); - } - else - { - GObjectNotifyQueue *nqueue; - - nqueue = g_object_notify_queue_freeze (obj, _gtk_widget_child_property_notify_context); - - g_object_notify_queue_add (obj, nqueue, pspec); - g_object_notify_queue_thaw (obj, nqueue); - } - - g_object_unref (obj); -} - -/** - * gtk_container_child_notify_by_pspec: - * @container: the #GtkContainer - * @child: the child widget - * @pspec: the #GParamSpec of a child property instealled on - * the class of @container - * - * Emits a #GtkWidget::child-notify signal for the - * [child property][child-properties] specified by - * @pspec on the child. - * - * This is an analogue of g_object_notify_by_pspec() for child properties. - */ -void -gtk_container_child_notify_by_pspec (GtkContainer *container, - GtkWidget *child, - GParamSpec *pspec) -{ - GObject *obj = G_OBJECT (child); - GObjectNotifyQueue *nqueue; - - g_return_if_fail (GTK_IS_CONTAINER (container)); - g_return_if_fail (GTK_IS_WIDGET (child)); - g_return_if_fail (G_IS_PARAM_SPEC (pspec)); - - if (obj->ref_count == 0) - return; - - g_object_ref (obj); - - nqueue = g_object_notify_queue_freeze (obj, _gtk_widget_child_property_notify_context); - - g_object_notify_queue_add (obj, nqueue, pspec); - g_object_notify_queue_thaw (obj, nqueue); - - g_object_unref (obj); -} - -static inline void -container_get_child_property (GtkContainer *container, - GtkWidget *child, - GParamSpec *pspec, - GValue *value) -{ - GtkContainerClass *class = g_type_class_peek (pspec->owner_type); - - class->get_child_property (container, child, PARAM_SPEC_PARAM_ID (pspec), value, pspec); -} - -/** - * gtk_container_child_get_valist: - * @container: a #GtkContainer - * @child: a widget which is a child of @container - * @first_property_name: the name of the first property to get - * @var_args: return location for the first property, followed - * optionally by more name/return location pairs, followed by %NULL - * - * Gets the values of one or more child properties for @child and @container. - **/ -void -gtk_container_child_get_valist (GtkContainer *container, - GtkWidget *child, - const gchar *first_property_name, - va_list var_args) -{ - const gchar *name; - - g_return_if_fail (GTK_IS_CONTAINER (container)); - g_return_if_fail (GTK_IS_WIDGET (child)); - - g_object_ref (container); - g_object_ref (child); - - name = first_property_name; - while (name) - { - GValue value = G_VALUE_INIT; - GParamSpec *pspec; - gchar *error; - - pspec = g_param_spec_pool_lookup (_gtk_widget_child_property_pool, - name, - G_OBJECT_TYPE (container), - TRUE); - if (!pspec) - { - g_warning ("%s: container class '%s' has no child property named '%s'", - G_STRLOC, - G_OBJECT_TYPE_NAME (container), - name); - break; - } - if (!(pspec->flags & G_PARAM_READABLE)) - { - g_warning ("%s: child property '%s' of container class '%s' is not readable", - G_STRLOC, - pspec->name, - G_OBJECT_TYPE_NAME (container)); - break; - } - g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec)); - container_get_child_property (container, child, pspec, &value); - G_VALUE_LCOPY (&value, var_args, 0, &error); - if (error) - { - g_warning ("%s: %s", G_STRLOC, error); - g_free (error); - g_value_unset (&value); - break; - } - g_value_unset (&value); - name = va_arg (var_args, gchar*); - } - - g_object_unref (child); - g_object_unref (container); -} - -/** - * gtk_container_child_get_property: - * @container: a #GtkContainer - * @child: a widget which is a child of @container - * @property_name: the name of the property to get - * @value: a location to return the value - * - * Gets the value of a child property for @child and @container. - **/ -void -gtk_container_child_get_property (GtkContainer *container, - GtkWidget *child, - const gchar *property_name, - GValue *value) -{ - GParamSpec *pspec; - - g_return_if_fail (GTK_IS_CONTAINER (container)); - g_return_if_fail (GTK_IS_WIDGET (child)); - g_return_if_fail (property_name != NULL); - g_return_if_fail (G_IS_VALUE (value)); - - g_object_ref (container); - g_object_ref (child); - pspec = g_param_spec_pool_lookup (_gtk_widget_child_property_pool, property_name, - G_OBJECT_TYPE (container), TRUE); - if (!pspec) - g_warning ("%s: container class '%s' has no child property named '%s'", - G_STRLOC, - G_OBJECT_TYPE_NAME (container), - property_name); - else if (!(pspec->flags & G_PARAM_READABLE)) - g_warning ("%s: child property '%s' of container class '%s' is not readable", - G_STRLOC, - pspec->name, - G_OBJECT_TYPE_NAME (container)); - else - { - GValue *prop_value, tmp_value = G_VALUE_INIT; - - /* auto-conversion of the callers value type - */ - if (G_VALUE_TYPE (value) == G_PARAM_SPEC_VALUE_TYPE (pspec)) - { - g_value_reset (value); - prop_value = value; - } - else if (!g_value_type_transformable (G_PARAM_SPEC_VALUE_TYPE (pspec), G_VALUE_TYPE (value))) - { - g_warning ("can't retrieve child property '%s' of type '%s' as value of type '%s'", - pspec->name, - g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)), - G_VALUE_TYPE_NAME (value)); - g_object_unref (child); - g_object_unref (container); - return; - } - else - { - g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec)); - prop_value = &tmp_value; - } - container_get_child_property (container, child, pspec, prop_value); - if (prop_value != value) - { - g_value_transform (prop_value, value); - g_value_unset (&tmp_value); - } - } - g_object_unref (child); - g_object_unref (container); -} - -/** - * gtk_container_child_set_valist: - * @container: a #GtkContainer - * @child: a widget which is a child of @container - * @first_property_name: the name of the first property to set - * @var_args: a %NULL-terminated list of property names and values, starting - * with @first_prop_name - * - * Sets one or more child properties for @child and @container. - **/ -void -gtk_container_child_set_valist (GtkContainer *container, - GtkWidget *child, - const gchar *first_property_name, - va_list var_args) -{ - GObjectNotifyQueue *nqueue; - const gchar *name; - - g_return_if_fail (GTK_IS_CONTAINER (container)); - g_return_if_fail (GTK_IS_WIDGET (child)); - - g_object_ref (container); - g_object_ref (child); - - nqueue = g_object_notify_queue_freeze (G_OBJECT (child), _gtk_widget_child_property_notify_context); - name = first_property_name; - while (name) - { - GValue value = G_VALUE_INIT; - gchar *error = NULL; - GParamSpec *pspec = g_param_spec_pool_lookup (_gtk_widget_child_property_pool, - name, - G_OBJECT_TYPE (container), - TRUE); - if (!pspec) - { - g_warning ("%s: container class '%s' has no child property named '%s'", - G_STRLOC, - G_OBJECT_TYPE_NAME (container), - name); - break; - } - if (!(pspec->flags & G_PARAM_WRITABLE)) - { - g_warning ("%s: child property '%s' of container class '%s' is not writable", - G_STRLOC, - pspec->name, - G_OBJECT_TYPE_NAME (container)); - break; - } - - G_VALUE_COLLECT_INIT (&value, G_PARAM_SPEC_VALUE_TYPE (pspec), - var_args, 0, &error); - if (error) - { - g_warning ("%s: %s", G_STRLOC, error); - g_free (error); - - /* we purposely leak the value here, it might not be - * in a sane state if an error condition occoured - */ - break; - } - container_set_child_property (container, child, pspec, &value, nqueue); - g_value_unset (&value); - name = va_arg (var_args, gchar*); - } - g_object_notify_queue_thaw (G_OBJECT (child), nqueue); - - g_object_unref (container); - g_object_unref (child); -} - -/** - * gtk_container_child_set_property: - * @container: a #GtkContainer - * @child: a widget which is a child of @container - * @property_name: the name of the property to set - * @value: the value to set the property to - * - * Sets a child property for @child and @container. - **/ -void -gtk_container_child_set_property (GtkContainer *container, - GtkWidget *child, - const gchar *property_name, - const GValue *value) -{ - GObjectNotifyQueue *nqueue; - GParamSpec *pspec; - - g_return_if_fail (GTK_IS_CONTAINER (container)); - g_return_if_fail (GTK_IS_WIDGET (child)); - g_return_if_fail (property_name != NULL); - g_return_if_fail (G_IS_VALUE (value)); - - g_object_ref (container); - g_object_ref (child); - - nqueue = g_object_notify_queue_freeze (G_OBJECT (child), _gtk_widget_child_property_notify_context); - pspec = g_param_spec_pool_lookup (_gtk_widget_child_property_pool, property_name, - G_OBJECT_TYPE (container), TRUE); - if (!pspec) - g_warning ("%s: container class '%s' has no child property named '%s'", - G_STRLOC, - G_OBJECT_TYPE_NAME (container), - property_name); - else if (!(pspec->flags & G_PARAM_WRITABLE)) - g_warning ("%s: child property '%s' of container class '%s' is not writable", - G_STRLOC, - pspec->name, - G_OBJECT_TYPE_NAME (container)); - else - { - container_set_child_property (container, child, pspec, value, nqueue); - } - g_object_notify_queue_thaw (G_OBJECT (child), nqueue); - g_object_unref (container); - g_object_unref (child); -} - -/** - * gtk_container_add_with_properties: - * @container: a #GtkContainer - * @widget: a widget to be placed inside @container - * @first_prop_name: the name of the first child property to set - * @...: a %NULL-terminated list of property names and values, starting - * with @first_prop_name - * - * Adds @widget to @container, setting child properties at the same time. - * See gtk_container_add() and gtk_container_child_set() for more details. - */ -void -gtk_container_add_with_properties (GtkContainer *container, - GtkWidget *widget, - const gchar *first_prop_name, - ...) -{ - g_return_if_fail (GTK_IS_CONTAINER (container)); - g_return_if_fail (GTK_IS_WIDGET (widget)); - g_return_if_fail (_gtk_widget_get_parent (widget) == NULL); - - g_object_ref (container); - g_object_ref (widget); - gtk_widget_freeze_child_notify (widget); - - g_signal_emit (container, container_signals[ADD], 0, widget); - if (_gtk_widget_get_parent (widget)) - { - va_list var_args; - - va_start (var_args, first_prop_name); - gtk_container_child_set_valist (container, widget, first_prop_name, var_args); - va_end (var_args); - } - - gtk_widget_thaw_child_notify (widget); - g_object_unref (widget); - g_object_unref (container); -} - -/** - * gtk_container_child_set: - * @container: a #GtkContainer - * @child: a widget which is a child of @container - * @first_prop_name: the name of the first property to set - * @...: a %NULL-terminated list of property names and values, starting - * with @first_prop_name - * - * Sets one or more child properties for @child and @container. - */ -void -gtk_container_child_set (GtkContainer *container, - GtkWidget *child, - const gchar *first_prop_name, - ...) -{ - va_list var_args; - - va_start (var_args, first_prop_name); - gtk_container_child_set_valist (container, child, first_prop_name, var_args); - va_end (var_args); -} - -/** - * gtk_container_child_get: - * @container: a #GtkContainer - * @child: a widget which is a child of @container - * @first_prop_name: the name of the first property to get - * @...: return location for the first property, followed - * optionally by more name/return location pairs, followed by %NULL - * - * Gets the values of one or more child properties for @child and @container. - */ -void -gtk_container_child_get (GtkContainer *container, - GtkWidget *child, - const gchar *first_prop_name, - ...) -{ - va_list var_args; - - va_start (var_args, first_prop_name); - gtk_container_child_get_valist (container, child, first_prop_name, var_args); - va_end (var_args); -} - -static inline void -install_child_property_internal (GType g_type, - guint property_id, - GParamSpec *pspec) -{ - if (g_param_spec_pool_lookup (_gtk_widget_child_property_pool, pspec->name, g_type, FALSE)) - { - g_warning ("Class '%s' already contains a child property named '%s'", - g_type_name (g_type), - pspec->name); - return; - } - g_param_spec_ref (pspec); - g_param_spec_sink (pspec); - PARAM_SPEC_SET_PARAM_ID (pspec, property_id); - g_param_spec_pool_insert (_gtk_widget_child_property_pool, pspec, g_type); -} - -/** - * gtk_container_class_install_child_property: - * @cclass: a #GtkContainerClass - * @property_id: the id for the property - * @pspec: the #GParamSpec for the property - * - * Installs a child property on a container class. - **/ -void -gtk_container_class_install_child_property (GtkContainerClass *cclass, - guint property_id, - GParamSpec *pspec) -{ - g_return_if_fail (GTK_IS_CONTAINER_CLASS (cclass)); - g_return_if_fail (G_IS_PARAM_SPEC (pspec)); - if (pspec->flags & G_PARAM_WRITABLE) - g_return_if_fail (cclass->set_child_property != NULL); - if (pspec->flags & G_PARAM_READABLE) - g_return_if_fail (cclass->get_child_property != NULL); - g_return_if_fail (property_id > 0); - g_return_if_fail (PARAM_SPEC_PARAM_ID (pspec) == 0); /* paranoid */ - if (pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)) - g_return_if_fail ((pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)) == 0); - - install_child_property_internal (G_OBJECT_CLASS_TYPE (cclass), property_id, pspec); -} - -/** - * gtk_container_class_install_child_properties: - * @cclass: a #GtkContainerClass - * @n_pspecs: the length of the #GParamSpec array - * @pspecs: (array length=n_pspecs): the #GParamSpec array defining the new - * child properties - * - * Installs child properties on a container class. - */ -void -gtk_container_class_install_child_properties (GtkContainerClass *cclass, - guint n_pspecs, - GParamSpec **pspecs) -{ - gint i; - - g_return_if_fail (GTK_IS_CONTAINER_CLASS (cclass)); - g_return_if_fail (n_pspecs > 1); - g_return_if_fail (pspecs[0] == NULL); - - /* we skip the first element of the array as it would have a 0 prop_id */ - for (i = 1; i < n_pspecs; i++) - { - GParamSpec *pspec = pspecs[i]; - - g_return_if_fail (G_IS_PARAM_SPEC (pspec)); - if (pspec->flags & G_PARAM_WRITABLE) - g_return_if_fail (cclass->set_child_property != NULL); - if (pspec->flags & G_PARAM_READABLE) - g_return_if_fail (cclass->get_child_property != NULL); - g_return_if_fail (PARAM_SPEC_PARAM_ID (pspec) == 0); /* paranoid */ - if (pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)) - g_return_if_fail ((pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)) == 0); - - install_child_property_internal (G_OBJECT_CLASS_TYPE (cclass), i, pspec); - } -} - -/** - * gtk_container_class_find_child_property: - * @cclass: (type GtkContainerClass): a #GtkContainerClass - * @property_name: the name of the child property to find - * - * Finds a child property of a container class by name. - * - * Returns: (nullable) (transfer none): the #GParamSpec of the child - * property or %NULL if @class has no child property with that - * name. - */ -GParamSpec* -gtk_container_class_find_child_property (GObjectClass *cclass, - const gchar *property_name) -{ - g_return_val_if_fail (GTK_IS_CONTAINER_CLASS (cclass), NULL); - g_return_val_if_fail (property_name != NULL, NULL); - - return g_param_spec_pool_lookup (_gtk_widget_child_property_pool, - property_name, - G_OBJECT_CLASS_TYPE (cclass), - TRUE); -} - -/** - * gtk_container_class_list_child_properties: - * @cclass: (type GtkContainerClass): a #GtkContainerClass - * @n_properties: location to return the number of child properties found - * - * Returns all child properties of a container class. - * - * Returns: (array length=n_properties) (transfer container): - * a newly allocated %NULL-terminated array of #GParamSpec*. - * The array must be freed with g_free(). - */ -GParamSpec** -gtk_container_class_list_child_properties (GObjectClass *cclass, - guint *n_properties) -{ - GParamSpec **pspecs; - guint n; - - g_return_val_if_fail (GTK_IS_CONTAINER_CLASS (cclass), NULL); - - pspecs = g_param_spec_pool_list (_gtk_widget_child_property_pool, - G_OBJECT_CLASS_TYPE (cclass), - &n); - if (n_properties) - *n_properties = n; - - return pspecs; + return G_TYPE_NONE; } static void -gtk_container_add_unimplemented (GtkContainer *container, - GtkWidget *widget) +gtk_container_add_unimplemented (GtkContainer *container, + GtkWidget *widget) { - g_warning ("GtkContainerClass::add not implemented for '%s'", g_type_name (G_TYPE_FROM_INSTANCE (container))); + g_warning ("GtkContainerClass::add not implemented for '%s'", G_OBJECT_TYPE_NAME (container)); } static void -gtk_container_remove_unimplemented (GtkContainer *container, - GtkWidget *widget) +gtk_container_remove_unimplemented (GtkContainer *container, + GtkWidget *widget) { - g_warning ("GtkContainerClass::remove not implemented for '%s'", g_type_name (G_TYPE_FROM_INSTANCE (container))); + g_warning ("GtkContainerClass::remove not implemented for '%s'", G_OBJECT_TYPE_NAME (container)); } static void @@ -1290,9 +289,9 @@ gtk_container_add (GtkContainer *container, g_warning ("Attempting to add a widget with type %s to a container of " "type %s, but the widget is already inside a container of type %s, " "please remove the widget from its existing container first." , - g_type_name (G_OBJECT_TYPE (widget)), - g_type_name (G_OBJECT_TYPE (container)), - g_type_name (G_OBJECT_TYPE (parent))); + G_OBJECT_TYPE_NAME (widget), + G_OBJECT_TYPE_NAME (container), + G_OBJECT_TYPE_NAME (parent)); return; } @@ -1498,9 +497,7 @@ gtk_container_forall (GtkContainer *container, g_return_if_fail (GTK_IS_CONTAINER (container)); g_return_if_fail (callback != NULL); - gtk_widget_forall (GTK_WIDGET (container), - callback, - callback_data); + gtk_widget_forall (GTK_WIDGET (container), callback, callback_data); } /** @@ -1526,15 +523,11 @@ gtk_container_foreach (GtkContainer *container, GtkCallback callback, gpointer callback_data) { - GtkContainerClass *class; - g_return_if_fail (GTK_IS_CONTAINER (container)); g_return_if_fail (callback != NULL); - class = GTK_CONTAINER_GET_CLASS (container); - - if (class->forall) - class->forall (container, callback, callback_data); + if (GTK_CONTAINER_GET_CLASS (container)->forall) + GTK_CONTAINER_GET_CLASS (container)->forall (container, callback, callback_data); } /** @@ -1660,10 +653,8 @@ gtk_container_real_get_path_for_child (GtkContainer *container, GtkWidget *child) { GtkWidgetPath *path; - GtkWidget *widget = GTK_WIDGET (container); - - path = _gtk_widget_create_path (widget); + path = _gtk_widget_create_path (GTK_WIDGET (container)); gtk_widget_path_append_for_widget (path, child); return path; diff --git a/gtk/gtkcontainer.h b/gtk/gtkcontainer.h index 4e2aa50aec..f092e40c86 100644 --- a/gtk/gtkcontainer.h +++ b/gtk/gtkcontainer.h @@ -83,16 +83,6 @@ struct _GtkContainerClass void (*set_focus_child) (GtkContainer *container, GtkWidget *child); GType (*child_type) (GtkContainer *container); - void (*set_child_property) (GtkContainer *container, - GtkWidget *child, - guint property_id, - const GValue *value, - GParamSpec *pspec); - void (*get_child_property) (GtkContainer *container, - GtkWidget *child, - guint property_id, - GValue *value, - GParamSpec *pspec); GtkWidgetPath * (*get_path_for_child) (GtkContainer *container, GtkWidget *child); @@ -145,81 +135,6 @@ GtkAdjustment *gtk_container_get_focus_hadjustment (GtkContainer *container); GDK_AVAILABLE_IN_ALL GType gtk_container_child_type (GtkContainer *container); - -GDK_AVAILABLE_IN_ALL -void gtk_container_class_install_child_property (GtkContainerClass *cclass, - guint property_id, - GParamSpec *pspec); -GDK_AVAILABLE_IN_ALL -void gtk_container_class_install_child_properties (GtkContainerClass *cclass, - guint n_pspecs, - GParamSpec **pspecs); -GDK_AVAILABLE_IN_ALL -GParamSpec* gtk_container_class_find_child_property (GObjectClass *cclass, - const gchar *property_name); -GDK_AVAILABLE_IN_ALL -GParamSpec** gtk_container_class_list_child_properties (GObjectClass *cclass, - guint *n_properties); -GDK_AVAILABLE_IN_ALL -void gtk_container_add_with_properties (GtkContainer *container, - GtkWidget *widget, - const gchar *first_prop_name, - ...) G_GNUC_NULL_TERMINATED; -GDK_AVAILABLE_IN_ALL -void gtk_container_child_set (GtkContainer *container, - GtkWidget *child, - const gchar *first_prop_name, - ...) G_GNUC_NULL_TERMINATED; -GDK_AVAILABLE_IN_ALL -void gtk_container_child_get (GtkContainer *container, - GtkWidget *child, - const gchar *first_prop_name, - ...) G_GNUC_NULL_TERMINATED; -GDK_AVAILABLE_IN_ALL -void gtk_container_child_set_valist (GtkContainer *container, - GtkWidget *child, - const gchar *first_property_name, - va_list var_args); -GDK_AVAILABLE_IN_ALL -void gtk_container_child_get_valist (GtkContainer *container, - GtkWidget *child, - const gchar *first_property_name, - va_list var_args); -GDK_AVAILABLE_IN_ALL -void gtk_container_child_set_property (GtkContainer *container, - GtkWidget *child, - const gchar *property_name, - const GValue *value); -GDK_AVAILABLE_IN_ALL -void gtk_container_child_get_property (GtkContainer *container, - GtkWidget *child, - const gchar *property_name, - GValue *value); - -GDK_AVAILABLE_IN_ALL -void gtk_container_child_notify (GtkContainer *container, - GtkWidget *child, - const gchar *child_property); - -GDK_AVAILABLE_IN_ALL -void gtk_container_child_notify_by_pspec (GtkContainer *container, - GtkWidget *child, - GParamSpec *pspec); - -/** - * GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID: - * @object: the #GObject on which set_child_property() or get_child_property() - * was called - * @property_id: the numeric id of the property - * @pspec: the #GParamSpec of the property - * - * This macro should be used to emit a standard warning about unexpected - * properties in set_child_property() and get_child_property() implementations. - */ -#define GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID(object, property_id, pspec) \ - G_OBJECT_WARN_INVALID_PSPEC ((object), "child property", (property_id), (pspec)) - - GDK_AVAILABLE_IN_ALL void gtk_container_forall (GtkContainer *container, GtkCallback callback, diff --git a/gtk/gtkgrid.c b/gtk/gtkgrid.c index ce67b00609..fdc3bec99e 100644 --- a/gtk/gtkgrid.c +++ b/gtk/gtkgrid.c @@ -1080,10 +1080,10 @@ gtk_grid_get_baseline_row (GtkGrid *grid) * gtk_grid_query_child: * @grid: a #GtkGrid * @child: a #GtkWidget child of @grid - * @left: (out): the column used to attach the left side of @child - * @top: (out): the row used to attach the top side of @child - * @width: (out): the number of columns @child spans - * @height: (out): the number of rows @child spans + * @left: (out) (optional): the column used to attach the left side of @child + * @top: (out) (optional): the row used to attach the top side of @child + * @width: (out) (optional): the number of columns @child spans + * @height: (out) (optiona): the number of rows @child spans * * Queries the attach points and spans of @child inside the given #GtkGrid. */ diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 868bbfa956..94c2b04ed0 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -3378,6 +3378,7 @@ do_detach_tab (GtkNotebook *from, gboolean tab_expand, tab_fill, reorderable, detachable; GList *element; gint page_num; + GtkNotebookPage *page; menu_label = gtk_notebook_get_menu_label (from, child); @@ -3391,13 +3392,13 @@ do_detach_tab (GtkNotebook *from, g_object_ref (child); - gtk_container_child_get (GTK_CONTAINER (from), - child, - "tab-expand", &tab_expand, - "tab-fill", &tab_fill, - "reorderable", &reorderable, - "detachable", &detachable, - NULL); + page = gtk_notebook_get_page (from, child); + g_object_get (page, + "tab-expand", &tab_expand, + "tab-fill", &tab_fill, + "reorderable", &reorderable, + "detachable", &detachable, + NULL); gtk_notebook_detach_tab (from, child); @@ -3405,12 +3406,14 @@ do_detach_tab (GtkNotebook *from, page_num = g_list_position (to_priv->children, element); gtk_notebook_insert_page_menu (to, child, tab_label, menu_label, page_num); - gtk_container_child_set (GTK_CONTAINER (to), child, - "tab-expand", tab_expand, - "tab-fill", tab_fill, - "reorderable", reorderable, - "detachable", detachable, - NULL); + page = gtk_notebook_get_page (to, child); + g_object_set (page, + "tab-expand", tab_expand, + "tab-fill", tab_fill, + "reorderable", reorderable, + "detachable", detachable, + NULL); + if (child) g_object_unref (child); diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c index 4ed06155f1..b39057023f 100644 --- a/gtk/gtkpaned.c +++ b/gtk/gtkpaned.c @@ -174,12 +174,6 @@ enum { PROP_ORIENTATION, }; -enum { - CHILD_PROP_0, - CHILD_PROP_RESIZE, - CHILD_PROP_SHRINK -}; - enum { CYCLE_CHILD_FOCUS, TOGGLE_HANDLE_FOCUS, diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c index c3e1d4a3b6..7f4dacc512 100644 --- a/gtk/gtkprintunixdialog.c +++ b/gtk/gtkprintunixdialog.c @@ -1359,17 +1359,14 @@ add_option_to_extension_point (GtkPrinterOption *option, static gint grid_rows (GtkGrid *table) { - gint t0, t1, t, h; + gint t0, t1, l, t, w, h; GList *children, *c; children = gtk_container_get_children (GTK_CONTAINER (table)); t0 = t1 = 0; for (c = children; c; c = c->next) { - gtk_container_child_get (GTK_CONTAINER (table), c->data, - "top-attach", &t, - "height", &h, - NULL); + gtk_grid_query_child (table, c->data, &l, &t, &w, &h); if (c == children) { t0 = t; diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index be0a2e8126..64deee9542 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -627,9 +627,6 @@ static gboolean gtk_widget_real_query_tooltip (GtkWidget *widget, GtkTooltip *tooltip); static void gtk_widget_real_style_updated (GtkWidget *widget); -static void gtk_widget_dispatch_child_properties_changed (GtkWidget *object, - guint n_pspecs, - GParamSpec **pspecs); static gboolean gtk_widget_real_focus (GtkWidget *widget, GtkDirectionType direction); static void gtk_widget_real_move_focus (GtkWidget *widget, @@ -689,6 +686,11 @@ static gboolean gtk_widget_buildable_custom_tag_start (GtkBuildable const gchar *tagname, GMarkupParser *parser, gpointer *data); +static void gtk_widget_buildable_custom_tag_end (GtkBuildable *buildable, + GtkBuilder *builder, + GObject *child, + const gchar *tagname, + gpointer data); static void gtk_widget_buildable_custom_finished (GtkBuildable *buildable, GtkBuilder *builder, GObject *child, @@ -804,14 +806,6 @@ gtk_widget_base_class_init (gpointer g_class) klass->priv->template = NULL; } -static void -child_property_notify_dispatcher (GObject *object, - guint n_pspecs, - GParamSpec **pspecs) -{ - GTK_WIDGET_GET_CLASS (object)->dispatch_child_properties_changed (GTK_WIDGET (object), n_pspecs, pspecs); -} - static void gtk_widget_real_snapshot (GtkWidget *widget, GtkSnapshot *snapshot) @@ -924,7 +918,6 @@ gtk_widget_real_unroot (GtkWidget *widget) static void gtk_widget_class_init (GtkWidgetClass *klass) { - static GObjectNotifyContext cpn_context = { 0, NULL, NULL }; GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GtkBindingSet *binding_set; @@ -946,11 +939,6 @@ gtk_widget_class_init (GtkWidgetClass *klass) quark_font_options = g_quark_from_static_string ("gtk-widget-font-options"); quark_font_map = g_quark_from_static_string ("gtk-widget-font-map"); - _gtk_widget_child_property_pool = g_param_spec_pool_new (TRUE); - cpn_context.quark_notify_queue = g_quark_from_static_string ("GtkWidget-child-property-notify-queue"); - cpn_context.dispatcher = child_property_notify_dispatcher; - _gtk_widget_child_property_notify_context = &cpn_context; - gobject_class->constructed = gtk_widget_constructed; gobject_class->dispose = gtk_widget_dispose; gobject_class->finalize = gtk_widget_finalize; @@ -960,7 +948,6 @@ gtk_widget_class_init (GtkWidgetClass *klass) klass->destroy = gtk_widget_real_destroy; klass->activate_signal = 0; - klass->dispatch_child_properties_changed = gtk_widget_dispatch_child_properties_changed; klass->show = gtk_widget_real_show; klass->hide = gtk_widget_real_hide; klass->map = gtk_widget_real_map; @@ -975,7 +962,6 @@ gtk_widget_class_init (GtkWidgetClass *klass) klass->state_flags_changed = gtk_widget_real_state_flags_changed; klass->direction_changed = gtk_widget_real_direction_changed; klass->grab_notify = gtk_widget_real_grab_notify; - klass->child_notify = NULL; klass->snapshot = gtk_widget_real_snapshot; klass->mnemonic_activate = gtk_widget_real_mnemonic_activate; klass->grab_focus = gtk_widget_real_grab_focus; @@ -1673,25 +1659,6 @@ gtk_widget_class_init (GtkWidgetClass *klass) G_TYPE_NONE, 1, G_TYPE_BOOLEAN); - /** - * GtkWidget::child-notify: - * @widget: the object which received the signal - * @child_property: the #GParamSpec of the changed child property - * - * The ::child-notify signal is emitted for each - * [child property][child-properties] that has - * changed on an object. The signal's detail holds the property name. - */ - widget_signals[CHILD_NOTIFY] = - g_signal_new (I_("child-notify"), - G_TYPE_FROM_CLASS (gobject_class), - G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | G_SIGNAL_NO_HOOKS, - G_STRUCT_OFFSET (GtkWidgetClass, child_notify), - NULL, NULL, - g_cclosure_marshal_VOID__PARAM, - G_TYPE_NONE, 1, - G_TYPE_PARAM); - /** * GtkWidget::mnemonic-activate: * @widget: the object which received the signal. @@ -2940,98 +2907,6 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class) priv->root = (GtkRoot *) widget; } - -static void -gtk_widget_dispatch_child_properties_changed (GtkWidget *widget, - guint n_pspecs, - GParamSpec **pspecs) -{ - GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget); - GtkWidget *container = priv->parent; - guint i; - - for (i = 0; widget->priv->parent == container && i < n_pspecs; i++) - g_signal_emit (widget, widget_signals[CHILD_NOTIFY], g_param_spec_get_name_quark (pspecs[i]), pspecs[i]); -} - -/** - * gtk_widget_freeze_child_notify: - * @widget: a #GtkWidget - * - * Stops emission of #GtkWidget::child-notify signals on @widget. The - * signals are queued until gtk_widget_thaw_child_notify() is called - * on @widget. - * - * This is the analogue of g_object_freeze_notify() for child properties. - **/ -void -gtk_widget_freeze_child_notify (GtkWidget *widget) -{ - g_return_if_fail (GTK_IS_WIDGET (widget)); - - if (!G_OBJECT (widget)->ref_count) - return; - - g_object_ref (widget); - g_object_notify_queue_freeze (G_OBJECT (widget), _gtk_widget_child_property_notify_context); - g_object_unref (widget); -} - -/** - * gtk_widget_child_notify: - * @widget: a #GtkWidget - * @child_property: the name of a child property installed on the - * class of @widget’s parent - * - * Emits a #GtkWidget::child-notify signal for the - * [child property][child-properties] @child_property - * on @widget. - * - * This is the analogue of g_object_notify() for child properties. - * - * Also see gtk_container_child_notify(). - */ -void -gtk_widget_child_notify (GtkWidget *widget, - const gchar *child_property) -{ - GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget); - - if (priv->parent == NULL) - return; - - gtk_container_child_notify (GTK_CONTAINER (priv->parent), widget, child_property); -} - -/** - * gtk_widget_thaw_child_notify: - * @widget: a #GtkWidget - * - * Reverts the effect of a previous call to gtk_widget_freeze_child_notify(). - * This causes all queued #GtkWidget::child-notify signals on @widget to be - * emitted. - */ -void -gtk_widget_thaw_child_notify (GtkWidget *widget) -{ - GObjectNotifyQueue *nqueue; - - g_return_if_fail (GTK_IS_WIDGET (widget)); - - if (!G_OBJECT (widget)->ref_count) - return; - - g_object_ref (widget); - nqueue = g_object_notify_queue_from_object (G_OBJECT (widget), _gtk_widget_child_property_notify_context); - if (!nqueue || !nqueue->freeze_count) - g_warning (G_STRLOC ": child-property-changed notification for %s(%p) is not frozen", - G_OBJECT_TYPE_NAME (widget), widget); - else - g_object_notify_queue_thaw (G_OBJECT (widget), nqueue); - g_object_unref (widget); -} - - /** * gtk_widget_new: * @type: type ID of the widget to create @@ -3117,7 +2992,6 @@ void gtk_widget_unparent (GtkWidget *widget) { GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget); - GObjectNotifyQueue *nqueue; GtkWidget *old_parent; GtkWidget *old_prev_sibling; GtkWidget *toplevel; @@ -3132,7 +3006,6 @@ gtk_widget_unparent (GtkWidget *widget) gtk_widget_push_verify_invariants (widget); g_object_freeze_notify (G_OBJECT (widget)); - nqueue = g_object_notify_queue_freeze (G_OBJECT (widget), _gtk_widget_child_property_notify_context); toplevel = _gtk_widget_get_toplevel (widget); if (_gtk_widget_is_toplevel (toplevel)) @@ -3221,9 +3094,6 @@ gtk_widget_unparent (GtkWidget *widget) g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_PARENT]); g_object_thaw_notify (G_OBJECT (widget)); - if (!priv->parent) - g_object_notify_queue_clear (G_OBJECT (widget), nqueue); - g_object_notify_queue_thaw (G_OBJECT (widget), nqueue); gtk_widget_pop_verify_invariants (widget); g_object_unref (widget); @@ -9599,6 +9469,7 @@ gtk_widget_buildable_interface_init (GtkBuildableIface *iface) iface->set_buildable_property = gtk_widget_buildable_set_buildable_property; iface->parser_finished = gtk_widget_buildable_parser_finished; iface->custom_tag_start = gtk_widget_buildable_custom_tag_start; + iface->custom_tag_end = gtk_widget_buildable_custom_tag_end; iface->custom_finished = gtk_widget_buildable_custom_finished; iface->add_child = gtk_widget_buildable_add_child; } @@ -10267,6 +10138,15 @@ gtk_widget_buildable_custom_tag_start (GtkBuildable *buildable, return FALSE; } +static void +gtk_widget_buildable_custom_tag_end (GtkBuildable *buildable, + GtkBuilder *builder, + GObject *child, + const gchar *tagname, + gpointer data) +{ +} + void _gtk_widget_buildable_finish_accelerator (GtkWidget *widget, GtkWidget *toplevel, diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 24edcc230e..8ff503a400 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -133,7 +133,6 @@ struct _GtkWidget * @activate_signal: The signal to emit when a widget of this class is * activated, gtk_widget_activate() handles the emission. * Implementation of this signal is optional. - * @dispatch_child_properties_changed: Seldomly overidden. * @destroy: Signals that all holders of a reference to the widget * should release the reference that they hold. * @show: Signal emitted when widget is shown @@ -234,11 +233,6 @@ struct _GtkWidgetClass guint activate_signal; - /* seldomly overidden */ - void (*dispatch_child_properties_changed) (GtkWidget *widget, - guint n_pspecs, - GParamSpec **pspecs); - /* basics */ void (* destroy) (GtkWidget *widget); void (* show) (GtkWidget *widget); @@ -259,8 +253,6 @@ struct _GtkWidgetClass GtkTextDirection previous_direction); void (* grab_notify) (GtkWidget *widget, gboolean was_grabbed); - void (* child_notify) (GtkWidget *widget, - GParamSpec *child_property); /* size requests */ GtkSizeRequestMode (* get_request_mode) (GtkWidget *widget); @@ -461,14 +453,6 @@ gboolean gtk_widget_event (GtkWidget *widget, GDK_AVAILABLE_IN_ALL gboolean gtk_widget_activate (GtkWidget *widget); -GDK_AVAILABLE_IN_ALL -void gtk_widget_freeze_child_notify (GtkWidget *widget); -GDK_AVAILABLE_IN_ALL -void gtk_widget_child_notify (GtkWidget *widget, - const gchar *child_property); -GDK_AVAILABLE_IN_ALL -void gtk_widget_thaw_child_notify (GtkWidget *widget); - GDK_AVAILABLE_IN_ALL void gtk_widget_set_can_focus (GtkWidget *widget, gboolean can_focus); diff --git a/gtk/tools/gtk-builder-tool-simplify.c b/gtk/tools/gtk-builder-tool-simplify.c index 144f823e6a..cd15fd504c 100644 --- a/gtk/tools/gtk-builder-tool-simplify.c +++ b/gtk/tools/gtk-builder-tool-simplify.c @@ -331,7 +331,7 @@ get_property_pspec (MyParserData *data, pspec = g_object_class_find_property (class, canonical_name); break; case PROP_KIND_PACKING: - pspec = gtk_container_class_find_child_property (class, canonical_name); + pspec = NULL; break; case PROP_KIND_CELL_PACKING: { diff --git a/tests/meson.build b/tests/meson.build index 59d48e3f54..67be74027f 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -108,11 +108,9 @@ gtk_tests = [ ['teststack'], ['testrevealer'], ['testrevealer2'], - ['testtitlebar'], ['testtreelistmodel'], ['testsplitheaders'], ['teststackedheaders'], - ['testactionbar'], ['testwindowsize'], ['testpopover'], ['gdkgears', ['gtkgears.c']], diff --git a/tests/testactionbar.c b/tests/testactionbar.c deleted file mode 100644 index 567c711fba..0000000000 --- a/tests/testactionbar.c +++ /dev/null @@ -1,169 +0,0 @@ -#include - -static void -toggle_center (GtkCheckButton *button, - GParamSpec *pspec, - GtkActionBar *bar) -{ - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) - { - GtkWidget *button; - - button = gtk_button_new_with_label ("Center"); - gtk_widget_show (button); - gtk_action_bar_set_center_widget (bar, button); - } - else - { - gtk_action_bar_set_center_widget (bar, NULL); - } -} - -static void -toggle_visibility (GtkCheckButton *button, - GParamSpec *pspec, - GtkActionBar *bar) -{ - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) - gtk_action_bar_set_revealed (bar, TRUE); - else - gtk_action_bar_set_revealed (bar, FALSE); -} - -static void -create_widgets (GtkActionBar *bar, - GtkPackType pack_type, - gint n) -{ - GList *children, *l; - GtkWidget *child; - gint i; - gchar *label; - - children = gtk_container_get_children (GTK_CONTAINER (bar)); - for (l = children; l; l = l->next) - { - GtkPackType type; - - child = l->data; - - if (child == gtk_action_bar_get_center_widget (bar)) - continue; - - gtk_container_child_get (GTK_CONTAINER (bar), child, "pack-type", &type, NULL); - if (type == pack_type) - gtk_container_remove (GTK_CONTAINER (bar), child); - } - g_list_free (children); - - for (i = 0; i < n; i++) - { - label = g_strdup_printf ("%d", i); - child = gtk_button_new_with_label (label); - g_free (label); - - gtk_widget_show (child); - if (pack_type == GTK_PACK_START) - gtk_action_bar_pack_start (bar, child); - else - gtk_action_bar_pack_end (bar, child); - } -} - -static void -change_start (GtkSpinButton *button, - GParamSpec *pspec, - GtkActionBar *bar) -{ - create_widgets (bar, - GTK_PACK_START, - gtk_spin_button_get_value_as_int (button)); -} - -static void -change_end (GtkSpinButton *button, - GParamSpec *pspec, - GtkActionBar *bar) -{ - create_widgets (bar, - GTK_PACK_END, - gtk_spin_button_get_value_as_int (button)); -} - -static void -activate (GApplication *gapp) -{ - GtkApplication *app = GTK_APPLICATION (gapp); - GtkWidget *window; - GtkWidget *box; - GtkWidget *grid; - GtkWidget *label; - GtkWidget *spin; - GtkWidget *check; - GtkWidget *bar; - - window = gtk_application_window_new (app); - gtk_application_add_window (app, GTK_WINDOW (window)); - - bar = gtk_action_bar_new (); - gtk_action_bar_set_revealed (GTK_ACTION_BAR (bar), FALSE); - - box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); - - grid = gtk_grid_new (); - g_object_set (grid, - "halign", GTK_ALIGN_CENTER, - "margin", 20, - "row-spacing", 12, - "column-spacing", 12, - "vexpand", TRUE, - NULL); - gtk_container_add (GTK_CONTAINER (box), grid); - - label = gtk_label_new ("Start"); - gtk_widget_set_halign (label, GTK_ALIGN_END); - spin = gtk_spin_button_new_with_range (0, 10, 1); - g_signal_connect (spin, "notify::value", - G_CALLBACK (change_start), bar); - gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1); - gtk_grid_attach (GTK_GRID (grid), spin, 1, 0, 1, 1); - - label = gtk_label_new ("Center"); - gtk_widget_set_halign (label, GTK_ALIGN_END); - check = gtk_check_button_new (); - g_signal_connect (check, "notify::active", - G_CALLBACK (toggle_center), bar); - gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1); - gtk_grid_attach (GTK_GRID (grid), check, 1, 1, 1, 1); - - label = gtk_label_new ("End"); - gtk_widget_set_halign (label, GTK_ALIGN_END); - spin = gtk_spin_button_new_with_range (0, 10, 1); - g_signal_connect (spin, "notify::value", - G_CALLBACK (change_end), bar); - gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1); - gtk_grid_attach (GTK_GRID (grid), spin, 1, 2, 1, 1); - - label = gtk_label_new ("Visible"); - gtk_widget_set_halign (label, GTK_ALIGN_END); - check = gtk_check_button_new (); - g_signal_connect (check, "notify::active", - G_CALLBACK (toggle_visibility), bar); - gtk_grid_attach (GTK_GRID (grid), label, 0, 3, 1, 1); - gtk_grid_attach (GTK_GRID (grid), check, 1, 3, 1, 1); - - gtk_container_add (GTK_CONTAINER (box), bar); - gtk_container_add (GTK_CONTAINER (window), box); - gtk_widget_show (window); -} - -int -main (int argc, char *argv[]) -{ - GtkApplication *app; - - app = gtk_application_new ("org.gtk.Test.ActionBar", 0); - g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); - - return g_application_run (G_APPLICATION (app), argc, argv); -} diff --git a/tests/testgtk.c b/tests/testgtk.c index 309a260aa6..e7719e39a5 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -4025,17 +4025,15 @@ page_switch (GtkWidget *widget, gpointer *page, gint page_num) static void tab_fill (GtkToggleButton *button, GtkWidget *child) { - gtk_container_child_set (GTK_CONTAINER (sample_notebook), child, - "tab-fill", gtk_toggle_button_get_active (button), - NULL); + GtkNotebookPage *page = gtk_notebook_get_page (GTK_NOTEBOOK (sample_notebook), child); + g_object_set (page, "tab-fill", gtk_toggle_button_get_active (button), NULL); } static void tab_expand (GtkToggleButton *button, GtkWidget *child) { - gtk_container_child_set (GTK_CONTAINER (sample_notebook), child, - "tab-expand", gtk_toggle_button_get_active (button), - NULL); + GtkNotebookPage *page = gtk_notebook_get_page (GTK_NOTEBOOK (sample_notebook), child); + g_object_set (page, "tab-expand", gtk_toggle_button_get_active (button), NULL); } static void @@ -4322,23 +4320,29 @@ create_notebook (GtkWidget *widget) void toggle_resize (GtkWidget *widget, GtkWidget *child) { - GtkContainer *container = GTK_CONTAINER (gtk_widget_get_parent (child)); - GValue value = G_VALUE_INIT; - g_value_init (&value, G_TYPE_BOOLEAN); - gtk_container_child_get_property (container, child, "resize", &value); - g_value_set_boolean (&value, !g_value_get_boolean (&value)); - gtk_container_child_set_property (container, child, "resize", &value); + GtkPaned *paned = GTK_PANED (gtk_widget_get_parent (child)); + gboolean is_child1; + gboolean resize; + const char *prop; + + is_child1 = (child == gtk_paned_get_child1 (paned)); + prop = is_child1 ? "resize-child1" : "resize-child2"; + g_object_get (paned, prop, &resize, NULL); + g_object_set (paned, prop, !resize, NULL); } void toggle_shrink (GtkWidget *widget, GtkWidget *child) { - GtkContainer *container = GTK_CONTAINER (gtk_widget_get_parent (child)); - GValue value = G_VALUE_INIT; - g_value_init (&value, G_TYPE_BOOLEAN); - gtk_container_child_get_property (container, child, "shrink", &value); - g_value_set_boolean (&value, !g_value_get_boolean (&value)); - gtk_container_child_set_property (container, child, "shrink", &value); + GtkPaned *paned = GTK_PANED (gtk_widget_get_parent (child)); + gboolean is_child1; + gboolean resize; + const char *prop; + + is_child1 = (child == gtk_paned_get_child1 (paned)); + prop = is_child1 ? "shrink-child1" : "shrink-child2"; + g_object_get (paned, prop, &resize, NULL); + g_object_set (paned, prop, !resize, NULL); } GtkWidget * diff --git a/tests/testtitlebar.c b/tests/testtitlebar.c deleted file mode 100644 index 640882b800..0000000000 --- a/tests/testtitlebar.c +++ /dev/null @@ -1,200 +0,0 @@ -#include - -static void -on_text_changed (GtkEntry *entry, - GParamSpec *pspec, - GtkHeaderBar *bar) -{ - const gchar *layout; - - layout = gtk_editable_get_text (GTK_EDITABLE (entry)); - - gtk_header_bar_set_decoration_layout (bar, layout); -} - -static void -create_widgets (GtkHeaderBar *bar, - GtkPackType pack_type, - gint n) -{ - GList *children, *l; - GtkWidget *child; - gint i; - gchar *label; - - children = gtk_container_get_children (GTK_CONTAINER (bar)); - for (l = children; l; l = l->next) - { - GtkPackType type; - - child = l->data; - gtk_container_child_get (GTK_CONTAINER (bar), child, "pack-type", &type, NULL); - if (type == pack_type) - gtk_container_remove (GTK_CONTAINER (bar), child); - } - g_list_free (children); - - for (i = 0; i < n; i++) - { - label = g_strdup_printf ("%d", i); - child = gtk_button_new_with_label (label); - g_free (label); - - gtk_widget_show (child); - if (pack_type == GTK_PACK_START) - gtk_header_bar_pack_start (bar, child); - else - gtk_header_bar_pack_end (bar, child); - } -} - -static void -change_start (GtkSpinButton *button, - GParamSpec *pspec, - GtkHeaderBar *bar) -{ - create_widgets (bar, - GTK_PACK_START, - gtk_spin_button_get_value_as_int (button)); -} - -static void -change_end (GtkSpinButton *button, - GParamSpec *pspec, - GtkHeaderBar *bar) -{ - create_widgets (bar, - GTK_PACK_END, - gtk_spin_button_get_value_as_int (button)); -} - -static void -activate (GApplication *gapp) -{ - GtkApplication *app = GTK_APPLICATION (gapp); - GtkWidget *window; - GtkWidget *header; - GtkWidget *grid; - GtkWidget *label; - GtkWidget *entry; - GtkWidget *check; - GtkWidget *spin; - GtkBuilder *builder; - GMenuModel *menu; - gchar *layout; - - g_action_map_add_action (G_ACTION_MAP (gapp), G_ACTION (g_simple_action_new ("test", NULL))); - builder = gtk_builder_new (); - gtk_builder_add_from_string (builder, - "" - " " - "
" - " " - " Test item" - " app.test" - " " - "
" - "
" - "
", -1, NULL); - window = gtk_application_window_new (app); - gtk_window_set_icon_name (GTK_WINDOW (window), "preferences-desktop-font"); - - menu = (GMenuModel*)gtk_builder_get_object (builder, "app-menu"); - gtk_application_add_window (app, GTK_WINDOW (window)); - gtk_application_set_app_menu (app, menu); - - header = gtk_header_bar_new (); - gtk_window_set_titlebar (GTK_WINDOW (window), header); - - grid = gtk_grid_new (); - g_object_set (grid, - "halign", GTK_ALIGN_CENTER, - "margin", 20, - "row-spacing", 12, - "column-spacing", 12, - NULL); - - label = gtk_label_new ("Title"); - gtk_widget_set_halign (label, GTK_ALIGN_END); - entry = gtk_entry_new (); - g_object_bind_property (header, "title", - entry, "text", - G_BINDING_BIDIRECTIONAL|G_BINDING_SYNC_CREATE); - gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1); - gtk_grid_attach (GTK_GRID (grid), entry, 1, 0, 1, 1); - - label = gtk_label_new ("Subtitle"); - gtk_widget_set_halign (label, GTK_ALIGN_END); - entry = gtk_entry_new (); - g_object_bind_property (header, "subtitle", - entry, "text", - G_BINDING_BIDIRECTIONAL|G_BINDING_SYNC_CREATE); - gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1); - gtk_grid_attach (GTK_GRID (grid), entry, 1, 1, 1, 1); - - label = gtk_label_new ("Layout"); - gtk_widget_set_halign (label, GTK_ALIGN_END); - entry = gtk_entry_new (); - - g_object_get (gtk_widget_get_settings (window), "gtk-decoration-layout", &layout, NULL); - gtk_editable_set_text (GTK_EDITABLE (entry), layout); - g_free (layout); - - g_signal_connect (entry, "notify::text", - G_CALLBACK (on_text_changed), header); - gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1); - gtk_grid_attach (GTK_GRID (grid), entry, 1, 2, 1, 1); - - label = gtk_label_new ("Decorations"); - gtk_widget_set_halign (label, GTK_ALIGN_END); - check = gtk_check_button_new (); - g_object_bind_property (header, "show-title-buttons", - check, "active", - G_BINDING_BIDIRECTIONAL|G_BINDING_SYNC_CREATE); - gtk_grid_attach (GTK_GRID (grid), label, 2, 0, 1, 1); - gtk_grid_attach (GTK_GRID (grid), check, 3, 0, 1, 1); - - label = gtk_label_new ("Has Subtitle"); - gtk_widget_set_halign (label, GTK_ALIGN_END); - check = gtk_check_button_new (); - g_object_bind_property (header, "has-subtitle", - check, "active", - G_BINDING_BIDIRECTIONAL|G_BINDING_SYNC_CREATE); - gtk_grid_attach (GTK_GRID (grid), label, 2, 1, 1, 1); - gtk_grid_attach (GTK_GRID (grid), check, 3, 1, 1, 1); - - label = gtk_label_new ("Shell Shows Menu"); - gtk_widget_set_halign (label, GTK_ALIGN_END); - check = gtk_check_button_new (); - g_object_bind_property (gtk_settings_get_default (), "gtk-shell-shows-app-menu", - check, "active", - G_BINDING_BIDIRECTIONAL|G_BINDING_SYNC_CREATE); - gtk_grid_attach (GTK_GRID (grid), label, 2, 2, 1, 1); - gtk_grid_attach (GTK_GRID (grid), check, 3, 2, 1, 1); - - label = gtk_label_new ("Custom"); - gtk_widget_set_halign (label, GTK_ALIGN_END); - spin = gtk_spin_button_new_with_range (0, 10, 1); - g_signal_connect (spin, "notify::value", - G_CALLBACK (change_start), header); - gtk_grid_attach (GTK_GRID (grid), label, 0, 3, 1, 1); - gtk_grid_attach (GTK_GRID (grid), spin, 1, 3, 1, 1); - spin = gtk_spin_button_new_with_range (0, 10, 1); - g_signal_connect (spin, "notify::value", - G_CALLBACK (change_end), header); - gtk_grid_attach (GTK_GRID (grid), spin, 2, 3, 2, 1); - - gtk_container_add (GTK_CONTAINER (window), grid); - gtk_widget_show (window); -} - -int -main (int argc, char *argv[]) -{ - GtkApplication *app; - - app = gtk_application_new ("org.gtk.Test.titlebar", 0); - g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); - - return g_application_run (G_APPLICATION (app), argc, argv); -} diff --git a/testsuite/gtk/ui/container2.expected b/testsuite/gtk/ui/container2.expected deleted file mode 100644 index f1350c80ea..0000000000 --- a/testsuite/gtk/ui/container2.expected +++ /dev/null @@ -1,2 +0,0 @@ -ERROR: g-markup-error-quark 6 -.:7:32 element 'property' requires attribute 'name' diff --git a/testsuite/gtk/ui/container2.ui b/testsuite/gtk/ui/container2.ui deleted file mode 100644 index 81a41a677c..0000000000 --- a/testsuite/gtk/ui/container2.ui +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/testsuite/gtk/ui/container3.expected b/testsuite/gtk/ui/container3.expected deleted file mode 100644 index 0ac1da51e0..0000000000 --- a/testsuite/gtk/ui/container3.expected +++ /dev/null @@ -1,2 +0,0 @@ -ERROR: gtk-builder-error-quark 1 -.:7:17 Unsupported tag for GtkContainer: diff --git a/testsuite/gtk/ui/container3.ui b/testsuite/gtk/ui/container3.ui deleted file mode 100644 index 04d35bfb9a..0000000000 --- a/testsuite/gtk/ui/container3.ui +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/testsuite/gtk/ui/container7.expected b/testsuite/gtk/ui/container7.expected deleted file mode 100644 index 8288126c99..0000000000 --- a/testsuite/gtk/ui/container7.expected +++ /dev/null @@ -1,2 +0,0 @@ -ERROR: g-markup-error-quark 4 -.:7:1 attribute 'try' invalid for element 'packing' diff --git a/testsuite/gtk/ui/container7.ui b/testsuite/gtk/ui/container7.ui deleted file mode 100644 index 436e4a68e1..0000000000 --- a/testsuite/gtk/ui/container7.ui +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - -