From abe9b245180b23b9c4f5c24052e98eb41903fc6d Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 18 Jan 2010 23:27:22 +0000 Subject: [PATCH] Implement titlebar colours --- terminatorlib/config.py | 6 ++++ terminatorlib/terminal.py | 2 +- terminatorlib/terminator.py | 2 +- terminatorlib/titlebar.py | 56 +++++++++++++++++++++++++++++++++++-- 4 files changed, 61 insertions(+), 5 deletions(-) diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 81328e7f..08718c9f 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -83,6 +83,12 @@ DEFAULTS = { 'hide_tabbar' : False, 'scroll_tabbar' : False, 'try_posix_regexp' : platform.system() != 'Linux', + 'title_transmit_fg_color' : '#ffffff', + 'title_transmit_bg_color' : '#c80003', + 'title_receive_fg_color' : '#ffffff', + 'title_receive_bg_color' : '#0076c9', + 'title_inactive_fg_color' : '#000000', + 'title_inactive_bg_color' : '#c0bebf', 'disabled_plugins' : ['TestPlugin', 'CustomCommandsMenu'], }, 'keybindings': { diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 534fd009..944bebe0 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -118,7 +118,7 @@ class Terminal(gtk.VBox): self.terminalbox = self.create_terminalbox() - self.titlebar = Titlebar() + self.titlebar = Titlebar(self) self.titlebar.connect_icon(self.on_group_button_press) self.titlebar.connect('edit-done', self.on_edit_done) self.connect('title-change', self.titlebar.set_terminal_title) diff --git a/terminatorlib/terminator.py b/terminatorlib/terminator.py index b0de2726..6c2955d6 100755 --- a/terminatorlib/terminator.py +++ b/terminatorlib/terminator.py @@ -218,6 +218,6 @@ class Terminator(Borg): def focus_changed(self, widget): """We just moved focus to a new terminal""" for terminal in self.terminals: - terminal.titlebar.update() + terminal.titlebar.update(widget) return # vim: set expandtab ts=4 sw=4: diff --git a/terminatorlib/titlebar.py b/terminatorlib/titlebar.py index 43f4d3b1..b1bab28f 100755 --- a/terminatorlib/titlebar.py +++ b/terminatorlib/titlebar.py @@ -17,6 +17,8 @@ class Titlebar(gtk.EventBox): """Class implementing the Titlebar widget""" terminator = None + terminal = None + config = None oldtitle = None termtext = None sizetext = None @@ -33,12 +35,14 @@ class Titlebar(gtk.EventBox): (gobject.TYPE_STRING,)), } - def __init__(self): + def __init__(self, terminal): """Class initialiser""" gtk.EventBox.__init__(self) self.__gobject_init__() self.terminator = Terminator() + self.terminal = terminal + self.config = self.terminal.config self.label = EditableLabel() self.label.connect('edit-done', self.on_edit_done) @@ -84,10 +88,56 @@ class Titlebar(gtk.EventBox): """Connect the supplied function to clicking on the group icon""" self.ebox.connect('button-release-event', func) - def update(self): + def update(self, other=None): """Update our contents""" self.label.set_text("%s %s" % (self.termtext, self.sizetext)) - # FIXME: Aren't we supposed to be setting a colour here too? + + if other: + term = self.terminal + terminator = self.terminator + if term != other and term.group and term.group == other.group: + if terminator.groupsend == terminator.groupsend_type['off']: + title_fg = self.config['title_inactive_fg_color'] + title_bg = self.config['title_inactive_bg_color'] + icon = '_receive_off' + else: + title_fg = self.config['title_receive_fg_color'] + title_bg = self.config['title_receive_bg_color'] + icon = '_receive_on' + group_fg = self.config['title_receive_fg_color'] + group_bg = self.config['title_receive_bg_color'] + elif term != other and not term.group or term.group != other.group: + if terminator.groupsend == terminator.groupsend_type['all']: + title_fg = self.config['title_receive_fg_color'] + title_bg = self.config['title_receive_bg_color'] + icon = '_receive_on' + else: + title_fg = self.config['title_inactive_fg_color'] + title_bg = self.config['title_inactive_bg_color'] + icon = '_receive_off' + group_fg = self.config['title_inactive_fg_color'] + group_bg = self.config['title_inactive_bg_color'] + else: + title_fg = self.config['title_transmit_fg_color'] + title_bg = self.config['title_transmit_bg_color'] + if terminator.groupsend == terminator.groupsend_type['all']: + icon = '_active_broadcast_all' + elif terminator.groupsend == terminator.groupsend_type['group']: + icon = '_active_broadcast_group' + else: + icon = '_active_broadcast_off' + group_fg = self.config['title_transmit_fg_color'] + group_bg = self.config['title_transmit_bg_color'] + + self.label.modify_fg(gtk.STATE_NORMAL, + gtk.gdk.color_parse(title_fg)) + self.grouplabel.modify_fg(gtk.STATE_NORMAL, + gtk.gdk.color_parse(group_fg)) + self.modify_bg(gtk.STATE_NORMAL, + gtk.gdk.color_parse(title_bg)) + self.ebox.modify_bg(gtk.STATE_NORMAL, + gtk.gdk.color_parse(group_bg)) + self.set_from_icon_name(icon, gtk.ICON_SIZE_MENU) def set_from_icon_name(self, name, size = gtk.ICON_SIZE_MENU): """Set an icon for the group label"""