From 87283a927adfac30313554ff03836142b9a3cf89 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 6 Apr 2010 22:36:09 +0100 Subject: [PATCH] Hook up the palette options in Preferences --- terminatorlib/preferences.glade | 78 +++++++++++++++++++--------- terminatorlib/prefseditor.py | 92 +++++++++++++++++++++++++++++++-- 2 files changed, 141 insertions(+), 29 deletions(-) diff --git a/terminatorlib/preferences.glade b/terminatorlib/preferences.glade index a68eb149..74557e25 100644 --- a/terminatorlib/preferences.glade +++ b/terminatorlib/preferences.glade @@ -229,6 +229,32 @@ + + + + + + + + Tango + + + Linux + + + XTerm + + + Rxvt + + + Ambience + + + Custom + + + 5 normal @@ -236,7 +262,6 @@ True - vertical 2 @@ -249,7 +274,6 @@ True - vertical 18 @@ -453,7 +477,6 @@ True - vertical 6 @@ -676,7 +699,6 @@ True - vertical True @@ -762,7 +784,6 @@ True 12 - vertical 6 @@ -897,7 +918,6 @@ True - vertical 6 @@ -919,7 +939,6 @@ True - vertical True @@ -1033,7 +1052,6 @@ True - vertical 6 @@ -1055,7 +1073,6 @@ True - vertical Titlebar icon @@ -1156,7 +1173,6 @@ True - vertical 6 @@ -1178,11 +1194,9 @@ True - vertical True - vertical 6 @@ -1352,12 +1366,10 @@ True 12 - vertical 18 True - vertical 6 @@ -1547,7 +1559,6 @@ True - vertical 6 @@ -1602,6 +1613,7 @@ True True #000000000000 + @@ -1614,6 +1626,7 @@ True True #000000000000 + 1 @@ -1628,6 +1641,7 @@ True True #000000000000 + 2 @@ -1642,6 +1656,7 @@ True True #000000000000 + 3 @@ -1656,6 +1671,7 @@ True True #000000000000 + 4 @@ -1670,6 +1686,7 @@ True True #000000000000 + 5 @@ -1684,6 +1701,7 @@ True True #000000000000 + 7 @@ -1698,6 +1716,7 @@ True True #000000000000 + 1 @@ -1712,6 +1731,7 @@ True True #000000000000 + 1 @@ -1728,6 +1748,7 @@ True True #000000000000 + 3 @@ -1744,6 +1765,7 @@ True True #000000000000 + 2 @@ -1760,6 +1782,7 @@ True True #000000000000 + 4 @@ -1776,6 +1799,7 @@ True True #000000000000 + 7 @@ -1792,6 +1816,7 @@ True True #000000000000 + 5 @@ -1808,6 +1833,7 @@ True True #000000000000 + 6 @@ -1822,6 +1848,7 @@ True True #000000000000 + 6 @@ -1859,7 +1886,15 @@ True + PaletteListStore + 0 + + + + 0 + + 1 @@ -1921,7 +1956,6 @@ True 12 - vertical 6 @@ -1943,7 +1977,6 @@ True - vertical 6 @@ -1969,7 +2002,6 @@ True - vertical 6 @@ -2057,7 +2089,6 @@ True - vertical 6 @@ -2293,9 +2324,6 @@ GTK_FILL - - - Infinite Scrollback @@ -2314,6 +2342,9 @@ + + + 4 @@ -2334,7 +2365,6 @@ True 12 - vertical 12 @@ -2504,7 +2534,6 @@ True - vertical True @@ -2635,7 +2664,6 @@ True - vertical True diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index 400a7d6f..61b2dc4f 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -41,7 +41,32 @@ class PrefsEditor: 'green_on_black': ['#00FF00', '#000000'], 'orange_on_black': ['#E53C00', '#000000'], 'ambience': ['#FFFFFF', '#300A24']} - + palettevalues = {'tango': 0, + 'linux': 1, + 'xterm': 2, + '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'} keybindingnames = { 'zoom_in' : 'Increase font size', 'zoom_out' : 'Decrease font size', 'zoom_normal' : 'Restore original font size', @@ -325,6 +350,7 @@ class PrefsEditor: widget.set_active(self.config['use_theme_colors']) # Colorscheme widget = guiget('color_scheme_combobox') + scheme = None for ascheme in self.colourschemes: forecol = self.colourschemes[ascheme][0] backcol = self.colourschemes[ascheme][1] @@ -349,7 +375,16 @@ class PrefsEditor: widget.set_sensitive(True) else: widget.set_sensitive(False) - # Palette + # Palette scheme + widget = guiget('palette_combobox') + palette = None + for apalette in self.palettes: + if self.config['palette'] == self.palettes[apalette]: + palette = apalette + if palette not in self.palettevalues: + palette = 'tango' + widget.set_active(self.palettevalues[palette]) + # Palette colour pickers palette = self.config['palette'].split(':') for i in xrange(1, 17): widget = guiget('palette_colorpicker_%d' % i) @@ -573,8 +608,42 @@ class PrefsEditor: def on_palette_combobox_changed(self, widget): """Palette selector changed""" - # FIXME: This doesn't really exist yet. - pass + value = None + guiget = self.builder.get_object + active = widget.get_active() + + for key in self.palettevalues.keys(): + if self.palettevalues[key] == active: + value = key + + if value == 'custom': + sensitive = True + else: + sensitive = False + + for num in xrange(1, 17): + picker = guiget('palette_colorpicker_%d' % num) + picker.set_sensitive(sensitive) + + if value in self.palettes: + palette = self.palettes[value] + palettebits = palette.split(':') + for num in xrange(1, 17): + # Update the visible elements + picker = guiget('palette_colorpicker_%d' % num) + picker.set_color(gtk.gdk.Color(palettebits[num - 1])) + elif value == 'custom': + palettebits = [] + for num in xrange(1, 17): + picker = guiget('palette_colorpicker_%d' % num) + palettebits.append(picker.get_color().to_string()) + palette = ':'.join(palettebits) + else: + err('Unknown palette value: %s' % value) + return + + self.config['palette'] = palette + self.config.save() def on_background_colorpicker_color_set(self, widget): """Background color changed""" @@ -586,6 +655,21 @@ class PrefsEditor: self.config['foreground_color'] = widget.get_color().to_string() self.config.save() + def on_palette_colorpicker_color_set(self, widget): + """A palette colour changed""" + palette = None + palettebits = [] + guiget = self.builder.get_object + + # 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()) + palette = ':'.join(palettebits) + + self.config['palette'] = palette + self.config.save() + def on_exit_action_combobox_changed(self, widget): """Exit action changed""" selected = widget.get_active()