From f6eedc86c3c1fac951e991f70ab801d8d120976a Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 20 Feb 2006 23:11:55 +0000 Subject: [PATCH] Properly update internal state when child visibility changes. (#331785, 2006-02-20 Matthias Clasen * gtk/gtknotebook.c: Properly update internal state when child visibility changes. (#331785, Sebastien Bacher) --- ChangeLog | 3 +++ ChangeLog.pre-2-10 | 3 +++ gtk/gtknotebook.c | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 5589ba333f..30487f4ec3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2006-02-20 Matthias Clasen + * gtk/gtknotebook.c: Properly update internal state + when child visibility changes. (#331785, Sebastien Bacher) + * gdk/gdkgc.c (_gdk_gc_update_context): Obtain the background color from the gc when it is needed. (#331820) diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 5589ba333f..30487f4ec3 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,8 @@ 2006-02-20 Matthias Clasen + * gtk/gtknotebook.c: Properly update internal state + when child visibility changes. (#331785, Sebastien Bacher) + * gdk/gdkgc.c (_gdk_gc_update_context): Obtain the background color from the gc when it is needed. (#331820) diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 4e1d8584d9..5f114166dd 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -112,7 +112,8 @@ struct _GtkNotebookPage GtkRequisition requisition; GtkAllocation allocation; - guint mnemonic_activate_signal; + gulong mnemonic_activate_signal; + gulong notify_visible_handler; }; #ifdef G_DISABLE_CHECKS @@ -2714,6 +2715,8 @@ gtk_notebook_real_remove (GtkNotebook *notebook, page = list->data; + g_signal_handler_disconnect (page->child, page->notify_visible_handler); + if (GTK_WIDGET_VISIBLE (page->child) && GTK_WIDGET_VISIBLE (notebook)) need_resize = TRUE; @@ -4326,6 +4329,33 @@ gtk_notebook_mnemonic_activate_switch_page (GtkWidget *child, return TRUE; } + +static void +page_visible_cb (GtkWidget *page, + GParamSpec *arg, + gpointer data) +{ + GtkNotebook *notebook = (GtkNotebook *)data; + GList *list; + GList *next = NULL; + + if (notebook->cur_page && + notebook->cur_page->child == page && + !GTK_WIDGET_VISIBLE (page)) + { + list = g_list_find (notebook->children, notebook->cur_page); + if (list) + { + next = gtk_notebook_search_page (notebook, list, STEP_NEXT, TRUE); + if (!next) + next = gtk_notebook_search_page (notebook, list, STEP_PREV, TRUE); + } + + if (next) + gtk_notebook_switch_page (notebook, GTK_NOTEBOOK_PAGE (next), -1); + } +} + /** * gtk_notebook_insert_page_menu: * @notebook: a #GtkNotebook @@ -4432,6 +4462,8 @@ gtk_notebook_insert_page_menu (GtkNotebook *notebook, gtk_notebook_switch_focus_tab (notebook, NULL); } + page->notify_visible_handler = g_signal_connect (G_OBJECT (child), "notify::visible", G_CALLBACK (page_visible_cb), notebook); + gtk_notebook_update_tab_states (notebook); if (tab_label)