From f7f4b30f8e6d8f2a74114d3b8689ea921e0e4a86 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Fri, 13 Jun 2003 23:13:57 +0000 Subject: Make visibility a tab GObject property. 2003-06-14 Christian Persch * src/ephy-tab.c: (ephy_tab_get_property), (ephy_tab_set_property), (ephy_tab_class_init), (ephy_tab_get_visibility), (ephy_tab_visibility_cb): Make visibility a tab GObject property. * src/ephy-window.h: * src/ephy-window.c: (sync_tab_visibility), (update_window_visibility), (tab_added_cb), (tab_removed_cb): Sync on tab visibility changes. --- src/ephy-window.c | 73 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 33 deletions(-) (limited to 'src/ephy-window.c') diff --git a/src/ephy-window.c b/src/ephy-window.c index a0250babf..0b9f38df3 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -748,6 +748,40 @@ sync_tab_title (EphyTab *tab, GParamSpec *pspec, EphyWindow *window) } } +static void +sync_tab_visibility (EphyTab *tab, GParamSpec *pspec, EphyWindow *window) +{ + GList *l, *tabs; + gboolean visible = FALSE; + + if (window->priv->closing) return; + + LOG ("sync tab visibility window %p tab %p", window, tab) + + tabs = ephy_window_get_tabs (window); + for (l = tabs; l != NULL; l = l->next) + { + EphyTab *tab = EPHY_TAB(l->data); + g_return_if_fail (IS_EPHY_TAB(tab)); + + if (ephy_tab_get_visibility (tab)) + { + visible = TRUE; + break; + } + } + g_list_free (tabs); + + if (visible) + { + gtk_widget_show (GTK_WIDGET(window)); + } + else + { + gtk_widget_hide (GTK_WIDGET (window)); + } +} + static void sync_tab_zoom (EphyTab *tab, GParamSpec *pspec, EphyWindow *window) { @@ -933,6 +967,9 @@ tab_added_cb (EphyNotebook *notebook, GtkWidget *child, EphyWindow *window) sync_tab_load_status (tab, NULL, window); g_signal_connect_object (G_OBJECT (tab), "notify::load-status", G_CALLBACK (sync_tab_load_status), window, 0); + sync_tab_visibility (tab, NULL, window); + g_signal_connect_object (G_OBJECT (tab), "notify::visible", + G_CALLBACK (sync_tab_visibility), window, 0); } static void @@ -946,6 +983,9 @@ tab_removed_cb (EphyNotebook *notebook, GtkWidget *child, EphyWindow *window) g_signal_handlers_disconnect_by_func (G_OBJECT (tab), G_CALLBACK (sync_tab_load_status), window); + g_signal_handlers_disconnect_by_func (G_OBJECT (tab), + G_CALLBACK (sync_tab_visibility), + window); window->priv->num_tabs--; @@ -1519,36 +1559,6 @@ update_find_control (EphyWindow *window) } } -static void -update_window_visibility (EphyWindow *window) -{ - GList *l, *tabs; - gboolean visible = FALSE; - - tabs = ephy_window_get_tabs (window); - for (l = tabs; l != NULL; l = l->next) - { - EphyTab *tab = EPHY_TAB(l->data); - g_return_if_fail (IS_EPHY_TAB(tab)); - - if (ephy_tab_get_visibility (tab)) - { - visible = TRUE; - break; - } - } - g_list_free (tabs); - - if (visible) - { - gtk_widget_show (GTK_WIDGET(window)); - } - else - { - gtk_widget_hide (GTK_WIDGET (window)); - } -} - void ephy_window_update_control (EphyWindow *window, ControlID control) @@ -1560,9 +1570,6 @@ ephy_window_update_control (EphyWindow *window, case FindControl: update_find_control (window); break; - case WindowVisibilityControl: - update_window_visibility (window); - break; case FavoritesControl: update_favorites_control (window); break; -- cgit v1.2.3