From 907f7a72ce96e1acf1c94cad25b5818f71db8aa0 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sun, 17 May 2009 20:29:31 +0200 Subject: [PATCH] Implement Open new pages in: New window preference --- midori/midori-app.c | 13 +++++++++---- midori/midori-browser.c | 37 ++++++++++++++++++++++++++----------- midori/midori-view.c | 7 ++++++- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/midori/midori-app.c b/midori/midori-app.c index 12452790..f9a430c0 100644 --- a/midori/midori-app.c +++ b/midori/midori-app.c @@ -135,13 +135,18 @@ midori_browser_focus_in_event_cb (MidoriBrowser* browser, static void midori_browser_new_window_cb (MidoriBrowser* browser, - const gchar* uri, + MidoriBrowser* new_browser, MidoriApp* app) { - MidoriBrowser* new_browser = midori_app_create_browser (app); - midori_app_add_browser (app, 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); - midori_browser_add_uri (new_browser, uri); + midori_app_add_browser (app, new_browser); gtk_widget_show (GTK_WIDGET (new_browser)); } diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 69115115..3a0dd568 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -1109,7 +1109,9 @@ midori_view_new_window_cb (GtkWidget* view, const gchar* uri, MidoriBrowser* browser) { - g_signal_emit (browser, signals[NEW_WINDOW], 0, uri); + MidoriBrowser* new_browser = g_object_new (MIDORI_TYPE_BROWSER, NULL); + midori_browser_add_uri (new_browser, uri); + g_signal_emit (browser, signals[NEW_WINDOW], 0, new_browser); } static void @@ -1120,12 +1122,10 @@ midori_view_new_view_cb (GtkWidget* view, { if (where == MIDORI_NEW_VIEW_WINDOW) { - /* MidoriBrowser* new_browser = g_object_new (MIDORI_TYPE_BROWSER, - NULL); - g_signal_emit (browser, signals[NEW_BROWSER], 0, new_browser); */ - g_debug ("Opening all pages in new windows not implemented"); - midori_browser_set_current_page (browser, - midori_browser_add_tab (browser, new_view)); + MidoriBrowser* new_browser = g_object_new (MIDORI_TYPE_BROWSER, NULL); + midori_browser_add_tab (new_browser, new_view); + midori_browser_set_current_tab (new_browser, new_view); + g_signal_emit (browser, signals[NEW_WINDOW], 0, new_browser); } else { @@ -1525,6 +1525,15 @@ midori_browser_class_init (MidoriBrowserClass* class) GObjectClass* gobject_class; GParamFlags flags; + /** + * MidoriBrowser::new-window: + * @browser: the object on which the signal is emitted + * @window: a new browser window + * + * Emitted when a new browser window was created. + * + * Note: Before 0.1.7 the second argument was an URI string. + */ signals[NEW_WINDOW] = g_signal_new ( "new-window", G_TYPE_FROM_CLASS (class), @@ -1532,9 +1541,9 @@ midori_browser_class_init (MidoriBrowserClass* class) G_STRUCT_OFFSET (MidoriBrowserClass, new_window), 0, NULL, - g_cclosure_marshal_VOID__STRING, + g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - G_TYPE_STRING); + MIDORI_TYPE_BROWSER); signals[ADD_TAB] = g_signal_new ( "add-tab", @@ -1849,7 +1858,9 @@ static void _action_window_new_activate (GtkAction* action, MidoriBrowser* browser) { - g_signal_emit (browser, signals[NEW_WINDOW], 0, ""); + MidoriBrowser* new_browser = g_object_new (MIDORI_TYPE_BROWSER, NULL); + midori_browser_add_uri (new_browser, ""); + g_signal_emit (browser, signals[NEW_WINDOW], 0, new_browser); } static void @@ -3174,7 +3185,11 @@ midori_browser_bookmark_open_in_window_activate_cb (GtkWidget* menuitem, uri = katze_item_get_uri (item); if (uri && *uri) - g_signal_emit (browser, signals[NEW_WINDOW], 0, uri); + { + MidoriBrowser* new_browser = g_object_new (MIDORI_TYPE_BROWSER, NULL); + midori_browser_add_uri (new_browser, uri); + g_signal_emit (browser, signals[NEW_WINDOW], 0, new_browser); + } } static void diff --git a/midori/midori-view.c b/midori/midori-view.c index 2e5466a3..8097c3b5 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -42,6 +42,9 @@ midori_search_action_get_icon (KatzeNet* net, KatzeItem* item, GtkWidget* widget); +static void +midori_view_construct_web_view (MidoriView* view); + struct _MidoriView { GtkScrolledWindow parent_instance; @@ -1387,7 +1390,7 @@ webkit_web_view_create_web_view_cb (GtkWidget* web_view, "net", view->net, "settings", view->settings, NULL); - midori_view_set_uri (MIDORI_VIEW (new_view), ""); + midori_view_construct_web_view (MIDORI_VIEW (new_view)); g_signal_connect (MIDORI_VIEW (new_view)->web_view, "web-view-ready", G_CALLBACK (webkit_web_view_web_view_ready_cb), view); return MIDORI_VIEW (new_view)->web_view; @@ -1916,6 +1919,8 @@ midori_view_construct_web_view (MidoriView* view) WebKitWebFrame* web_frame; gpointer inspector; + g_return_if_fail (!view->web_view); + view->web_view = webkit_web_view_new (); /* Load something to avoid a bug where WebKit might not set a main frame */