From 3efbc1b4628c1b0b6512e24eb2fe19e02e6dfa17 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Fri, 30 Oct 2009 23:43:28 +0100 Subject: [PATCH] Leave setting up windows to the app, which is a lot faster With a mature history setting up a browser window can be slow, but if it's setup at creation time it is extremely fast. The signal prototype of MidoriBrowser::new-window had to change, all call sites were adjusted. --- extensions/feed-panel/feed-panel.c | 5 ++++- midori/marshal.list | 1 + midori/midori-app.c | 24 ++++++++++++++++-------- midori/midori-browser.c | 26 +++++++++++++++----------- 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/extensions/feed-panel/feed-panel.c b/extensions/feed-panel/feed-panel.c index bbef14f6..6e4d310c 100644 --- a/extensions/feed-panel/feed-panel.c +++ b/extensions/feed-panel/feed-panel.c @@ -509,8 +509,11 @@ feed_panel_open_in_window_activate_cb (GtkWidget* menuitem, if (uri && *uri) { MidoriBrowser* browser; + MidoriBrowser* new_browser; + browser = midori_browser_get_for_widget (GTK_WIDGET (panel)); - g_signal_emit_by_name (browser, "new-window", uri); + g_signal_emit_by_name (browser, "new-window", NULL, &new_browser); + midori_browser_add_uri (new_browser, uri); } } diff --git a/midori/marshal.list b/midori/marshal.list index 5ca263be..8d27c7c6 100644 --- a/midori/marshal.list +++ b/midori/marshal.list @@ -1,5 +1,6 @@ BOOLEAN:OBJECT BOOLEAN:VOID +OBJECT:OBJECT VOID:BOOLEAN,STRING VOID:OBJECT,ENUM VOID:STRING,BOOLEAN diff --git a/midori/midori-app.c b/midori/midori-app.c index f5c1c522..55bf2bd5 100644 --- a/midori/midori-app.c +++ b/midori/midori-app.c @@ -140,21 +140,26 @@ midori_browser_focus_in_event_cb (MidoriBrowser* browser, return FALSE; } -static void +static MidoriBrowser* midori_browser_new_window_cb (MidoriBrowser* browser, MidoriBrowser* new_browser, MidoriApp* app) { - g_object_set (new_browser, - "settings", app->settings, - "bookmarks", app->bookmarks, - "trash", app->trash, - "search-engines", app->search_engines, - "history", app->history, - NULL); + if (new_browser) + g_object_set (new_browser, + "settings", app->settings, + "bookmarks", app->bookmarks, + "trash", app->trash, + "search-engines", app->search_engines, + "history", app->history, + NULL); + else + new_browser = midori_app_create_browser (app); midori_app_add_browser (app, new_browser); gtk_widget_show (GTK_WIDGET (new_browser)); + + return new_browser; } static gboolean @@ -1003,6 +1008,9 @@ midori_app_add_browser (MidoriApp* app, * Creates a #MidoriBrowser which inherits its settings, * bookmarks, trash, search engines and history from @app. * + * Note that creating a browser this way can be a lot + * faster than setting it up manually. + * * Return value: a new #MidoriBrowser * * Since: 0.1.2 diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 254a3dde..2ef5c0a1 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -1194,8 +1194,8 @@ midori_view_new_window_cb (GtkWidget* view, const gchar* uri, MidoriBrowser* browser) { - MidoriBrowser* new_browser = g_object_new (MIDORI_TYPE_BROWSER, NULL); - g_signal_emit (browser, signals[NEW_WINDOW], 0, new_browser); + MidoriBrowser* new_browser; + g_signal_emit (browser, signals[NEW_WINDOW], 0, NULL, &new_browser); midori_browser_add_uri (new_browser, uri); } @@ -1208,8 +1208,8 @@ midori_view_new_view_cb (GtkWidget* view, midori_browser_view_copy_history (new_view, view, TRUE); if (where == MIDORI_NEW_VIEW_WINDOW) { - MidoriBrowser* new_browser = g_object_new (MIDORI_TYPE_BROWSER, NULL); - g_signal_emit (browser, signals[NEW_WINDOW], 0, new_browser); + MidoriBrowser* new_browser; + g_signal_emit (browser, signals[NEW_WINDOW], 0, NULL, &new_browser); midori_browser_add_tab (new_browser, new_view); midori_browser_set_current_tab (new_browser, new_view); } @@ -1685,11 +1685,15 @@ midori_browser_class_init (MidoriBrowserClass* class) /** * MidoriBrowser::new-window: * @browser: the object on which the signal is emitted - * @window: a new browser window + * @window: a new browser window, or %NULL * * Emitted when a new browser window was created. * * Note: Before 0.1.7 the second argument was an URI string. + * + * Note: Since 0.2.1 the return value is a #MidoriBrowser + * + * Return value: a new #MidoriBrowser */ signals[NEW_WINDOW] = g_signal_new ( "new-window", @@ -1698,8 +1702,8 @@ midori_browser_class_init (MidoriBrowserClass* class) G_STRUCT_OFFSET (MidoriBrowserClass, new_window), 0, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, + midori_cclosure_marshal_OBJECT__OBJECT, + MIDORI_TYPE_BROWSER, 1, MIDORI_TYPE_BROWSER); signals[ADD_TAB] = g_signal_new ( @@ -2061,8 +2065,8 @@ static void _action_window_new_activate (GtkAction* action, MidoriBrowser* browser) { - MidoriBrowser* new_browser = g_object_new (MIDORI_TYPE_BROWSER, NULL); - g_signal_emit (browser, signals[NEW_WINDOW], 0, new_browser); + MidoriBrowser* new_browser; + g_signal_emit (browser, signals[NEW_WINDOW], 0, NULL, &new_browser); midori_browser_add_uri (new_browser, ""); midori_browser_activate_action (new_browser, "Location"); } @@ -3753,8 +3757,8 @@ midori_browser_bookmark_open_in_window_activate_cb (GtkWidget* menuitem, if (uri && *uri) { - MidoriBrowser* new_browser = g_object_new (MIDORI_TYPE_BROWSER, NULL); - g_signal_emit (browser, signals[NEW_WINDOW], 0, new_browser); + MidoriBrowser* new_browser; + g_signal_emit (browser, signals[NEW_WINDOW], 0, NULL, &new_browser); midori_browser_add_uri (new_browser, uri); } } -- 2.39.5