diff options
author | Marco Pesenti Gritti <marco@gnome.org> | 2003-11-15 01:11:16 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <marco@src.gnome.org> | 2003-11-15 01:11:16 +0800 |
commit | fa2e94db1e8ec3bd0cb8be19b29ece77c66452bf (patch) | |
tree | 3ddbeeaf56fa62e472d4e619b736a2e926cfab89 /src/ephy-shell.c | |
parent | b086814a1ff6d94b29ae2185aebb22321da7e1a4 (diff) | |
download | gsoc2013-epiphany-fa2e94db1e8ec3bd0cb8be19b29ece77c66452bf.tar.gz gsoc2013-epiphany-fa2e94db1e8ec3bd0cb8be19b29ece77c66452bf.tar.zst gsoc2013-epiphany-fa2e94db1e8ec3bd0cb8be19b29ece77c66452bf.zip |
Use an unique factory for both interfaces.
2003-11-14 Marco Pesenti Gritti <marco@gnome.org>
* data/GNOME_Epiphany_Automation.server.in:
* data/GNOME_Epiphany_NautilusView.server.in:
Use an unique factory for both interfaces.
* data/ui/Makefile.am:
Do not try to merge translations in nautilus xml.
* src/ephy-nautilus-view.c: (disconnected_idle),
(control_disconnected_cb), (ephy_nautilus_view_instance_init),
(ephy_nautilus_view_finalize):
Unref the view on control disconnected, not on finalize.
* src/ephy-main.c: (main):
Add a server mode argument, used internally by bonobo interface.
Free popt context only when no more necessary.
* src/ephy-automation.c:
* src/ephy-automation.h:
* src/ephy-shell.c: (ephy_nautilus_view_new),
(ephy_automation_factory_cb), (ephy_automation_factory_new),
(ephy_shell_init), (path_from_command_line_arg), (open_urls),
(server_timeout), (ephy_shell_startup), (ephy_shell_finalize),
(ephy_shell_new_tab):
* src/ephy-shell.h:
When running in server mode unref (and so exit) on a timeout.
Expand args passed to the command line.
Diffstat (limited to 'src/ephy-shell.c')
-rw-r--r-- | src/ephy-shell.c | 170 |
1 files changed, 102 insertions, 68 deletions
diff --git a/src/ephy-shell.c b/src/ephy-shell.c index 4d11fec89..90f8ddbc4 100644 --- a/src/ephy-shell.c +++ b/src/ephy-shell.c @@ -50,15 +50,13 @@ #include <unistd.h> #ifdef ENABLE_NAUTILUS_VIEW - #include <bonobo/bonobo-generic-factory.h> #include "ephy-nautilus-view.h" - -#define EPHY_NAUTILUS_VIEW_OAFIID "OAFIID:GNOME_Epiphany_NautilusViewFactory" - #endif +#define EPHY_NAUTILUS_VIEW_IID "OAFIID:GNOME_Epiphany_NautilusView" #define AUTOMATION_IID "OAFIID:GNOME_Epiphany_Automation" +#define SERVER_TIMEOUT 60000 #define EPHY_SHELL_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_SHELL, EphyShellPrivate)) @@ -73,6 +71,7 @@ struct EphyShellPrivate GtkWidget *bme; GtkWidget *history_window; GList *del_on_exit; + guint server_timeout; }; static void @@ -82,17 +81,6 @@ ephy_shell_init (EphyShell *gs); static void ephy_shell_finalize (GObject *object); -#ifdef ENABLE_NAUTILUS_VIEW - -static void -ephy_nautilus_view_init_factory (EphyShell *gs); -static BonoboObject * -ephy_nautilus_view_new (BonoboGenericFactory *factory, - const char *id, - EphyShell *gs); - -#endif - static GObjectClass *parent_class = NULL; EphyShell *ephy_shell; @@ -151,6 +139,60 @@ ephy_shell_class_init (EphyShellClass *klass) g_type_class_add_private (object_class, sizeof(EphyShellPrivate)); } +#ifdef ENABLE_NAUTILUS_VIEW + +static BonoboObject * +ephy_nautilus_view_new (EphyShell *gs) +{ + EphyNautilusView *view; + + view = EPHY_NAUTILUS_VIEW + (ephy_nautilus_view_new_component (gs)); + + return BONOBO_OBJECT (view); +} + +#endif + +static BonoboObject * +ephy_automation_factory_cb (BonoboGenericFactory *this_factory, + const char *iid, + EphyShell *es) +{ + if (strcmp (iid, AUTOMATION_IID) == 0) + { + return BONOBO_OBJECT (g_object_new (EPHY_TYPE_AUTOMATION, NULL)); + } +#ifdef ENABLE_NAUTILUS_VIEW + else if (strcmp (iid, EPHY_NAUTILUS_VIEW_IID) == 0) + { + return ephy_nautilus_view_new (es); + } +#endif + + g_assert_not_reached (); + + return NULL; +} + + +static BonoboGenericFactory * +ephy_automation_factory_new (EphyShell *es) +{ + BonoboGenericFactory *factory; + GClosure *factory_closure; + + factory = g_object_new (bonobo_generic_factory_get_type (), NULL); + + factory_closure = g_cclosure_new + (G_CALLBACK (ephy_automation_factory_cb), es, NULL); + + bonobo_generic_factory_construct_noreg + (factory, AUTOMATION_FACTORY_IID, factory_closure); + + return factory; +} + static void ephy_shell_init (EphyShell *gs) { @@ -165,13 +207,29 @@ ephy_shell_init (EphyShell *gs) gs->priv->toolbars_model = NULL; gs->priv->fs_toolbars_model = NULL; gs->priv->extensions_manager = NULL; + gs->priv->server_timeout = 0; ephy_shell = gs; g_object_add_weak_pointer (G_OBJECT(ephy_shell), (gpointer *)ptr); /* Instantiate the automation factory */ - gs->priv->automation_factory = ephy_automation_factory_new (); + gs->priv->automation_factory = ephy_automation_factory_new (gs); +} + +static char * +path_from_command_line_arg (const char *arg) +{ + char path[PATH_MAX]; + + if (realpath (arg, path) != NULL) + { + return g_strdup (path); + } + else + { + return g_strdup (arg); + } } static void @@ -193,13 +251,27 @@ open_urls (GNOME_EphyAutomation automation, { for (i = 0; args[i] != NULL; i++) { + char *path; + + path = path_from_command_line_arg (args[i]); + GNOME_EphyAutomation_loadurl - (automation, args[i], fullscreen, + (automation, path, fullscreen, existing_window, new_tab, ev); + + g_free (path); } } } +static gboolean +server_timeout (EphyShell *gs) +{ + g_object_unref (gs); + + return FALSE; +} + gboolean ephy_shell_startup (EphyShell *gs, EphyShellStartupFlags flags, @@ -213,10 +285,6 @@ ephy_shell_startup (EphyShell *gs, ephy_ensure_dir_exists (ephy_dot_dir ()); -#ifdef ENABLE_NAUTILUS_VIEW - ephy_nautilus_view_init_factory (gs); -#endif - CORBA_exception_init (&ev); result = bonobo_activation_register_active_server @@ -246,8 +314,14 @@ ephy_shell_startup (EphyShell *gs, g_assert_not_reached (); } - if (result == Bonobo_ACTIVATION_REG_SUCCESS || - result == Bonobo_ACTIVATION_REG_ALREADY_ACTIVE) + if (flags & EPHY_SHELL_STARTUP_SERVER) + { + g_object_ref (gs); + gs->priv->server_timeout = g_timeout_add + (SERVER_TIMEOUT, (GSourceFunc)server_timeout, gs); + } + else if (result == Bonobo_ACTIVATION_REG_SUCCESS || + result == Bonobo_ACTIVATION_REG_ALREADY_ACTIVE) { automation = bonobo_activation_activate_from_id (AUTOMATION_IID, 0, NULL, &ev); @@ -316,6 +390,11 @@ ephy_shell_finalize (GObject *object) g_assert (ephy_shell == NULL); + if (gs->priv->server_timeout > 0) + { + g_source_remove (gs->priv->server_timeout); + } + /* this will unload the extensions */ LOG ("Unref extension manager") g_object_unref (gs->priv->extensions_manager); @@ -487,51 +566,6 @@ ephy_shell_new_tab (EphyShell *shell, return tab; } -#ifdef ENABLE_NAUTILUS_VIEW - -static void -ephy_nautilus_view_all_controls_dead (void) -{ - if (!bonobo_control_life_get_count ()) - { - g_object_unref (G_OBJECT (ephy_shell)); - } -} - -static void -ephy_nautilus_view_init_factory (EphyShell *gs) -{ - BonoboGenericFactory *ephy_nautilusview_factory; - - ephy_nautilusview_factory = bonobo_generic_factory_new - (EPHY_NAUTILUS_VIEW_OAFIID, - (BonoboFactoryCallback) ephy_nautilus_view_new, gs); - if (!BONOBO_IS_GENERIC_FACTORY (ephy_nautilusview_factory)) - { - g_warning ("Couldn't create the factory!"); - return; - } - - bonobo_control_life_set_callback (ephy_nautilus_view_all_controls_dead); -} - -static BonoboObject * -ephy_nautilus_view_new (BonoboGenericFactory *factory, const char *id, - EphyShell *gs) -{ - EphyNautilusView *view; - - view = EPHY_NAUTILUS_VIEW ( - ephy_nautilus_view_new_component (gs)); - - bonobo_control_life_instrument ( - nautilus_view_get_bonobo_control (NAUTILUS_VIEW (view))); - - return BONOBO_OBJECT (view); -} - -#endif - /** * ephy_shell_get_session: * @gs: a #EphyShell |