diff --git a/terminatorlib/container.py b/terminatorlib/container.py index 5609cc74..57599546 100755 --- a/terminatorlib/container.py +++ b/terminatorlib/container.py @@ -6,6 +6,7 @@ import gobject import gtk +from factory import Factory from config import Config from util import dbg, err from translation import _ @@ -171,5 +172,21 @@ the %s will also close all terminals within it.') % (reqtype, reqtype)) dialog.show_all() return(dialog) - + + def propagate_title_change(self, widget, title): + """Pass a title change up the widget stack""" + maker = Factory() + 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'): + self.title.set_title(widget, title) + + if maker.isinstance(parent, 'Container'): + parent.propagate_title_change(widget, title) + # vim: set expandtab ts=4 sw=4: diff --git a/terminatorlib/editablelabel.py b/terminatorlib/editablelabel.py index db942bf8..e0216e07 100644 --- a/terminatorlib/editablelabel.py +++ b/terminatorlib/editablelabel.py @@ -55,13 +55,13 @@ class EditableLabel(gtk.EventBox): """set angle of the label""" self._label.set_angle( angle ) - def set_text( self, text, force=False): + def set_text(self, text, force=False): """set the text of the label""" self._autotext = text if not self._custom or force: self._label.set_text(text) - def get_text( self ): + def get_text(self): """get the text from the label""" return(self._label.get_text()) diff --git a/terminatorlib/factory.py b/terminatorlib/factory.py index 606d43d0..2cc6ff5f 100755 --- a/terminatorlib/factory.py +++ b/terminatorlib/factory.py @@ -26,7 +26,8 @@ class Factory(Borg): 'HPaned': 'paned', 'Paned': 'paned', 'Notebook': 'notebook', - 'Container': 'container'} + 'Container': 'container', + 'Window': 'window'} if classtype in types.keys(): module = __import__(types[classtype], None, None, ['']) return(isinstance(product, getattr(module, classtype))) diff --git a/terminatorlib/notebook.py b/terminatorlib/notebook.py index 1ab76e50..264dce93 100755 --- a/terminatorlib/notebook.py +++ b/terminatorlib/notebook.py @@ -105,9 +105,9 @@ class Notebook(Container, gtk.Notebook): widget.spawn_child() signals = {'close-term': self.wrapcloseterm, - #'title-change': self.title.set_title, 'split-horiz': self.split_horiz, 'split-vert': self.split_vert, + 'title-change': self.propagate_title_change, 'unzoom': self.unzoom} maker = Factory() @@ -226,6 +226,18 @@ class Notebook(Container, gtk.Notebook): """Unzoom a terminal""" raise NotImplementedError('unzoom') + 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) + if not label: + err('Notebook::update_tab_label_text: %s not found' % widget) + return + + label.set_label(text) + class TabLabel(gtk.HBox): """Class implementing a label widget for Notebook tabs""" notebook = None @@ -257,6 +269,10 @@ class TabLabel(gtk.HBox): self.update_button() self.show_all() + def set_label(self, text): + """Update the text of our label""" + self.label.set_text(text) + def update_button(self): """Update the state of our close button""" if not self.config['close_button_on_tab']: diff --git a/terminatorlib/paned.py b/terminatorlib/paned.py index bee7a28a..8a6c9588 100755 --- a/terminatorlib/paned.py +++ b/terminatorlib/paned.py @@ -83,10 +83,10 @@ class Paned(Container): if maker.isinstance(widget, 'Terminal'): top_window = get_top_window(self) - # FIXME: somehow propagate the title-change signal to the Window signals = {'close-term': self.wrapcloseterm, 'split-horiz': self.split_horiz, 'split-vert': self.split_vert, + 'title-change': self.propagate_title_change, 'resize-term': self.resizeterm, 'zoom': top_window.zoom} diff --git a/terminatorlib/titlebar.py b/terminatorlib/titlebar.py index da6a6df6..fc47df9c 100755 --- a/terminatorlib/titlebar.py +++ b/terminatorlib/titlebar.py @@ -107,6 +107,8 @@ class Titlebar(gtk.EventBox): """Update the terminal title""" self.termtext = title self.update() + # Return False so we don't interrupt any chains of signal handling + return False def set_group_label(self, name): """Set the name of the group"""