[Xfce4-commits] <midori:master> Merge gtk_init into midori_app_setup

Christian Dywan noreply at xfce.org
Mon Aug 6 00:34:03 CEST 2012


Updating branch refs/heads/master
         to 9fb173ba69ea2660d71f3b05cb4f92b456abe38b (commit)
       from b925dbca33bc1283299097f7903102a4ffb1fef3 (commit)

commit 9fb173ba69ea2660d71f3b05cb4f92b456abe38b
Author: Christian Dywan <christian at twotoasts.de>
Date:   Mon Aug 6 00:25:29 2012 +0200

    Merge gtk_init into midori_app_setup
    
    gtk_init must come before stock items but we
    need to copy the arguments before.
    
    Fixes: https://bugs.launchpad.net/midori/+bug/1033043

 midori/main.c       |    5 +----
 midori/midori-app.c |   18 +++++++++++++-----
 midori/midori-app.h |    7 +++++--
 tests/bookmarks.c   |    4 +---
 tests/browser.c     |    3 +--
 tests/extensions.c  |    3 +--
 tests/magic-uri.c   |    3 +--
 tests/properties.c  |    3 +--
 8 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/midori/main.c b/midori/main.c
index 57ee6f3..874421c 100644
--- a/midori/main.c
+++ b/midori/main.c
@@ -2004,8 +2004,6 @@ main (int    argc,
     #endif
     #endif
 
-    midori_app_setup (argv);
-
     /* Parse cli options */
     webapp = NULL;
     config = NULL;
@@ -2022,8 +2020,7 @@ main (int    argc,
     block_uris = NULL;
     inactivity_reset = 0;
     error = NULL;
-    if (!gtk_init_with_args (&argc, &argv, _("[Addresses]"), entries,
-                             GETTEXT_PACKAGE, &error))
+    if (!midori_app_setup (&argc, &argv, entries, &error))
     {
         g_print ("%s - %s\n", _("Midori"), error->message);
         g_error_free (error);
diff --git a/midori/midori-app.c b/midori/midori-app.c
index f27562c..3b6e480 100644
--- a/midori/midori-app.c
+++ b/midori/midori-app.c
@@ -1434,14 +1434,18 @@ midori_app_get_lib_path (const gchar* package)
  *
  * Since: 0.4.2
  **/
-void
-midori_app_setup (gchar** argument_vector)
+gboolean
+midori_app_setup (gint               *argc,
+                  gchar**            *argument_vector,
+                  const GOptionEntry *entries,
+                  GError*            *error)
 {
     GtkIconSource* icon_source;
     GtkIconSet* icon_set;
     GtkIconFactory* factory;
     gsize i;
     gchar* executable;
+    gboolean success;
 
     static GtkStockItem items[] =
     {
@@ -1488,7 +1492,11 @@ midori_app_setup (gchar** argument_vector)
     textdomain (GETTEXT_PACKAGE);
     #endif
 
-    g_type_init ();
+    /* Preserve argument vector */
+    command_line = g_strdupv (*argument_vector);
+    success = gtk_init_with_args (argc, argument_vector, _("[Addresses]"),
+                                  entries, GETTEXT_PACKAGE, error);
+
     factory = gtk_icon_factory_new ();
     for (i = 0; i < G_N_ELEMENTS (items); i++)
     {
@@ -1504,8 +1512,6 @@ midori_app_setup (gchar** argument_vector)
     gtk_icon_factory_add_default (factory);
     g_object_unref (factory);
 
-    /* Preserve argument vector */
-    command_line = g_strdupv (argument_vector);
     #ifdef G_OS_WIN32
     exec_path = g_win32_get_package_installation_directory_of_module (NULL);
     #else
@@ -1550,6 +1556,8 @@ midori_app_setup (gchar** argument_vector)
         }
     }
     #endif
+
+    return success;
 }
 
 gboolean
diff --git a/midori/midori-app.h b/midori/midori-app.h
index a8fae5e..de0015e 100644
--- a/midori/midori-app.h
+++ b/midori/midori-app.h
@@ -82,8 +82,11 @@ midori_app_send_notification      (MidoriApp*         app,
                                    const gchar*       title,
                                    const gchar*       message);
 
-void
-midori_app_setup                  (gchar**            argument_vector);
+gboolean
+midori_app_setup                  (gint               *argc,
+                                   gchar**            *argument_vector,
+                                   const GOptionEntry *entries,
+                                   GError*            *error);
 
 gchar**
 midori_app_get_command_line       (void);
diff --git a/tests/bookmarks.c b/tests/bookmarks.c
index 9a13593..bce08d7 100644
--- a/tests/bookmarks.c
+++ b/tests/bookmarks.c
@@ -195,9 +195,7 @@ main (int    argc,
     //TestParameters default_params = {":memory:", TRUE, NULL, NULL};
     TestParameters default_params = {":memory:", FALSE, NULL, NULL};
 
-    midori_app_setup (argv);
-    g_test_init (&argc, &argv, NULL);
-    gtk_init_check (&argc, &argv);
+    midori_app_setup (&argc, &argv, NULL, NULL);
 
     g_test_add ("/bookmarks/simple test",
                     BookmarksFixture, &default_params,
diff --git a/tests/browser.c b/tests/browser.c
index c6fda19..5b9ee85 100644
--- a/tests/browser.c
+++ b/tests/browser.c
@@ -130,11 +130,10 @@ int
 main (int    argc,
       char** argv)
 {
-    midori_app_setup (argv);
     g_object_set_data (G_OBJECT (webkit_get_default_session ()),
                        "midori-session-initialized", (void*)1);
     g_test_init (&argc, &argv, NULL);
-    gtk_init_check (&argc, &argv);
+    midori_app_setup (&argc, &argv, NULL, NULL);
 
     g_test_add_func ("/browser/create", browser_create);
     g_test_add_func ("/browser/tooltips", browser_tooltips);
diff --git a/tests/extensions.c b/tests/extensions.c
index a5baa1f..3da96cd 100644
--- a/tests/extensions.c
+++ b/tests/extensions.c
@@ -245,9 +245,8 @@ int
 main (int    argc,
       char** argv)
 {
-    midori_app_setup (argv);
     g_test_init (&argc, &argv, NULL);
-    gtk_init_check (&argc, &argv);
+    midori_app_setup (&argc, &argv, NULL, NULL);
     soup_session_add_feature_by_type (webkit_get_default_session (),
         SOUP_TYPE_COOKIE_JAR);
 
diff --git a/tests/magic-uri.c b/tests/magic-uri.c
index 8a3a73c..35f5781 100644
--- a/tests/magic-uri.c
+++ b/tests/magic-uri.c
@@ -334,9 +334,8 @@ int
 main (int    argc,
       char** argv)
 {
-    midori_app_setup (argv);
     g_test_init (&argc, &argv, NULL);
-    gtk_init_check (&argc, &argv);
+    midori_app_setup (&argc, &argv, NULL, NULL);
 
     g_test_add_func ("/magic-uri/uri", magic_uri_uri);
     g_test_add_func ("/magic-uri/idn", magic_uri_idn);
diff --git a/tests/properties.c b/tests/properties.c
index e6d2994..d6abd2f 100644
--- a/tests/properties.c
+++ b/tests/properties.c
@@ -187,11 +187,10 @@ int
 main (int    argc,
       char** argv)
 {
-    midori_app_setup (argv);
     g_object_set_data (G_OBJECT (webkit_get_default_session ()),
                        "midori-session-initialized", (void*)1);
     g_test_init (&argc, &argv, NULL);
-    gtk_init_check (&argc, &argv);
+    midori_app_setup (&argc, &argv, NULL, NULL);
 
     g_test_add_data_func ("/properties/app",
         (gconstpointer)MIDORI_TYPE_APP, properties_type_test);


More information about the Xfce4-commits mailing list