From cc7bc356e8f74fc736a6b33cde2e9c95c0919836 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Tue, 10 Nov 2009 20:04:48 +0100 Subject: [PATCH] Open all links in the current tab if Open new pages in: Current Tab is set There is a small flaw in that we also open all windows opened by scripts in the current tab and we don't treat popup windows specially. --- midori/midori-browser.c | 2 +- midori/midori-view.c | 37 ++++++++++++++++++++++--------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 347eecdf..08da67b1 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -1221,7 +1221,7 @@ midori_view_new_view_cb (GtkWidget* view, midori_browser_add_tab (new_browser, new_view); midori_browser_set_current_tab (new_browser, new_view); } - else + else if (gtk_widget_get_parent (new_view) != browser->notebook) { gint n = midori_browser_add_tab (browser, new_view); if (where != MIDORI_NEW_VIEW_BACKGROUND) diff --git a/midori/midori-view.c b/midori/midori-view.c index e05b8bc0..d2419e36 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -2062,6 +2062,12 @@ webkit_web_view_web_view_ready_cb (GtkWidget* web_view, { GtkWidget* new_view = gtk_widget_get_parent (web_view); MidoriNewView where = MIDORI_NEW_VIEW_TAB; + + /* FIXME: Open windows opened by scripts in tabs if they otherwise + would be replacing the page the user opened. */ + if (view->open_new_pages_in == MIDORI_NEW_PAGE_CURRENT) + return TRUE; + if (view->open_new_pages_in == MIDORI_NEW_PAGE_TAB) { if (view->open_tabs_in_the_background) @@ -2071,13 +2077,7 @@ webkit_web_view_web_view_ready_cb (GtkWidget* web_view, where = MIDORI_NEW_VIEW_WINDOW; gtk_widget_show (new_view); - if (view->open_new_pages_in == MIDORI_NEW_PAGE_CURRENT) - { - g_debug ("Opening all pages in current tab not implemented"); - g_signal_emit (view, signals[NEW_VIEW], 0, new_view, where); - } - else - g_signal_emit (view, signals[NEW_VIEW], 0, new_view, where); + g_signal_emit (view, signals[NEW_VIEW], 0, new_view, where); return TRUE; } @@ -2087,14 +2087,21 @@ webkit_web_view_create_web_view_cb (GtkWidget* web_view, WebKitWebFrame* web_frame, MidoriView* view) { - GtkWidget* new_view = g_object_new (MIDORI_TYPE_VIEW, - "net", view->net, - "settings", view->settings, - NULL); - 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; + MidoriView* new_view; + + if (view->open_new_pages_in == MIDORI_NEW_PAGE_CURRENT) + new_view = view; + else + { + new_view = g_object_new (MIDORI_TYPE_VIEW, + "net", view->net, + "settings", view->settings, + NULL); + midori_view_construct_web_view (new_view); + g_signal_connect (new_view->web_view, "web-view-ready", + G_CALLBACK (webkit_web_view_web_view_ready_cb), view); + } + return new_view->web_view; } static gboolean -- 2.39.5