From 84480b3da86c7782f5d16b9c232d5a36d181da2d Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 27 Mar 2019 13:16:07 -0400 Subject: [PATCH] action bar: Drop pack-type Drop the pack-type child property. Allow ui files to direct children by adding a child type for it. --- gtk/gtkactionbar.c | 93 +++------------------------------------------- 1 file changed, 5 insertions(+), 88 deletions(-) diff --git a/gtk/gtkactionbar.c b/gtk/gtkactionbar.c index 599ecf43a1..0a48b72922 100644 --- a/gtk/gtkactionbar.c +++ b/gtk/gtkactionbar.c @@ -61,11 +61,6 @@ struct _GtkActionBarPrivate GtkWidget *revealer; }; -enum { - CHILD_PROP_0, - CHILD_PROP_PACK_TYPE, -}; - enum { PROP_0, PROP_REVEALED, @@ -139,78 +134,6 @@ gtk_action_bar_child_type (GtkContainer *container) return GTK_TYPE_WIDGET; } -static void -gtk_action_bar_get_child_property (GtkContainer *container, - GtkWidget *child, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (GTK_ACTION_BAR (container)); - - switch (property_id) - { - case CHILD_PROP_PACK_TYPE: - if (gtk_widget_get_parent (child) == priv->start_box) - g_value_set_enum (value, GTK_PACK_START); - else if (gtk_widget_get_parent (child) == priv->end_box) - g_value_set_enum (value, GTK_PACK_END); - else /* Center widget */ - g_value_set_enum (value, GTK_PACK_START); - - break; - - default: - GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec); - break; - } -} - -static void -gtk_action_bar_set_child_property (GtkContainer *container, - GtkWidget *child, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (GTK_ACTION_BAR (container)); - - switch (property_id) - { - case CHILD_PROP_PACK_TYPE: - if (gtk_widget_get_parent (child) == priv->start_box) - { - if (g_value_get_enum (value) == GTK_PACK_END) - { - g_object_ref (child); - gtk_container_remove (GTK_CONTAINER (priv->start_box), child); - gtk_box_insert_child_after (GTK_BOX (priv->end_box), child, NULL); - g_object_unref (child); - } - } - else if (gtk_widget_get_parent (child) == priv->end_box) - { - if (g_value_get_enum (value) == GTK_PACK_START) - { - g_object_ref (child); - gtk_container_remove (GTK_CONTAINER (priv->end_box), child); - gtk_container_add (GTK_CONTAINER (priv->start_box), child); - g_object_unref (child); - } - } - else - { - /* Ignore the center widget */ - } - - break; - - default: - GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec); - break; - } -} - static void gtk_action_bar_size_allocate (GtkWidget *widget, int width, @@ -322,16 +245,6 @@ gtk_action_bar_class_init (GtkActionBarClass *klass) container_class->remove = gtk_action_bar_remove; container_class->forall = gtk_action_bar_forall; container_class->child_type = gtk_action_bar_child_type; - container_class->set_child_property = gtk_action_bar_set_child_property; - container_class->get_child_property = gtk_action_bar_get_child_property; - - gtk_container_class_install_child_property (container_class, - CHILD_PROP_PACK_TYPE, - g_param_spec_enum ("pack-type", - P_("Pack type"), - P_("A GtkPackType indicating whether the child is packed with reference to the start or end of the parent"), - GTK_TYPE_PACK_TYPE, GTK_PACK_START, - G_PARAM_READWRITE)); props[PROP_REVEALED] = g_param_spec_boolean ("revealed", @@ -380,8 +293,12 @@ gtk_action_bar_buildable_add_child (GtkBuildable *buildable, { GtkActionBar *action_bar = GTK_ACTION_BAR (buildable); - if (type && strcmp (type, "center") == 0) + if (g_strcmp0 (type, "center") == 0) gtk_action_bar_set_center_widget (action_bar, GTK_WIDGET (child)); + else if (g_strcmp0 (type, "start") == 0) + gtk_action_bar_pack_start (action_bar, GTK_WIDGET (child)); + else if (g_strcmp0 (type, "end") == 0) + gtk_action_bar_pack_end (action_bar, GTK_WIDGET (child)); else parent_buildable_iface->add_child (buildable, builder, child, type); }