From: Christian Dywan Date: Wed, 24 Dec 2008 23:39:35 +0000 (+0100) Subject: Implement and make use of midori_app_create_browser X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be9c907c7ec9ea93e65f0090e911b03eca8c6068;p=midori Implement and make use of midori_app_create_browser --- diff --git a/midori/midori-app.c b/midori/midori-app.c index 76250823..fe091136 100644 --- a/midori/midori-app.c +++ b/midori/midori-app.c @@ -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 diff --git a/midori/midori-app.h b/midori/midori-app.h index c42e1cd3..a2f197e9 100644 --- a/midori/midori-app.h +++ b/midori/midori-app.h @@ -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);