diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2003-11-11 05:36:34 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2003-11-11 05:36:34 +0800 |
commit | 6e5d0d68dce662ca6db4a753154b010e3e82bfdc (patch) | |
tree | f58000182e2ad17e3c0dc271dd70f02cbb94927c /src/ephy-shell.c | |
parent | 5dd52c6c36d647d844372b3baad27df7f014bdf6 (diff) | |
download | gsoc2013-epiphany-6e5d0d68dce662ca6db4a753154b010e3e82bfdc.tar gsoc2013-epiphany-6e5d0d68dce662ca6db4a753154b010e3e82bfdc.tar.gz gsoc2013-epiphany-6e5d0d68dce662ca6db4a753154b010e3e82bfdc.tar.bz2 gsoc2013-epiphany-6e5d0d68dce662ca6db4a753154b010e3e82bfdc.tar.lz gsoc2013-epiphany-6e5d0d68dce662ca6db4a753154b010e3e82bfdc.tar.xz gsoc2013-epiphany-6e5d0d68dce662ca6db4a753154b010e3e82bfdc.tar.zst gsoc2013-epiphany-6e5d0d68dce662ca6db4a753154b010e3e82bfdc.zip |
New extensions API.
2003-11-10 Christian Persch <chpe@cvs.gnome.org>
New extensions API.
* Makefile.am:
* configure.in:
* lib/Makefile.am:
* lib/ephy-module-loader.c: (ephy_module_loader_get_type),
(ephy_module_loader_new), (ephy_module_loader_load),
(ephy_module_loader_unload), (ephy_module_loader_class_init),
(ephy_module_loader_init), (ephy_module_loader_finalize),
(ephy_module_loader_factory):
* lib/ephy-module-loader.h:
* plugins/.cvsignore:
* plugins/Makefile.am:
* plugins/sample/.cvsignore:
* plugins/sample/Makefile.am:
* plugins/sample/sample.c:
* src/Makefile.am:
* src/bookmarks/ephy-bookmarks-editor.c: (get_target_window):
* src/bookmarks/ephy-bookmarks.c:
* src/ephy-automation.c: (ephy_automation_factory),
(ephy_automation_factory_new), (impl_ephy_automation_loadurl),
(impl_ephy_automation_load_session), (ephy_automation_class_init):
* src/ephy-extension.c: (ephy_extension_get_type),
(ephy_extension_attach_window), (ephy_extension_detach_window):
* src/ephy-extension.h:
* src/ephy-extensions-manager.c:
(ephy_extensions_manager_get_type),
(ephy_extensions_manager_instantiate_extension),
(ephy_extensions_manager_load), (ephy_extensions_manager_load_dir),
(ephy_extensions_manager_add), (ephy_extensions_manager_init),
(ephy_extensions_manager_finalize), (impl_attach_window),
(impl_detach_window), (ephy_extensions_manager_iface_init),
(ephy_extensions_manager_class_init),
(ephy_extensions_manager_new):
* src/ephy-extensions-manager.h:
* src/ephy-history-window.c: (get_target_window):
* src/ephy-plugin.c:
* src/ephy-plugin.h:
* src/ephy-session.c: (ephy_session_get_type),
(get_session_filename), (session_delete), (net_stop_cb),
(tab_added_cb), (tab_removed_cb), (tabs_reordered_cb),
(impl_attach_window), (impl_detach_window), (save_yourself_cb),
(die_cb), (gnome_session_attach), (gnome_session_detach),
(ensure_session_directory), (ephy_session_init),
(ephy_session_dispose), (ephy_session_finalize),
(ephy_session_iface_init), (ephy_session_class_init),
(offer_to_resume), (ephy_session_autoresume), (ephy_session_close),
(write_tab), (write_window_geometry), (write_tool_window),
(write_ephy_window), (ephy_session_save), (parse_embed),
(ephy_session_load), (ephy_session_get_windows),
(ephy_session_add_window), (ephy_session_remove_window),
(ephy_session_get_active_window):
* src/ephy-session.h:
* src/ephy-shell.c: (ephy_shell_init), (ephy_shell_finalize),
(ephy_shell_get_session), (ephy_shell_get_extensions_manager),
(toolwindow_show_cb), (toolwindow_hide_cb):
* src/ephy-shell.h:
* src/ephy-window.c: (ephy_window_destroy), (ephy_window_init):
* src/prefs-dialog.c: (prefs_homepage_current_button_clicked_cb):
* src/session.c:
* src/session.h:
Create a new extensions API. Make session an internal extension :)
Port callers to session API changes.
Diffstat (limited to 'src/ephy-shell.c')
-rw-r--r-- | src/ephy-shell.c | 129 |
1 files changed, 34 insertions, 95 deletions
diff --git a/src/ephy-shell.c b/src/ephy-shell.c index 806b8ca47..c476d3ac1 100644 --- a/src/ephy-shell.c +++ b/src/ephy-shell.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000, 2001, 2002, 2003 Marco Pesenti Gritti + * Copyright (C) 2000-2003 Marco Pesenti Gritti * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ */ #ifdef HAVE_CONFIG_H -#include <config.h> +#include "config.h" #endif #include "ephy-shell.h" @@ -36,9 +36,9 @@ #include "ephy-bookmarks-editor.h" #include "ephy-history-window.h" #include "ephy-debug.h" -#include "ephy-plugin.h" +#include "ephy-extensions-manager.h" #include "toolbar.h" -#include "session.h" +#include "ephy-session.h" #include "downloader-view.h" #include "ephy-toolbars-model.h" #include "ephy-automation.h" @@ -69,13 +69,13 @@ struct EphyShellPrivate { BonoboGenericFactory *automation_factory; - Session *session; + EphySession *session; EphyBookmarks *bookmarks; EphyToolbarsModel *toolbars_model; EggToolbarsModel *fs_toolbars_model; + EphyExtensionsManager *extensions_manager; GtkWidget *bme; GtkWidget *history_window; - GList *plugins; GList *del_on_exit; }; @@ -164,39 +164,6 @@ ephy_shell_new_window_cb (EphyEmbedShell *shell, } static void -ephy_shell_load_plugins (EphyShell *es) -{ - DIR *d; - struct dirent *e; - - d = opendir (PLUGINS_DIR); - - if (d == NULL) - { - return; - } - - while ((e = readdir (d)) != NULL) - { - char *plugin; - - plugin = g_strconcat (PLUGINS_DIR"/", e->d_name, NULL); - - if (g_str_has_suffix (plugin, ".so")) - { - EphyPlugin *obj; - - obj = ephy_plugin_new (plugin); - es->priv->plugins = g_list_append - (es->priv->plugins, obj); - } - - g_free (plugin); - } - closedir (d); -} - -static void ephy_shell_init (EphyShell *gs) { EphyEmbedSingle *single; @@ -213,7 +180,6 @@ ephy_shell_init (EphyShell *gs) gs->priv->history_window = NULL; gs->priv->toolbars_model = NULL; gs->priv->fs_toolbars_model = NULL; - gs->priv->plugins = NULL; ephy_shell = gs; g_object_add_weak_pointer (G_OBJECT(ephy_shell), @@ -255,9 +221,8 @@ ephy_shell_init (EphyShell *gs) exit (0); } - ephy_shell_load_plugins (gs); - /* FIXME listen on icon changes */ + /* FIXME MultiHead: icon theme is per-display, not global */ icon_theme = gtk_icon_theme_get_default (); icon_info = gtk_icon_theme_lookup_icon (icon_theme, "web-browser", -1, 0); @@ -265,9 +230,10 @@ ephy_shell_init (EphyShell *gs) { icon_file = gtk_icon_info_get_filename (icon_info); - g_return_if_fail (icon_file != NULL); - - gtk_window_set_default_icon_from_file (icon_file, NULL); + if (icon_file) + { + gtk_window_set_default_icon_from_file (icon_file, NULL); + } gtk_icon_info_free (icon_info); } @@ -276,6 +242,15 @@ ephy_shell_init (EphyShell *gs) g_warning ("Web browser gnome icon not found"); } + /* Instantiate extensions manager; this will load the extensions */ + gs->priv->extensions_manager = ephy_extensions_manager_new (); + + /* Instantiate internal extensions */ + gs->priv->session = + EPHY_SESSION (ephy_extensions_manager_add + (gs->priv->extensions_manager, EPHY_TYPE_SESSION)); + + /* Instantiate the automation factory */ gs->priv->automation_factory = ephy_automation_factory_new (); } @@ -295,8 +270,9 @@ ephy_shell_finalize (GObject *object) g_assert (ephy_shell == NULL); - g_list_foreach (gs->priv->plugins, (GFunc)g_type_module_unuse, NULL); - g_list_free (gs->priv->plugins); + /* this will unload the extensions */ + LOG ("Unref extension manager") + g_object_unref (gs->priv->extensions_manager); delete_files (gs->priv->del_on_exit); g_list_foreach (gs->priv->del_on_exit, (GFunc)g_free, NULL); @@ -314,12 +290,6 @@ ephy_shell_finalize (GObject *object) g_object_unref (G_OBJECT (gs->priv->fs_toolbars_model)); } - LOG ("Unref session") - if (gs->priv->session) - { - g_object_unref (G_OBJECT (gs->priv->session)); - } - LOG ("Unref Bookmarks Editor"); if (gs->priv->bme) { @@ -398,42 +368,6 @@ load_homepage (EphyEmbed *embed) } /** - * ephy_shell_get_active_window: - * @gs: a #EphyShell - * - * Get the current active window. Use it when you - * need to take an action (like opening an url) on - * a window but you dont have a target window. - * Ex. open a new tab from command line. - * - * Return value: the current active window - **/ -EphyWindow * -ephy_shell_get_active_window (EphyShell *gs) -{ - Session *session; - GList *windows, *l; - EphyWindow *window = NULL; - - session = EPHY_SESSION (ephy_shell_get_session (gs)); - - windows = session_get_windows (session); - - for (l = windows; l != NULL; l = l->next) - { - if (EPHY_IS_WINDOW (l->data)) - { - window = EPHY_WINDOW (l->data); - break; - } - } - - g_list_free (windows); - - return window; -} - -/** * ephy_shell_new_tab: * @shell: a #EphyShell * @parent_window: the target #EphyWindow or %NULL @@ -584,10 +518,7 @@ ephy_nautilus_view_new (BonoboGenericFactory *factory, const char *id, GObject * ephy_shell_get_session (EphyShell *gs) { - if (!gs->priv->session) - { - gs->priv->session = session_new (); - } + g_return_val_if_fail (EPHY_IS_SHELL (gs), NULL); return G_OBJECT (gs->priv->session); } @@ -638,11 +569,19 @@ ephy_shell_get_toolbars_model (EphyShell *gs, gboolean fullscreen) } } +GObject * +ephy_shell_get_extensions_manager (EphyShell *es) +{ + g_return_val_if_fail (EPHY_IS_SHELL (es), NULL); + + return G_OBJECT (es->priv->extensions_manager); +} + static void toolwindow_show_cb (GtkWidget *widget) { LOG ("Ref shell for %s", G_OBJECT_TYPE_NAME (widget)) - session_add_window (ephy_shell->priv->session, GTK_WINDOW (widget)); + ephy_session_add_window (ephy_shell->priv->session, GTK_WINDOW (widget)); g_object_ref (ephy_shell); } @@ -650,7 +589,7 @@ static void toolwindow_hide_cb (GtkWidget *widget) { LOG ("Unref shell for %s", G_OBJECT_TYPE_NAME (widget)) - session_remove_window (ephy_shell->priv->session, GTK_WINDOW (widget)); + ephy_session_remove_window (ephy_shell->priv->session, GTK_WINDOW (widget)); g_object_unref (ephy_shell); } |