Merge pull request #486 from Vulcalien/master
Cursor: make it possible to change foreground color (#467)
This commit is contained in:
commit
6904998a56
@ -215,8 +215,9 @@ DEFAULTS = {
|
||||
'color_scheme' : 'grey_on_black',
|
||||
'cursor_blink' : True,
|
||||
'cursor_shape' : 'block',
|
||||
'cursor_color' : '',
|
||||
'cursor_color_fg' : True,
|
||||
'cursor_fg_color' : '',
|
||||
'cursor_bg_color' : '',
|
||||
'cursor_color_default' : True,
|
||||
'term' : 'xterm-256color',
|
||||
'colorterm' : 'truecolor',
|
||||
'font' : 'Mono 10',
|
||||
@ -844,4 +845,3 @@ class ConfigBase(Borg):
|
||||
def set_layout(self, layout, tree):
|
||||
"""Set a layout"""
|
||||
self.layouts[layout] = tree
|
||||
|
||||
|
@ -1536,8 +1536,8 @@
|
||||
<property name="can-focus">False</property>
|
||||
<property name="left-padding">12</property>
|
||||
<child>
|
||||
<!-- n-columns=2 n-rows=3 -->
|
||||
<object class="GtkGrid" id="grid10">
|
||||
<!-- n-columns=2 n-rows=5 -->
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="row-spacing">6</property>
|
||||
@ -1574,18 +1574,6 @@
|
||||
<property name="top-attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label22">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Color:</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="cursor_blink">
|
||||
<property name="label" translatable="yes">Blink</property>
|
||||
@ -1599,26 +1587,61 @@
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">2</property>
|
||||
<property name="top-attach">4</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="hbox1">
|
||||
<object class="GtkCheckButton" id="cursor_color_default_checkbutton">
|
||||
<property name="label" translatable="yes">Use default colors</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">False</property>
|
||||
<property name="draw-indicator">True</property>
|
||||
<signal name="toggled" handler="on_cursor_color_default_checkbutton_toggled" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">1</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-left">12</property>
|
||||
<property name="label" translatable="yes">Foreground:</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-left">12</property>
|
||||
<property name="label" translatable="yes">Background:</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</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="use-action-appearance">False</property>
|
||||
<object class="GtkColorButton" id="cursor_fg_color">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw-indicator">True</property>
|
||||
<signal name="toggled" handler="on_cursor_color_type_toggled" swapped="no"/>
|
||||
<property name="receives-default">True</property>
|
||||
<signal name="color-set" handler="on_cursor_fg_color_color_set" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@ -1626,55 +1649,33 @@
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="hbox4">
|
||||
<object class="GtkColorButton" id="cursor_bg_color">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="cursor_color_custom_radiobutton">
|
||||
<property name="use-action-appearance">False</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">False</property>
|
||||
<property name="xalign">0.5</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>
|
||||
<object class="GtkColorButton" id="cursor_color">
|
||||
<property name="use-action-appearance">False</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="xalign">0</property>
|
||||
<signal name="color-set" handler="on_cursor_color_color_set" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<signal name="color-set" handler="on_cursor_bg_color_color_set" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">1</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
@ -2032,7 +2033,7 @@
|
||||
<object class="GtkLabel" id="foreground_colorpicker_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">_Text color:</property>
|
||||
<property name="label" translatable="yes">_Foreground:</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="justify">center</property>
|
||||
<property name="mnemonic-widget">foreground_colorbutton</property>
|
||||
@ -2047,7 +2048,7 @@
|
||||
<object class="GtkLabel" id="background_colorpicker_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">_Background color:</property>
|
||||
<property name="label" translatable="yes">_Background:</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="justify">center</property>
|
||||
<property name="mnemonic-widget">background_colorbutton</property>
|
||||
@ -2548,8 +2549,8 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw-indicator">True</property>
|
||||
<signal name="toggled" handler="on_background_type_toggled" swapped="no"/>
|
||||
@ -2567,8 +2568,8 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="draw-indicator">True</property>
|
||||
<property name="group">solid_radiobutton</property>
|
||||
<signal name="toggled" handler="on_background_type_toggled" swapped="no"/>
|
||||
@ -2585,7 +2586,7 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">False</property>
|
||||
<property name="active">True</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="draw-indicator">True</property>
|
||||
<property name="group">solid_radiobutton</property>
|
||||
</object>
|
||||
@ -3112,16 +3113,17 @@
|
||||
<property name="spacing">18</property>
|
||||
<child>
|
||||
<!-- n-columns=4 n-rows=3 -->
|
||||
<object class="GtkGrid" id="grid5">
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="row-spacing">6</property>
|
||||
<property name="column-spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label16">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Font color:</property>
|
||||
<property name="label" translatable="yes">Foreground:</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
@ -3264,7 +3266,7 @@
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
@ -3310,9 +3312,10 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box2">
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-left">12</property>
|
||||
<property name="spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="font_selector_label1">
|
||||
|
@ -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,30 @@ 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)
|
||||
|
||||
if not value:
|
||||
self.config['cursor_fg_color'] = color2hex(guiget('cursor_fg_color'))
|
||||
self.config['cursor_bg_color'] = color2hex(guiget('cursor_bg_color'))
|
||||
self.config.save()
|
||||
|
||||
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):
|
||||
|
@ -837,12 +837,24 @@ class Terminal(Gtk.VBox):
|
||||
|
||||
def set_cursor_color(self):
|
||||
"""Set the cursor color appropriately"""
|
||||
if self.config['cursor_color_fg']:
|
||||
if self.config['cursor_color_default']:
|
||||
self.vte.set_color_cursor(None)
|
||||
self.vte.set_color_cursor_foreground(None)
|
||||
else:
|
||||
cursor_color = Gdk.RGBA()
|
||||
cursor_color.parse(self.config['cursor_color'])
|
||||
self.vte.set_color_cursor(cursor_color)
|
||||
# foreground
|
||||
cursor_fg_color = Gdk.RGBA()
|
||||
if self.config['cursor_fg_color'] == '':
|
||||
cursor_fg_color.parse(self.config['background_color'])
|
||||
else:
|
||||
cursor_fg_color.parse(self.config['cursor_fg_color'])
|
||||
self.vte.set_color_cursor_foreground(cursor_fg_color)
|
||||
# background
|
||||
cursor_bg_color = Gdk.RGBA()
|
||||
if self.config['cursor_bg_color'] == '':
|
||||
cursor_bg_color.parse(self.config['foreground_color'])
|
||||
else:
|
||||
cursor_bg_color.parse(self.config['cursor_bg_color'])
|
||||
self.vte.set_color_cursor(cursor_bg_color)
|
||||
|
||||
def get_window_title(self):
|
||||
"""Return the window title"""
|
||||
|
Loading…
Reference in New Issue
Block a user