aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@gnome.org>2003-09-24 01:08:54 +0800
committerMarco Pesenti Gritti <marco@src.gnome.org>2003-09-24 01:08:54 +0800
commit30930917e8ce020776e0096928aedfebe779bfd5 (patch)
treec888c0b43e0249264f098b3be4cbfbc876cceb25
parent2e1474156400d308faf8836801ee87607d9632d7 (diff)
downloadgsoc2013-epiphany-30930917e8ce020776e0096928aedfebe779bfd5.tar
gsoc2013-epiphany-30930917e8ce020776e0096928aedfebe779bfd5.tar.gz
gsoc2013-epiphany-30930917e8ce020776e0096928aedfebe779bfd5.tar.bz2
gsoc2013-epiphany-30930917e8ce020776e0096928aedfebe779bfd5.tar.lz
gsoc2013-epiphany-30930917e8ce020776e0096928aedfebe779bfd5.tar.xz
gsoc2013-epiphany-30930917e8ce020776e0096928aedfebe779bfd5.tar.zst
gsoc2013-epiphany-30930917e8ce020776e0096928aedfebe779bfd5.zip
Refactor initialization/automation code. Now all the code used by the
2003-09-23 Marco Pesenti Gritti <marco@gnome.org> * src/ephy-automation.c: (ephy_automation_factory_new): * src/ephy-automation.h: * src/ephy-main.c: (main), (ephy_main_start): * src/ephy-shell.c: (ephy_shell_init), (ephy_shell_finalize): Refactor initialization/automation code. Now all the code used by the first instance is in ephy_shell, all the code used by other instances is in ephy_main. Unref the factory before quitting so we dont risk new automation object are created and used with a dead shell.
-rw-r--r--ChangeLog13
-rw-r--r--src/ephy-automation.c15
-rw-r--r--src/ephy-automation.h7
-rw-r--r--src/ephy-main.c65
-rw-r--r--src/ephy-shell.c32
5 files changed, 68 insertions, 64 deletions
diff --git a/ChangeLog b/ChangeLog
index 93a596638..d85fc4163 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2003-09-23 Marco Pesenti Gritti <marco@gnome.org>
+
+ * src/ephy-automation.c: (ephy_automation_factory_new):
+ * src/ephy-automation.h:
+ * src/ephy-main.c: (main), (ephy_main_start):
+ * src/ephy-shell.c: (ephy_shell_init), (ephy_shell_finalize):
+
+ Refactor initialization/automation code. Now all the code
+ used by the first instance is in ephy_shell, all the code
+ used by other instances is in ephy_main.
+ Unref the factory before quitting so we dont risk new
+ automation object are created and used with a dead shell.
+
2003-09-23 Christian Persch <chpe@cvs.gnome.org>
* src/bookmarks/ephy-bookmarks-editor.c:
diff --git a/src/ephy-automation.c b/src/ephy-automation.c
index 5980f9c09..0abb0d540 100644
--- a/src/ephy-automation.c
+++ b/src/ephy-automation.c
@@ -28,7 +28,6 @@
#include "ephy-bookmarks-import.h"
#include <string.h>
-#include <bonobo/bonobo-generic-factory.h>
#include <bonobo/bonobo-main.h>
#include <bonobo/bonobo-context.h>
@@ -75,18 +74,20 @@ ephy_automation_factory (BonoboGenericFactory *this_factory,
return BONOBO_OBJECT(a);
}
-BonoboObject *
-ephy_automation_new (void)
+BonoboGenericFactory *
+ephy_automation_factory_new (void)
{
- BonoboGenericFactory *factory;
+ BonoboGenericFactory *factory;
factory = bonobo_generic_factory_new (EPHY_FACTORY_OAFIID,
ephy_automation_factory,
NULL);
+ if (factory == NULL)
+ {
+ g_warning ("Could not initialize EphyAutomation factory");
+ }
- g_return_val_if_fail (factory != NULL, NULL);
-
- return BONOBO_OBJECT (factory);
+ return factory;
}
static void
diff --git a/src/ephy-automation.h b/src/ephy-automation.h
index 3474b9705..5a730290e 100644
--- a/src/ephy-automation.h
+++ b/src/ephy-automation.h
@@ -21,8 +21,7 @@
#include "EphyAutomation.h"
-#include <bonobo/bonobo-control.h>
-#include <bonobo/bonobo-object.h>
+#include <bonobo/bonobo-generic-factory.h>
G_BEGIN_DECLS
@@ -43,9 +42,9 @@ typedef struct {
POA_GNOME_EphyAutomation__epv epv;
} EphyAutomationClass;
-GType ephy_automation_get_type (void);
+GType ephy_automation_get_type (void);
-BonoboObject *ephy_automation_new (void);
+BonoboGenericFactory *ephy_automation_factory_new (void);
G_END_DECLS
diff --git a/src/ephy-main.c b/src/ephy-main.c
index 986588ed8..5edd4617c 100644
--- a/src/ephy-main.c
+++ b/src/ephy-main.c
@@ -29,15 +29,10 @@
#include <libbonoboui.h>
#include <libgnome/gnome-program.h>
#include <libgnomeui/gnome-ui-init.h>
-#include <libgnomeui/gnome-icon-theme.h>
#include <gtk/gtkwindow.h>
-#include <libgnomevfs/gnome-vfs-init.h>
-#include <glade/glade-init.h>
#define EPHY_FACTORY_OAFIID "OAFIID:GNOME_Epiphany_Automation_Factory"
-static gboolean
-ephy_main_automation_init (void);
static gint
ephy_main_translate_url_arguments (poptContext context, gchar ***urls);
static gboolean
@@ -59,7 +54,6 @@ static gboolean ephy_server_mode = FALSE;
static gboolean open_as_bookmarks_editor = FALSE; /* --bookmarks-editor */
static gboolean open_as_nautilus_view = FALSE;
-static BonoboObject *automation_object;
static gint n_urls;
static gchar **url;
static gboolean first_instance;
@@ -120,7 +114,7 @@ main (int argc, char *argv[])
poptContext context;
GValue context_as_value = { 0 };
GnomeProgram *program;
- char *file;
+ CORBA_Object factory;
#ifdef ENABLE_NLS
/* Initialize the i18n stuff */
@@ -148,38 +142,25 @@ main (int argc, char *argv[])
g_value_unset (&context_as_value);
- first_instance = ephy_main_automation_init ();
+ factory = bonobo_activation_activate_from_id
+ (EPHY_FACTORY_OAFIID,
+ Bonobo_ACTIVATION_FLAG_EXISTING_ONLY,
+ NULL, NULL);
- if (first_instance)
+ if (factory != NULL)
{
- GnomeIconTheme *icon_theme;
-
- gnome_vfs_init ();
-
- glade_gnome_init ();
+ first_instance = FALSE;
+ ephy_main_start (NULL);
+ }
+ else
+ {
+ first_instance = TRUE;
ephy_shell_new ();
- icon_theme = gnome_icon_theme_new ();
- file = gnome_icon_theme_lookup_icon (icon_theme, "web-browser",
- -1, NULL, NULL);
- g_object_unref (icon_theme);
-
- if (file)
- {
- gtk_window_set_default_icon_from_file (file, NULL);
- g_free (file);
- }
- else
- {
- g_warning ("Web browser gnome icon not found");
- }
-
g_idle_add ((GSourceFunc) ephy_main_start, NULL);
bonobo_main ();
-
- gnome_vfs_shutdown ();
}
return 0;
@@ -296,28 +277,6 @@ ephy_main_start (gpointer data)
return FALSE;
}
-static gboolean
-ephy_main_automation_init (void)
-{
- CORBA_Object factory;
-
- factory = bonobo_activation_activate_from_id
- (EPHY_FACTORY_OAFIID,
- Bonobo_ACTIVATION_FLAG_EXISTING_ONLY,
- NULL, NULL);
-
- if (!factory)
- {
- automation_object = ephy_automation_new ();
- return TRUE;
- }
- else
- {
- ephy_main_start (NULL);
- return FALSE;
- }
-}
-
/**
* translate_url_arguments: gather URL arguments and expand them fully
* with realpath if they're filenames
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 2be34fdf6..b70435892 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -42,6 +42,7 @@
#include "downloader-view.h"
#include "ephy-toolbars-model.h"
#include "ephy-autocompletion.h"
+#include "ephy-automation.h"
#include <string.h>
#include <libgnomeui/gnome-client.h>
@@ -51,6 +52,9 @@
#include <gtk/gtkmain.h>
#include <gtk/gtkmessagedialog.h>
#include <dirent.h>
+#include <libgnomevfs/gnome-vfs-init.h>
+#include <libgnomeui/gnome-icon-theme.h>
+#include <glade/glade-init.h>
#ifdef ENABLE_NAUTILUS_VIEW
@@ -65,6 +69,7 @@
struct EphyShellPrivate
{
+ BonoboGenericFactory *automation_factory;
Session *session;
EphyAutocompletion *autocompletion;
EphyBookmarks *bookmarks;
@@ -197,6 +202,8 @@ ephy_shell_init (EphyShell *gs)
{
EphyEmbedSingle *single;
EphyShell **ptr = &ephy_shell;
+ GnomeIconTheme *icon_theme;
+ char *file;
gs->priv = EPHY_SHELL_GET_PRIVATE (gs);
@@ -212,6 +219,8 @@ ephy_shell_init (EphyShell *gs)
g_object_add_weak_pointer (G_OBJECT(ephy_shell),
(gpointer *)ptr);
+ gnome_vfs_init ();
+ glade_gnome_init ();
ephy_debug_init ();
ephy_thread_helpers_init ();
ephy_file_helpers_init ();
@@ -247,6 +256,23 @@ ephy_shell_init (EphyShell *gs)
}
ephy_shell_load_plugins (gs);
+
+ icon_theme = gnome_icon_theme_new ();
+ file = gnome_icon_theme_lookup_icon (icon_theme, "web-browser",
+ -1, NULL, NULL);
+ g_object_unref (icon_theme);
+
+ if (file)
+ {
+ gtk_window_set_default_icon_from_file (file, NULL);
+ g_free (file);
+ }
+ else
+ {
+ g_warning ("Web browser gnome icon not found");
+ }
+
+ gs->priv->automation_factory = ephy_automation_factory_new ();
}
static void
@@ -309,6 +335,12 @@ ephy_shell_finalize (GObject *object)
ephy_state_save ();
ephy_file_helpers_shutdown ();
+ gnome_vfs_shutdown ();
+
+ if (gs->priv->automation_factory)
+ {
+ bonobo_object_unref (gs->priv->automation_factory);
+ }
LOG ("Ephy shell finalized")