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.
This commit is contained in:
Christian Dywan 2009-10-30 23:43:28 +01:00
parent ec9ea0233e
commit 3efbc1b462
4 changed files with 36 additions and 20 deletions

View file

@ -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);
}
}

View file

@ -1,5 +1,6 @@
BOOLEAN:OBJECT
BOOLEAN:VOID
OBJECT:OBJECT
VOID:BOOLEAN,STRING
VOID:OBJECT,ENUM
VOID:STRING,BOOLEAN

View file

@ -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

View file

@ -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);
}
}