From 5f01f6f36b08b3615e129525b341f9446ae32954 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 28 Apr 2020 19:53:33 -0400 Subject: [PATCH 1/2] Drop GtkStack:homogeneous We have hhomogeneous and vhomogeneous properties that can be set individually. Fixes: #2673 --- docs/reference/gtk/gtk4-sections.txt | 2 - gtk/gtkemojicompletion.c | 3 +- gtk/gtkshortcutssection.c | 3 +- gtk/gtkshortcutswindow.c | 3 +- gtk/gtkstack.c | 79 ---------------------------- gtk/inspector/window.ui | 6 ++- 6 files changed, 10 insertions(+), 86 deletions(-) diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index 5e67701836..bb3488926e 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -5626,8 +5626,6 @@ gtk_stack_get_visible_child gtk_stack_set_visible_child_name gtk_stack_get_visible_child_name gtk_stack_set_visible_child_full -gtk_stack_set_homogeneous -gtk_stack_get_homogeneous gtk_stack_set_hhomogeneous gtk_stack_get_hhomogeneous gtk_stack_set_vhomogeneous diff --git a/gtk/gtkemojicompletion.c b/gtk/gtkemojicompletion.c index 11a1946e27..810d6c1729 100644 --- a/gtk/gtkemojicompletion.c +++ b/gtk/gtkemojicompletion.c @@ -509,7 +509,8 @@ add_emoji (GtkWidget *list, g_object_set_data (G_OBJECT (child), "base", label); stack = gtk_stack_new (); - gtk_stack_set_homogeneous (GTK_STACK (stack), TRUE); + gtk_stack_set_hhomogeneous (GTK_STACK (stack), TRUE); + gtk_stack_set_vhomogeneous (GTK_STACK (stack), TRUE); gtk_stack_set_transition_type (GTK_STACK (stack), GTK_STACK_TRANSITION_TYPE_OVER_RIGHT_LEFT); gtk_container_add (GTK_CONTAINER (box), stack); g_object_set_data (G_OBJECT (child), "stack", stack); diff --git a/gtk/gtkshortcutssection.c b/gtk/gtkshortcutssection.c index 337ece2539..348889996a 100644 --- a/gtk/gtkshortcutssection.c +++ b/gtk/gtkshortcutssection.c @@ -418,7 +418,8 @@ gtk_shortcuts_section_init (GtkShortcutsSection *self) gtk_box_set_spacing (GTK_BOX (self), 22); self->stack = g_object_new (GTK_TYPE_STACK, - "homogeneous", TRUE, + "hhomogeneous", TRUE, + "vhomogeneous", TRUE, "transition-type", GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT, "vexpand", TRUE, "visible", TRUE, diff --git a/gtk/gtkshortcutswindow.c b/gtk/gtkshortcutswindow.c index a2d580f0eb..935c0c3c74 100644 --- a/gtk/gtkshortcutswindow.c +++ b/gtk/gtkshortcutswindow.c @@ -913,7 +913,8 @@ gtk_shortcuts_window_init (GtkShortcutsWindow *self) priv->stack = g_object_new (GTK_TYPE_STACK, "hexpand", TRUE, "vexpand", TRUE, - "homogeneous", TRUE, + "hhomogeneous", TRUE, + "vhomogeneous", TRUE, "transition-type", GTK_STACK_TRANSITION_TYPE_CROSSFADE, NULL); gtk_container_add (GTK_CONTAINER (priv->main_box), GTK_WIDGET (priv->stack)); diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c index 2efdd2be06..d2f455af65 100644 --- a/gtk/gtkstack.c +++ b/gtk/gtkstack.c @@ -163,7 +163,6 @@ G_DEFINE_TYPE_WITH_CODE (GtkStack, gtk_stack, GTK_TYPE_CONTAINER, gtk_stack_buildable_interface_init)) enum { PROP_0, - PROP_HOMOGENEOUS, PROP_HHOMOGENEOUS, PROP_VHOMOGENEOUS, PROP_VISIBLE_CHILD, @@ -641,9 +640,6 @@ gtk_stack_get_property (GObject *object, switch (property_id) { - case PROP_HOMOGENEOUS: - g_value_set_boolean (value, gtk_stack_get_homogeneous (stack)); - break; case PROP_HHOMOGENEOUS: g_value_set_boolean (value, gtk_stack_get_hhomogeneous (stack)); break; @@ -687,9 +683,6 @@ gtk_stack_set_property (GObject *object, switch (property_id) { - case PROP_HOMOGENEOUS: - gtk_stack_set_homogeneous (stack, g_value_get_boolean (value)); - break; case PROP_HHOMOGENEOUS: gtk_stack_set_hhomogeneous (stack, g_value_get_boolean (value)); break; @@ -738,11 +731,6 @@ gtk_stack_class_init (GtkStackClass *klass) container_class->remove = gtk_stack_remove; container_class->forall = gtk_stack_forall; - stack_props[PROP_HOMOGENEOUS] = - g_param_spec_boolean ("homogeneous", P_("Homogeneous"), P_("Homogeneous sizing"), - TRUE, - GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY); - /** * GtkStack:hhomogeneous: * @@ -1570,73 +1558,6 @@ gtk_stack_page_get_child (GtkStackPage *page) return page->widget; } -/** - * gtk_stack_set_homogeneous: - * @stack: a #GtkStack - * @homogeneous: %TRUE to make @stack homogeneous - * - * Sets the #GtkStack to be homogeneous or not. If it - * is homogeneous, the #GtkStack will request the same - * size for all its children. If it isn't, the stack - * may change size when a different child becomes visible. - * - * Homogeneity can be controlled separately - * for horizontal and vertical size, with the - * #GtkStack:hhomogeneous and #GtkStack:vhomogeneous. - */ -void -gtk_stack_set_homogeneous (GtkStack *stack, - gboolean homogeneous) -{ - GtkStackPrivate *priv = gtk_stack_get_instance_private (stack); - - g_return_if_fail (GTK_IS_STACK (stack)); - - homogeneous = !!homogeneous; - - if ((priv->hhomogeneous && priv->vhomogeneous) == homogeneous) - return; - - g_object_freeze_notify (G_OBJECT (stack)); - - if (priv->hhomogeneous != homogeneous) - { - priv->hhomogeneous = homogeneous; - g_object_notify_by_pspec (G_OBJECT (stack), stack_props[PROP_HHOMOGENEOUS]); - } - - if (priv->vhomogeneous != homogeneous) - { - priv->vhomogeneous = homogeneous; - g_object_notify_by_pspec (G_OBJECT (stack), stack_props[PROP_VHOMOGENEOUS]); - } - - if (gtk_widget_get_visible (GTK_WIDGET(stack))) - gtk_widget_queue_resize (GTK_WIDGET (stack)); - - g_object_notify_by_pspec (G_OBJECT (stack), stack_props[PROP_HOMOGENEOUS]); - g_object_thaw_notify (G_OBJECT (stack)); -} - -/** - * gtk_stack_get_homogeneous: - * @stack: a #GtkStack - * - * Gets whether @stack is homogeneous. - * See gtk_stack_set_homogeneous(). - * - * Returns: whether @stack is homogeneous. - */ -gboolean -gtk_stack_get_homogeneous (GtkStack *stack) -{ - GtkStackPrivate *priv = gtk_stack_get_instance_private (stack); - - g_return_val_if_fail (GTK_IS_STACK (stack), FALSE); - - return priv->hhomogeneous && priv->vhomogeneous; -} - /** * gtk_stack_set_hhomogeneous: * @stack: a #GtkStack diff --git a/gtk/inspector/window.ui b/gtk/inspector/window.ui index 4fc07bcfc8..e469cb23c2 100644 --- a/gtk/inspector/window.ui +++ b/gtk/inspector/window.ui @@ -242,7 +242,8 @@ - 0 + 0 + 0 empty @@ -299,7 +300,8 @@ crossfade 1 center - 0 + 0 + 0 title From 2e2121c7ad42a3cacddb63503c26a5fb2dd4b22b Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 28 Apr 2020 19:59:13 -0400 Subject: [PATCH 2/2] builder-tool: Replace GtkStack:homogeneous Replace this property by h/vhomogeneous. Add a test. --- gtk/tools/gtk-builder-tool-simplify.c | 3 ++- testsuite/tools/simplify-data-3to4/stack.expected | 2 ++ testsuite/tools/simplify-data-3to4/stack.ui | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/gtk/tools/gtk-builder-tool-simplify.c b/gtk/tools/gtk-builder-tool-simplify.c index 5dc2464cc2..06a31fb2b9 100644 --- a/gtk/tools/gtk-builder-tool-simplify.c +++ b/gtk/tools/gtk-builder-tool-simplify.c @@ -732,7 +732,8 @@ maybe_rename_property (Element *element, MyParserData *data) { "GtkWidget", "margin", GTK_TYPE_WIDGET, PROP_KIND_OBJECT, "margin-bottom", { "margin-start", "margin-end", "margin-top" } }, { "GtkWidget", "margin-left", GTK_TYPE_WIDGET, PROP_KIND_OBJECT, "margin-start", { NULL, NULL, NULL } }, { "GtkWidget", "margin-right", GTK_TYPE_WIDGET, PROP_KIND_OBJECT, "margin-end", { NULL, NULL, NULL } }, - { "GtkHeaderBar", "show-close-button", GTK_TYPE_HEADER_BAR, PROP_KIND_OBJECT, "show-title-buttons", { NULL, NULL, NULL } } + { "GtkHeaderBar", "show-close-button", GTK_TYPE_HEADER_BAR, PROP_KIND_OBJECT, "show-title-buttons", { NULL, NULL, NULL } }, + { "GtkStack", "homogeneous", GTK_TYPE_STACK, PROP_KIND_OBJECT, "hhomogeneous", { "vhomogeneous", NULL, NULL } } }; int i, k, l; PropKind kind; diff --git a/testsuite/tools/simplify-data-3to4/stack.expected b/testsuite/tools/simplify-data-3to4/stack.expected index 5bf7f70024..1c5c0beb56 100644 --- a/testsuite/tools/simplify-data-3to4/stack.expected +++ b/testsuite/tools/simplify-data-3to4/stack.expected @@ -10,6 +10,8 @@ + 0 + 0 page1 diff --git a/testsuite/tools/simplify-data-3to4/stack.ui b/testsuite/tools/simplify-data-3to4/stack.ui index 090100f26d..e3133911ca 100644 --- a/testsuite/tools/simplify-data-3to4/stack.ui +++ b/testsuite/tools/simplify-data-3to4/stack.ui @@ -14,6 +14,7 @@ True + 0 Yes