From e9b29a1dfc9e5fe2a27d8609e64afc4d93234ed2 Mon Sep 17 00:00:00 2001 From: Vulcalien Date: Wed, 25 Aug 2021 22:21:37 +0200 Subject: [PATCH 1/4] Make tabs detachable --- terminatorlib/notebook.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/terminatorlib/notebook.py b/terminatorlib/notebook.py index 69d8216e..49dc0661 100644 --- a/terminatorlib/notebook.py +++ b/terminatorlib/notebook.py @@ -37,6 +37,7 @@ class Notebook(Container, Gtk.Notebook): self.register_signals(Notebook) self.connect('switch-page', self.deferred_on_tab_switch) self.connect('scroll-event', self.on_scroll_event) + self.connect('create-window', self.create_window_detach) self.configure() self.set_can_focus(False) @@ -77,6 +78,21 @@ class Notebook(Container, Gtk.Notebook): # self.modify_style(style) self.last_active_term = {} + def create_window_detach(self, notebook, widget, x, y): + """Create a window to contain a detached tab""" + maker = Factory() + + window = maker.make('Window') + window.move(x, y) + size = self.window.get_size() + window.resize(size.width, size.height) + + self.detach_tab(widget) + self.hoover() + window.add(widget) + + window.show_all() + def create_layout(self, layout): """Apply layout configuration""" def child_compare(a, b): @@ -173,6 +189,7 @@ class Notebook(Container, Gtk.Notebook): sibling.force_set_profile(None, widget.get_profile()) self.insert_page(container, None, page_num) + self.set_tab_detachable(container, True) self.child_set_property(container, 'tab-expand', True) self.child_set_property(container, 'tab-fill', True) self.set_tab_reorderable(container, True) @@ -299,6 +316,7 @@ class Notebook(Container, Gtk.Notebook): dbg('inserting page at position: %s' % tabpos) self.insert_page(widget, None, tabpos) + self.set_tab_detachable(widget, True) if maker.isinstance(widget, 'Terminal'): containers, objects = ([], [widget]) From 387bcd2ee3d164051ea8994361293267d2f3e053 Mon Sep 17 00:00:00 2001 From: Vulcalien Date: Thu, 26 Aug 2021 18:42:58 +0200 Subject: [PATCH 2/4] Disconnect child after detaching the tab --- terminatorlib/notebook.py | 1 + 1 file changed, 1 insertion(+) diff --git a/terminatorlib/notebook.py b/terminatorlib/notebook.py index 49dc0661..8228416a 100644 --- a/terminatorlib/notebook.py +++ b/terminatorlib/notebook.py @@ -88,6 +88,7 @@ class Notebook(Container, Gtk.Notebook): window.resize(size.width, size.height) self.detach_tab(widget) + self.disconnect_child(widget) self.hoover() window.add(widget) From dea06ed3bde81220c375e0376b5b1461fb0487cc Mon Sep 17 00:00:00 2001 From: Vulcalien Date: Fri, 27 Aug 2021 11:13:12 +0200 Subject: [PATCH 3/4] Add dbg message for Notebook::create_window_detach --- terminatorlib/notebook.py | 1 + 1 file changed, 1 insertion(+) diff --git a/terminatorlib/notebook.py b/terminatorlib/notebook.py index 8228416a..41e8187f 100644 --- a/terminatorlib/notebook.py +++ b/terminatorlib/notebook.py @@ -80,6 +80,7 @@ class Notebook(Container, Gtk.Notebook): def create_window_detach(self, notebook, widget, x, y): """Create a window to contain a detached tab""" + dbg('creating window for detached tab: %s' % widget) maker = Factory() window = maker.make('Window') From 28e76fe4697b8565085f52591d7a74f756673bf9 Mon Sep 17 00:00:00 2001 From: Vulcalien Date: Fri, 27 Aug 2021 18:54:21 +0200 Subject: [PATCH 4/4] BugFix: on destroy, window does not close every terminal in it --- terminatorlib/window.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terminatorlib/window.py b/terminatorlib/window.py index 0b77b40d..1a073989 100644 --- a/terminatorlib/window.py +++ b/terminatorlib/window.py @@ -299,7 +299,7 @@ class Window(Container, Gtk.Window): def on_destroy_event(self, widget, data=None): """Handle window destruction""" dbg('destroying self') - for terminal in self.get_visible_terminals(): + for terminal in self.get_terminals(): terminal.close() self.cnxids.remove_all() self.terminator.deregister_window(self)