Describe and restore custom tab labels in the layout. Closes LP #568500
This commit is contained in:
parent
78e0bd56be
commit
e4890ebdd1
|
@ -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
|
||||
|
||||
|
|
|
@ -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']:
|
||||
|
|
Loading…
Reference in New Issue