From 4f6235bc5e5172cafc72bbce4e6412ab570838b4 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 13 Apr 2010 23:17:52 +0100 Subject: [PATCH] Thanks to some #pygtk folks we now have a way out of the ridiculous 16bit colour values that Gtk+ gives us from the ColorPicker widget. Now we get the 8bit values that everyone is used to --- doc/terminator_config.5 | 2 +- terminatorlib/config.py | 25 +++++++------ terminatorlib/prefseditor.py | 68 +++++++++++++++++++----------------- 3 files changed, 48 insertions(+), 47 deletions(-) diff --git a/doc/terminator_config.5 b/doc/terminator_config.5 index adfac4dc..1aa32603 100644 --- a/doc/terminator_config.5 +++ b/doc/terminator_config.5 @@ -400,7 +400,7 @@ Default value: \fBclose\fR .B palette Terminals have a 16-colour palette that applications inside the terminal can use. This is that palette, in the form of a colon-separated list of colour names. Colour names should be in hex format e.g. "#FF00FF". .NA -Default value: \fB'#2E2E34343636:#CCCC00000000:#4E4E9A9A0606:#C4C4A0A00000:#34346565A4A4:#757550507B7B:#060698209A9A:#D3D3D7D7CFCF:#555557575353:#EFEF29292929:#8A8AE2E23434:#FCFCE9E94F4F:#72729F9FCFCF:#ADAD7F7FA8A8:#3434E2E2E2E2:#EEEEEEEEECEC'\fR +Default value: \fB'#2E3436:#CC0000:#4E9A06:#C4A000:#3465A4:#75507B:#06989A:#D3D7CF:#555753:#EF2929:#8AE234:#FCE94F:#729FCF:#AD7FA8:#34E2E2:#EEEEEC'\fR .AD .TP .B word_chars diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 41132a60..e53ff766 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -86,12 +86,12 @@ DEFAULTS = { 'hide_tabbar' : False, 'scroll_tabbar' : False, 'try_posix_regexp' : platform.system() != 'Linux', - 'title_transmit_fg_color' : '#ffffffffffff', - 'title_transmit_bg_color' : '#c8c800000303', - 'title_receive_fg_color' : '#ffffffffffff', - 'title_receive_bg_color' : '#00007676c9c9', - 'title_inactive_fg_color' : '#000000000000', - 'title_inactive_bg_color' : '#c0c0bebebfbf', + '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': { @@ -153,7 +153,7 @@ DEFAULTS = { 'visible_bell' : False, 'urgent_bell' : False, 'icon_bell' : True, - 'background_color' : '#000000000000', + 'background_color' : '#000000', 'background_darkness' : 0.5, 'background_type' : 'solid', 'background_image' : None, @@ -162,10 +162,10 @@ DEFAULTS = { 'color_scheme' : 'grey_on_black', 'cursor_blink' : True, 'cursor_shape' : 'block', - 'cursor_color' : '#aaaaaaaaaaaa', + 'cursor_color' : '#aaaaaa', 'emulation' : 'xterm', 'font' : 'Mono 10', - 'foreground_color' : '#aaaaaaaaaaaa', + 'foreground_color' : '#aaaaaa', 'show_titlebar' : True, 'scrollbar_position' : "right", 'scroll_background' : True, @@ -174,10 +174,9 @@ DEFAULTS = { 'scrollback_lines' : 500, 'scrollback_infinite' : False, 'exit_action' : 'close', - 'palette' : '#2E2E34343636:#CCCC00000000:\ -#4E4E9A9A0606:#C4C4A0A00000:#34346565A4A4:#757550507B7B:#060698209A9A:\ -#D3D3D7D7CFCF:#555557575353:#EFEF29292929:#8A8AE2E23434:#FCFCE9E94F4F:\ -#72729F9FCFCF:#ADAD7F7FA8A8:#3434E2E2E2E2:#EEEEEEEEECEC', + 'palette' : '#2e3436:#cc0000:#4e9a06:#c4a000:\ +#3465a4:#75507b:#06989a:#d3d7cf:#555753:#ef2929:#8ae234:#fce94f:\ +#729fcf:#ad7fa8:#34e2e2:#eeeeec', 'word_chars' : '-A-Za-z0-9,./?%&#:_', 'mouse_autohide' : True, 'update_records' : True, diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index 9df69fac..2698371b 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -16,6 +16,12 @@ from keybindings import Keybindings, KeymapError from translation import _ from terminator import Terminator +def color2hex(widget): + """Pull the colour values out of a Gtk ColorPicker widget and return them + as 8bit hex values, sinces its default behaviour is to give 16bit values""" + widcol = widget.get_color() + return('#%02x%02x%02x' % (widcol.red>>8, widcol.green>>8, widcol.blue>>8)) + # FIXME: We need to check that we have represented all of Config() below class PrefsEditor: """Class implementing the various parts of the preferences editor""" @@ -47,26 +53,21 @@ class PrefsEditor: 'rxvt': 3, 'ambience': 4, 'custom': 5} - palettes = {'tango': '#000000000000:#CCCC00000000:#4E4E9A9A0606:\ -#C4C4A0A00000:#34346565A4A4:#757550507B7B:#060698209A9A:#D3D3D7D7CFCF:\ -#555557575353:#EFEF29292929:#8A8AE2E23434:#FCFCE9E94F4F:#72729F9FCFCF:\ -#ADAD7F7FA8A8:#3434E2E2E2E2:#EEEEEEEEECEC', - 'linux': '#000000000000:#AAAA00000000:#0000AAAA0000:\ -#AAAA55550000:#00000000AAAA:#AAAA0000AAAA:#0000AAAAAAAA:#AAAAAAAAAAAA:\ -#555555555555:#FFFF55555555:#5555FFFF5555:#FFFFFFFF5555:#55555555FFFF:\ -#FFFF5555FFFF:#5555FFFFFFFF:#FFFFFFFFFFFF', - 'xterm': '#000000000000:#CDCB00000000:#0000CDCB0000:\ -#CDCBCDCB0000:#1E1A908FFFFF:#CDCB0000CDCB:#0000CDCBCDCB:#E5E2E5E2E5E2:\ -#4CCC4CCC4CCC:#FFFF00000000:#0000FFFF0000:#FFFFFFFF0000:#46458281B4AE:\ -#FFFF0000FFFF:#0000FFFFFFFF:#FFFFFFFFFFFF', - 'rxvt': '#000000000000:#CDCD00000000:#0000CDCD0000:\ -#CDCDCDCD0000:#00000000CDCD:#CDCD0000CDCD:#0000CDCDCDCD:#FAFAEBEBD7D7:\ -#404040404040:#FFFF00000000:#0000FFFF0000:#FFFFFFFF0000:#00000000FFFF:\ -#FFFF0000FFFF:#0000FFFFFFFF:#FFFFFFFFFFFF', - 'ambience': '#2E2E34343636:#CCCC00000000:#4E4E9A9A0606:\ -#C4C4A0A00000:#34346565A4A4:#757550507B7B:#060698209A9A:#D3D3D7D7CFCF:\ -#555557575353:#EFEF29292929:#8A8AE2E23434:#FCFCE9E94F4F:#72729F9FCFCF:\ -#ADAD7F7FA8A8:#3434E2E2E2E2:#EEEEEEEEECEC'} + palettes = {'tango': '#000000:#cc0000:#4e9a06:#c4a000:#3465a4:\ +#75507b:#06989a:#d3d7cf:#555753:#ef2929:#8ae234:#fce94f:#729fcf:\ +#ad7fa8:#34e2e2:#eeeeec', + 'linux': '#000000:#aa0000:#00aa00:#aa5500:#0000aa:\ +#aa00aa:#00aaaa:#aaaaaa:#555555:#ff5555:#55ff55:#ffff55:#5555ff:\ +#ff55ff:#55ffff:#ffffff', + 'xterm': '#000000:#cd0000:#00cd00:#cdcd00:#1e90ff:\ +#cd00cd:#00cdcd:#e5e5e5:#4c4c4c:#ff0000:#00ff00:#ffff00:#4682b4:\ +#ff00ff:#00ffff:#ffffff', + 'rxvt': '#000000:#cd0000:#00cd00:#cdcd00:#0000cd:\ +#cd00cd:#00cdcd:#faebd7:#404040:#ff0000:#00ff00:#ffff00:#0000ff:\ +#ff00ff:#00ffff:#ffffff', + 'ambience': '#2e3436:#cc0000:#4e9a06:#c4a000:\ +#3465a4:#75507b:#06989a:#d3d7cf:#555753:#ef2929:#8ae234:#fce94f:\ +#729fcf:#ad7fa8:#34e2e2:#eeeeec'} keybindingnames = { 'zoom_in' : 'Increase font size', 'zoom_out' : 'Decrease font size', 'zoom_normal' : 'Restore original font size', @@ -644,7 +645,7 @@ class PrefsEditor: palettebits = [] for num in xrange(1, 17): picker = guiget('palette_colorpicker_%d' % num) - palettebits.append(picker.get_color().to_string()) + palettebits.append(color2hex(picker)) palette = ':'.join(palettebits) else: err('Unknown palette value: %s' % value) @@ -655,12 +656,12 @@ class PrefsEditor: def on_background_colorpicker_color_set(self, widget): """Background color changed""" - self.config['background_color'] = widget.get_color().to_string() + self.config['background_color'] = color2hex(widget) self.config.save() def on_foreground_colorpicker_color_set(self, widget): """Foreground color changed""" - self.config['foreground_color'] = widget.get_color().to_string() + self.config['foreground_color'] = color2hex(widget) self.config.save() def on_palette_colorpicker_color_set(self, widget): @@ -672,7 +673,8 @@ class PrefsEditor: # FIXME: We do this at least once elsewhere. refactor! for num in xrange(1, 17): picker = guiget('palette_colorpicker_%d' % num) - palettebits.append(picker.get_color().to_string()) + value = color2hex(picker) + palettebits.append(value) palette = ':'.join(palettebits) self.config['palette'] = palette @@ -697,7 +699,7 @@ class PrefsEditor: def on_cursor_color_color_set(self, widget): """Cursor colour changed""" - self.config['cursor_color'] = widget.get_color().to_string() + self.config['cursor_color'] = color2hex(widget) self.config.save() def on_cursor_shape_combobox_changed(self, widget): @@ -724,32 +726,32 @@ class PrefsEditor: def on_title_receive_bg_color_color_set(self, widget): """Title receive background colour changed""" - self.config['title_receive_bg_color'] = widget.get_color().to_string() + self.config['title_receive_bg_color'] = color2hex(widget) self.config.save() def on_title_receive_fg_color_color_set(self, widget): """Title receive foreground colour changed""" - self.config['title_receive_fg_color'] = widget.get_color().to_string() + self.config['title_receive_fg_color'] = color2hex(widget) self.config.save() def on_title_inactive_bg_color_color_set(self, widget): """Title inactive background colour changed""" - self.config['title_inactive_bg_color'] = widget.get_color().to_string() + self.config['title_inactive_bg_color'] = color2hex(widget) self.config.save() def on_title_transmit_bg_color_color_set(self, widget): """Title transmit backgruond colour changed""" - self.config['title_transmit_bg_color'] = widget.get_color().to_string() + self.config['title_transmit_bg_color'] = color2hex(widget) self.config.save() def on_title_inactive_fg_color_color_set(self, widget): """Title inactive foreground colour changed""" - self.config['title_inactive_fg_color'] = widget.get_color().to_string() + self.config['title_inactive_fg_color'] = color2hex(widget) self.config.save() def on_title_transmit_fg_color_color_set(self, widget): """Title transmit foreground colour changed""" - self.config['title_transmit_fg_color'] = widget.get_color().to_string() + self.config['title_transmit_fg_color'] = color2hex(widget) self.config.save() def on_handlesize_change_value(self, widget, scroll, value): @@ -1050,8 +1052,8 @@ class PrefsEditor: forecol = self.colourschemes[value][0] backcol = self.colourschemes[value][1] elif value == 'custom': - forecol = fore.get_color().to_string() - backcol = back.get_color().to_string() + forecol = color2hex(fore) + backcol = color2hex(back) else: err('Unknown colourscheme value: %s' % value) return