Support closing windows via javascript.

This commit is contained in:
Florian Bruhin 2014-06-10 16:50:14 +02:00
parent 7315712359
commit 43c0578ede

View File

@ -155,6 +155,8 @@ class TabbedBrowser(TabWidget):
tab.iconChanged.connect(self.on_icon_changed)
tab.page().mainFrame().loadStarted.connect(partial(
self.on_load_started, tab))
tab.page().windowCloseRequested.connect(partial(
self.on_window_close_requested, tab))
def cntwidget(self, count=None):
"""Return a widget based on a count/idx.
@ -241,6 +243,11 @@ class TabbedBrowser(TabWidget):
"""Close a tab via an index."""
self.close_tab(idx)
@pyqtSlot(WebView)
def on_window_close_requested(self, widget):
"""Close a tab with a widget given."""
self.close_tab(widget)
@pyqtSlot(str, bool)
def tabopen(self, url=None, background=None):
"""Open a new tab with a given URL.