add feat: config to open links with single click

Instead of Ctrl-left click.
This commit is contained in:
nojhan 2021-03-04 11:17:26 +01:00
parent 3a6392668d
commit c47f3a2bad
4 changed files with 39 additions and 16 deletions

View File

@ -125,6 +125,7 @@ DEFAULTS = {
'line_height' : 1.0, 'line_height' : 1.0,
'case_sensitive' : True, 'case_sensitive' : True,
'invert_search' : False, 'invert_search' : False,
'link_single_click' : False,
}, },
'keybindings': { 'keybindings': {
'zoom_in' : '<Control>plus', 'zoom_in' : '<Control>plus',

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.36.0 --> <!-- Generated with glade 3.22.2 -->
<interface> <interface>
<requires lib="gtk+" version="3.10"/> <requires lib="gtk+" version="3.10"/>
<object class="GtkListStore" id="BackspaceKeyListStore"> <object class="GtkListStore" id="BackspaceKeyListStore">
@ -345,20 +345,20 @@
</object> </object>
<object class="GtkAdjustment" id="adjustment7"> <object class="GtkAdjustment" id="adjustment7">
<property name="upper">1</property> <property name="upper">1</property>
<property name="step_increment">0.1</property> <property name="step_increment">0.10000000000000001</property>
<property name="page_increment">0.2</property> <property name="page_increment">0.20000000000000001</property>
</object> </object>
<object class="GtkAdjustment" id="adjustment_lineheight"> <object class="GtkAdjustment" id="adjustment_lineheight">
<property name="lower">1</property> <property name="lower">1</property>
<property name="upper">2</property> <property name="upper">2</property>
<property name="value">1</property> <property name="value">1</property>
<property name="step_increment">0.1</property> <property name="step_increment">0.10000000000000001</property>
<property name="page_increment">0.2</property> <property name="page_increment">0.20000000000000001</property>
</object> </object>
<object class="GtkAdjustment" id="background_darkness_scale"> <object class="GtkAdjustment" id="background_darkness_scale">
<property name="upper">1</property> <property name="upper">1</property>
<property name="step_increment">0.1</property> <property name="step_increment">0.10000000000000001</property>
<property name="page_increment">0.2</property> <property name="page_increment">0.20000000000000001</property>
</object> </object>
<object class="GtkWindow" id="prefswin"> <object class="GtkWindow" id="prefswin">
<property name="can_focus">False</property> <property name="can_focus">False</property>
@ -366,6 +366,9 @@
<property name="title" translatable="yes">Terminator Preferences</property> <property name="title" translatable="yes">Terminator Preferences</property>
<property name="default_width">640</property> <property name="default_width">640</property>
<property name="default_height">400</property> <property name="default_height">400</property>
<child type="titlebar">
<placeholder/>
</child>
<child> <child>
<object class="GtkBox" id="dialog_vbox1"> <object class="GtkBox" id="dialog_vbox1">
<property name="visible">True</property> <property name="visible">True</property>
@ -700,7 +703,7 @@
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">5</property> <property name="top_attach">6</property>
<property name="width">3</property> <property name="width">3</property>
</packing> </packing>
</child> </child>
@ -747,7 +750,7 @@
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">6</property> <property name="top_attach">7</property>
<property name="width">4</property> <property name="width">4</property>
</packing> </packing>
</child> </child>
@ -801,6 +804,21 @@
<property name="width">2</property> <property name="width">2</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkCheckButton" id="link_single_click">
<property name="label" translatable="yes">Open links with a single click (instead of Ctrl-left click)</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_link_single_click_toggled" swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
<property name="width">4</property>
</packing>
</child>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>
@ -3256,7 +3274,7 @@
<property name="use_markup">True</property> <property name="use_markup">True</property>
<property name="wrap">True</property> <property name="wrap">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="yalign">0.00000000745058015283</property> <property name="yalign">7.4505801528346183e-09</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
@ -4106,9 +4124,6 @@ Much of the behavior of Terminator is based on GNOME Terminal, and we are adding
</child> </child>
</object> </object>
</child> </child>
<child type="titlebar">
<placeholder/>
</child>
</object> </object>
<object class="GtkSizeGroup" id="sizegroup1"> <object class="GtkSizeGroup" id="sizegroup1">
<widgets> <widgets>
@ -4141,7 +4156,7 @@ Much of the behavior of Terminator is based on GNOME Terminal, and we are adding
</object> </object>
<object class="GtkAdjustment" id="background_image_shading_adjustment"> <object class="GtkAdjustment" id="background_image_shading_adjustment">
<property name="upper">1</property> <property name="upper">1</property>
<property name="step_increment">0.1</property> <property name="step_increment">0.10000000000000001</property>
<property name="page_increment">0.01</property> <property name="page_increment">0.01</property>
</object> </object>
</interface> </interface>

View File

@ -24,7 +24,7 @@ def get_color_string(widcol):
def color2hex(widget): def color2hex(widget):
"""Pull the colour values out of a Gtk ColorPicker widget and return them """Pull the colour values out of a Gtk ColorPicker widget and return them
as 8bit hex values, sinces its default behaviour is to give 16bit values""" as 8bit hex values, sinces its default behaviour is to give 16bit values"""
return get_color_string(widget.get_color()) return get_color_string(widget.get_color())
def rgba2hex(widget): def rgba2hex(widget):
@ -619,6 +619,9 @@ class PrefsEditor:
widget.set_value(float(self.config['inactive_color_offset'])) widget.set_value(float(self.config['inactive_color_offset']))
widget = guiget('inactive_color_offset_value_label') widget = guiget('inactive_color_offset_value_label')
widget.set_text('%d%%' % (int(float(self.config['inactive_color_offset'])*100))) widget.set_text('%d%%' % (int(float(self.config['inactive_color_offset'])*100)))
# Open links with a single click (instead of a Ctrl-left click)
widget = guiget('link_single_click')
widget.set_active(self.config['link_single_click'])
# Use custom URL handler # Use custom URL handler
widget = guiget('use_custom_url_handler_checkbox') widget = guiget('use_custom_url_handler_checkbox')
widget.set_active(self.config['use_custom_url_handler']) widget.set_active(self.config['use_custom_url_handler'])
@ -1419,6 +1422,10 @@ class PrefsEditor:
selection.select_iter(model.get_iter_first()) selection.select_iter(model.get_iter_first())
self.config.save() self.config.save()
def on_link_single_click_toggled(self, checkbox):
self.config['link_single_click'] = widget.get_active()
self.config.save()
def on_use_custom_url_handler_checkbutton_toggled(self, checkbox): def on_use_custom_url_handler_checkbutton_toggled(self, checkbox):
"""Toggling the use_custom_url_handler checkbox needs to alter the """Toggling the use_custom_url_handler checkbox needs to alter the
sensitivity of the custom_url_handler entrybox""" sensitivity of the custom_url_handler entrybox"""

View File

@ -942,7 +942,7 @@ class Terminal(Gtk.VBox):
# Ctrl-click event here. # Ctrl-click event here.
if event.button == self.MOUSEBUTTON_LEFT: if event.button == self.MOUSEBUTTON_LEFT:
# Ctrl+leftclick on a URL should open it # Ctrl+leftclick on a URL should open it
if event.get_state() & Gdk.ModifierType.CONTROL_MASK == Gdk.ModifierType.CONTROL_MASK: if self.config["link_single_click"] or event.get_state() & Gdk.ModifierType.CONTROL_MASK == Gdk.ModifierType.CONTROL_MASK:
# Check new OSC-8 method first # Check new OSC-8 method first
url = self.vte.hyperlink_check_event(event) url = self.vte.hyperlink_check_event(event)
dbg('url: %s' % url) dbg('url: %s' % url)