aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXan Lopez <xan@src.gnome.org>2008-12-21 23:54:49 +0800
committerXan Lopez <xan@src.gnome.org>2008-12-21 23:54:49 +0800
commit086140d4b7d8835f4b2928b515a4e3c783b81a50 (patch)
tree8a35507680fccd1425b652b47a89754070ee7ef3
parent73d1fa1b5df4b72953787da6eb1c5117ecd7c262 (diff)
downloadgsoc2013-epiphany-086140d4b7d8835f4b2928b515a4e3c783b81a50.tar
gsoc2013-epiphany-086140d4b7d8835f4b2928b515a4e3c783b81a50.tar.gz
gsoc2013-epiphany-086140d4b7d8835f4b2928b515a4e3c783b81a50.tar.bz2
gsoc2013-epiphany-086140d4b7d8835f4b2928b515a4e3c783b81a50.tar.lz
gsoc2013-epiphany-086140d4b7d8835f4b2928b515a4e3c783b81a50.tar.xz
gsoc2013-epiphany-086140d4b7d8835f4b2928b515a4e3c783b81a50.tar.zst
gsoc2013-epiphany-086140d4b7d8835f4b2928b515a4e3c783b81a50.zip
Open links in new tab with middle click.
Bug #518338 svn path=/trunk/; revision=8639
-rw-r--r--src/ephy-window.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 98696ad09..5587f9248 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -2481,6 +2481,42 @@ create_web_view_cb (WebKitWebView *web_view,
return new_web_view;
}
+static gboolean
+navigation_policy_decision_required_cb (WebKitWebView *web_view,
+ WebKitWebFrame *web_frame,
+ WebKitNetworkRequest *request,
+ WebKitWebNavigationAction *action,
+ WebKitWebPolicyDecision *decision,
+ EphyWindow *window)
+{
+ WebKitWebNavigationReason reason;
+ gint button;
+
+ reason = webkit_web_navigation_action_get_reason (action);
+ button = webkit_web_navigation_action_get_button (action);
+
+ if (reason == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED &&
+ button == 2 /* middle button */) {
+ const char *uri;
+ EphyEmbed *embed;
+
+ uri = webkit_network_request_get_uri (request);
+ embed = ephy_embed_container_get_active_child
+ (EPHY_EMBED_CONTAINER (window));
+
+ ephy_shell_new_tab (ephy_shell_get_default (),
+ window,
+ embed,
+ uri,
+ EPHY_NEW_TAB_IN_EXISTING_WINDOW |
+ EPHY_NEW_TAB_OPEN_PAGE);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static void
ephy_window_set_active_tab (EphyWindow *window, EphyEmbed *new_embed)
{
@@ -2510,6 +2546,9 @@ ephy_window_set_active_tab (EphyWindow *window, EphyEmbed *new_embed)
g_signal_handlers_disconnect_by_func (web_view,
G_CALLBACK (create_web_view_cb),
window);
+ g_signal_handlers_disconnect_by_func (web_view,
+ G_CALLBACK (navigation_policy_decision_required_cb),
+ window);
g_signal_handlers_disconnect_by_func (embed,
G_CALLBACK (sync_tab_popup_windows),
@@ -2594,6 +2633,9 @@ ephy_window_set_active_tab (EphyWindow *window, EphyEmbed *new_embed)
g_signal_connect_object (web_view, "create-web-view",
G_CALLBACK (create_web_view_cb),
window, 0);
+ g_signal_connect_object (web_view, "navigation-policy-decision-requested",
+ G_CALLBACK (navigation_policy_decision_required_cb),
+ window, 0);
g_signal_connect_object (embed, "notify::hidden-popup-count",
G_CALLBACK (sync_tab_popup_windows),