From bf20587edc51e21202b77bc74d4d8d7297a64819 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 2 Sep 2009 23:17:54 +0100 Subject: [PATCH] decouple Terminal from Terminator, and add the minimum necessary group icon handling --- terminatorlib/newterminator.py | 12 +++++++----- terminatorlib/test.py | 4 +++- terminatorlib/titlebar.py | 23 ++++++++++++++++++++++- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/terminatorlib/newterminator.py b/terminatorlib/newterminator.py index be8132eb..b1853aa1 100755 --- a/terminatorlib/newterminator.py +++ b/terminatorlib/newterminator.py @@ -4,7 +4,8 @@ """terminator.py - class for the master Terminator singleton""" from borg import Borg -from terminal import Terminal + +groupsend_type = {'all':0, 'group':1, 'off':2} class Terminator(Borg): """master object for the application""" @@ -14,6 +15,7 @@ class Terminator(Borg): terminals = None groups = None config = None + groupsend = None def __init__(self): """Class initialiser""" @@ -28,13 +30,13 @@ class Terminator(Borg): self.terminals = [] if not self.groups: self.groups = [] + if not self.groupsend: + self.groupsend = groupsend_type['group'] - def new_terminal(self): - """Create and register a new terminal widget""" + def register_terminal(self, terminal): + """Register a new terminal widget""" - terminal = Terminal() self.terminals.append(terminal) - return(terminal) def reconfigure_terminals(self): """Tell all terminals to update their configuration""" diff --git a/terminatorlib/test.py b/terminatorlib/test.py index 71e38032..62f83f2e 100755 --- a/terminatorlib/test.py +++ b/terminatorlib/test.py @@ -4,10 +4,12 @@ import gtk from newterminator import Terminator from window import Window +from terminal import Terminal window = Window() foo = Terminator() -term = foo.new_terminal() +term = Terminal() +foo.register_terminal(term) window.add(term) window.show() diff --git a/terminatorlib/titlebar.py b/terminatorlib/titlebar.py index 959f510b..99deb360 100755 --- a/terminatorlib/titlebar.py +++ b/terminatorlib/titlebar.py @@ -6,12 +6,15 @@ import gtk import gobject +from version import APP_NAME +from newterminator import Terminator,groupsend_type from editablelabel import EditableLabel # pylint: disable-msg=R0904 class Titlebar(gtk.EventBox): """Class implementing the Titlebar widget""" + terminator = None oldtitle = None termtext = None sizetext = None @@ -27,13 +30,22 @@ class Titlebar(gtk.EventBox): gtk.EventBox.__init__(self) self.__gobject_init__() + self.terminator = Terminator() + self.label = EditableLabel() self.ebox = gtk.EventBox() self.grouphbox = gtk.HBox() self.grouplabel = gtk.Label() self.groupicon = gtk.Image() - # FIXME: How do we decide which icon to use? + if self.terminator.groupsend == groupsend_type['all']: + icon_name = 'all' + elif self.terminator.groupsend == groupsend_type['group']: + icon_name = 'group' + elif self.terminator.groupsend == groupsend_type['off']: + icon_name = 'off' + self.set_from_icon_name('_active_broadcast_%s' % icon_name, + gtk.ICON_SIZE_MENU) self.grouphbox.pack_start(self.groupicon, False, True, 2) self.grouphbox.pack_start(self.grouplabel, False, True, 2) @@ -56,6 +68,15 @@ class Titlebar(gtk.EventBox): """Update our contents""" self.label.set_text("%s %s" % (self.termtext, self.sizetext)) + def set_from_icon_name(self, name, size = gtk.ICON_SIZE_MENU): + """Set an icon for the group label""" + if not name: + self.groupicon.hide() + return + + self.groupicon.set_from_icon_name(APP_NAME + name, size) + self.groupicon.show() + def update_terminal_size(self, width, height): """Update the displayed terminal size""" self.sizetext = "%sx%s" % (width, height)