diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2008-07-24 10:08:43 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2008-07-24 10:08:43 (GMT) |
commit | 2cb1ae0ff2cb0fc7fcad6c936ce1e7cc3a08564f (patch) | |
tree | d5613b5742b1323e5de3391b07c05ea17958e21f | |
parent | 1b49f91a3eb89523a11d7b616ad189d7bb57eff6 (diff) |
Open in the same page only _blank targets.
Add a way lookup the view from the chrome.
-rw-r--r-- | python/webview.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/python/webview.py b/python/webview.py index 6b0af57..b4dc51f 100644 --- a/python/webview.py +++ b/python/webview.py @@ -25,6 +25,8 @@ from xpcom import components from xpcom.components import interfaces from xpcom.nsError import * +_views = [] + class _Chrome: _com_interfaces_ = interfaces.nsIWebBrowserChrome, \ interfaces.nsIWebBrowserChrome2, \ @@ -41,7 +43,10 @@ class _Chrome: def provideWindow(self, parent, flags, position_specified, size_specified, uri, name, features): - return parent, False + if name == "_blank": + return parent, False + else: + return None, False # nsIWebBrowserChrome def destroyBrowserWindow(self): @@ -223,6 +228,13 @@ class WebView(_hulahop.WebView): self.create_window() + self.connect('destroy', self.__destroy_cb) + + _views.append(self) + + def __destroy_cb(self): + _views.remove(self) + def _notify_title_changed(self): self.notify('title') @@ -267,3 +279,8 @@ class WebView(_hulahop.WebView): web_progress = property(get_web_progress) web_navigation = property(get_web_navigation) +def lookup_view(chrome): + for view in _views: + if view._chrome == chrome: + return view + return None |