Describe and restore custom tab labels in the layout. Closes LP #568500

This commit is contained in:
Chris Jones 2010-07-04 17:22:39 +01:00
parent 78e0bd56be
commit e4890ebdd1
2 changed files with 26 additions and 0 deletions

View File

@ -232,6 +232,15 @@ the %s will also close all terminals within it.') % (reqtype, reqtype))
if hasattr(self, 'get_size'): if hasattr(self, 'get_size'):
layout['size'] = 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 name = 'child%d' % count
count = count + 1 count = count + 1

View File

@ -95,6 +95,11 @@ class Notebook(Container, gtk.Notebook):
# This page does not yet exist, so make it # This page does not yet exist, so make it
self.newtab(children[child_key]) self.newtab(children[child_key])
page = self.get_nth_page(num) 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]) page.create_layout(children[child_key])
num = num + 1 num = num + 1
@ -376,6 +381,18 @@ class TabLabel(gtk.HBox):
"""Update the text of our label""" """Update the text of our label"""
self.label.set_text(text) 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): def update_button(self):
"""Update the state of our close button""" """Update the state of our close button"""
if not self.config['close_button_on_tab']: if not self.config['close_button_on_tab']: