From d007bc45c5acdef2c5860fe048f43d35a0709830 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 2 Sep 2009 22:38:27 +0100 Subject: [PATCH] bare minimum titlebar functionality --- terminatorlib/titlebar.py | 49 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/terminatorlib/titlebar.py b/terminatorlib/titlebar.py index 6a9e9420..959f510b 100755 --- a/terminatorlib/titlebar.py +++ b/terminatorlib/titlebar.py @@ -6,18 +6,47 @@ import gtk import gobject +from editablelabel import EditableLabel + # pylint: disable-msg=R0904 class Titlebar(gtk.EventBox): """Class implementing the Titlebar widget""" oldtitle = None + termtext = None + sizetext = None + label = None + hbox = None + ebox = None + grouphbox = None + groupicon = None + grouplabel = None def __init__(self): """Class initialiser""" gtk.EventBox.__init__(self) self.__gobject_init__() - self.show() + 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? + + self.grouphbox.pack_start(self.groupicon, False, True, 2) + self.grouphbox.pack_start(self.grouplabel, False, True, 2) + self.ebox.add(self.grouphbox) + self.ebox.show_all() + + self.hbox = gtk.HBox() + self.hbox.pack_start(self.ebox, False, True, 0) + self.hbox.pack_start(gtk.VSeparator(), False, True, 0) + self.hbox.pack_start(self.label, True, True) + + self.add(self.hbox) + self.show_all() def connect_icon(self, func): """Connect the supplied function to clicking on the group icon""" @@ -25,14 +54,28 @@ class Titlebar(gtk.EventBox): def update(self): """Update our contents""" - pass + self.label.set_text("%s %s" % (self.termtext, self.sizetext)) def update_terminal_size(self, width, height): """Update the displayed terminal size""" - pass + self.sizetext = "%sx%s" % (width, height) + self.update() def set_terminal_title(self, widget, title): """Update the terminal title""" + self.termtext = title + self.update() + + def set_group_label(self, name): + """Set the name of the group""" + if name: + self.grouplabel.set_text(name) + self.grouplabel.show() + else: + self.grouplabel.hide() + + def on_clicked(self, widget, event): + """Handle a click on the label""" pass gobject.type_register(Titlebar)