diff options
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | src/ephy-extension.c | 34 | ||||
-rw-r--r-- | src/ephy-extension.h | 14 | ||||
-rw-r--r-- | src/ephy-extensions-manager.c | 83 | ||||
-rw-r--r-- | src/ephy-window.c | 10 |
5 files changed, 152 insertions, 4 deletions
@@ -1,3 +1,18 @@ +2004-12-17 Adam Hooper <adamh@cvs.gnome.org> + + * src/ephy-extension.c: (ephy_extension_attach_window), + (ephy_extension_detach_window), (ephy_extension_attach_tab), + (ephy_extension_detach_tab): + * src/ephy-extension.h: + * src/ephy-extensions-manager.c: (attach_window), (detach_window), + (attach_extension_to_window), (impl_attach_window), + (impl_detach_window), (impl_attach_tab), (impl_detach_tab), + (ephy_extensions_manager_iface_init): + * src/ephy-window.c: (tab_added_cb), (tab_removed_cb): + + Add attach_tab and detach_tab functions to extension interface (bug + #153732). Thanks to Crispin for almost all of the code. + 2004-12-17 Christian Persch <chpe@cvs.gnome.org> * src/prefs-dialog.c: diff --git a/src/ephy-extension.c b/src/ephy-extension.c index 6b90876c4..b4e92b891 100644 --- a/src/ephy-extension.c +++ b/src/ephy-extension.c @@ -50,7 +50,10 @@ ephy_extension_attach_window (EphyExtension *extension, EphyWindow *window) { EphyExtensionIface *iface = EPHY_EXTENSION_GET_IFACE (extension); - iface->attach_window (extension, window); + if (iface->attach_window) + { + iface->attach_window (extension, window); + } } void @@ -58,5 +61,32 @@ ephy_extension_detach_window (EphyExtension *extension, EphyWindow *window) { EphyExtensionIface *iface = EPHY_EXTENSION_GET_IFACE (extension); - iface->detach_window (extension, window); + if (iface->detach_window) + { + iface->detach_window (extension, window); + } +} + +void +ephy_extension_attach_tab (EphyExtension *extension, + EphyWindow *window, + EphyTab *tab) +{ + EphyExtensionIface *iface = EPHY_EXTENSION_GET_IFACE (extension); + if (iface->attach_tab) + { + iface->attach_tab (extension, window, tab); + } +} + +void +ephy_extension_detach_tab (EphyExtension *extension, + EphyWindow *window, + EphyTab *tab) +{ + EphyExtensionIface *iface = EPHY_EXTENSION_GET_IFACE (extension); + if (iface->detach_tab) + { + iface->detach_tab (extension, window, tab); + } } diff --git a/src/ephy-extension.h b/src/ephy-extension.h index 06d48e06f..d2af710a9 100644 --- a/src/ephy-extension.h +++ b/src/ephy-extension.h @@ -46,6 +46,12 @@ struct _EphyExtensionIface EphyWindow *window); void (* detach_window) (EphyExtension *extension, EphyWindow *window); + void (* attach_tab) (EphyExtension *extension, + EphyWindow *window, + EphyTab *tab); + void (* detach_tab) (EphyExtension *extension, + EphyWindow *window, + EphyTab *tab); }; GType ephy_extension_get_type (void); @@ -56,6 +62,14 @@ void ephy_extension_attach_window (EphyExtension *extension, void ephy_extension_detach_window (EphyExtension *extension, EphyWindow *window); +void ephy_extension_attach_tab (EphyExtension *extension, + EphyWindow *window, + EphyTab *tab); + +void ephy_extension_detach_tab (EphyExtension *extension, + EphyWindow *window, + EphyTab *tab); + G_END_DECLS #endif diff --git a/src/ephy-extensions-manager.c b/src/ephy-extensions-manager.c index a6ef2bf36..ed650c749 100644 --- a/src/ephy-extensions-manager.c +++ b/src/ephy-extensions-manager.c @@ -742,12 +742,21 @@ get_loader_for_type (EphyExtensionsManager *manager, return NULL; } - static void attach_window (EphyWindow *window, EphyExtension *extension) { + GList *tabs, *l; + ephy_extension_attach_window (extension, window); + + tabs = ephy_window_get_tabs (window); + for (l = tabs; l; l = l->next) + { + ephy_extension_attach_tab (extension, window, + EPHY_TAB (l->data)); + } + g_list_free (tabs); } static void @@ -805,6 +814,16 @@ static void detach_window (EphyWindow *window, EphyExtension *extension) { + GList *tabs, *l; + + tabs = ephy_window_get_tabs (window); + for (l = tabs; l; l = l->next) + { + ephy_extension_detach_tab (extension, window, + EPHY_TAB (l->data)); + } + g_list_free (tabs); + ephy_extension_detach_window (extension, window); } @@ -1225,6 +1244,13 @@ ephy_extensions_manager_finalize (GObject *object) } static void +attach_extension_to_window (EphyExtension *extension, + EphyWindow *window) +{ + attach_window (window, extension); +} + +static void impl_attach_window (EphyExtension *extension, EphyWindow *window) { @@ -1233,7 +1259,7 @@ impl_attach_window (EphyExtension *extension, LOG ("Attach") g_list_foreach (manager->priv->extensions, - (GFunc) ephy_extension_attach_window, window); + (GFunc) attach_extension_to_window, window); manager->priv->windows = g_list_prepend (manager->priv->windows, window); } @@ -1243,6 +1269,7 @@ impl_detach_window (EphyExtension *extension, EphyWindow *window) { EphyExtensionsManager *manager = EPHY_EXTENSIONS_MANAGER (extension); + GList *tabs, *l; LOG ("Detach") @@ -1250,6 +1277,16 @@ impl_detach_window (EphyExtension *extension, g_object_ref (window); + /* Detach tabs (uses impl_detach_tab) */ + tabs = ephy_window_get_tabs (window); + for (l = tabs; l; l = l->next) + { + ephy_extension_detach_tab (extension, window, + EPHY_TAB (l->data)); + } + g_list_free (tabs); + + /* Then detach the window */ g_list_foreach (manager->priv->extensions, (GFunc) ephy_extension_detach_window, window); @@ -1257,10 +1294,52 @@ impl_detach_window (EphyExtension *extension, } static void +impl_attach_tab (EphyExtension *extension, + EphyWindow *window, + EphyTab *tab) +{ + EphyExtensionsManager *manager = EPHY_EXTENSIONS_MANAGER (extension); + GList *l; + + LOG ("Attach tab"); + + for (l = manager->priv->extensions; l; l = l->next) + { + ephy_extension_attach_tab (EPHY_EXTENSION (l->data), + window, tab); + } +} + +static void +impl_detach_tab (EphyExtension *extension, + EphyWindow *window, + EphyTab *tab) +{ + EphyExtensionsManager *manager = EPHY_EXTENSIONS_MANAGER (extension); + GList *l; + + LOG ("Detach Tab"); + + g_object_ref (window); + g_object_ref (tab); + + for (l = manager->priv->extensions; l; l = l->next) + { + ephy_extension_detach_tab (EPHY_EXTENSION (l->data), + window, tab); + } + + g_object_unref (tab); + g_object_unref (window); +} + +static void ephy_extensions_manager_iface_init (EphyExtensionIface *iface) { iface->attach_window = impl_attach_window; iface->detach_window = impl_detach_window; + iface->attach_tab = impl_attach_tab; + iface->detach_tab = impl_detach_tab; } static void diff --git a/src/ephy-window.c b/src/ephy-window.c index c0ec381fc..3c08bf238 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -2007,6 +2007,7 @@ tab_added_cb (EphyNotebook *notebook, EphyTab *tab, EphyWindow *window) { + EphyExtension *manager; EphyEmbed *embed; g_return_if_fail (EPHY_IS_TAB (tab)); @@ -2023,6 +2024,10 @@ tab_added_cb (EphyNotebook *notebook, g_signal_connect_after (embed, "ge-modal-alert", G_CALLBACK (modal_alert_cb), window); + + /* Let the extensions attach themselves to the tab */ + manager = EPHY_EXTENSION (ephy_shell_get_extensions_manager (ephy_shell)); + ephy_extension_attach_tab (manager, window, tab); } static void @@ -2030,10 +2035,15 @@ tab_removed_cb (EphyNotebook *notebook, EphyTab *tab, EphyWindow *window) { + EphyExtension *manager; EphyEmbed *embed; g_return_if_fail (EPHY_IS_TAB (tab)); + /* Let the extensions remove themselves from the tab */ + manager = EPHY_EXTENSION (ephy_shell_get_extensions_manager (ephy_shell)); + ephy_extension_detach_tab (manager, window, tab); + g_signal_handlers_disconnect_by_func (G_OBJECT (tab), G_CALLBACK (sync_tab_visibility), window); |