decouple Terminal from Terminator, and add the minimum necessary group icon handling
This commit is contained in:
parent
0f5cf7c496
commit
bf20587edc
|
@ -4,7 +4,8 @@
|
||||||
"""terminator.py - class for the master Terminator singleton"""
|
"""terminator.py - class for the master Terminator singleton"""
|
||||||
|
|
||||||
from borg import Borg
|
from borg import Borg
|
||||||
from terminal import Terminal
|
|
||||||
|
groupsend_type = {'all':0, 'group':1, 'off':2}
|
||||||
|
|
||||||
class Terminator(Borg):
|
class Terminator(Borg):
|
||||||
"""master object for the application"""
|
"""master object for the application"""
|
||||||
|
@ -14,6 +15,7 @@ class Terminator(Borg):
|
||||||
terminals = None
|
terminals = None
|
||||||
groups = None
|
groups = None
|
||||||
config = None
|
config = None
|
||||||
|
groupsend = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Class initialiser"""
|
"""Class initialiser"""
|
||||||
|
@ -28,13 +30,13 @@ class Terminator(Borg):
|
||||||
self.terminals = []
|
self.terminals = []
|
||||||
if not self.groups:
|
if not self.groups:
|
||||||
self.groups = []
|
self.groups = []
|
||||||
|
if not self.groupsend:
|
||||||
|
self.groupsend = groupsend_type['group']
|
||||||
|
|
||||||
def new_terminal(self):
|
def register_terminal(self, terminal):
|
||||||
"""Create and register a new terminal widget"""
|
"""Register a new terminal widget"""
|
||||||
|
|
||||||
terminal = Terminal()
|
|
||||||
self.terminals.append(terminal)
|
self.terminals.append(terminal)
|
||||||
return(terminal)
|
|
||||||
|
|
||||||
def reconfigure_terminals(self):
|
def reconfigure_terminals(self):
|
||||||
"""Tell all terminals to update their configuration"""
|
"""Tell all terminals to update their configuration"""
|
||||||
|
|
|
@ -4,10 +4,12 @@ import gtk
|
||||||
|
|
||||||
from newterminator import Terminator
|
from newterminator import Terminator
|
||||||
from window import Window
|
from window import Window
|
||||||
|
from terminal import Terminal
|
||||||
|
|
||||||
window = Window()
|
window = Window()
|
||||||
foo = Terminator()
|
foo = Terminator()
|
||||||
term = foo.new_terminal()
|
term = Terminal()
|
||||||
|
foo.register_terminal(term)
|
||||||
|
|
||||||
window.add(term)
|
window.add(term)
|
||||||
window.show()
|
window.show()
|
||||||
|
|
|
@ -6,12 +6,15 @@
|
||||||
import gtk
|
import gtk
|
||||||
import gobject
|
import gobject
|
||||||
|
|
||||||
|
from version import APP_NAME
|
||||||
|
from newterminator import Terminator,groupsend_type
|
||||||
from editablelabel import EditableLabel
|
from editablelabel import EditableLabel
|
||||||
|
|
||||||
# pylint: disable-msg=R0904
|
# pylint: disable-msg=R0904
|
||||||
class Titlebar(gtk.EventBox):
|
class Titlebar(gtk.EventBox):
|
||||||
"""Class implementing the Titlebar widget"""
|
"""Class implementing the Titlebar widget"""
|
||||||
|
|
||||||
|
terminator = None
|
||||||
oldtitle = None
|
oldtitle = None
|
||||||
termtext = None
|
termtext = None
|
||||||
sizetext = None
|
sizetext = None
|
||||||
|
@ -27,13 +30,22 @@ class Titlebar(gtk.EventBox):
|
||||||
gtk.EventBox.__init__(self)
|
gtk.EventBox.__init__(self)
|
||||||
self.__gobject_init__()
|
self.__gobject_init__()
|
||||||
|
|
||||||
|
self.terminator = Terminator()
|
||||||
|
|
||||||
self.label = EditableLabel()
|
self.label = EditableLabel()
|
||||||
self.ebox = gtk.EventBox()
|
self.ebox = gtk.EventBox()
|
||||||
self.grouphbox = gtk.HBox()
|
self.grouphbox = gtk.HBox()
|
||||||
self.grouplabel = gtk.Label()
|
self.grouplabel = gtk.Label()
|
||||||
self.groupicon = gtk.Image()
|
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.groupicon, False, True, 2)
|
||||||
self.grouphbox.pack_start(self.grouplabel, False, True, 2)
|
self.grouphbox.pack_start(self.grouplabel, False, True, 2)
|
||||||
|
@ -56,6 +68,15 @@ class Titlebar(gtk.EventBox):
|
||||||
"""Update our contents"""
|
"""Update our contents"""
|
||||||
self.label.set_text("%s %s" % (self.termtext, self.sizetext))
|
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):
|
def update_terminal_size(self, width, height):
|
||||||
"""Update the displayed terminal size"""
|
"""Update the displayed terminal size"""
|
||||||
self.sizetext = "%sx%s" % (width, height)
|
self.sizetext = "%sx%s" % (width, height)
|
||||||
|
|
Loading…
Reference in New Issue