diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 7c24f59e..03d1686d 100644 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -215,8 +215,8 @@ DEFAULTS = { 'color_scheme' : 'grey_on_black', 'cursor_blink' : True, 'cursor_shape' : 'block', - 'cursor_fg_color' : '#000000', - 'cursor_bg_color' : '#ffffff', + 'cursor_fg_color' : '', + 'cursor_bg_color' : '', 'cursor_color_default' : True, 'term' : 'xterm-256color', 'colorterm' : 'truecolor', diff --git a/terminatorlib/preferences.glade b/terminatorlib/preferences.glade index d06a95fe..67b5ed59 100644 --- a/terminatorlib/preferences.glade +++ b/terminatorlib/preferences.glade @@ -1592,12 +1592,13 @@ - + Use default colors True True False True + 0 @@ -1640,6 +1641,7 @@ True True True + False @@ -1662,6 +1664,7 @@ True True True + False diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index c35c0d0f..5f195d63 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -498,24 +498,27 @@ class PrefsEditor: # Cursor blink widget = guiget('cursor_blink') widget.set_active(self.config['cursor_blink']) - # Cursor colour - Radio values - if self.config['cursor_color_fg']: - widget = guiget('cursor_color_foreground_radiobutton') - else: - widget = guiget('cursor_color_custom_radiobutton') - widget.set_active(True) - # Cursor colour - swatch - widget = guiget('cursor_color') - widget.set_sensitive(not self.config['cursor_color_fg']) + # Cursor use default colors + widget = guiget('cursor_color_default_checkbutton') + widget.set_active(self.config['cursor_color_default']) + # Cursor foreground + widget = guiget('cursor_fg_color') try: - widget.set_color(Gdk.color_parse(self.config['cursor_color'])) - except (ValueError, TypeError): + widget.set_color(Gdk.color_parse(self.config['cursor_fg_color'])) + except: try: - self.config['cursor_color'] = self.config['foreground_color'] - widget.set_color(Gdk.color_parse(self.config['cursor_color'])) - except ValueError: - self.config['cursor_color'] = "#FFFFFF" - widget.set_color(Gdk.color_parse(self.config['cursor_color'])) + widget.set_color(Gdk.color_parse(self.config['background_color'])) + except: + widget.set_color(Gdk.color_parse('#000000')) + # Cursor background + widget = guiget('cursor_bg_color') + try: + widget.set_color(Gdk.color_parse(self.config['cursor_bg_color'])) + except: + try: + widget.set_color(Gdk.color_parse(self.config['foreground_color'])) + except: + widget.set_color(Gdk.color_parse('#ffffff')) ## Command tab # Login shell @@ -1159,29 +1162,25 @@ class PrefsEditor: self.config['custom_command'] = widget.get_text() self.config.save() - def on_cursor_color_type_toggled(self, widget): + def on_cursor_color_default_checkbutton_toggled(self, checkbutton): + """Cursor: Use default colors changed""" guiget = self.builder.get_object - customwidget = guiget('cursor_color_custom_radiobutton') - colorwidget = guiget('cursor_color') - - colorwidget.set_sensitive(customwidget.get_active()) - self.config['cursor_color_fg'] = not customwidget.get_active() - - try: - colorwidget.set_color(Gdk.color_parse(self.config['cursor_color'])) - except (ValueError, TypeError): - try: - self.config['cursor_color'] = self.config['foreground_color'] - colorwidget.set_color(Gdk.color_parse(self.config['cursor_color'])) - except ValueError: - self.config['cursor_color'] = "#FFFFFF" - colorwidget.set_color(Gdk.color_parse(self.config['cursor_color'])) + value = checkbutton.get_active() + guiget('cursor_fg_color').set_sensitive(not value) + guiget('cursor_bg_color').set_sensitive(not value) + + self.config['cursor_color_default'] = value self.config.save() - def on_cursor_color_color_set(self, widget): - """Cursor colour changed""" - self.config['cursor_color'] = color2hex(widget) + def on_cursor_fg_color_color_set(self, widget): + """Cursor foreground color changed""" + self.config['cursor_fg_color'] = color2hex(widget) + self.config.save() + + def on_cursor_bg_color_color_set(self, widget): + """Cursor background color changed""" + self.config['cursor_bg_color'] = color2hex(widget) self.config.save() def on_cursor_shape_combobox_changed(self, widget):