From 7d897eaef7e98c36fae0661bc59a0ba91bf629c0 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 10 Dec 2009 23:25:52 +0000 Subject: [PATCH] Make title propagation work properly --- terminatorlib/container.py | 2 -- terminatorlib/notebook.py | 21 +++++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/terminatorlib/container.py b/terminatorlib/container.py index 57599546..6b52ee53 100755 --- a/terminatorlib/container.py +++ b/terminatorlib/container.py @@ -179,8 +179,6 @@ the %s will also close all terminals within it.') % (reqtype, reqtype)) parent = self.get_parent() title = widget.get_window_title() - dbg('Container::propagate_title_change: I am %s. My parent is %s' % - (self, parent)) if maker.isinstance(self, 'Notebook'): self.update_tab_label_text(widget, title) elif maker.isinstance(self, 'Window'): diff --git a/terminatorlib/notebook.py b/terminatorlib/notebook.py index 264dce93..4eb69e10 100755 --- a/terminatorlib/notebook.py +++ b/terminatorlib/notebook.py @@ -226,12 +226,25 @@ class Notebook(Container, gtk.Notebook): """Unzoom a terminal""" raise NotImplementedError('unzoom') + def find_tab_root(self, widget): + """Look for the tab child which is or ultimately contains the supplied + widget""" + parent = widget.get_parent() + previous = parent + + while parent is not None and parent is not self: + previous = parent + parent = parent.get_parent() + + if previous == self: + return(widget) + else: + return(previous) + def update_tab_label_text(self, widget, text): """Update the text of a tab label""" - # FIXME: get_tab_label() doesn't descend the widget tree. We need - # something that does or this only works for Notebook->Terminal, not - # Notebook->Container->...->Terminal - label = self.get_tab_label(widget) + notebook = self.find_tab_root(widget) + label = self.get_tab_label(notebook) if not label: err('Notebook::update_tab_label_text: %s not found' % widget) return