From 594ee479125d89e01bc4eae958decd775d5c018d Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 8 Jan 2010 23:51:45 +0000 Subject: [PATCH] Complete the Terminal Command profile tab. Teach the colour scheme picker how to exist in the config and how to be controlled by the prefs UI --- data/preferences.glade | 119 +++++++++++++---------------------- terminatorlib/config.py | 1 + terminatorlib/prefseditor.py | 116 ++++++++++++++++++++++++++++++++++ 3 files changed, 162 insertions(+), 74 deletions(-) diff --git a/data/preferences.glade b/data/preferences.glade index 20be3ccd..0e862b32 100644 --- a/data/preferences.glade +++ b/data/preferences.glade @@ -109,6 +109,35 @@ + + + + + + + + Black on light yellow + + + Black on white + + + Grey on black + + + Green on black + + + White on black + + + Orange on black + + + Custom + + + 5 normal @@ -625,76 +654,12 @@ - + True - 12 - vertical - 18 - - - True - vertical - 6 - - - True - 0 - <b>Title</b> - True - - - False - False - 0 - - - - - True - 12 - - - True - 12 - - - True - 0 - Initial _title: - True - center - title-entry - - - False - False - 0 - - - - - True - True - - - - 1 - - - - - - - False - 1 - - - - - False - 0 - - + 6 + 6 + 6 + 6 True @@ -867,10 +832,6 @@ - - False - 1 - @@ -880,7 +841,7 @@ True - Title and Command + Terminal Command True center @@ -948,6 +909,7 @@ False True True + 2 @@ -1050,6 +1012,15 @@ True + ColourSchemeListStore + 2 + + + + + 0 + + 1 diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 7efc8f3d..faaba1a6 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -137,6 +137,7 @@ DEFAULTS = { 'background_image' : '', 'backspace_binding' : 'ascii-del', 'delete_binding' : 'delete-sequence', + 'color_scheme' : 'grey_on_black', 'cursor_blink' : True, 'cursor_shape' : 'block', 'cursor_color' : '', diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index b949b69e..282958fa 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -10,6 +10,14 @@ from version import APP_NAME, APP_VERSION from translation import _ class PrefsEditor: + colorschemevalues = {'black_on_yellow': 0, + 'black_on_white': 1, + 'grey_on_black': 2, + 'green_on_black': 3, + 'white_on_black': 4, + 'orange_on_black': 5, + 'custom': 6} + data = {'titlebars': ['Show titlebars', 'This places a bar above each terminal which displays its title.'], 'zoomedtitlebar': ['Show titlebar when zoomed', 'This places an informative bar above a zoomed terminal to indicate there are hidden terminals.'], 'allow_bold': ['Allow bold text', 'Controls whether or not the terminals will honour requests for bold text'], @@ -182,6 +190,54 @@ class PrefsEditor: widget = guiget('word-chars-entry') widget.set_text(self.config['word_chars']) + ## Teminal Command tab + # Login shell + widget = guiget('login-shell-checkbutton') + widget.set_active(self.config['login_shell']) + # Login records + widget = guiget('update-records-checkbutton') + widget.set_active(self.config['update_records']) + # Use Custom command + widget = guiget('use-custom-command-checkbutton') + widget.set_active(self.config['use_custom_command']) + # Custom Command + widget = guiget('custom-command-entry') + widget.set_text(self.config['custom_command']) + # Exit action + widget = guiget('exit-action-combobox') + if self.config['exit_action'] == 'restart': + widget.set_active(1) + elif self.config['exit_action'] == 'hold': + widget.set_active(2) + else: + # Default is to close the terminal + widget.set_active(0) + + ## Colors tab + # Use system colors + widget = guiget('use-theme-colors-checkbutton') + widget.set_active(self.config['use_theme_colors']) + # Colorscheme + widget = guiget('color-scheme-combobox') + scheme = self.config['color_scheme'] + if scheme not in self.colorschemevalues: + scheme = 'grey_on_black' + widget.set_active(self.colorschemevalues[scheme]) + # Foreground color + widget = guiget('foreground-colorpicker') + widget.set_color(gtk.gdk.Color(self.config['foreground_color'])) + if scheme == 'custom': + widget.set_sensitive(True) + else: + widget.set_sensitive(False) + # Background color + widget = guiget('background-colorpicker') + widget.set_color(gtk.gdk.Color(self.config['background_color'])) + if scheme == 'custom': + widget.set_sensitive(True) + else: + widget.set_sensitive(False) + def on_profile_selection_changed(self, selection): """A different profile was selected""" (listmodel, rowiter) = selection.get_selected() @@ -202,6 +258,66 @@ class PrefsEditor: iter = model.get_iter(path) model.set_value(iter, 0, newtext) + def on_color_scheme_combobox_changed(self, widget): + """Update the fore/background colour pickers""" + value = None + guiget = self.builder.get_object + active = widget.get_active() + for key in self.colorschemevalues.keys(): + if self.colorschemevalues[key] == active: + value = key + + fore = guiget('foreground-colorpicker') + back = guiget('background-colorpicker') + if value == 'custom': + fore.set_sensitive(True) + back.set_sensitive(True) + else: + fore.set_sensitive(False) + back.set_sensitive(False) + + forecol = None + backcol = None + if value == 'grey_on_black': + forecol = '#AAAAAA' + backcol = '#000000' + elif value == 'black_on_yellow': + forecol = '#000000' + backcol = '#FFFFDD' + elif value == 'black_on_white': + forecol = '#000000' + backcol = '#FFFFFF' + elif value == 'white_on_black': + forecol = '#FFFFFF' + backcol = '#000000' + elif value == 'green_on_black': + forecol = '#00FF00' + backcol = '#000000' + elif value == 'orange_on_black': + forecol = '#E53C00' + backcol = '#000000' + + if forecol is not None: + fore.set_color(gtk.gdk.Color(forecol)) + if backcol is not None: + back.set_color(gtk.gdk.Color(backcol)) + + def on_use_theme_colors_checkbutton_toggled(self, widget): + """Update colour pickers""" + guiget = self.builder.get_object + active = widget.get_active() + + scheme = guiget('color-scheme-combobox') + fore = guiget('foreground-colorpicker') + back = guiget('background-colorpicker') + + if active: + for widget in [scheme, fore, back]: + widget.set_sensitive(False) + else: + scheme.set_sensitive(True) + self.on_color_scheme_combobox_changed(scheme) + def source_get_type (self, key): if config.DEFAULTS['global_config'].has_key (key): print "found %s in global_config" % key