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',
|
'color_scheme' : 'grey_on_black',
|
||||||
'cursor_blink' : True,
|
'cursor_blink' : True,
|
||||||
'cursor_shape' : 'block',
|
'cursor_shape' : 'block',
|
||||||
'cursor_color' : '',
|
'cursor_fg_color' : '',
|
||||||
'cursor_color_fg' : True,
|
'cursor_bg_color' : '',
|
||||||
|
'cursor_color_default' : True,
|
||||||
'term' : 'xterm-256color',
|
'term' : 'xterm-256color',
|
||||||
'colorterm' : 'truecolor',
|
'colorterm' : 'truecolor',
|
||||||
'font' : 'Mono 10',
|
'font' : 'Mono 10',
|
||||||
|
@ -844,4 +845,3 @@ class ConfigBase(Borg):
|
||||||
def set_layout(self, layout, tree):
|
def set_layout(self, layout, tree):
|
||||||
"""Set a layout"""
|
"""Set a layout"""
|
||||||
self.layouts[layout] = tree
|
self.layouts[layout] = tree
|
||||||
|
|
||||||
|
|
|
@ -1536,8 +1536,8 @@
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="left-padding">12</property>
|
<property name="left-padding">12</property>
|
||||||
<child>
|
<child>
|
||||||
<!-- n-columns=2 n-rows=3 -->
|
<!-- n-columns=2 n-rows=5 -->
|
||||||
<object class="GtkGrid" id="grid10">
|
<object class="GtkGrid">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="row-spacing">6</property>
|
<property name="row-spacing">6</property>
|
||||||
|
@ -1574,18 +1574,6 @@
|
||||||
<property name="top-attach">0</property>
|
<property name="top-attach">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</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>
|
<child>
|
||||||
<object class="GtkCheckButton" id="cursor_blink">
|
<object class="GtkCheckButton" id="cursor_blink">
|
||||||
<property name="label" translatable="yes">Blink</property>
|
<property name="label" translatable="yes">Blink</property>
|
||||||
|
@ -1599,82 +1587,95 @@
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left-attach">0</property>
|
<property name="left-attach">0</property>
|
||||||
<property name="top-attach">2</property>
|
<property name="top-attach">4</property>
|
||||||
<property name="width">2</property>
|
<property name="width">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="hbox1">
|
<object class="GtkCheckButton" id="cursor_color_default_checkbutton">
|
||||||
<property name="visible">True</property>
|
<property name="label" translatable="yes">Use default colors</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>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="receives-default">False</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="draw-indicator">True</property>
|
||||||
<signal name="toggled" handler="on_cursor_color_type_toggled" swapped="no"/>
|
<signal name="toggled" handler="on_cursor_color_default_checkbutton_toggled" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="left-attach">0</property>
|
||||||
<property name="fill">True</property>
|
<property name="top-attach">1</property>
|
||||||
<property name="position">0</property>
|
<property name="width">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="hbox4">
|
<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="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkRadioButton" id="cursor_color_custom_radiobutton">
|
<object class="GtkColorButton" id="cursor_fg_color">
|
||||||
<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="visible">True</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="receives-default">True</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="halign">center</property>
|
<signal name="color-set" handler="on_cursor_fg_color_color_set" swapped="no"/>
|
||||||
<property name="xalign">0</property>
|
|
||||||
<signal name="color-set" handler="on_cursor_color_color_set" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="position">1</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left-attach">1</property>
|
<property name="left-attach">1</property>
|
||||||
<property name="top-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="GtkColorButton" id="cursor_bg_color">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<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">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">1</property>
|
||||||
|
<property name="top-attach">3</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
@ -2032,7 +2033,7 @@
|
||||||
<object class="GtkLabel" id="foreground_colorpicker_label">
|
<object class="GtkLabel" id="foreground_colorpicker_label">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</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="use-underline">True</property>
|
||||||
<property name="justify">center</property>
|
<property name="justify">center</property>
|
||||||
<property name="mnemonic-widget">foreground_colorbutton</property>
|
<property name="mnemonic-widget">foreground_colorbutton</property>
|
||||||
|
@ -2047,7 +2048,7 @@
|
||||||
<object class="GtkLabel" id="background_colorpicker_label">
|
<object class="GtkLabel" id="background_colorpicker_label">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</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="use-underline">True</property>
|
||||||
<property name="justify">center</property>
|
<property name="justify">center</property>
|
||||||
<property name="mnemonic-widget">background_colorbutton</property>
|
<property name="mnemonic-widget">background_colorbutton</property>
|
||||||
|
@ -2548,8 +2549,8 @@
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="receives-default">False</property>
|
<property name="receives-default">False</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
<property name="use-underline">True</property>
|
<property name="use-underline">True</property>
|
||||||
<property name="xalign">0.5</property>
|
|
||||||
<property name="active">True</property>
|
<property name="active">True</property>
|
||||||
<property name="draw-indicator">True</property>
|
<property name="draw-indicator">True</property>
|
||||||
<signal name="toggled" handler="on_background_type_toggled" swapped="no"/>
|
<signal name="toggled" handler="on_background_type_toggled" swapped="no"/>
|
||||||
|
@ -2567,8 +2568,8 @@
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="receives-default">False</property>
|
<property name="receives-default">False</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
<property name="use-underline">True</property>
|
<property name="use-underline">True</property>
|
||||||
<property name="xalign">0.5</property>
|
|
||||||
<property name="draw-indicator">True</property>
|
<property name="draw-indicator">True</property>
|
||||||
<property name="group">solid_radiobutton</property>
|
<property name="group">solid_radiobutton</property>
|
||||||
<signal name="toggled" handler="on_background_type_toggled" swapped="no"/>
|
<signal name="toggled" handler="on_background_type_toggled" swapped="no"/>
|
||||||
|
@ -2585,7 +2586,7 @@
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="receives-default">False</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="draw-indicator">True</property>
|
||||||
<property name="group">solid_radiobutton</property>
|
<property name="group">solid_radiobutton</property>
|
||||||
</object>
|
</object>
|
||||||
|
@ -3112,16 +3113,17 @@
|
||||||
<property name="spacing">18</property>
|
<property name="spacing">18</property>
|
||||||
<child>
|
<child>
|
||||||
<!-- n-columns=4 n-rows=3 -->
|
<!-- n-columns=4 n-rows=3 -->
|
||||||
<object class="GtkGrid" id="grid5">
|
<object class="GtkGrid">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
<property name="row-spacing">6</property>
|
<property name="row-spacing">6</property>
|
||||||
<property name="column-spacing">12</property>
|
<property name="column-spacing">12</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="label16">
|
<object class="GtkLabel" id="label16">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</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>
|
<property name="xalign">0</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
|
@ -3264,7 +3266,7 @@
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">False</property>
|
<property name="fill">True</property>
|
||||||
<property name="position">0</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
@ -3310,9 +3312,10 @@
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="box2">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
|
<property name="margin-left">12</property>
|
||||||
<property name="spacing">12</property>
|
<property name="spacing">12</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="font_selector_label1">
|
<object class="GtkLabel" id="font_selector_label1">
|
||||||
|
|
|
@ -498,24 +498,27 @@ 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 - Radio values
|
# Cursor use default colors
|
||||||
if self.config['cursor_color_fg']:
|
widget = guiget('cursor_color_default_checkbutton')
|
||||||
widget = guiget('cursor_color_foreground_radiobutton')
|
widget.set_active(self.config['cursor_color_default'])
|
||||||
else:
|
# Cursor foreground
|
||||||
widget = guiget('cursor_color_custom_radiobutton')
|
widget = guiget('cursor_fg_color')
|
||||||
widget.set_active(True)
|
|
||||||
# Cursor colour - swatch
|
|
||||||
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_fg_color']))
|
||||||
except (ValueError, TypeError):
|
except:
|
||||||
try:
|
try:
|
||||||
self.config['cursor_color'] = self.config['foreground_color']
|
widget.set_color(Gdk.color_parse(self.config['background_color']))
|
||||||
widget.set_color(Gdk.color_parse(self.config['cursor_color']))
|
except:
|
||||||
except ValueError:
|
widget.set_color(Gdk.color_parse('#000000'))
|
||||||
self.config['cursor_color'] = "#FFFFFF"
|
# Cursor background
|
||||||
widget.set_color(Gdk.color_parse(self.config['cursor_color']))
|
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
|
## Command tab
|
||||||
# Login shell
|
# Login shell
|
||||||
|
@ -1159,29 +1162,30 @@ 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):
|
def on_cursor_color_default_checkbutton_toggled(self, checkbutton):
|
||||||
|
"""Cursor: Use default colors changed"""
|
||||||
guiget = self.builder.get_object
|
guiget = self.builder.get_object
|
||||||
|
|
||||||
customwidget = guiget('cursor_color_custom_radiobutton')
|
value = checkbutton.get_active()
|
||||||
colorwidget = guiget('cursor_color')
|
guiget('cursor_fg_color').set_sensitive(not value)
|
||||||
|
guiget('cursor_bg_color').set_sensitive(not value)
|
||||||
|
|
||||||
colorwidget.set_sensitive(customwidget.get_active())
|
if not value:
|
||||||
self.config['cursor_color_fg'] = not customwidget.get_active()
|
self.config['cursor_fg_color'] = color2hex(guiget('cursor_fg_color'))
|
||||||
|
self.config['cursor_bg_color'] = color2hex(guiget('cursor_bg_color'))
|
||||||
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()
|
self.config.save()
|
||||||
|
|
||||||
def on_cursor_color_color_set(self, widget):
|
self.config['cursor_color_default'] = value
|
||||||
"""Cursor colour changed"""
|
self.config.save()
|
||||||
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()
|
self.config.save()
|
||||||
|
|
||||||
def on_cursor_shape_combobox_changed(self, widget):
|
def on_cursor_shape_combobox_changed(self, widget):
|
||||||
|
|
|
@ -837,12 +837,24 @@ 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_fg']:
|
if self.config['cursor_color_default']:
|
||||||
self.vte.set_color_cursor(None)
|
self.vte.set_color_cursor(None)
|
||||||
|
self.vte.set_color_cursor_foreground(None)
|
||||||
else:
|
else:
|
||||||
cursor_color = Gdk.RGBA()
|
# foreground
|
||||||
cursor_color.parse(self.config['cursor_color'])
|
cursor_fg_color = Gdk.RGBA()
|
||||||
self.vte.set_color_cursor(cursor_color)
|
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):
|
def get_window_title(self):
|
||||||
"""Return the window title"""
|
"""Return the window title"""
|
||||||
|
|
Loading…
Reference in New Issue