Make title changes propagate better, albeit not perfectly yet

This commit is contained in:
Chris Jones 2009-12-10 13:20:03 +00:00
parent f10f43fa8a
commit 602c6a3b57
6 changed files with 42 additions and 6 deletions

View File

@ -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:

View File

@ -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())

View File

@ -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)))

View File

@ -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']:

View File

@ -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}

View File

@ -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"""