aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@gnome.org>2003-11-15 01:11:16 +0800
committerMarco Pesenti Gritti <marco@src.gnome.org>2003-11-15 01:11:16 +0800
commitfa2e94db1e8ec3bd0cb8be19b29ece77c66452bf (patch)
tree3ddbeeaf56fa62e472d4e619b736a2e926cfab89 /src
parentb086814a1ff6d94b29ae2185aebb22321da7e1a4 (diff)
downloadgsoc2013-epiphany-fa2e94db1e8ec3bd0cb8be19b29ece77c66452bf.tar
gsoc2013-epiphany-fa2e94db1e8ec3bd0cb8be19b29ece77c66452bf.tar.gz
gsoc2013-epiphany-fa2e94db1e8ec3bd0cb8be19b29ece77c66452bf.tar.bz2
gsoc2013-epiphany-fa2e94db1e8ec3bd0cb8be19b29ece77c66452bf.tar.lz
gsoc2013-epiphany-fa2e94db1e8ec3bd0cb8be19b29ece77c66452bf.tar.xz
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')
-rw-r--r--src/ephy-automation.c25
-rw-r--r--src/ephy-automation.h2
-rw-r--r--src/ephy-main.c18
-rw-r--r--src/ephy-nautilus-view.c28
-rw-r--r--src/ephy-shell.c170
-rw-r--r--src/ephy-shell.h8
6 files changed, 137 insertions, 114 deletions
diff --git a/src/ephy-automation.c b/src/ephy-automation.c
index 182e785bb..33f5dc822 100644
--- a/src/ephy-automation.c
+++ b/src/ephy-automation.c
@@ -36,31 +36,6 @@ static void ephy_automation_class_init (EphyAutomationClass *klass);
static GObjectClass *parent_class = NULL;
-static BonoboObject *
-ephy_automation_factory_cb (BonoboGenericFactory *this_factory,
- const char *iid,
- gpointer user_data)
-{
- return BONOBO_OBJECT (g_object_new (EPHY_TYPE_AUTOMATION, NULL));
-}
-
-BonoboGenericFactory *
-ephy_automation_factory_new (void)
-{
- 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), NULL, NULL);
-
- bonobo_generic_factory_construct_noreg
- (factory, AUTOMATION_FACTORY_IID, factory_closure);
-
- return factory;
-}
-
static void
impl_ephy_automation_loadurl (PortableServer_Servant _servant,
const CORBA_char *url,
diff --git a/src/ephy-automation.h b/src/ephy-automation.h
index 319aa8b18..5422ce45e 100644
--- a/src/ephy-automation.h
+++ b/src/ephy-automation.h
@@ -48,8 +48,6 @@ typedef struct
GType ephy_automation_get_type (void);
-BonoboGenericFactory *ephy_automation_factory_new (void);
-
G_END_DECLS
#endif /* _EPHY_AUTOMATION_H_ */
diff --git a/src/ephy-main.c b/src/ephy-main.c
index d94e301a1..b7d29b4af 100644
--- a/src/ephy-main.c
+++ b/src/ephy-main.c
@@ -41,7 +41,7 @@ static gboolean open_in_existing = FALSE;
static gboolean open_in_new_tab = FALSE;
static gboolean open_fullscreen = FALSE;
static gboolean open_as_bookmarks_editor = FALSE;
-static gboolean open_as_nautilus_view = FALSE;
+static gboolean server_mode = FALSE;
static const char *session_filename = NULL;
static const char *bookmark_url = NULL;
@@ -64,12 +64,12 @@ static struct poptOption popt_options[] =
{ "import-bookmarks", '\0', POPT_ARG_STRING, &bookmarks_file,
0, N_("Import bookmarks from the given file"),
N_("FILE") },
- { "nautilus-view", 'v', POPT_ARG_NONE, &open_as_nautilus_view, 0,
- N_("Used internally by the nautilus view"),
- NULL },
{ "bookmarks-editor", 'b', POPT_ARG_NONE, &open_as_bookmarks_editor, 0,
N_("Launch the bookmarks editor"),
NULL },
+ { "server", 's', POPT_ARG_NONE, &server_mode, 0,
+ N_("Used internally by the bonobo interface"),
+ NULL },
{ NULL, 0, 0, NULL, 0, NULL, NULL }
};
@@ -111,7 +111,6 @@ main (int argc, char *argv[])
g_value_init (&context_as_value, G_TYPE_POINTER));
context = g_value_get_pointer (&context_as_value);
args = poptGetArgs (context);
- poptFreeContext (context);
startup_flags = 0;
string_arg = NULL;
@@ -131,10 +130,6 @@ main (int argc, char *argv[])
{
startup_flags |= EPHY_SHELL_STARTUP_BOOKMARKS_EDITOR;
}
- else if (open_as_nautilus_view)
- {
- startup_flags |= EPHY_SHELL_STARTUP_NAUTILUS_VIEW;
- }
else if (session_filename != NULL)
{
startup_flags |= EPHY_SHELL_STARTUP_SESSION;
@@ -150,6 +145,10 @@ main (int argc, char *argv[])
startup_flags |= EPHY_SHELL_STARTUP_ADD_BOOKMARK;
string_arg = bookmark_url;
}
+ else if (server_mode)
+ {
+ startup_flags |= EPHY_SHELL_STARTUP_SERVER;
+ }
gnome_vfs_init ();
glade_gnome_init ();
@@ -186,6 +185,7 @@ main (int argc, char *argv[])
ephy_state_save ();
ephy_file_helpers_shutdown ();
gnome_vfs_shutdown ();
+ poptFreeContext (context);
return 0;
}
diff --git a/src/ephy-nautilus-view.c b/src/ephy-nautilus-view.c
index e1c799dbd..2d2de8300 100644
--- a/src/ephy-nautilus-view.c
+++ b/src/ephy-nautilus-view.c
@@ -139,6 +139,20 @@ BonoboUIVerb ephy_verbs [] = {
BONOBO_CLASS_BOILERPLATE (EphyNautilusView, ephy_nautilus_view,
NautilusView, NAUTILUS_TYPE_VIEW)
+static gboolean
+disconnected_idle (EphyShell *shell)
+{
+ g_object_unref (shell);
+
+ return FALSE;
+}
+
+static void
+control_disconnected_cb (BonoboControl *control)
+{
+ g_idle_add ((GSourceFunc)disconnected_idle, ephy_shell);
+}
+
static void
ephy_nautilus_view_instance_init (EphyNautilusView *view)
{
@@ -148,6 +162,7 @@ ephy_nautilus_view_instance_init (EphyNautilusView *view)
float *levels;
gchar **names;
guint i;
+ BonoboControl *control;
single = ephy_embed_shell_get_embed_single
(EPHY_EMBED_SHELL (ephy_shell));
@@ -155,15 +170,13 @@ ephy_nautilus_view_instance_init (EphyNautilusView *view)
view->priv = p;
view->priv->embed = ephy_embed_new (G_OBJECT (single));
- g_object_ref (G_OBJECT (ephy_shell));
-
g_signal_connect (view->priv->embed, "ge_link_message",
G_CALLBACK (gnv_embed_link_message_cb),
view);
g_signal_connect (view->priv->embed, "ge_location",
G_CALLBACK (gnv_embed_location_cb),
view);
- g_signal_connect (view->priv->embed, "ge_title",
+ g_signal_connect (view->priv->embed, "title",
G_CALLBACK (gnv_embed_title_cb),
view);
g_signal_connect (view->priv->embed, "ge_new_window",
@@ -190,7 +203,12 @@ ephy_nautilus_view_instance_init (EphyNautilusView *view)
g_signal_connect (G_OBJECT (view), "stop_loading",
G_CALLBACK (gnv_stop_loading_cb), NULL);
- g_signal_connect (G_OBJECT (nautilus_view_get_bonobo_control (NAUTILUS_VIEW (view))),
+ control = nautilus_view_get_bonobo_control (NAUTILUS_VIEW (view));
+ g_object_ref (ephy_shell);
+
+ g_signal_connect (control, "disconnected",
+ G_CALLBACK (control_disconnected_cb), NULL);
+ g_signal_connect (control,
"activate",
G_CALLBACK (gnv_bonobo_control_activate_cb), view);
@@ -276,8 +294,6 @@ ephy_nautilus_view_finalize (GObject *object)
g_free (p->location);
GNOME_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
-
- g_object_unref (G_OBJECT (ephy_shell));
}
static void
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
diff --git a/src/ephy-shell.h b/src/ephy-shell.h
index 66e12ace5..9ca8dce2d 100644
--- a/src/ephy-shell.h
+++ b/src/ephy-shell.h
@@ -64,10 +64,10 @@ typedef enum
EPHY_SHELL_STARTUP_EXISTING_WINDOW = 1 << 2,
EPHY_SHELL_STARTUP_FULLSCREEN = 1 << 3,
EPHY_SHELL_STARTUP_BOOKMARKS_EDITOR = 1 << 4,
- EPHY_SHELL_STARTUP_NAUTILUS_VIEW = 1 << 5,
- EPHY_SHELL_STARTUP_SESSION = 1 << 6,
- EPHY_SHELL_STARTUP_IMPORT_BOOKMARKS = 1 << 7,
- EPHY_SHELL_STARTUP_ADD_BOOKMARK = 1 << 8
+ EPHY_SHELL_STARTUP_SESSION = 1 << 5,
+ EPHY_SHELL_STARTUP_IMPORT_BOOKMARKS = 1 << 6,
+ EPHY_SHELL_STARTUP_ADD_BOOKMARK = 1 << 7,
+ EPHY_SHELL_STARTUP_SERVER = 1 << 8
} EphyShellStartupFlags;
typedef enum