Allow live previewing of profile color changes

This commit is contained in:
Aaron Faanes 2020-07-07 19:48:42 -05:00
parent 1aaf935a4c
commit a3ef71548e
2 changed files with 247 additions and 200 deletions

View File

@ -2312,7 +2312,7 @@
<property name="label" translatable="yes">_Text color:</property>
<property name="use_underline">True</property>
<property name="justify">center</property>
<property name="mnemonic_widget">foreground_colorpicker</property>
<property name="mnemonic_widget">foreground_colorbutton</property>
<property name="xalign">0</property>
</object>
<packing>
@ -2327,7 +2327,7 @@
<property name="label" translatable="yes">_Background color:</property>
<property name="use_underline">True</property>
<property name="justify">center</property>
<property name="mnemonic_widget">background_colorpicker</property>
<property name="mnemonic_widget">background_colorbutton</property>
<property name="xalign">0</property>
</object>
<packing>
@ -2360,15 +2360,14 @@
<object class="GtkBox" id="hbox18">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkColorButton" id="foreground_colorpicker">
<property name="use_action_appearance">False</property>
<object class="GtkDrawingArea" id="foreground_colorbutton">
<property name="height_request">24</property>
<property name="width_request">36</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="title" translatable="yes">Choose Terminal Text Color</property>
<property name="color">#000000000000</property>
<signal name="color-set" handler="on_foreground_colorpicker_color_set" swapped="no"/>
<signal name="draw" handler="on_foreground_colorbutton_draw" swapped="no"/>
<signal name="button-press-event" handler="on_foreground_colorbutton_click" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
@ -2389,15 +2388,14 @@
<object class="GtkBox" id="hbox19">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkColorButton" id="background_colorpicker">
<property name="use_action_appearance">False</property>
<object class="GtkDrawingArea" id="background_colorbutton">
<property name="height_request">24</property>
<property name="width_request">36</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="title" translatable="yes">Choose Terminal Background Color</property>
<property name="color">#000000000000</property>
<signal name="color-set" handler="on_background_colorpicker_color_set" swapped="no"/>
<signal name="draw" handler="on_background_colorbutton_draw" swapped="no"/>
<signal name="button-press-event" handler="on_background_colorbutton_click" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
@ -2520,13 +2518,11 @@
<property name="row_homogeneous">True</property>
<property name="column_homogeneous">True</property>
<child>
<object class="GtkColorButton" id="palette_colorpicker_1">
<property name="use_action_appearance">False</property>
<object class="GtkDrawingArea" id="palette_colorpicker_1">
<property name="height_request">24</property>
<property name="width_request">36</property>
<property name="visible">True</property>
<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" swapped="no"/>
<signal name="draw" handler="on_palette_colorpicker_draw" swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>
@ -2534,13 +2530,11 @@
</packing>
</child>
<child>
<object class="GtkColorButton" id="palette_colorpicker_2">
<property name="use_action_appearance">False</property>
<object class="GtkDrawingArea" id="palette_colorpicker_2">
<property name="height_request">24</property>
<property name="width_request">36</property>
<property name="visible">True</property>
<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" swapped="no"/>
<signal name="draw" handler="on_palette_colorpicker_draw" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
@ -2548,13 +2542,11 @@
</packing>
</child>
<child>
<object class="GtkColorButton" id="palette_colorpicker_3">
<property name="use_action_appearance">False</property>
<object class="GtkDrawingArea" id="palette_colorpicker_3">
<property name="height_request">24</property>
<property name="width_request">36</property>
<property name="visible">True</property>
<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" swapped="no"/>
<signal name="draw" handler="on_palette_colorpicker_draw" swapped="no"/>
</object>
<packing>
<property name="left_attach">2</property>
@ -2562,13 +2554,11 @@
</packing>
</child>
<child>
<object class="GtkColorButton" id="palette_colorpicker_4">
<property name="use_action_appearance">False</property>
<object class="GtkDrawingArea" id="palette_colorpicker_4">
<property name="height_request">24</property>
<property name="width_request">36</property>
<property name="visible">True</property>
<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" swapped="no"/>
<signal name="draw" handler="on_palette_colorpicker_draw" swapped="no"/>
</object>
<packing>
<property name="left_attach">3</property>
@ -2576,13 +2566,11 @@
</packing>
</child>
<child>
<object class="GtkColorButton" id="palette_colorpicker_5">
<property name="use_action_appearance">False</property>
<object class="GtkDrawingArea" id="palette_colorpicker_5">
<property name="height_request">24</property>
<property name="width_request">36</property>
<property name="visible">True</property>
<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" swapped="no"/>
<signal name="draw" handler="on_palette_colorpicker_draw" swapped="no"/>
</object>
<packing>
<property name="left_attach">4</property>
@ -2590,13 +2578,11 @@
</packing>
</child>
<child>
<object class="GtkColorButton" id="palette_colorpicker_6">
<property name="use_action_appearance">False</property>
<object class="GtkDrawingArea" id="palette_colorpicker_6">
<property name="height_request">24</property>
<property name="width_request">36</property>
<property name="visible">True</property>
<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" swapped="no"/>
<signal name="draw" handler="on_palette_colorpicker_draw" swapped="no"/>
</object>
<packing>
<property name="left_attach">5</property>
@ -2604,13 +2590,11 @@
</packing>
</child>
<child>
<object class="GtkColorButton" id="palette_colorpicker_7">
<property name="use_action_appearance">False</property>
<object class="GtkDrawingArea" id="palette_colorpicker_7">
<property name="height_request">24</property>
<property name="width_request">36</property>
<property name="visible">True</property>
<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" swapped="no"/>
<signal name="draw" handler="on_palette_colorpicker_draw" swapped="no"/>
</object>
<packing>
<property name="left_attach">6</property>
@ -2618,13 +2602,11 @@
</packing>
</child>
<child>
<object class="GtkColorButton" id="palette_colorpicker_8">
<property name="use_action_appearance">False</property>
<object class="GtkDrawingArea" id="palette_colorpicker_8">
<property name="height_request">24</property>
<property name="width_request">36</property>
<property name="visible">True</property>
<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" swapped="no"/>
<signal name="draw" handler="on_palette_colorpicker_draw" swapped="no"/>
</object>
<packing>
<property name="left_attach">7</property>
@ -2632,13 +2614,11 @@
</packing>
</child>
<child>
<object class="GtkColorButton" id="palette_colorpicker_9">
<property name="use_action_appearance">False</property>
<object class="GtkDrawingArea" id="palette_colorpicker_9">
<property name="height_request">24</property>
<property name="width_request">36</property>
<property name="visible">True</property>
<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" swapped="no"/>
<signal name="draw" handler="on_palette_colorpicker_draw" swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>
@ -2646,13 +2626,11 @@
</packing>
</child>
<child>
<object class="GtkColorButton" id="palette_colorpicker_10">
<property name="use_action_appearance">False</property>
<object class="GtkDrawingArea" id="palette_colorpicker_10">
<property name="height_request">24</property>
<property name="width_request">36</property>
<property name="visible">True</property>
<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" swapped="no"/>
<signal name="draw" handler="on_palette_colorpicker_draw" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
@ -2660,13 +2638,11 @@
</packing>
</child>
<child>
<object class="GtkColorButton" id="palette_colorpicker_11">
<property name="use_action_appearance">False</property>
<object class="GtkDrawingArea" id="palette_colorpicker_11">
<property name="height_request">24</property>
<property name="width_request">36</property>
<property name="visible">True</property>
<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" swapped="no"/>
<signal name="draw" handler="on_palette_colorpicker_draw" swapped="no"/>
</object>
<packing>
<property name="left_attach">2</property>
@ -2674,13 +2650,11 @@
</packing>
</child>
<child>
<object class="GtkColorButton" id="palette_colorpicker_12">
<property name="use_action_appearance">False</property>
<object class="GtkDrawingArea" id="palette_colorpicker_12">
<property name="height_request">24</property>
<property name="width_request">36</property>
<property name="visible">True</property>
<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" swapped="no"/>
<signal name="draw" handler="on_palette_colorpicker_draw" swapped="no"/>
</object>
<packing>
<property name="left_attach">3</property>
@ -2688,13 +2662,11 @@
</packing>
</child>
<child>
<object class="GtkColorButton" id="palette_colorpicker_13">
<property name="use_action_appearance">False</property>
<object class="GtkDrawingArea" id="palette_colorpicker_13">
<property name="height_request">24</property>
<property name="width_request">36</property>
<property name="visible">True</property>
<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" swapped="no"/>
<signal name="draw" handler="on_palette_colorpicker_draw" swapped="no"/>
</object>
<packing>
<property name="left_attach">4</property>
@ -2702,13 +2674,11 @@
</packing>
</child>
<child>
<object class="GtkColorButton" id="palette_colorpicker_14">
<property name="use_action_appearance">False</property>
<object class="GtkDrawingArea" id="palette_colorpicker_14">
<property name="height_request">24</property>
<property name="width_request">36</property>
<property name="visible">True</property>
<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" swapped="no"/>
<signal name="draw" handler="on_palette_colorpicker_draw" swapped="no"/>
</object>
<packing>
<property name="left_attach">5</property>
@ -2716,13 +2686,11 @@
</packing>
</child>
<child>
<object class="GtkColorButton" id="palette_colorpicker_15">
<property name="use_action_appearance">False</property>
<object class="GtkDrawingArea" id="palette_colorpicker_15">
<property name="height_request">24</property>
<property name="width_request">36</property>
<property name="visible">True</property>
<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" swapped="no"/>
<signal name="draw" handler="on_palette_colorpicker_draw" swapped="no"/>
</object>
<packing>
<property name="left_attach">6</property>
@ -2730,13 +2698,11 @@
</packing>
</child>
<child>
<object class="GtkColorButton" id="palette_colorpicker_16">
<property name="use_action_appearance">False</property>
<object class="GtkDrawingArea" id="palette_colorpicker_16">
<property name="height_request">24</property>
<property name="width_request">36</property>
<property name="visible">True</property>
<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" swapped="no"/>
<signal name="draw" handler="on_palette_colorpicker_draw" swapped="no"/>
</object>
<packing>
<property name="left_attach">7</property>
@ -4016,36 +3982,6 @@ Much of the behavior of Terminator is based on GNOME Terminal, and we are adding
<widget name="palette_combobox"/>
</widgets>
</object>
<object class="GtkSizeGroup" id="sizegroup3">
<property name="mode">both</property>
<widgets>
<widget name="title_transmit_fg_color"/>
<widget name="title_inactive_fg_color"/>
<widget name="title_receive_fg_color"/>
<widget name="title_transmit_bg_color"/>
<widget name="title_inactive_bg_color"/>
<widget name="title_receive_bg_color"/>
<widget name="cursor_color"/>
<widget name="foreground_colorpicker"/>
<widget name="background_colorpicker"/>
<widget name="palette_colorpicker_1"/>
<widget name="palette_colorpicker_2"/>
<widget name="palette_colorpicker_3"/>
<widget name="palette_colorpicker_4"/>
<widget name="palette_colorpicker_5"/>
<widget name="palette_colorpicker_6"/>
<widget name="palette_colorpicker_7"/>
<widget name="palette_colorpicker_8"/>
<widget name="palette_colorpicker_9"/>
<widget name="palette_colorpicker_10"/>
<widget name="palette_colorpicker_11"/>
<widget name="palette_colorpicker_12"/>
<widget name="palette_colorpicker_13"/>
<widget name="palette_colorpicker_14"/>
<widget name="palette_colorpicker_15"/>
<widget name="palette_colorpicker_16"/>
</widgets>
</object>
<object class="GtkSizeGroup" id="sizegroup4">
<widgets>
<widget name="scrollbar_position_combobox"/>

