diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2006-01-18 23:53:54 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2006-01-18 23:53:54 +0800 |
commit | bc05ca2fb4d1d031e5ba4f081666bfcbec875872 (patch) | |
tree | bce80060063e65e63366c4063267802dc35cde61 | |
parent | 539426a9bd327676ad71b263e497ce19da1adde9 (diff) | |
download | gsoc2013-epiphany-bc05ca2fb4d1d031e5ba4f081666bfcbec875872.tar.gz gsoc2013-epiphany-bc05ca2fb4d1d031e5ba4f081666bfcbec875872.tar.zst gsoc2013-epiphany-bc05ca2fb4d1d031e5ba4f081666bfcbec875872.zip |
Decouple embed single instantiation and initialisation. Prevents
2006-01-18 Christian Persch <chpe@cvs.gnome.org>
* embed/ephy-embed-shell.c: (impl_get_embed_single):
* embed/ephy-embed-single.c: (ephy_embed_single_init):
* embed/ephy-embed-single.h:
* embed/mozilla/mozilla-embed-single.cpp:
Decouple embed single instantiation and initialisation.
Prevents double-initialisation on startup.
* embed/mozilla/EphyContentPolicy.cpp:
* embed/mozilla/EphyContentPolicy.h:
Remove embed single variable, it was unused.
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | embed/ephy-embed-shell.c | 37 | ||||
-rw-r--r-- | embed/ephy-embed-single.c | 14 | ||||
-rw-r--r-- | embed/ephy-embed-single.h | 3 | ||||
-rw-r--r-- | embed/mozilla/EphyContentPolicy.cpp | 3 | ||||
-rw-r--r-- | embed/mozilla/EphyContentPolicy.h | 3 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed-single.cpp | 22 | ||||
-rw-r--r-- | po/POTFILES.in | 1 |
8 files changed, 74 insertions, 24 deletions
@@ -1,5 +1,20 @@ 2006-01-18 Christian Persch <chpe@cvs.gnome.org> + * embed/ephy-embed-shell.c: (impl_get_embed_single): + * embed/ephy-embed-single.c: (ephy_embed_single_init): + * embed/ephy-embed-single.h: + * embed/mozilla/mozilla-embed-single.cpp: + + Decouple embed single instantiation and initialisation. + Prevents double-initialisation on startup. + + * embed/mozilla/EphyContentPolicy.cpp: + * embed/mozilla/EphyContentPolicy.h: + + Remove embed single variable, it was unused. + +2006-01-18 Christian Persch <chpe@cvs.gnome.org> + * src/ephy-statusbar.c: (create_caret_indicator), (ephy_statusbar_init), (ephy_statusbar_new), (ephy_statusbar_set_caret_mode): diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c index 9e50c59fc..32dd8e1bc 100644 --- a/embed/ephy-embed-shell.c +++ b/embed/ephy-embed-shell.c @@ -33,6 +33,9 @@ #include "ephy-debug.h" #include "ephy-adblock-manager.h" +#include <glib/gi18n.h> +#include <gtk/gtkmessagedialog.h> + #define EPHY_EMBED_SHELL_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_EMBED_SHELL, EphyEmbedShellPrivate)) struct _EphyEmbedShellPrivate @@ -43,6 +46,7 @@ struct _EphyEmbedShellPrivate EphyEmbedSingle *embed_single; EphyEncodings *encodings; EphyAdBlockManager *adblock_manager; + guint single_initialised : 1; }; enum @@ -201,12 +205,41 @@ ephy_embed_shell_get_downloader_view (EphyEmbedShell *shell) static GObject * impl_get_embed_single (EphyEmbedShell *shell) { + EphyEmbedShellPrivate *priv; + g_return_val_if_fail (EPHY_IS_EMBED_SHELL (shell), NULL); - if (shell->priv->embed_single == NULL) + priv = shell->priv; + + if (priv->embed_single != NULL && + !priv->single_initialised) + { + g_warning ("ephy_embed_shell_get_embed_single called while the single is being initialised!\n"); + return G_OBJECT (priv->embed_single); + } + + if (priv->embed_single == NULL) { - shell->priv->embed_single = EPHY_EMBED_SINGLE + priv->embed_single = EPHY_EMBED_SINGLE (ephy_embed_factory_new_object (EPHY_TYPE_EMBED_SINGLE)); + + if (!ephy_embed_single_init (priv->embed_single)) + { + GtkWidget *dialog; + + dialog = gtk_message_dialog_new + (NULL, + GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + _("Epiphany can't be used now. " + "Mozilla initialization failed.")); + gtk_dialog_run (GTK_DIALOG (dialog)); + + exit (0); + } + + priv->single_initialised = TRUE; } return G_OBJECT (shell->priv->embed_single); diff --git a/embed/ephy-embed-single.c b/embed/ephy-embed-single.c index fe32a0289..33831f157 100644 --- a/embed/ephy-embed-single.c +++ b/embed/ephy-embed-single.c @@ -163,6 +163,20 @@ ephy_embed_single_iface_init (gpointer g_iface) } /** + * ephy_embed_single_init: + * @single: the #EphyEmbedSingle + * + * Performs startup initialisations. Must be called before calling + * any other methods. + **/ +gboolean +ephy_embed_single_init (EphyEmbedSingle *single) +{ + EphyEmbedSingleIface *iface = EPHY_EMBED_SINGLE_GET_IFACE (single); + return iface->init (single); +} + +/** * ephy_embed_single_clear_cache: * @single: the #EphyEmbedSingle * diff --git a/embed/ephy-embed-single.h b/embed/ephy-embed-single.h index 916773d7f..0ff733e94 100644 --- a/embed/ephy-embed-single.h +++ b/embed/ephy-embed-single.h @@ -60,6 +60,7 @@ struct _EphyEmbedSingleIface /* Methods */ + gboolean (* init) (EphyEmbedSingle *single); GtkWidget * (* open_window) (EphyEmbedSingle *single, EphyEmbed *parent, const char *address, @@ -76,6 +77,8 @@ struct _EphyEmbedSingleIface GType ephy_embed_single_get_type (void); +gboolean ephy_embed_single_init (EphyEmbedSingle *single); + GtkWidget *ephy_embed_single_open_window (EphyEmbedSingle *single, EphyEmbed *parent, const char *address, diff --git a/embed/mozilla/EphyContentPolicy.cpp b/embed/mozilla/EphyContentPolicy.cpp index b5910063b..930e39e86 100644 --- a/embed/mozilla/EphyContentPolicy.cpp +++ b/embed/mozilla/EphyContentPolicy.cpp @@ -55,9 +55,6 @@ EphyContentPolicy::EphyContentPolicy() mLocked = eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_UNSAFE_PROTOCOLS); mSafeProtocols = eel_gconf_get_string_list (CONF_LOCKDOWN_ADDITIONAL_SAFE_PROTOCOLS); - - mEmbedSingle = ephy_embed_shell_get_embed_single (embed_shell); - g_return_if_fail (mEmbedSingle); } EphyContentPolicy::~EphyContentPolicy() diff --git a/embed/mozilla/EphyContentPolicy.h b/embed/mozilla/EphyContentPolicy.h index 3c4813a17..7639a6d00 100644 --- a/embed/mozilla/EphyContentPolicy.h +++ b/embed/mozilla/EphyContentPolicy.h @@ -50,9 +50,8 @@ public: EphyContentPolicy(); virtual ~EphyContentPolicy(); private: - GtkWidget *GetEmbedFromContext (nsISupports *aContext); + static GtkWidget *GetEmbedFromContext (nsISupports *aContext); - GObject *mEmbedSingle; gboolean mLocked; GSList *mSafeProtocols; }; diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp index 0c7d04e0a..a7b3b0d49 100644 --- a/embed/mozilla/mozilla-embed-single.cpp +++ b/embed/mozilla/mozilla-embed-single.cpp @@ -783,8 +783,10 @@ mozilla_stylesheet_shutdown (MozillaEmbedSingle *single) #endif /* HAVE_GECKO_1_8 */ static gboolean -init_services (MozillaEmbedSingle *single) +impl_init (EphyEmbedSingle *esingle) { + MozillaEmbedSingle *single = MOZILLA_EMBED_SINGLE (esingle); + /* Pre initialization */ mozilla_init_plugin_path (); mozilla_init_home (); @@ -803,6 +805,7 @@ init_services (MozillaEmbedSingle *single) /* Fire up the beast */ gtk_moz_embed_push_startup (); + /* FIXME check that it succeeded! */ mozilla_register_components (); @@ -864,22 +867,6 @@ mozilla_embed_single_init (MozillaEmbedSingle *mes) MOZILLA_PROFILE_FILE, NULL); - if (!init_services (mes)) - { - GtkWidget *dialog; - - dialog = gtk_message_dialog_new - (NULL, - GTK_DIALOG_MODAL, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - _("Epiphany can't be used now. " - "Mozilla initialization failed.")); - gtk_dialog_run (GTK_DIALOG (dialog)); - - exit (0); - } - g_signal_connect_object (embed_shell, "prepare-close", G_CALLBACK (prepare_close_cb), mes, (GConnectFlags) 0); @@ -1506,6 +1493,7 @@ mozilla_embed_single_class_init (MozillaEmbedSingleClass *klass) static void ephy_embed_single_iface_init (EphyEmbedSingleIface *iface) { + iface->init = impl_init; iface->clear_cache = impl_clear_cache; iface->clear_auth_cache = impl_clear_auth_cache; iface->set_network_status = impl_set_network_status; diff --git a/po/POTFILES.in b/po/POTFILES.in index e2b8ecddc..d771fdeec 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -10,6 +10,7 @@ data/glade/epiphany.glade data/glade/prefs-dialog.glade data/glade/print.glade embed/downloader-view.c +embed/ephy-embed-shell.c embed/ephy-encodings.c embed/ephy-history.c embed/mozilla/ContentHandler.cpp |