From aa552229c96b97d1e8366cbe727ae9de45cc4db0 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 15 Feb 2019 10:20:48 -0500 Subject: [PATCH 1/4] singleselection: Make tests build without warnings --- testsuite/gtk/singleselection.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/testsuite/gtk/singleselection.c b/testsuite/gtk/singleselection.c index efe4a91ece..f13fbacebf 100644 --- a/testsuite/gtk/singleselection.c +++ b/testsuite/gtk/singleselection.c @@ -298,6 +298,7 @@ test_create (void) g_object_unref (selection); } +#if GLIB_CHECK_VERSION (2, 58, 0) /* g_list_store_splice() is broken before 2.58 */ static void test_changes (void) { @@ -332,7 +333,9 @@ test_changes (void) g_object_unref (selection); g_object_unref (store); } +#endif +#if GLIB_CHECK_VERSION (2, 59, 0) /* g_list_store_get_item() has overflow issues before */ static void test_selection (void) { @@ -383,7 +386,9 @@ test_selection (void) g_object_unref (store); g_object_unref (selection); } +#endif +#if GLIB_CHECK_VERSION (2, 59, 0) /* g_list_store_get_item() has overflow issues before */ static void test_autoselect (void) { @@ -418,7 +423,9 @@ test_autoselect (void) g_object_unref (store); g_object_unref (selection); } +#endif +#if GLIB_CHECK_VERSION (2, 59, 0) /* g_list_store_get_item() has overflow issues before */ static void test_can_unselect (void) { @@ -449,7 +456,9 @@ test_can_unselect (void) g_object_unref (store); g_object_unref (selection); } +#endif +#if GLIB_CHECK_VERSION (2, 59, 0) /* g_list_store_get_item() has overflow issues before */ static int sort_inverse (gconstpointer a, gconstpointer b, gpointer data) { @@ -484,6 +493,7 @@ test_persistence (void) g_object_unref (store); g_object_unref (selection); } +#endif static void check_query_range (GtkSelectionModel *selection) From fb4f5e0a78b46138ca670d348d183fa60a35d2cd Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 14 Feb 2019 14:29:54 -0500 Subject: [PATCH 2/4] assistant: Add docs Without this, introspection complains about a missing transfer annotation. --- gtk/gtkassistant.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gtk/gtkassistant.c b/gtk/gtkassistant.c index 3dbdf0c323..f5a275260b 100644 --- a/gtk/gtkassistant.c +++ b/gtk/gtkassistant.c @@ -2545,6 +2545,14 @@ gtk_assistant_pages_new (GtkAssistant *assistant) return pages; } +/** + * gtk_assistant_get_pages: + * @assistant: a #GtkAssistant + * + * Gets a list model of the assistant pages. + * + * Returns: (transfer full): A list model of the pages. + */ GListModel * gtk_assistant_get_pages (GtkAssistant *assistant) { From d327d3fab232eda14acc5d0610845f9c679bc5c4 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 14 Feb 2019 14:07:46 -0500 Subject: [PATCH 3/4] assistant: Use a stack We don't use any non-stack features of the notebook here. --- gtk/gtkassistant.c | 25 +++++++++++++++---------- gtk/ui/gtkassistant.ui | 4 +--- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/gtk/gtkassistant.c b/gtk/gtkassistant.c index f5a275260b..b78089e0fe 100644 --- a/gtk/gtkassistant.c +++ b/gtk/gtkassistant.c @@ -74,7 +74,7 @@ #include "gtkintl.h" #include "gtkimage.h" #include "gtklabel.h" -#include "gtknotebook.h" +#include "gtkstack.h" #include "gtkprivate.h" #include "gtksettings.h" #include "gtksizegroup.h" @@ -967,7 +967,7 @@ set_current_page (GtkAssistant *assistant, gtk_window_set_title (GTK_WINDOW (assistant), priv->current_page->title); - gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->content), page_num); + gtk_stack_set_visible_child (GTK_STACK (priv->content), priv->current_page->box); /* update buttons state, flow may have changed */ if (gtk_widget_get_mapped (GTK_WIDGET (assistant))) @@ -1348,13 +1348,15 @@ gtk_assistant_destroy (GtkWidget *widget) if (priv->content) { - GtkNotebook *notebook; - GtkWidget *page; + GList *children, *l; - /* Remove all pages from the content notebook. */ - notebook = (GtkNotebook *) priv->content; - while ((page = gtk_notebook_get_nth_page (notebook, 0)) != NULL) - gtk_container_remove ((GtkContainer *) notebook, page); + children = gtk_container_get_children (GTK_CONTAINER (priv->content)); + for (l = children; l; l = l->next) + { + GtkWidget *page = l->data; + gtk_container_remove (GTK_CONTAINER (priv->content), page); + } + g_list_free (children); /* Our GtkAssistantPage list should be empty now. */ g_warn_if_fail (priv->pages == NULL); @@ -1500,7 +1502,7 @@ gtk_assistant_remove (GtkContainer *container, GtkAssistant *assistant = (GtkAssistant*) container; GtkWidget *box; - /* Forward this removal to the content notebook */ + /* Forward this removal to the content stack */ box = gtk_widget_get_parent (page); if (GTK_IS_BOX (box) && assistant->priv->content != NULL && @@ -1806,6 +1808,7 @@ gtk_assistant_add_page (GtkAssistant *assistant, GtkStyleContext *context; GtkWidget *box; GtkWidget *sibling; + char *name; page_info->regular_title = gtk_label_new (page_info->title); page_info->current_title = gtk_label_new (page_info->title); @@ -1857,7 +1860,9 @@ gtk_assistant_add_page (GtkAssistant *assistant, g_object_set (box, "margin", 12, NULL); g_signal_connect (box, "remove", G_CALLBACK (assistant_remove_page_cb), assistant); - gtk_notebook_insert_page (GTK_NOTEBOOK (priv->content), box, NULL, position); + name = g_strdup_printf ("page%d", position); + gtk_stack_add_named (GTK_STACK (priv->content), box, name); + g_free (name); page_info->box = box; diff --git a/gtk/ui/gtkassistant.ui b/gtk/ui/gtkassistant.ui index d519a79ce9..f39fbf494b 100644 --- a/gtk/ui/gtkassistant.ui +++ b/gtk/ui/gtkassistant.ui @@ -18,10 +18,8 @@ vertical 1 - + 1 - 0 - 0 1 From e5e2bd3187ca44ec88d87d68506737939a2b9f0f Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 14 Feb 2019 14:46:01 -0500 Subject: [PATCH 4/4] Drop GtkAssistantPage::has-padding This is causing us some internal complications, and it is very easy to just add padding to the pages yourself. --- docs/reference/gtk/gtk4-sections.txt | 2 - docs/reference/gtk/migrating-3to4.xml | 8 ++ gtk/gtkassistant.c | 108 ++------------------------ gtk/gtkassistant.h | 7 -- tests/testassistant.c | 1 - 5 files changed, 14 insertions(+), 112 deletions(-) diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index fd93df5a50..fd48280bed 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -233,8 +233,6 @@ gtk_assistant_set_page_title gtk_assistant_get_page_title gtk_assistant_set_page_complete gtk_assistant_get_page_complete -gtk_assistant_set_page_has_padding -gtk_assistant_get_page_has_padding gtk_assistant_add_action_widget gtk_assistant_remove_action_widget gtk_assistant_update_buttons_state diff --git a/docs/reference/gtk/migrating-3to4.xml b/docs/reference/gtk/migrating-3to4.xml index 4fbafaa6a8..53e49c77b2 100644 --- a/docs/reference/gtk/migrating-3to4.xml +++ b/docs/reference/gtk/migrating-3to4.xml @@ -593,6 +593,14 @@ child properties to child meta objects. + +
+ Adapt to changes in the GtkAssistant API + + The ::has-padding property is gone, and GtkAssistant no longer adds padding + to pages. You can easily do that yourself. + +
diff --git a/gtk/gtkassistant.c b/gtk/gtkassistant.c index b78089e0fe..639e06e8b2 100644 --- a/gtk/gtkassistant.c +++ b/gtk/gtkassistant.c @@ -92,11 +92,9 @@ struct _GtkAssistantPage GtkAssistantPageType type; guint complete : 1; guint complete_set : 1; - guint has_padding : 1; gchar *title; - GtkWidget *box; GtkWidget *page; GtkWidget *regular_title; GtkWidget *current_title; @@ -217,7 +215,6 @@ static void gtk_assistant_page_init (GtkAssistantPage *page) { page->type = GTK_ASSISTANT_PAGE_CONTENT; - page->has_padding = TRUE; } static void @@ -281,13 +278,6 @@ gtk_assistant_page_class_init (GtkAssistantPageClass *class) P_("Whether all required fields on the page have been filled out"), FALSE, G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY)); - g_object_class_install_property (object_class, - CHILD_PROP_HAS_PADDING, - g_param_spec_boolean ("has-padding", - P_("Has padding"), - P_("Whether the assistant adds padding around the page"), - TRUE, - G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY)); g_object_class_install_property (object_class, CHILD_PROP_CHILD, g_param_spec_object ("child", @@ -967,7 +957,7 @@ set_current_page (GtkAssistant *assistant, gtk_window_set_title (GTK_WINDOW (assistant), priv->current_page->title); - gtk_stack_set_visible_child (GTK_STACK (priv->content), priv->current_page->box); + gtk_stack_set_visible_child (GTK_STACK (priv->content), priv->current_page->page); /* update buttons state, flow may have changed */ if (gtk_widget_get_mapped (GTK_WIDGET (assistant))) @@ -1280,16 +1270,6 @@ gtk_assistant_page_set_property (GObject *object, } break; - case CHILD_PROP_HAS_PADDING: - if (page->has_padding != g_value_get_boolean (value)) - { - page->has_padding = g_value_get_boolean (value); - if (page->box) - g_object_set (page->box, "margin", page->has_padding ? 12 : 0, NULL); - g_object_notify (G_OBJECT (page), "has-padding"); - } - break; - default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -1322,10 +1302,6 @@ gtk_assistant_page_get_property (GObject *object, g_value_set_boolean (value, page->complete); break; - case CHILD_PROP_HAS_PADDING: - g_value_set_boolean (value, page->has_padding); - break; - default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -1401,7 +1377,7 @@ find_page (GtkAssistant *assistant, while (child) { GtkAssistantPage *page_info = child->data; - if (page_info->page == page || page_info->box == page) + if (page_info->page == page) return child; child = child->next; @@ -1500,16 +1476,11 @@ gtk_assistant_remove (GtkContainer *container, GtkWidget *page) { GtkAssistant *assistant = (GtkAssistant*) container; - GtkWidget *box; /* Forward this removal to the content stack */ - box = gtk_widget_get_parent (page); - if (GTK_IS_BOX (box) && - assistant->priv->content != NULL && - gtk_widget_get_parent (box) == assistant->priv->content) + if (gtk_widget_get_parent (page) == assistant->priv->content) { - gtk_container_remove (GTK_CONTAINER (box), page); - gtk_container_remove (GTK_CONTAINER (assistant->priv->content), box); + gtk_container_remove (GTK_CONTAINER (assistant->priv->content), page); } else { @@ -1791,7 +1762,6 @@ gtk_assistant_insert_page (GtkAssistant *assistant, page_info = g_object_new (GTK_TYPE_ASSISTANT_PAGE, NULL); page_info->page = g_object_ref (page); - page_info->has_padding = TRUE; return gtk_assistant_add_page (assistant, page_info, position); @@ -1806,7 +1776,6 @@ gtk_assistant_add_page (GtkAssistant *assistant, GtkAssistantPrivate *priv = assistant->priv; gint n_pages; GtkStyleContext *context; - GtkWidget *box; GtkWidget *sibling; char *name; @@ -1854,18 +1823,10 @@ gtk_assistant_add_page (GtkAssistant *assistant, gtk_box_insert_child_after (GTK_BOX (priv->sidebar), page_info->current_title, sibling); gtk_box_insert_child_after (GTK_BOX (priv->sidebar), page_info->regular_title, sibling); - box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - gtk_widget_show (box); - gtk_container_add (GTK_CONTAINER (box), page_info->page); - g_object_set (box, "margin", 12, NULL); - g_signal_connect (box, "remove", G_CALLBACK (assistant_remove_page_cb), assistant); - - name = g_strdup_printf ("page%d", position); - gtk_stack_add_named (GTK_STACK (priv->content), box, name); + name = g_strdup_printf ("%p", page_info->page); + gtk_stack_add_named (GTK_STACK (priv->content), page_info->page, name); g_free (name); - page_info->box = box; - if (gtk_widget_get_mapped (GTK_WIDGET (assistant))) { update_buttons_state (assistant); @@ -2203,63 +2164,6 @@ gtk_assistant_get_page_complete (GtkAssistant *assistant, return page_info->complete; } -/** - * gtk_assistant_set_page_has_padding: - * @assistant: a #GtkAssistant - * @page: a page of @assistant - * @has_padding: whether this page has padding - * - * Sets whether the assistant is adding padding around - * the page. - */ -void -gtk_assistant_set_page_has_padding (GtkAssistant *assistant, - GtkWidget *page, - gboolean has_padding) -{ - GtkAssistantPage *page_info; - GList *child; - - g_return_if_fail (GTK_IS_ASSISTANT (assistant)); - g_return_if_fail (GTK_IS_WIDGET (page)); - - child = find_page (assistant, page); - - g_return_if_fail (child != NULL); - - page_info = (GtkAssistantPage*) child->data; - - g_object_set (page_info, "has-padding", has_padding, NULL); -} - -/** - * gtk_assistant_get_page_has_padding: - * @assistant: a #GtkAssistant - * @page: a page of @assistant - * - * Gets whether page has padding. - * - * Returns: %TRUE if @page has padding - */ -gboolean -gtk_assistant_get_page_has_padding (GtkAssistant *assistant, - GtkWidget *page) -{ - GtkAssistantPage *page_info; - GList *child; - - g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), FALSE); - g_return_val_if_fail (GTK_IS_WIDGET (page), FALSE); - - child = find_page (assistant, page); - - g_return_val_if_fail (child != NULL, TRUE); - - page_info = (GtkAssistantPage*) child->data; - - return page_info->has_padding; -} - /** * gtk_assistant_update_buttons_state: * @assistant: a #GtkAssistant diff --git a/gtk/gtkassistant.h b/gtk/gtkassistant.h index 164add62c8..533fc83e17 100644 --- a/gtk/gtkassistant.h +++ b/gtk/gtkassistant.h @@ -214,13 +214,6 @@ void gtk_assistant_update_buttons_state (GtkAssistant *assista GDK_AVAILABLE_IN_ALL void gtk_assistant_commit (GtkAssistant *assistant); -GDK_AVAILABLE_IN_ALL -void gtk_assistant_set_page_has_padding (GtkAssistant *assistant, - GtkWidget *page, - gboolean has_padding); -GDK_AVAILABLE_IN_ALL -gboolean gtk_assistant_get_page_has_padding (GtkAssistant *assistant, - GtkWidget *page); GDK_AVAILABLE_IN_ALL GtkAssistantPage * gtk_assistant_get_page (GtkAssistant *assistant, GtkWidget *child); diff --git a/tests/testassistant.c b/tests/testassistant.c index 70e02e6d13..ec3d3f9928 100644 --- a/tests/testassistant.c +++ b/tests/testassistant.c @@ -570,7 +570,6 @@ create_full_featured_assistant (GtkWidget *widget) gtk_assistant_append_page (GTK_ASSISTANT (assistant), page); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), page, "Filechooser"); gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), page, TRUE); - gtk_assistant_set_page_has_padding (GTK_ASSISTANT (assistant), page, FALSE); page = get_test_page ("Page 3"); gtk_widget_show (page);