View File

@ -19,11 +19,18 @@ from .terminator import Terminator
from .plugin import PluginRegistry
from .version import APP_NAME
def get_color_string(widcol):
return('#%02x%02x%02x' % (widcol.red>>8, widcol.green>>8, widcol.blue>>8))
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))
return get_color_string(widget.get_color())
def rgba2hex(widget):
return get_color_string(widget.get_rgba().to_color())
NUM_PALETTE_COLORS = 16
# FIXME: We need to check that we have represented all of Config() below
class PrefsEditor:
@ -553,15 +560,16 @@ class PrefsEditor:
scheme = 'custom'
# NOTE: The scheme is set in the GUI widget after the fore/back colours
# Foreground color
widget = guiget('foreground_colorpicker')
widget.set_color(Gdk.color_parse(self.config['foreground_color']))
widget = guiget('foreground_colorbutton')
widget.set_events(Gdk.EventMask.BUTTON_PRESS_MASK)
if scheme == 'custom':
widget.set_sensitive(True)
else:
widget.set_sensitive(False)
# Background color
widget = guiget('background_colorpicker')
widget.set_color(Gdk.color_parse(self.config['background_color']))
widget = guiget('background_colorbutton')
widget.set_events(Gdk.EventMask.BUTTON_PRESS_MASK)
if scheme == 'custom':
widget.set_sensitive(True)
else:
@ -582,10 +590,13 @@ class PrefsEditor:
palette = 'custom'
# NOTE: The palette selector is set after the colour pickers
# Palette colour pickers
colourpalette = self.config['palette'].split(':')
for i in range(1, 17):
widget = guiget('palette_colorpicker_%d' % i)
widget.set_color(Gdk.color_parse(colourpalette[i - 1]))
for palette_id in range(0, NUM_PALETTE_COLORS):
widget = self.get_palette_widget(palette_id)
widget.set_events(Gdk.EventMask.BUTTON_PRESS_MASK)
def on_palette_click(event, data, widget=widget):
self.edit_palette_button(widget)
widget.connect('button-press-event', on_palette_click)
self.load_palette()
# Now set the palette selector widget
widget = guiget('palette_combobox')
widget.set_active(self.palettevalues[palette])
@ -918,34 +929,28 @@ class PrefsEditor:
def on_palette_combobox_changed(self, widget):
"""Palette selector changed"""
value = None
guiget = self.builder.get_object
active = widget.get_active()
for key in list(self.palettevalues.keys()):
if self.palettevalues[key] == active:
value = key
if value == 'custom':
sensitive = True
else:
sensitive = False
for num in range(1, 17):
picker = guiget('palette_colorpicker_%d' % num)
picker.set_sensitive(sensitive)
sensitive = value == 'custom'
for palette_id in range(0, NUM_PALETTE_COLORS):
self.get_palette_widget(palette_id).set_sensitive(sensitive)
if value in self.palettes:
palette = self.palettes[value]
palettebits = palette.split(':')
for num in range(1, 17):
for palette_id in range(0, NUM_PALETTE_COLORS):
# Update the visible elements
picker = guiget('palette_colorpicker_%d' % num)
picker.set_color(Gdk.color_parse(palettebits[num - 1]))
color = Gdk.color_parse(palettebits[palette_id])
self.load_palette_color(palette_id, color)
elif value == 'custom':
palettebits = []
for num in range(1, 17):
picker = guiget('palette_colorpicker_%d' % num)
palettebits.append(color2hex(picker))
for palette_id in range(0, NUM_PALETTE_COLORS):
# Save the custom values into the configuration.
palettebits.append(get_color_string(self.get_palette_color(palette_id)))
palette = ':'.join(palettebits)
else:
err('Unknown palette value: %s' % value)
@ -954,32 +959,148 @@ class PrefsEditor:
self.config['palette'] = palette
self.config.save()
def on_background_colorpicker_color_set(self, widget):
"""Background color changed"""
self.config['background_color'] = color2hex(widget)
self.config.save()
def on_foreground_colorbutton_draw(self, widget, cr):
width = widget.get_allocated_width()
height = widget.get_allocated_height()
col = Gdk.color_parse(self.config['foreground_color'])
cr.rectangle(0, 0, width, height)
cr.set_source_rgba(0.7, 0.7, 0.7, 1)
cr.fill()
cr.rectangle(1, 1, width-2, height-2)
cr.set_source_rgba(col.red_float, col.green_float, col.blue_float)
cr.fill()
def on_foreground_colorpicker_color_set(self, widget):
def on_foreground_colorbutton_click(self, event, data):
dialog = Gtk.ColorChooserDialog("Choose Terminal Text Color")
fg = self.config['foreground_color']
dialog.set_rgba(Gdk.RGBA.from_color(Gdk.color_parse(self.config['foreground_color'])))
dialog.connect('notify::rgba', self.on_foreground_colorpicker_color_change)
res = dialog.run()
if res != Gtk.ResponseType.OK:
self.config['foreground_color'] = fg
self.config.save()
terminator = Terminator()
terminator.reconfigure()
dialog.destroy()
def on_foreground_colorpicker_color_change(self, widget, color):
"""Foreground color changed"""
self.config['foreground_color'] = color2hex(widget)
self.config['foreground_color'] = rgba2hex(widget)
self.config.save()
terminator = Terminator()
terminator.reconfigure()
def on_palette_colorpicker_color_set(self, widget):
"""A palette colour changed"""
palette = None
palettebits = []
def on_background_colorbutton_draw(self, widget, cr):
width = widget.get_allocated_width()
height = widget.get_allocated_height()
col = Gdk.color_parse(self.config['background_color'])
cr.rectangle(0, 0, width, height)
cr.set_source_rgba(0.7, 0.7, 0.7, 1)
cr.fill()
cr.rectangle(1, 1, width-2, height-2)
cr.set_source_rgba(col.red_float, col.green_float, col.blue_float)
cr.fill()
def on_background_colorbutton_click(self, event, data):
dialog = Gtk.ColorChooserDialog("Choose Terminal Background Color")
orig = self.config['background_color']
dialog.connect('notify::rgba', self.on_background_colorpicker_color_change)
dialog.set_rgba(Gdk.RGBA.from_color(Gdk.color_parse(orig)))
res = dialog.run()
if res != Gtk.ResponseType.OK:
self.config['background_color'] = orig
self.config.save()
terminator = Terminator()
terminator.reconfigure()
dialog.destroy()
def on_background_colorpicker_color_change(self, widget, color):
"""Background color changed"""
self.config['background_color'] = rgba2hex(widget)
self.config.save()
terminator = Terminator()
terminator.reconfigure()
def get_palette_widget(self, palette_id):
"""Returns the palette widget for the given palette ID."""
guiget = self.builder.get_object
return guiget('palette_colorpicker_%d' % (palette_id + 1))
# FIXME: We do this at least once elsewhere. refactor!
for num in range(1, 17):
picker = guiget('palette_colorpicker_%d' % num)
value = color2hex(picker)
palettebits.append(value)
palette = ':'.join(palettebits)
def get_palette_id(self, widget):
"""Returns the palette ID for the given palette widget."""
for palette_id in range(0, NUM_PALETTE_COLORS):
if widget == self.get_palette_widget(palette_id):
return palette_id
return None
self.config['palette'] = palette
def get_palette_color(self, palette_id):
"""Returns the configured Gdk color for the given palette ID."""
if self.config['palette'] in self.palettes:
colourpalette = self.palettes[self.config['palette']]
else:
colourpalette = self.config['palette'].split(':')
return Gdk.color_parse(colourpalette[palette_id])
def on_palette_colorpicker_draw(self, widget, cr):
width = widget.get_allocated_width()
height = widget.get_allocated_height()
cr.rectangle(0, 0, width, height)
cr.set_source_rgba(0.7, 0.7, 0.7, 1)
cr.fill()
cr.rectangle(1, 1, width-2, height-2)
col = self.get_palette_color(self.get_palette_id(widget))
cr.set_source_rgba(col.red_float, col.green_float, col.blue_float)
cr.fill()
def load_palette_color(self, palette_id, color):
"""Given a palette ID and a Gdk color, load that color into the
specified widget."""
widget = self.get_palette_widget(palette_id)
widget.queue_draw()
def replace_palette_color(self, palette_id, color):
"""Replace the configured palette color for the given palette ID
with the given color."""
palettebits = self.config['palette'].split(':')
palettebits[palette_id] = get_color_string(color)
self.config['palette'] = ':'.join(palettebits)
self.config.save()
def load_palette(self):
"""Load the palette from the configuration into the color buttons."""
colourpalette = self.config['palette'].split(':')
for palette_id in range(0, NUM_PALETTE_COLORS):
color = Gdk.color_parse(colourpalette[palette_id])
self.load_palette_color(palette_id, color)
def edit_palette_button(self, widget):
"""When the palette colorbutton is clicked, open a dialog to
configure a custom color."""
terminator = Terminator()
palette_id = self.get_palette_id(widget)
orig = self.get_palette_color(palette_id)
try:
# Create the dialog to choose a custom color
dialog = Gtk.ColorChooserDialog("Choose Palette Color")
dialog.set_rgba(Gdk.RGBA.from_color(orig))
def on_color_set(_, color):
# The color is set, so save the palette config and refresh Terminator
self.replace_palette_color(palette_id, dialog.get_rgba().to_color())
terminator.reconfigure()
dialog.connect('notify::rgba', on_color_set)
# Show the dialog
res = dialog.run()
if res != Gtk.ResponseType.OK:
# User cancelled the color change, so reset to the original.
self.replace_palette_color(palette_id, orig)
terminator.reconfigure()
finally:
if dialog:
dialog.destroy()
def on_exit_action_combobox_changed(self, widget):
"""Exit action changed"""
selected = widget.get_active()
@ -1496,8 +1617,8 @@ class PrefsEditor:
if self.colorschemevalues[key] == active:
value = key
fore = guiget('foreground_colorpicker')
back = guiget('background_colorpicker')
fore = guiget('foreground_colorbutton')
back = guiget('background_colorbutton')
if value == 'custom':
fore.set_sensitive(True)
back.set_sensitive(True)
@ -1510,18 +1631,8 @@ class PrefsEditor:
if value in self.colourschemes:
forecol = self.colourschemes[value][0]
backcol = self.colourschemes[value][1]
elif value == 'custom':
forecol = color2hex(fore)
backcol = color2hex(back)
else:
err('Unknown colourscheme value: %s' % value)
return
fore.set_color(Gdk.color_parse(forecol))
back.set_color(Gdk.color_parse(backcol))
self.config['foreground_color'] = forecol
self.config['background_color'] = backcol
self.config['foreground_color'] = forecol
self.config['background_color'] = backcol
self.config.save()
def on_use_theme_colors_checkbutton_toggled(self, widget):
@ -1530,8 +1641,8 @@ class PrefsEditor:
active = widget.get_active()
scheme = guiget('color_scheme_combobox')
fore = guiget('foreground_colorpicker')
back = guiget('background_colorpicker')
fore = guiget('foreground_colorbutton')
back = guiget('background_colorbutton')
if active:
for widget in [scheme, fore, back]: