[epiphany] embed: Remove ephy_embed_prefs_init/shutdown methods



commit f3f29ee905b423fc23ad0410d427040cf9dad012
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Thu Feb 13 15:22:55 2014 +0100

    embed: Remove ephy_embed_prefs_init/shutdown methods
    
    Create the WebKitWebViewGroup object on demand when the first web view
    is created.

 embed/ephy-embed-prefs.c           |   15 +++++++--------
 embed/ephy-embed-prefs.h           |    2 --
 embed/ephy-embed-shell.c           |    4 +---
 tests/ephy-completion-model-test.c |    1 -
 tests/ephy-download-test.c         |    1 -
 tests/ephy-encodings-test.c        |    1 -
 tests/ephy-migration-test.c        |    1 -
 tests/ephy-session-test.c          |    1 -
 tests/ephy-shell-test.c            |    1 -
 tests/ephy-web-app-utils-test.c    |    1 -
 tests/ephy-web-view-test.c         |    1 -
 11 files changed, 8 insertions(+), 21 deletions(-)
---
diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c
index a0cb640..3d77d42 100644
--- a/embed/ephy-embed-prefs.c
+++ b/embed/ephy-embed-prefs.c
@@ -524,10 +524,11 @@ static const PrefData webkit_pref_entries[] =
       webkit_pref_callback_cookie_accept_policy },
   };
 
-void
-ephy_embed_prefs_init (void)
+static gpointer
+ephy_embed_prefs_init (gpointer user_data)
 {
   int i;
+
   web_view_group = webkit_web_view_group_new ("Ephy WebView Group");
   webkit_settings = webkit_web_view_group_get_settings (web_view_group);
 
@@ -591,16 +592,14 @@ ephy_embed_prefs_init (void)
                    EPHY_PREFS_ENABLE_SMOOTH_SCROLLING,
                    webkit_settings, "enable-smooth-scrolling",
                    G_SETTINGS_BIND_GET);
-}
 
-void
-ephy_embed_prefs_shutdown (void)
-{
-  g_object_unref (web_view_group);
+  return web_view_group;
 }
 
 WebKitWebViewGroup *
 ephy_embed_prefs_get_web_view_group (void)
 {
-  return web_view_group;
+  static GOnce once_init = G_ONCE_INIT;
+
+  return g_once (&once_init, ephy_embed_prefs_init, NULL);
 }
diff --git a/embed/ephy-embed-prefs.h b/embed/ephy-embed-prefs.h
index 346c94d..e7d47ae 100644
--- a/embed/ephy-embed-prefs.h
+++ b/embed/ephy-embed-prefs.h
@@ -34,8 +34,6 @@
 
 G_BEGIN_DECLS
 
-void ephy_embed_prefs_init                              (void);
-void ephy_embed_prefs_shutdown                          (void);
 WebKitWebViewGroup *ephy_embed_prefs_get_web_view_group (void);
 void ephy_embed_prefs_set_cookie_accept_policy          (WebKitCookieManager *cookie_manager,
                                                          const char          *settings_policy);
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index 154722b..c919c19 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -611,8 +611,6 @@ ephy_embed_shell_startup (GApplication* application)
                                          EPHY_PREFS_WEB_COOKIES_POLICY);
   ephy_embed_prefs_set_cookie_accept_policy (cookie_manager, cookie_policy);
   g_free (cookie_policy);
-
-  ephy_embed_prefs_init ();
 }
 
 static void
@@ -639,7 +637,7 @@ ephy_embed_shell_shutdown (GApplication* application)
 
   g_list_foreach (priv->web_extensions, (GFunc)ephy_embed_shell_unwatch_web_extension, application);
 
-  ephy_embed_prefs_shutdown ();
+  g_object_unref (ephy_embed_prefs_get_web_view_group ());
 }
 
 static void
diff --git a/tests/ephy-completion-model-test.c b/tests/ephy-completion-model-test.c
index c717210..672d19a 100644
--- a/tests/ephy-completion-model-test.c
+++ b/tests/ephy-completion-model-test.c
@@ -80,7 +80,6 @@ main (int argc, char *argv[])
 
   gtk_test_init (&argc, &argv);
   ephy_debug_init ();
-  ephy_embed_prefs_init ();
 
   if (!ephy_file_helpers_init (NULL,
                                EPHY_FILE_HELPERS_PRIVATE_PROFILE | EPHY_FILE_HELPERS_ENSURE_EXISTS,
diff --git a/tests/ephy-download-test.c b/tests/ephy-download-test.c
index b2fd907..6fff06e 100644
--- a/tests/ephy-download-test.c
+++ b/tests/ephy-download-test.c
@@ -167,7 +167,6 @@ main (int argc, char *argv[])
   gtk_test_init (&argc, &argv);
 
   ephy_debug_init ();
-  ephy_embed_prefs_init ();
 
   if (!ephy_file_helpers_init (NULL,
                                EPHY_FILE_HELPERS_PRIVATE_PROFILE | EPHY_FILE_HELPERS_ENSURE_EXISTS,
diff --git a/tests/ephy-encodings-test.c b/tests/ephy-encodings-test.c
index da85d0c..1ef727f 100644
--- a/tests/ephy-encodings-test.c
+++ b/tests/ephy-encodings-test.c
@@ -80,7 +80,6 @@ main (int argc, char *argv[])
   gtk_test_init (&argc, &argv);
 
   ephy_debug_init ();
-  ephy_embed_prefs_init ();
 
   if (!ephy_file_helpers_init (NULL,
                                EPHY_FILE_HELPERS_PRIVATE_PROFILE | EPHY_FILE_HELPERS_ENSURE_EXISTS,
diff --git a/tests/ephy-migration-test.c b/tests/ephy-migration-test.c
index 983e8ce..fab9ee7 100644
--- a/tests/ephy-migration-test.c
+++ b/tests/ephy-migration-test.c
@@ -55,7 +55,6 @@ main (int argc, char *argv[])
   gtk_test_init (&argc, &argv);
 
   ephy_debug_init ();
-  ephy_embed_prefs_init ();
 
   if (!ephy_file_helpers_init (NULL,
                                EPHY_FILE_HELPERS_PRIVATE_PROFILE | EPHY_FILE_HELPERS_ENSURE_EXISTS,
diff --git a/tests/ephy-session-test.c b/tests/ephy-session-test.c
index 685fa13..5d0b855 100644
--- a/tests/ephy-session-test.c
+++ b/tests/ephy-session-test.c
@@ -348,7 +348,6 @@ main (int argc, char *argv[])
   gtk_test_init (&argc, &argv);
 
   ephy_debug_init ();
-  ephy_embed_prefs_init ();
 
   if (!ephy_file_helpers_init (NULL,
                                EPHY_FILE_HELPERS_PRIVATE_PROFILE | EPHY_FILE_HELPERS_ENSURE_EXISTS,
diff --git a/tests/ephy-shell-test.c b/tests/ephy-shell-test.c
index a1bea9a..6d68810 100644
--- a/tests/ephy-shell-test.c
+++ b/tests/ephy-shell-test.c
@@ -332,7 +332,6 @@ main (int argc, char *argv[])
   gtk_test_init (&argc, &argv);
 
   ephy_debug_init ();
-  ephy_embed_prefs_init ();
 
   if (!ephy_file_helpers_init (NULL, EPHY_FILE_HELPERS_PRIVATE_PROFILE | EPHY_FILE_HELPERS_ENSURE_EXISTS, 
NULL)) {
     g_debug ("Something wrong happened with ephy_file_helpers_init()");
diff --git a/tests/ephy-web-app-utils-test.c b/tests/ephy-web-app-utils-test.c
index 25ee59c..98279d5 100644
--- a/tests/ephy-web-app-utils-test.c
+++ b/tests/ephy-web-app-utils-test.c
@@ -139,7 +139,6 @@ main (int argc, char *argv[])
   gtk_test_init (&argc, &argv);
 
   ephy_debug_init ();
-  ephy_embed_prefs_init ();
 
   g_test_add_func ("/embed/ephy-web-app-utils/lifetime",
                    test_web_app_lifetime);
diff --git a/tests/ephy-web-view-test.c b/tests/ephy-web-view-test.c
index 1a01863..b078583 100644
--- a/tests/ephy-web-view-test.c
+++ b/tests/ephy-web-view-test.c
@@ -453,7 +453,6 @@ main (int argc, char *argv[])
   gtk_test_init (&argc, &argv);
 
   ephy_debug_init ();
-  ephy_embed_prefs_init ();
 
   if (!ephy_file_helpers_init (NULL,
                                EPHY_FILE_HELPERS_PRIVATE_PROFILE | EPHY_FILE_HELPERS_ENSURE_EXISTS,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]