]> spindle.queued.net Git - midori/commitdiff
Implement and make use of midori_app_create_browser
authorChristian Dywan <christian@twotoasts.de>
Wed, 24 Dec 2008 23:39:35 +0000 (00:39 +0100)
committerChristian Dywan <christian@twotoasts.de>
Wed, 24 Dec 2008 23:39:35 +0000 (00:39 +0100)
midori/midori-app.c
midori/midori-app.h

index 76250823a995fe77f3bd183084bd033aff7fb4be..fe091136aa7426a15f15786135d26626295e4df1 100644 (file)
@@ -108,17 +108,11 @@ midori_browser_new_window_cb (MidoriBrowser* browser,
                               const gchar*   uri,
                               MidoriApp*     app)
 {
-    MidoriBrowser* new_browser = g_object_new (MIDORI_TYPE_BROWSER,
-                                               "settings", app->settings,
-                                               "bookmarks", app->bookmarks,
-                                               "trash", app->trash,
-                                               "search-engines", app->search_engines,
-                                               "history", app->history,
-                                               NULL);
+    MidoriBrowser* new_browser = midori_app_create_browser (app);
+    midori_app_add_browser (app, new_browser);
+
     midori_browser_add_uri (new_browser, uri);
     gtk_widget_show (GTK_WIDGET (new_browser));
-
-    g_signal_emit (app, signals[ADD_BROWSER], 0, new_browser);
 }
 
 static gboolean
@@ -307,17 +301,11 @@ midori_browser_message_received_cb (UniqueApp*         instance,
       response = UNIQUE_RESPONSE_OK;
       break;
   case UNIQUE_NEW:
-      browser = g_object_new (MIDORI_TYPE_BROWSER,
-                              "settings", app->settings,
-                              "bookmarks", app->bookmarks,
-                              "trash", app->trash,
-                              "search-engines", app->search_engines,
-                              "history", app->history,
-                              NULL);
+      browser = midori_app_create_browser (app);
+      midori_app_add_browser (app, browser);
       /* FIXME: Should open the homepage according to settings */
       midori_browser_add_uri (browser, "");
       midori_browser_activate_action (browser, "Location");
-      midori_app_add_browser (app, browser);
       gtk_window_set_screen (GTK_WINDOW (app->browser),
                              unique_message_data_get_screen (message));
       gtk_widget_show (GTK_WIDGET (browser));
@@ -336,13 +324,7 @@ midori_browser_message_received_cb (UniqueApp*         instance,
               &open_external_pages_in, NULL);
           if (open_external_pages_in == MIDORI_NEW_PAGE_WINDOW)
           {
-              browser = g_object_new (MIDORI_TYPE_BROWSER,
-                  "settings", app->settings,
-                  "bookmarks", app->bookmarks,
-                  "trash", app->trash,
-                  "search-engines", app->search_engines,
-                  "history", app->history,
-                  NULL);
+              browser = midori_app_create_browser (app);
               midori_app_add_browser (app, browser);
               gtk_window_set_screen (GTK_WINDOW (app->browser),
                                      unique_message_data_get_screen (message));
@@ -649,7 +631,7 @@ midori_app_instance_send_uris (MidoriApp* app,
  * @app: a #MidoriApp
  * @browser: a #MidoriBrowser
  *
- * Adds a #MidoriBrowser to the #MidoriApp singleton.
+ * Adds a #MidoriBrowser to the #MidoriApp.
  *
  * The app will take care of the browser's new-window and quit signals, as well
  * as watch window closing so that the last closed window quits the app.
@@ -667,6 +649,31 @@ midori_app_add_browser (MidoriApp*     app,
     g_signal_emit (app, signals[ADD_BROWSER], 0, browser);
 }
 
+/**
+ * midori_app_create_browser:
+ * @app: a #MidoriApp
+ *
+ * Creates a #MidoriBrowser which inherits its settings,
+ * bookmarks, trash, search engines and history from  @app.
+ *
+ * Return value: a new #MidoriBrowser
+ *
+ * Since: 1.0.2
+ **/
+MidoriBrowser*
+midori_app_create_browser (MidoriApp* app)
+{
+    g_return_val_if_fail (MIDORI_IS_APP (app), NULL);
+
+    return g_object_new (MIDORI_TYPE_BROWSER,
+                         "settings", app->settings,
+                         "bookmarks", app->bookmarks,
+                         "trash", app->trash,
+                         "search-engines", app->search_engines,
+                         "history", app->history,
+                         NULL);
+}
+
 /**
  * midori_app_quit:
  * @app: a #MidoriApp
index c42e1cd32da2d05a0b827a94e6df537805a7c842..a2f197e908f7c55d6d19c958047e57c4c899c887 100644 (file)
@@ -58,6 +58,9 @@ void
 midori_app_add_browser            (MidoriApp*         app,
                                    MidoriBrowser*     browser);
 
+MidoriBrowser*
+midori_app_create_browser         (MidoriApp*         app);
+
 void
 midori_app_quit                   (MidoriApp*         app);