From 04bd6935868dad81fb1771ae95bcd57c566bf842 Mon Sep 17 00:00:00 2001 From: Vulcalien Date: Sat, 9 Apr 2022 11:15:36 +0200 Subject: [PATCH 1/4] Zoom/maximize with one terminal in notebook tab --- terminatorlib/notebook.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/terminatorlib/notebook.py b/terminatorlib/notebook.py index 7daccaa4..4c0b92dc 100644 --- a/terminatorlib/notebook.py +++ b/terminatorlib/notebook.py @@ -290,7 +290,9 @@ class Notebook(Container, Gtk.Notebook): 'ungroup-tab': top_window.ungroup_tab, 'move-tab': top_window.move_tab, 'tab-new': [top_window.tab_new, widget], - 'navigate': top_window.navigate_terminal} + 'navigate': top_window.navigate_terminal, + 'zoom': top_window.zoom, + 'maximise': [top_window.zoom, False]} if maker.isinstance(widget, 'Terminal'): for signal in signals: From c2f2addf056d97fa57c4b554da480adcb3b9498a Mon Sep 17 00:00:00 2001 From: Vulcalien Date: Sat, 9 Apr 2022 11:19:36 +0200 Subject: [PATCH 2/4] Remove unused code (container.py, toggle_zoom) --- terminatorlib/container.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/terminatorlib/container.py b/terminatorlib/container.py index 53d4914c..97bea7fc 100644 --- a/terminatorlib/container.py +++ b/terminatorlib/container.py @@ -134,17 +134,6 @@ class Container(object): """Handle a keyboard event requesting a terminal resize""" raise NotImplementedError('resizeterm') - def toggle_zoom(self, widget, fontscale = False): - """Toggle the existing zoom state""" - try: - if self.get_property('term_zoomed'): - self.unzoom(widget) - else: - self.zoom(widget, fontscale) - except TypeError: - err('Container::toggle_zoom: %s is unable to handle zooming, for \ - %s' % (self, widget)) - def zoom(self, widget, fontscale = False): """Zoom a terminal""" raise NotImplementedError('zoom') From 06ada7c655739dbc14d5341cc645da63ca4654ad Mon Sep 17 00:00:00 2001 From: Vulcalien Date: Fri, 20 May 2022 13:12:16 +0200 Subject: [PATCH 3/4] Notebook tab zoom: keep label and position --- terminatorlib/window.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/terminatorlib/window.py b/terminatorlib/window.py index 04c60a4c..f4830aaf 100644 --- a/terminatorlib/window.py +++ b/terminatorlib/window.py @@ -529,6 +529,7 @@ class Window(Container, Gtk.Window): def zoom(self, widget, font_scale=True): """Zoom a terminal widget""" + maker = Factory() children = self.get_children() if widget in children: @@ -541,8 +542,13 @@ class Window(Container, Gtk.Window): self.zoom_data['old_child'] = children[0] self.zoom_data['font_scale'] = font_scale + old_parent = self.zoom_data['old_parent'] + if maker.isinstance(old_parent, 'Notebook'): + self.zoom_data['notebook_tabnum'] = old_parent.page_num(widget) + self.zoom_data['notebook_label'] = old_parent.get_tab_label(widget).get_label() + self.remove(self.zoom_data['old_child']) - self.zoom_data['old_parent'].remove(widget) + old_parent.remove(widget) self.add(widget) self.set_property('term_zoomed', True) @@ -554,6 +560,8 @@ class Window(Container, Gtk.Window): def unzoom(self, widget=None): """Restore normal terminal layout""" + maker = Factory() + if not self.is_zoomed(): # We're not zoomed anyway dbg('not zoomed, no-op') @@ -565,7 +573,13 @@ class Window(Container, Gtk.Window): self.remove(widget) self.add(self.zoom_data['old_child']) - self.zoom_data['old_parent'].add(widget) + if maker.isinstance(self.zoom_data['old_parent'], 'Notebook'): + self.zoom_data['old_parent'].newtab(widget=widget, metadata={ + 'tabnum': self.zoom_data['notebook_tabnum'], + 'label': self.zoom_data['notebook_label'] + }) + else: + self.zoom_data['old_parent'].add(widget) widget.grab_focus() self.zoom_data = None self.set_property('term_zoomed', False) From df0643b1a447446eec8a592f3534da3f57402114 Mon Sep 17 00:00:00 2001 From: Vulcalien Date: Sat, 27 Aug 2022 22:06:00 +0200 Subject: [PATCH 4/4] Notebook rotate: keep tab position and label --- terminatorlib/paned.py | 4 ++-- terminatorlib/window.py | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/terminatorlib/paned.py b/terminatorlib/paned.py index bf944160..86ca3cd2 100644 --- a/terminatorlib/paned.py +++ b/terminatorlib/paned.py @@ -424,7 +424,7 @@ class Paned(Container): """We don't want focus, we want a Terminal to have it""" self.get_child1().grab_focus() - def rotate_recursive(self, parent, w, h, clockwise): + def rotate_recursive(self, parent, w, h, clockwise, metadata=None): """ Recursively rotate "self" into a new paned that'll have "w" x "h" size. Attach it to "parent". @@ -458,7 +458,7 @@ class Paned(Container): w2 = max(w - w1 - handle_size, 0) container.set_pos(pos) - parent.add(container) + parent.add(container, metadata=metadata) if maker.isinstance(children[0], 'Terminal'): children[0].get_parent().remove(children[0]) diff --git a/terminatorlib/window.py b/terminatorlib/window.py index f4830aaf..eadb0aba 100644 --- a/terminatorlib/window.py +++ b/terminatorlib/window.py @@ -597,8 +597,17 @@ class Window(Container, Gtk.Window): # If our child is a Notebook, reset to work from its visible child if maker.isinstance(child, 'Notebook'): - pagenum = child.get_current_page() - child = child.get_nth_page(pagenum) + notebook = child + + pagenum = notebook.get_current_page() + child = notebook.get_nth_page(pagenum) + + metadata = { + 'tabnum': pagenum, + 'label': notebook.get_tab_label(child).get_label() + } + else: + metadata = None if maker.isinstance(child, 'Paned'): parent = child.get_parent() @@ -606,7 +615,7 @@ class Window(Container, Gtk.Window): # otherwise _sometimes_ we get incorrect values. alloc = child.get_allocation() parent.remove(child) - child.rotate_recursive(parent, alloc.width, alloc.height, clockwise) + child.rotate_recursive(parent, alloc.width, alloc.height, clockwise, metadata) self.show_all() while Gtk.events_pending():