aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
Diffstat (limited to 'embed')
-rw-r--r--embed/mozilla/mozilla-embed-single.cpp51
-rw-r--r--embed/mozilla/mozilla-notifiers.cpp120
-rw-r--r--embed/mozilla/mozilla-notifiers.h2
3 files changed, 66 insertions, 107 deletions
diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp
index 355e33583..e752af11e 100644
--- a/embed/mozilla/mozilla-embed-single.cpp
+++ b/embed/mozilla/mozilla-embed-single.cpp
@@ -18,6 +18,7 @@
#include "glib.h"
#include "ephy-string.h"
+#include "ephy-debug.h"
#include "gtkmozembed.h"
#include "mozilla-embed-single.h"
#include "mozilla-prefs.h"
@@ -291,41 +292,6 @@ mozilla_init_profile (void)
}
static gboolean
-is_new_build (MozillaEmbedSingle *mes)
-{
- gboolean new_build = FALSE;
- char *build_test;
- char *prefs_file;
-
- prefs_file = g_build_filename (ephy_dot_dir (),
- MOZILLA_PROFILE_DIR,
- MOZILLA_PROFILE_NAME,
- MOZILLA_PROFILE_FILE,
- NULL);
-
- /* no mozilla prefs ? or new epiphany build */
- build_test = eel_gconf_get_string ("/apps/epiphany/gconf_test");
- if (!g_file_test(mes->priv->user_prefs, G_FILE_TEST_EXISTS) ||
- build_test == NULL ||
- strncmp (build_test, __TIME__, 8) != 0)
- {
- new_build = TRUE;
- eel_gconf_set_string ("/apps/epiphany/gconf_test", __TIME__);
- }
-
- g_free (build_test);
-
- return new_build;
-}
-
-static void
-mozilla_init_prefs (MozillaEmbedSingle *mes)
-{
- mozilla_set_default_prefs (mes);
- mozilla_notifiers_set_defaults ();
-}
-
-static gboolean
have_gnome_url_handler (const gchar *protocol)
{
gchar *key, *cmd;
@@ -368,8 +334,6 @@ mozilla_register_external_protocols (void)
static void
mozilla_embed_single_init (MozillaEmbedSingle *mes)
{
- gboolean new_build;
-
mes->priv = g_new0 (MozillaEmbedSinglePrivate, 1);
mes->priv->charsets_hash = NULL;
mes->priv->sorted_charsets_titles = NULL;
@@ -381,24 +345,21 @@ mozilla_embed_single_init (MozillaEmbedSingle *mes)
MOZILLA_PROFILE_FILE,
NULL);
- new_build = is_new_build (mes);
-
/* Pre initialization */
- mozilla_notifiers_init (EPHY_EMBED_SINGLE (mes));
mozilla_init_home ();
mozilla_init_profile ();
/* Fire up the best */
gtk_moz_embed_push_startup ();
- /* Post initialization */
- if (new_build)
- {
- mozilla_init_prefs (mes);
- }
+ mozilla_set_default_prefs (mes);
mozilla_load_proxy_prefs (mes);
+ START_PROFILER ("Mozilla prefs notifiers")
+ mozilla_notifiers_init (EPHY_EMBED_SINGLE (mes));
+ STOP_PROFILER ("Mozilla prefs notifiers")
+
mozilla_init_single (mes);
mozilla_register_components ();
diff --git a/embed/mozilla/mozilla-notifiers.cpp b/embed/mozilla/mozilla-notifiers.cpp
index eaa12dad4..674e541df 100644
--- a/embed/mozilla/mozilla-notifiers.cpp
+++ b/embed/mozilla/mozilla-notifiers.cpp
@@ -263,9 +263,47 @@ mozilla_proxy_autoconfig_notifier (GConfClient *client,
(single, gconf_value_get_string(entry->value));
}
+static void
+add_notification_and_notify (GConfClient *client,
+ const char *key,
+ GConfClientNotifyFunc func,
+ gpointer user_data)
+{
+ GConfEntry *entry;
+ GError *error = NULL;
+ guint cnxn_id;
+
+ cnxn_id = gconf_client_notify_add (client, key, func, user_data, NULL, &error);
+ if (eel_gconf_handle_error (&error))
+ {
+ if (cnxn_id != EEL_GCONF_UNDEFINED_CONNECTION)
+ {
+ gconf_client_notify_remove (client, cnxn_id);
+ }
+ return;
+ }
+
+ mozilla_notifiers = g_list_append (mozilla_notifiers,
+ GUINT_TO_POINTER (cnxn_id));
+
+ entry = gconf_client_get_entry (client, key, NULL, TRUE, &error);
+ if (eel_gconf_handle_error (&error))
+ {
+ return;
+ }
+ g_return_if_fail (entry != NULL);
+
+ if (entry->value != NULL)
+ {
+ func (client, cnxn_id, entry, user_data);
+ }
+ gconf_entry_free (entry);
+}
+
void
mozilla_notifiers_init(EphyEmbedSingle *single)
{
+ GConfClient *client = eel_gconf_client_get_global ();
int i;
for (i = 0; conversion_table[i].gconf_key != NULL; i++)
@@ -287,20 +325,20 @@ mozilla_notifiers_init(EphyEmbedSingle *single)
g_assert (func != NULL);
- ephy_notification_add(
- conversion_table[i].gconf_key,
- func,
- (gpointer)conversion_table[i].mozilla_key,
- &mozilla_notifiers);
+ add_notification_and_notify
+ (client,
+ conversion_table[i].gconf_key,
+ func,
+ (gpointer)conversion_table[i].mozilla_key);
}
for (i = 0; custom_notifiers[i].gconf_key != NULL; i++)
{
- ephy_notification_add(
- custom_notifiers[i].gconf_key,
- custom_notifiers[i].func,
- (gpointer)single,
- &mozilla_notifiers);
+ add_notification_and_notify
+ (client,
+ custom_notifiers[i].gconf_key,
+ custom_notifiers[i].func,
+ (gpointer)single);
}
/* fonts notifiers */
@@ -318,35 +356,31 @@ mozilla_notifiers_init(EphyEmbedSingle *single)
sprintf (key, "%s_%s_%s", CONF_RENDERING_FONT,
types[k],
lang_encode_item[i]);
- ephy_notification_add (key,
- (GConfClientNotifyFunc)mozilla_font_notifier,
- info,
- &mozilla_notifiers);
+ add_notification_and_notify (client, key,
+ (GConfClientNotifyFunc)mozilla_font_notifier,
+ info);
font_infos = g_list_append (font_infos, info);
}
sprintf (key, "%s_%s", CONF_RENDERING_FONT_MIN_SIZE, lang_encode_item[i]);
info = g_strconcat ("minimum-size", ".", lang_encode_item[i], NULL);
- ephy_notification_add (key,
- (GConfClientNotifyFunc)mozilla_font_size_notifier,
- info,
- &mozilla_notifiers);
+ add_notification_and_notify (client, key,
+ (GConfClientNotifyFunc)mozilla_font_size_notifier,
+ info);
font_infos = g_list_append (font_infos, info);
sprintf (key, "%s_%s", CONF_RENDERING_FONT_FIXED_SIZE, lang_encode_item[i]);
info = g_strconcat ("size.fixed", ".", lang_encode_item[i], NULL);
- ephy_notification_add (key,
- (GConfClientNotifyFunc)mozilla_font_size_notifier,
- info,
- &mozilla_notifiers);
+ add_notification_and_notify (client, key,
+ (GConfClientNotifyFunc)mozilla_font_size_notifier,
+ info);
font_infos = g_list_append (font_infos, info);
sprintf (key, "%s_%s", CONF_RENDERING_FONT_VAR_SIZE, lang_encode_item[i]);
info = g_strconcat ("size.variable", ".", lang_encode_item[i], NULL);
- ephy_notification_add (key,
- (GConfClientNotifyFunc)mozilla_font_size_notifier,
- info,
- &mozilla_notifiers);
+ add_notification_and_notify (client, key,
+ (GConfClientNotifyFunc)mozilla_font_size_notifier,
+ info);
font_infos = g_list_append (font_infos, info);
}
}
@@ -366,40 +400,6 @@ mozilla_notifiers_free (void)
g_list_free (font_infos);
}
-void
-mozilla_notifiers_set_defaults(void)
-{
- GConfClient* client = eel_gconf_client_get_global();
- GConfValue* value;
- int i;
-
- for (i = 0; conversion_table[i].gconf_key != NULL; i++)
- {
- value = gconf_client_get
- (client, conversion_table[i].gconf_key, NULL);
- if (value)
- {
- gconf_client_set (client,
- conversion_table[i].gconf_key,
- value, NULL);
- gconf_value_free (value);
- }
- }
-
- for (i = 0; custom_notifiers[i].gconf_key != NULL; i++)
- {
- value = gconf_client_get
- (client, custom_notifiers[i].gconf_key, NULL);
- if (value)
- {
- gconf_client_set (client,
- custom_notifiers[i].gconf_key,
- value, NULL);
- gconf_value_free (value);
- }
- }
-}
-
/**
* generic_mozilla_string_notify: update mozilla pref to match epiphany prefs.
* user_data should match the mozilla key
diff --git a/embed/mozilla/mozilla-notifiers.h b/embed/mozilla/mozilla-notifiers.h
index f7882b83f..579bc5638 100644
--- a/embed/mozilla/mozilla-notifiers.h
+++ b/embed/mozilla/mozilla-notifiers.h
@@ -23,8 +23,6 @@
void mozilla_notifiers_init (EphyEmbedSingle *single);
-void mozilla_notifiers_set_defaults (void);
-
void mozilla_notifiers_free (void);
#endif