From c47f3a2bad9d12adf3071e1e9c228628467c9577 Mon Sep 17 00:00:00 2001 From: nojhan Date: Thu, 4 Mar 2021 11:17:26 +0100 Subject: [PATCH 1/2] add feat: config to open links with single click Instead of Ctrl-left click. --- terminatorlib/config.py | 1 + terminatorlib/preferences.glade | 43 ++++++++++++++++++++++----------- terminatorlib/prefseditor.py | 9 ++++++- terminatorlib/terminal.py | 2 +- 4 files changed, 39 insertions(+), 16 deletions(-) diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 35d05e2b..a4c08a2f 100644 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -125,6 +125,7 @@ DEFAULTS = { 'line_height' : 1.0, 'case_sensitive' : True, 'invert_search' : False, + 'link_single_click' : False, }, 'keybindings': { 'zoom_in' : 'plus', diff --git a/terminatorlib/preferences.glade b/terminatorlib/preferences.glade index 12b3ae46..be2f81d7 100644 --- a/terminatorlib/preferences.glade +++ b/terminatorlib/preferences.glade @@ -1,5 +1,5 @@ - + @@ -345,20 +345,20 @@ 1 - 0.1 - 0.2 + 0.10000000000000001 + 0.20000000000000001 1 2 1 - 0.1 - 0.2 + 0.10000000000000001 + 0.20000000000000001 1 - 0.1 - 0.2 + 0.10000000000000001 + 0.20000000000000001 False @@ -366,6 +366,9 @@ Terminator Preferences 640 400 + + + True @@ -700,7 +703,7 @@ 0 - 5 + 6 3 @@ -747,7 +750,7 @@ 0 - 6 + 7 4 @@ -801,6 +804,21 @@ 2 + + + Open links with a single click (instead of Ctrl-left click) + True + True + False + True + + + + 0 + 5 + 4 + + @@ -3256,7 +3274,7 @@ True True 0 - 0.00000000745058015283 + 7.4505801528346183e-09 0 @@ -4106,9 +4124,6 @@ Much of the behavior of Terminator is based on GNOME Terminal, and we are adding - - - @@ -4141,7 +4156,7 @@ Much of the behavior of Terminator is based on GNOME Terminal, and we are adding 1 - 0.1 + 0.10000000000000001 0.01 diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index 5d43953f..1193cc43 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -24,7 +24,7 @@ def get_color_string(widcol): def color2hex(widget): """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()) def rgba2hex(widget): @@ -619,6 +619,9 @@ class PrefsEditor: widget.set_value(float(self.config['inactive_color_offset'])) widget = guiget('inactive_color_offset_value_label') 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 widget = guiget('use_custom_url_handler_checkbox') widget.set_active(self.config['use_custom_url_handler']) @@ -1419,6 +1422,10 @@ class PrefsEditor: selection.select_iter(model.get_iter_first()) 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): """Toggling the use_custom_url_handler checkbox needs to alter the sensitivity of the custom_url_handler entrybox""" diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index c76cd9a8..ac2c349c 100644 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -942,7 +942,7 @@ class Terminal(Gtk.VBox): # Ctrl-click event here. if event.button == self.MOUSEBUTTON_LEFT: # 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 url = self.vte.hyperlink_check_event(event) dbg('url: %s' % url) From eef5ffb01f0acc11b5cfa8f17a334a00c25b0522 Mon Sep 17 00:00:00 2001 From: nojhan Date: Tue, 9 Mar 2021 09:22:22 +0100 Subject: [PATCH 2/2] fix link_single_click configuration --- terminatorlib/prefseditor.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index 1193cc43..74e08164 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -1423,6 +1423,9 @@ class PrefsEditor: self.config.save() def on_link_single_click_toggled(self, checkbox): + """Configure link_single_click option from checkbox.""" + guiget = self.builder.get_object + widget = guiget('link_single_click') self.config['link_single_click'] = widget.get_active() self.config.save()