Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Quiñones <manuq@laptop.org>2012-04-25 18:43:03 (GMT)
committer Manuel Quiñones <manuq@laptop.org>2012-04-27 16:44:44 (GMT)
commit022ef0dd9791af51d7b9de38e813096f2ca60948 (patch)
treec02d275c1cbc2f07dd12e473c5bb261f39afd83c
parentccd363c1f70a54ce84468c4e850c867a48b6a99e (diff)
Handle new windows request and instead open links in new tabs #3507
Browse being a Sugar activity only has one full screen window. This patchs adds a callback to the new window policy decision requested signal and handles new links in new tabs. If in need, we can also take the decision to not open the link, using: reason = navigation_action.get_reason() I have not come to a reason to do that yet. Signed-off-by: Manuel Quiñones <manuq@laptop.org> Acked-by: Simon Schampijer <simon@laptop.org>
-rw-r--r--browser.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/browser.py b/browser.py
index f35ded3..259d888 100644
--- a/browser.py
+++ b/browser.py
@@ -490,6 +490,8 @@ class Browser(WebKit.WebView):
self.connect('download-requested', self.__download_requested_cb)
self.connect('mime-type-policy-decision-requested',
self.__mime_type_policy_cb)
+ self.connect('new-window-policy-decision-requested',
+ self.__new_window_policy_cb)
def get_history(self):
"""Return the browsing history of this browser."""
@@ -591,6 +593,21 @@ class Browser(WebKit.WebView):
policy_decision.download()
return True
+ def __new_window_policy_cb(self, webview, webframe, request,
+ navigation_action, policy_decision):
+ """Open new tab instead of a new window.
+
+ Browse doesn't support many windows, as any Sugar activity.
+ So we will handle the request, ignoring it and returning True
+ to inform WebKit that a decision was made. And we will open a
+ new tab instead.
+
+ """
+ policy_decision.ignore()
+ uri = request.get_uri()
+ self.open_new_tab(uri)
+ return True
+
def __download_requested_cb(self, browser, download):
downloadmanager.add_download(download, browser)
return True