Hook up the palette options in Preferences

This commit is contained in:
Chris Jones 2010-04-06 22:36:09 +01:00
parent fd8bc65654
commit 87283a927a
2 changed files with 141 additions and 29 deletions

View File

@ -229,6 +229,32 @@
<column type="gchararray"/>
</columns>
</object>
<object class="GtkListStore" id="PaletteListStore">
<columns>
<!-- column-name Palette -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Tango</col>
</row>
<row>
<col id="0" translatable="yes">Linux</col>
</row>
<row>
<col id="0" translatable="yes">XTerm</col>
</row>
<row>
<col id="0" translatable="yes">Rxvt</col>
</row>
<row>
<col id="0" translatable="yes">Ambience</col>
</row>
<row>
<col id="0" translatable="yes">Custom</col>
</row>
</data>
</object>
<object class="GtkDialog" id="prefswin">
<property name="border_width">5</property>
<property name="type_hint">normal</property>
@ -236,7 +262,6 @@
<child internal-child="vbox">
<object class="GtkVBox" id="dialog_vbox1">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkNotebook" id="notebook1">
@ -249,7 +274,6 @@
<child>
<object class="GtkVBox" id="vbox5">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">18</property>
<child>
<object class="GtkTable" id="global_config_table">
@ -453,7 +477,6 @@
<child>
<object class="GtkVBox" id="vbox7">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label15">
@ -676,7 +699,6 @@
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkTreeView" id="profilelist">
<property name="visible">True</property>
@ -762,7 +784,6 @@
<object class="GtkVBox" id="vbox3">
<property name="visible">True</property>
<property name="border_width">12</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkCheckButton" id="system_font_checkbutton">
@ -897,7 +918,6 @@
<child>
<object class="GtkVBox" id="vbox8">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label21">
@ -919,7 +939,6 @@
<child>
<object class="GtkVBox" id="vbox9">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkHBox" id="hbox4">
<property name="visible">True</property>
@ -1033,7 +1052,6 @@
<child>
<object class="GtkVBox" id="vbox10">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label23">
@ -1055,7 +1073,6 @@
<child>
<object class="GtkVBox" id="vbox11">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkCheckButton" id="icon_bell_checkbutton">
<property name="label" translatable="yes">Titlebar icon</property>
@ -1156,7 +1173,6 @@
<child>
<object class="GtkVBox" id="vbox80">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label36">
@ -1178,11 +1194,9 @@
<child>
<object class="GtkVBox" id="vbox81">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkVBox" id="vbox92">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkCheckButton" id="login_shell_checkbutton">
@ -1352,12 +1366,10 @@
<object class="GtkVBox" id="vbox90">
<property name="visible">True</property>
<property name="border_width">12</property>
<property name="orientation">vertical</property>
<property name="spacing">18</property>
<child>
<object class="GtkVBox" id="vbox82">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label39">
@ -1547,7 +1559,6 @@
<child>
<object class="GtkVBox" id="vbox83">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label42">
@ -1602,6 +1613,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="color">#000000000000</property>
<signal name="color_set" handler="on_palette_colorpicker_color_set"/>
</object>
<packing>
<property name="x_options"></property>
@ -1614,6 +1626,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="color">#000000000000</property>
<signal name="color_set" handler="on_palette_colorpicker_color_set"/>
</object>
<packing>
<property name="left_attach">1</property>
@ -1628,6 +1641,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="color">#000000000000</property>
<signal name="color_set" handler="on_palette_colorpicker_color_set"/>
</object>
<packing>
<property name="left_attach">2</property>
@ -1642,6 +1656,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="color">#000000000000</property>
<signal name="color_set" handler="on_palette_colorpicker_color_set"/>
</object>
<packing>
<property name="left_attach">3</property>
@ -1656,6 +1671,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="color">#000000000000</property>
<signal name="color_set" handler="on_palette_colorpicker_color_set"/>
</object>
<packing>
<property name="left_attach">4</property>
@ -1670,6 +1686,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="color">#000000000000</property>
<signal name="color_set" handler="on_palette_colorpicker_color_set"/>
</object>
<packing>
<property name="left_attach">5</property>
@ -1684,6 +1701,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="color">#000000000000</property>
<signal name="color_set" handler="on_palette_colorpicker_color_set"/>
</object>
<packing>
<property name="left_attach">7</property>
@ -1698,6 +1716,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="color">#000000000000</property>
<signal name="color_set" handler="on_palette_colorpicker_color_set"/>
</object>
<packing>
<property name="top_attach">1</property>
@ -1712,6 +1731,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="color">#000000000000</property>
<signal name="color_set" handler="on_palette_colorpicker_color_set"/>
</object>
<packing>
<property name="left_attach">1</property>
@ -1728,6 +1748,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="color">#000000000000</property>
<signal name="color_set" handler="on_palette_colorpicker_color_set"/>
</object>
<packing>
<property name="left_attach">3</property>
@ -1744,6 +1765,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="color">#000000000000</property>
<signal name="color_set" handler="on_palette_colorpicker_color_set"/>
</object>
<packing>
<property name="left_attach">2</property>
@ -1760,6 +1782,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="color">#000000000000</property>
<signal name="color_set" handler="on_palette_colorpicker_color_set"/>
</object>
<packing>
<property name="left_attach">4</property>
@ -1776,6 +1799,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="color">#000000000000</property>
<signal name="color_set" handler="on_palette_colorpicker_color_set"/>
</object>
<packing>
<property name="left_attach">7</property>
@ -1792,6 +1816,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="color">#000000000000</property>
<signal name="color_set" handler="on_palette_colorpicker_color_set"/>
</object>
<packing>
<property name="left_attach">5</property>
@ -1808,6 +1833,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="color">#000000000000</property>
<signal name="color_set" handler="on_palette_colorpicker_color_set"/>
</object>
<packing>
<property name="left_attach">6</property>
@ -1822,6 +1848,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="color">#000000000000</property>
<signal name="color_set" handler="on_palette_colorpicker_color_set"/>
</object>
<packing>
<property name="left_attach">6</property>
@ -1859,7 +1886,15 @@
<child>
<object class="GtkComboBox" id="palette_combobox">
<property name="visible">True</property>
<property name="model">PaletteListStore</property>
<property name="active">0</property>
<signal name="changed" handler="on_palette_combobox_changed"/>
<child>
<object class="GtkCellRendererText" id="cellrenderertext14"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left_attach">1</property>
@ -1921,7 +1956,6 @@
<object class="GtkVBox" id="vbox86">
<property name="visible">True</property>
<property name="border_width">12</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkRadioButton" id="solid_radiobutton">
@ -1943,7 +1977,6 @@
<child>
<object class="GtkVBox" id="vbox87">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkRadioButton" id="image_radiobutton">
@ -1969,7 +2002,6 @@
<child>
<object class="GtkVBox" id="vbox89">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkHBox" id="hbox2">
@ -2057,7 +2089,6 @@
<child>
<object class="GtkVBox" id="darken_background_vbox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="darken_background_scale_label">
@ -2293,9 +2324,6 @@
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<object class="GtkCheckButton" id="scrollback_infinite">
<property name="label" translatable="yes">Infinite Scrollback</property>
@ -2314,6 +2342,9 @@
<property name="y_options"></property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="position">4</property>
@ -2334,7 +2365,6 @@
<object class="GtkVBox" id="vbox4">
<property name="visible">True</property>
<property name="border_width">12</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="label51">
@ -2504,7 +2534,6 @@
<child>
<object class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkTreeView" id="layoutlist">
<property name="visible">True</property>
@ -2635,7 +2664,6 @@
<child>
<object class="GtkVBox" id="vbox6">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkAlignment" id="alignment3">
<property name="visible">True</property>

View File

@ -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()