From ff45920874714bfd68ca0c2c9190f185e49a8f2b Mon Sep 17 00:00:00 2001 From: Vishweshwar Saran Singh Deo Date: Fri, 20 Oct 2023 23:50:25 +0530 Subject: [PATCH 1/2] [bug 835] 835-crash-after-unzooming-a-single-terminal-inside-a-tab #835 -removed previous code to start fresh -added event type for tab-change since other way of identifying zoomed widget was not simple and clear -emit tab-change is done at a single point now in notebook.py --- terminatorlib/notebook.py | 6 ++---- terminatorlib/terminal.py | 26 +++++++++++++------------- terminatorlib/terminator.py | 10 ++-------- terminatorlib/window.py | 8 +++++++- 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/terminatorlib/notebook.py b/terminatorlib/notebook.py index eb630b17..358c82d4 100644 --- a/terminatorlib/notebook.py +++ b/terminatorlib/notebook.py @@ -343,10 +343,6 @@ class Notebook(Container, Gtk.Notebook): self.set_current_page(tabpos) self.show_all() if maker.isinstance(term_widget, 'Terminal'): - #notify plugins of tab-change - dbg("emit tab-change for tabpos: %s " % tabpos) - term_widget.emit('tab-change', tabpos) - self.set_current_page(tabpos) widget.grab_focus() def wrapcloseterm(self, widget): @@ -528,6 +524,8 @@ class Notebook(Container, Gtk.Notebook): # if we can't find a last active term we must be starting up if term is not None: GObject.idle_add(term.ensure_visible_and_focussed) + dbg('emit tab-change type: targe-plugin for page:%s' % page_num) + term.emit('tab-change', page_num, 'target-plugin') return True def on_scroll_event(self, notebook, event): diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 7ed248b0..e19b14f3 100644 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -68,7 +68,7 @@ class Terminal(Gtk.VBox): 'navigate': (GObject.SignalFlags.RUN_LAST, None, (GObject.TYPE_STRING,)), 'tab-change': (GObject.SignalFlags.RUN_LAST, None, - (GObject.TYPE_INT,)), + (GObject.TYPE_INT,GObject.TYPE_STRING,)), 'group-all': (GObject.SignalFlags.RUN_LAST, None, ()), 'group-all-toggle': (GObject.SignalFlags.RUN_LAST, None, ()), 'move-tab': (GObject.SignalFlags.RUN_LAST, None, @@ -1985,40 +1985,40 @@ class Terminal(Gtk.VBox): self.zoom() def key_next_tab(self): - self.emit('tab-change', -1) + self.emit('tab-change', -1, None) def key_prev_tab(self): - self.emit('tab-change', -2) + self.emit('tab-change', -2, None) def key_switch_to_tab_1(self): - self.emit('tab-change', 0) + self.emit('tab-change', 0, None) def key_switch_to_tab_2(self): - self.emit('tab-change', 1) + self.emit('tab-change', 1, None) def key_switch_to_tab_3(self): - self.emit('tab-change', 2) + self.emit('tab-change', 2, None) def key_switch_to_tab_4(self): - self.emit('tab-change', 3) + self.emit('tab-change', 3, None) def key_switch_to_tab_5(self): - self.emit('tab-change', 4) + self.emit('tab-change', 4, None) def key_switch_to_tab_6(self): - self.emit('tab-change', 5) + self.emit('tab-change', 5, None) def key_switch_to_tab_7(self): - self.emit('tab-change', 6) + self.emit('tab-change', 6, None) def key_switch_to_tab_8(self): - self.emit('tab-change', 7) + self.emit('tab-change', 7, None) def key_switch_to_tab_9(self): - self.emit('tab-change', 8) + self.emit('tab-change', 8, None) def key_switch_to_tab_10(self): - self.emit('tab-change', 9) + self.emit('tab-change', 9, None) def key_reset(self): self.vte.reset (True, False) diff --git a/terminatorlib/terminator.py b/terminatorlib/terminator.py index aede3336..d133667d 100644 --- a/terminatorlib/terminator.py +++ b/terminatorlib/terminator.py @@ -186,13 +186,6 @@ class Terminator(Borg): for terminal in self.terminals: dbg('checking: %s (%s)' % (terminal.uuid.urn, terminal)) if terminal.uuid.urn == uuid: - if terminal.get_toplevel().is_child_notebook(): - topchild = terminal.get_toplevel().get_child() - current_page = topchild.get_current_page() - #we need to emit signal for plugin and retain same page - dbg("current_page for tab-change-signal:%s" % current_page) - terminal.emit('tab-change', current_page) - return terminal return None @@ -203,6 +196,7 @@ class Terminator(Borg): dbg('checking: %s (%s)' % (window.uuid.urn, window)) if window.uuid.urn == uuid: return window + return None def new_window(self, cwd=None, profile=None): @@ -217,7 +211,7 @@ class Terminator(Borg): window.add(terminal) window.show(True) terminal.spawn_child() - terminal.emit('tab-change', 0) + terminal.emit('tab-change', 0, None) return(window, terminal) diff --git a/terminatorlib/window.py b/terminatorlib/window.py index 9cf7f688..c76976d0 100644 --- a/terminatorlib/window.py +++ b/terminatorlib/window.py @@ -738,8 +738,14 @@ class Window(Container, Gtk.Window): def disable_geometry_hints(self): self.set_geometry_hints(None, None, 0) - def tab_change(self, widget, num=None): + def tab_change(self, widget, num=None, event_type=None): """Change to a specific tab""" + + #we return if event_type is set by a component + #we only handle default + if event_type: + return + if self.is_zoomed(): self.unzoom() From c7c9fd0d4b1da29c71f8079b5661c4f308385196 Mon Sep 17 00:00:00 2001 From: Vishweshwar Saran Singh Deo Date: Tue, 24 Oct 2023 10:14:19 +0530 Subject: [PATCH 2/2] [bug 835] 835-crash-after-unzooming-a-single-terminal-inside-a-tab #835 - removing the tab-change event dependency and having a simpler solution with focus-in --- terminatorlib/notebook.py | 2 -- terminatorlib/terminal.py | 26 +++++++++++++------------- terminatorlib/terminator.py | 3 +-- terminatorlib/window.py | 8 +------- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/terminatorlib/notebook.py b/terminatorlib/notebook.py index 358c82d4..9cb6bd48 100644 --- a/terminatorlib/notebook.py +++ b/terminatorlib/notebook.py @@ -524,8 +524,6 @@ class Notebook(Container, Gtk.Notebook): # if we can't find a last active term we must be starting up if term is not None: GObject.idle_add(term.ensure_visible_and_focussed) - dbg('emit tab-change type: targe-plugin for page:%s' % page_num) - term.emit('tab-change', page_num, 'target-plugin') return True def on_scroll_event(self, notebook, event): diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index e19b14f3..7ed248b0 100644 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -68,7 +68,7 @@ class Terminal(Gtk.VBox): 'navigate': (GObject.SignalFlags.RUN_LAST, None, (GObject.TYPE_STRING,)), 'tab-change': (GObject.SignalFlags.RUN_LAST, None, - (GObject.TYPE_INT,GObject.TYPE_STRING,)), + (GObject.TYPE_INT,)), 'group-all': (GObject.SignalFlags.RUN_LAST, None, ()), 'group-all-toggle': (GObject.SignalFlags.RUN_LAST, None, ()), 'move-tab': (GObject.SignalFlags.RUN_LAST, None, @@ -1985,40 +1985,40 @@ class Terminal(Gtk.VBox): self.zoom() def key_next_tab(self): - self.emit('tab-change', -1, None) + self.emit('tab-change', -1) def key_prev_tab(self): - self.emit('tab-change', -2, None) + self.emit('tab-change', -2) def key_switch_to_tab_1(self): - self.emit('tab-change', 0, None) + self.emit('tab-change', 0) def key_switch_to_tab_2(self): - self.emit('tab-change', 1, None) + self.emit('tab-change', 1) def key_switch_to_tab_3(self): - self.emit('tab-change', 2, None) + self.emit('tab-change', 2) def key_switch_to_tab_4(self): - self.emit('tab-change', 3, None) + self.emit('tab-change', 3) def key_switch_to_tab_5(self): - self.emit('tab-change', 4, None) + self.emit('tab-change', 4) def key_switch_to_tab_6(self): - self.emit('tab-change', 5, None) + self.emit('tab-change', 5) def key_switch_to_tab_7(self): - self.emit('tab-change', 6, None) + self.emit('tab-change', 6) def key_switch_to_tab_8(self): - self.emit('tab-change', 7, None) + self.emit('tab-change', 7) def key_switch_to_tab_9(self): - self.emit('tab-change', 8, None) + self.emit('tab-change', 8) def key_switch_to_tab_10(self): - self.emit('tab-change', 9, None) + self.emit('tab-change', 9) def key_reset(self): self.vte.reset (True, False) diff --git a/terminatorlib/terminator.py b/terminatorlib/terminator.py index d133667d..86aa0999 100644 --- a/terminatorlib/terminator.py +++ b/terminatorlib/terminator.py @@ -196,7 +196,6 @@ class Terminator(Borg): dbg('checking: %s (%s)' % (window.uuid.urn, window)) if window.uuid.urn == uuid: return window - return None def new_window(self, cwd=None, profile=None): @@ -211,7 +210,7 @@ class Terminator(Borg): window.add(terminal) window.show(True) terminal.spawn_child() - terminal.emit('tab-change', 0, None) + terminal.emit('tab-change', 0) return(window, terminal) diff --git a/terminatorlib/window.py b/terminatorlib/window.py index c76976d0..9cf7f688 100644 --- a/terminatorlib/window.py +++ b/terminatorlib/window.py @@ -738,14 +738,8 @@ class Window(Container, Gtk.Window): def disable_geometry_hints(self): self.set_geometry_hints(None, None, 0) - def tab_change(self, widget, num=None, event_type=None): + def tab_change(self, widget, num=None): """Change to a specific tab""" - - #we return if event_type is set by a component - #we only handle default - if event_type: - return - if self.is_zoomed(): self.unzoom()