From 43c0578ede9d91bbc4e6bd67a7010043bc56ea22 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 10 Jun 2014 16:50:14 +0200 Subject: [PATCH] Support closing windows via javascript. --- qutebrowser/widgets/tabbedbrowser.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qutebrowser/widgets/tabbedbrowser.py b/qutebrowser/widgets/tabbedbrowser.py index cf9147011..7bec5ebd4 100644 --- a/qutebrowser/widgets/tabbedbrowser.py +++ b/qutebrowser/widgets/tabbedbrowser.py @@ -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.