decouple Terminal from Terminator, and add the minimum necessary group icon handling

This commit is contained in:
Chris Jones 2009-09-02 23:17:54 +01:00
parent 0f5cf7c496
commit bf20587edc
3 changed files with 32 additions and 7 deletions

View File

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

View File

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

View File

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