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.
This commit is contained in:
Christian Dywan 2009-11-10 20:04:48 +01:00
parent f60403a24f
commit cc7bc356e8
2 changed files with 23 additions and 16 deletions

View file

@ -1221,7 +1221,7 @@ midori_view_new_view_cb (GtkWidget* view,
midori_browser_add_tab (new_browser, new_view); midori_browser_add_tab (new_browser, new_view);
midori_browser_set_current_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); gint n = midori_browser_add_tab (browser, new_view);
if (where != MIDORI_NEW_VIEW_BACKGROUND) if (where != MIDORI_NEW_VIEW_BACKGROUND)

View file

@ -2062,6 +2062,12 @@ webkit_web_view_web_view_ready_cb (GtkWidget* web_view,
{ {
GtkWidget* new_view = gtk_widget_get_parent (web_view); GtkWidget* new_view = gtk_widget_get_parent (web_view);
MidoriNewView where = MIDORI_NEW_VIEW_TAB; 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_new_pages_in == MIDORI_NEW_PAGE_TAB)
{ {
if (view->open_tabs_in_the_background) 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; where = MIDORI_NEW_VIEW_WINDOW;
gtk_widget_show (new_view); gtk_widget_show (new_view);
if (view->open_new_pages_in == MIDORI_NEW_PAGE_CURRENT) g_signal_emit (view, signals[NEW_VIEW], 0, new_view, where);
{
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);
return TRUE; return TRUE;
} }
@ -2087,14 +2087,21 @@ webkit_web_view_create_web_view_cb (GtkWidget* web_view,
WebKitWebFrame* web_frame, WebKitWebFrame* web_frame,
MidoriView* view) MidoriView* view)
{ {
GtkWidget* new_view = g_object_new (MIDORI_TYPE_VIEW, MidoriView* new_view;
"net", view->net,
"settings", view->settings, if (view->open_new_pages_in == MIDORI_NEW_PAGE_CURRENT)
NULL); new_view = view;
midori_view_construct_web_view (MIDORI_VIEW (new_view)); else
g_signal_connect (MIDORI_VIEW (new_view)->web_view, "web-view-ready", {
G_CALLBACK (webkit_web_view_web_view_ready_cb), view); new_view = g_object_new (MIDORI_TYPE_VIEW,
return MIDORI_VIEW (new_view)->web_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 static gboolean