From 86216970f40adf7ed9c682217a00b275714dc293 Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Thu, 3 Dec 2015 15:36:39 +0100 Subject: [PATCH] Added radio options to the Cursor colour to make it easier to go back to the XOR'd foreground colour --- terminatorlib/config.py | 3 +- terminatorlib/preferences.glade | 60 +++++++++++++++++++++++++++++---- terminatorlib/prefseditor.py | 41 +++++++++++++++++++--- terminatorlib/terminal.py | 2 +- 4 files changed, 92 insertions(+), 14 deletions(-) diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 8c794f32..fc2603f1 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -215,7 +215,8 @@ DEFAULTS = { 'color_scheme' : 'grey_on_black', 'cursor_blink' : True, 'cursor_shape' : 'block', - 'cursor_color' : '#aaaaaa', + 'cursor_color' : '', + 'cursor_color_fg' : True, 'emulation' : 'xterm', 'term' : 'xterm-256color', 'colorterm' : 'gnome-terminal', diff --git a/terminatorlib/preferences.glade b/terminatorlib/preferences.glade index 021c2920..62650cf3 100644 --- a/terminatorlib/preferences.glade +++ b/terminatorlib/preferences.glade @@ -1784,24 +1784,70 @@ True False + 6 - + + Foreground True True - True + False False - 0 - #000000000000 - + True + True + False - False + True 0 - + + True + False + + + True + True + False + False + True + True + cursor_color_foreground_radiobutton + + + + False + True + 0 + + + + + True + True + True + False + 0 + #000000000000 + + + + False + False + 1 + + + + + + + + True + True + 1 + diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index 3b353092..72c2f216 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -448,13 +448,24 @@ class PrefsEditor: # Cursor blink widget = guiget('cursor_blink') widget.set_active(self.config['cursor_blink']) - # Cursor colour + # 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']) try: - widget.set_color(gtk.gdk.Color(self.config['cursor_color'])) - except ValueError: - self.config['cursor_color'] = "#FFFFFF" - widget.set_color(gtk.gdk.Color(self.config['cursor_color'])) + widget.set_color(gtk.gdk.Color(self.config['cursor_color'])) + except (ValueError, TypeError): + try: + self.config['cursor_color'] = self.config['foreground_color'] + widget.set_color(gtk.gdk.Color(self.config['cursor_color'])) + except ValueError: + self.config['cursor_color'] = "#FFFFFF" + widget.set_color(gtk.gdk.Color(self.config['cursor_color'])) ## Command tab # Login shell @@ -961,6 +972,26 @@ class PrefsEditor: self.config['custom_command'] = widget.get_text() self.config.save() + def on_cursor_color_type_toggled(self, widget): + 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(gtk.gdk.color_parse(self.config['cursor_color'])) + except (ValueError, TypeError): + try: + self.config['cursor_color'] = self.config['foreground_color'] + colorwidget.set_color(gtk.gdk.color_parse(self.config['cursor_color'])) + except ValueError: + self.config['cursor_color'] = "#FFFFFF" + colorwidget.set_color(gtk.gdk.color_parse(self.config['cursor_color'])) + self.config.save() + def on_cursor_color_color_set(self, widget): """Cursor colour changed""" self.config['cursor_color'] = color2hex(widget) diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 6dfbd6a2..46128706 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -799,7 +799,7 @@ class Terminal(gtk.VBox): def set_cursor_color(self): """Set the cursor color appropriately""" - if self.config['cursor_color'] == self.config['foreground_color']: + if self.config['cursor_color_fg']: try: self.vte.set_color_cursor(None) except TypeError: