From e4890ebdd1fd6462a39ffd6993709dadc6af82e6 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Sun, 4 Jul 2010 17:22:39 +0100 Subject: [PATCH] Describe and restore custom tab labels in the layout. Closes LP #568500 --- terminatorlib/container.py | 9 +++++++++ terminatorlib/notebook.py | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/terminatorlib/container.py b/terminatorlib/container.py index 2ddf5f2c..e9b05fd9 100755 --- a/terminatorlib/container.py +++ b/terminatorlib/container.py @@ -232,6 +232,15 @@ the %s will also close all terminals within it.') % (reqtype, reqtype)) if hasattr(self, 'get_size'): layout['size'] = self.get_size() + labels = [] + if mytype == 'Notebook': + for tabnum in xrange(0, self.get_n_pages()): + page = self.get_nth_page(tabnum) + label = self.get_tab_label(page) + labels.append(label.get_custom_label()) + if len(labels) > 0: + layout['labels'] = labels + name = 'child%d' % count count = count + 1 diff --git a/terminatorlib/notebook.py b/terminatorlib/notebook.py index 9e72da36..f3747c1c 100755 --- a/terminatorlib/notebook.py +++ b/terminatorlib/notebook.py @@ -95,6 +95,11 @@ class Notebook(Container, gtk.Notebook): # This page does not yet exist, so make it self.newtab(children[child_key]) page = self.get_nth_page(num) + if layout.has_key('labels'): + labeltext = layout['labels'][num] + if labeltext and labeltext != "None": + label = self.get_tab_label(page) + label.set_custom_label(labeltext) page.create_layout(children[child_key]) num = num + 1 @@ -376,6 +381,18 @@ class TabLabel(gtk.HBox): """Update the text of our label""" self.label.set_text(text) + def set_custom_label(self, text): + """Set a permanent label as if the user had edited it""" + self.label.set_text(text) + self.label.set_custom() + + def get_custom_label(self): + """Return a custom label if we have one, otherwise None""" + if self.label.is_custom(): + return(self.label.get_text()) + else: + return(None) + def update_button(self): """Update the state of our close button""" if not self.config['close_button_on_tab']: