assistant: Deal with spontaneous page disappearance

Removing pages from the assistant with gtk_widget_destroy() used
to work. It broke with the recent interposition of a box between
each page and the notebook. Fix this by cleaning up when the box
child is removed.

https://bugzilla.gnome.org/show_bug.cgi?id=756042
This commit is contained in:
Matthias Clasen 2015-10-05 08:19:07 -04:00
parent 1ae98e72f7
commit 35b088459e

View File

@ -88,6 +88,7 @@ struct _GtkAssistantPage
gchar *title; gchar *title;
GtkWidget *box;
GtkWidget *page; GtkWidget *page;
GtkWidget *regular_title; GtkWidget *regular_title;
GtkWidget *current_title; GtkWidget *current_title;
@ -184,7 +185,7 @@ static void on_assistant_cancel (GtkWidget *wid
GtkAssistant *assistant); GtkAssistant *assistant);
static void on_assistant_last (GtkWidget *widget, static void on_assistant_last (GtkWidget *widget,
GtkAssistant *assistant); GtkAssistant *assistant);
static void assistant_remove_page_cb (GtkNotebook *notebook, static void assistant_remove_page_cb (GtkContainer *container,
GtkWidget *page, GtkWidget *page,
GtkAssistant *assistant); GtkAssistant *assistant);
@ -1113,7 +1114,7 @@ on_page_notify_visibility (GtkWidget *widget,
} }
static void static void
assistant_remove_page_cb (GtkNotebook *notebook, assistant_remove_page_cb (GtkContainer *container,
GtkWidget *page, GtkWidget *page,
GtkAssistant *assistant) GtkAssistant *assistant)
{ {
@ -1122,15 +1123,6 @@ assistant_remove_page_cb (GtkNotebook *notebook,
GList *page_node; GList *page_node;
GList *element; GList *element;
if (GTK_IS_BOX (page))
{
GList *children;
children = gtk_container_get_children (GTK_CONTAINER (page));
page = GTK_WIDGET (children->data);
g_list_free (children);
}
element = find_page (assistant, page); element = find_page (assistant, page);
if (!element) if (!element)
return; return;
@ -1367,7 +1359,7 @@ find_page (GtkAssistant *assistant,
while (child) while (child)
{ {
GtkAssistantPage *page_info = child->data; GtkAssistantPage *page_info = child->data;
if (page_info->page == page) if (page_info->page == page || page_info->box == page)
return child; return child;
child = child->next; child = child->next;
@ -1816,9 +1808,12 @@ gtk_assistant_insert_page (GtkAssistant *assistant,
gtk_widget_show (box); gtk_widget_show (box);
gtk_box_pack_start (GTK_BOX (box), page, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (box), page, TRUE, TRUE, 0);
g_object_set (box, "margin", 12, NULL); 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); gtk_notebook_insert_page (GTK_NOTEBOOK (priv->content), box, NULL, position);
page_info->box = box;
if (gtk_widget_get_mapped (GTK_WIDGET (assistant))) if (gtk_widget_get_mapped (GTK_WIDGET (assistant)))
{ {
update_buttons_state (assistant); update_buttons_state (assistant);
@ -2415,7 +2410,7 @@ gtk_assistant_set_page_has_padding (GtkAssistant *assistant,
{ {
page_info->has_padding = has_padding; page_info->has_padding = has_padding;
g_object_set (gtk_widget_get_parent (page), g_object_set (page_info->box,
"margin", has_padding ? 12 : 0, "margin", has_padding ? 12 : 0,
NULL); NULL);