Added radio options to the Cursor colour to make it easier to go back to the XOR'd foreground colour

This commit is contained in:
Stephen Boddy 2015-12-06 15:43:36 +01:00
commit e3323e23e3
5 changed files with 96 additions and 21 deletions

View File

@ -20,6 +20,8 @@ terminator GTK3:
* Added smart copy mode switch to prefs (Steve Boddy, LP#1223129) * Added smart copy mode switch to prefs (Steve Boddy, LP#1223129)
* Merge feature branch for tab/terminal title editing (Haim * Merge feature branch for tab/terminal title editing (Haim
Daniel LP#1417747) Daniel LP#1417747)
* Added radio options to the Cursor colour to make it easier to
go back to the XOR'd foreground colour (Steve Boddy, LP#1512317)
Bug fixes Bug fixes
* Fix a GI version warning for Notify library (Mattias Eriksson) * Fix a GI version warning for Notify library (Mattias Eriksson)

View File

@ -214,7 +214,8 @@ DEFAULTS = {
'color_scheme' : 'grey_on_black', 'color_scheme' : 'grey_on_black',
'cursor_blink' : True, 'cursor_blink' : True,
'cursor_shape' : 'block', 'cursor_shape' : 'block',
'cursor_color' : '#aaaaaa', 'cursor_color' : '',
'cursor_color_fg' : True,
'term' : 'xterm-256color', 'term' : 'xterm-256color',
'colorterm' : 'truecolor', 'colorterm' : 'truecolor',
'font' : 'Mono 10', 'font' : 'Mono 10',

View File

@ -1808,6 +1808,45 @@
<object class="GtkHBox" id="hbox1"> <object class="GtkHBox" id="hbox1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkRadioButton" id="cursor_color_foreground_radiobutton">
<property name="label" translatable="yes">Foreground</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_cursor_color_type_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkRadioButton" id="cursor_color_custom_radiobutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">cursor_color_foreground_radiobutton</property>
<signal name="toggled" handler="on_cursor_color_type_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child> <child>
<object class="GtkColorButton" id="cursor_color"> <object class="GtkColorButton" id="cursor_color">
<property name="visible">True</property> <property name="visible">True</property>
@ -1821,13 +1860,20 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="position">0</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>
</object> </object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="right_attach">2</property> <property name="right_attach">2</property>

View File

@ -450,10 +450,21 @@ class PrefsEditor:
# Cursor blink # Cursor blink
widget = guiget('cursor_blink') widget = guiget('cursor_blink')
widget.set_active(self.config['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 = guiget('cursor_color')
widget.set_sensitive(not self.config['cursor_color_fg'])
try: try:
widget.set_color(Gdk.color_parse(self.config['cursor_color'])) widget.set_color(Gdk.color_parse(self.config['cursor_color']))
except (ValueError, TypeError):
try:
self.config['cursor_color'] = self.config['foreground_color']
widget.set_color(Gdk.color_parse(self.config['cursor_color']))
except ValueError: except ValueError:
self.config['cursor_color'] = "#FFFFFF" self.config['cursor_color'] = "#FFFFFF"
widget.set_color(Gdk.color_parse(self.config['cursor_color'])) widget.set_color(Gdk.color_parse(self.config['cursor_color']))
@ -931,6 +942,26 @@ class PrefsEditor:
self.config['custom_command'] = widget.get_text() self.config['custom_command'] = widget.get_text()
self.config.save() 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(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']))
self.config.save()
def on_cursor_color_color_set(self, widget): def on_cursor_color_color_set(self, widget):
"""Cursor colour changed""" """Cursor colour changed"""
self.config['cursor_color'] = color2hex(widget) self.config['cursor_color'] = color2hex(widget)

View File

@ -780,14 +780,9 @@ class Terminal(Gtk.VBox):
def set_cursor_color(self): def set_cursor_color(self):
"""Set the cursor color appropriately""" """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) self.vte.set_color_cursor(None)
except TypeError: else:
# FIXME: I think this is only necessary because of
# https://bugzilla.gnome.org/show_bug.cgi?id=614910
pass
elif self.config['cursor_color'] != '':
cursor_color = Gdk.RGBA() cursor_color = Gdk.RGBA()
cursor_color.parse(self.config['cursor_color']) cursor_color.parse(self.config['cursor_color'])
self.vte.set_color_cursor(cursor_color) self.vte.set_color_cursor(cursor_color)