From e4160dddc90ad2a83f18161ed2450d65f15b364f Mon Sep 17 00:00:00 2001 From: Filip Kilibarda Date: Tue, 28 Apr 2020 22:57:15 -0700 Subject: [PATCH 1/2] Added option to disable ctrl+mousewheel zoom --- terminatorlib/config.py | 1 + terminatorlib/preferences.glade | 18 ++++++++++++++++++ terminatorlib/prefseditor.py | 8 ++++++++ terminatorlib/terminal.py | 2 ++ 4 files changed, 29 insertions(+) diff --git a/terminatorlib/config.py b/terminatorlib/config.py index fbfcb84e..be0fa223 100644 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -118,6 +118,7 @@ 'title_font' : 'Sans 9', 'putty_paste_style' : False, 'smart_copy' : True, + 'disable_mousewheel_zoom': False, }, 'keybindings': { 'zoom_in' : 'plus', diff --git a/terminatorlib/preferences.glade b/terminatorlib/preferences.glade index 518a08e6..487de81c 100644 --- a/terminatorlib/preferences.glade +++ b/terminatorlib/preferences.glade @@ -552,6 +552,24 @@ 2 + + + Disable Ctrl+mousewheel zoom + False + True + True + False + 0.5 + True + True + + + + 0 + 7 + 2 + + True diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index 6b923905..69951acd 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -286,6 +286,9 @@ def set_values(self): else: active = 1 widget.set_active(active) + # Disable Ctrl+mousewheel zoom + widget = guiget('disablemousewheelzoom') + widget.set_active(self.config['disable_mousewheel_zoom']) # scroll_tabbar widget = guiget('scrolltabbarcheck') widget.set_active(self.config['scroll_tabbar']) @@ -695,6 +698,11 @@ def on_dbuscheck_toggled(self, widget): self.config['dbus'] = widget.get_active() self.config.save() + def on_disable_mousewheel_zoom_toggled(self, widget): + """Ctrl+mousewheel zoom setting changed""" + self.config['disable_mousewheel_zoom'] = widget.get_active() + self.config.save() + def on_winbordercheck_toggled(self, widget): """Window border setting changed""" self.config['borderless'] = not widget.get_active() diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 2f22dfb9..bbb06696 100644 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -972,6 +972,8 @@ def on_buttonpress(self, widget, event): def on_mousewheel(self, widget, event): """Handler for modifier + mouse wheel scroll events""" + if self.config["disable_mousewheel_zoom"] is True: + return (True) SMOOTH_SCROLL_UP = event.direction == Gdk.ScrollDirection.SMOOTH and event.delta_y <= 0. SMOOTH_SCROLL_DOWN = event.direction == Gdk.ScrollDirection.SMOOTH and event.delta_y > 0. if event.state & Gdk.ModifierType.CONTROL_MASK == Gdk.ModifierType.CONTROL_MASK: From a7bd53a2d9e7a1a1efd54b0a65eff7df49bf9a43 Mon Sep 17 00:00:00 2001 From: Filip Kilibarda Date: Wed, 29 Apr 2020 13:49:32 -0700 Subject: [PATCH 2/2] Fixed issues with mousewheel zoom PR - moved disable mousewheel zoom checkbox to profile level settings - fixed so it doesn't disable all scrolling events --- terminatorlib/config.py | 2 +- terminatorlib/preferences.glade | 37 ++++++++++++++++----------------- terminatorlib/terminal.py | 7 ++++--- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/terminatorlib/config.py b/terminatorlib/config.py index be0fa223..66f82ae9 100644 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -118,7 +118,6 @@ 'title_font' : 'Sans 9', 'putty_paste_style' : False, 'smart_copy' : True, - 'disable_mousewheel_zoom': False, }, 'keybindings': { 'zoom_in' : 'plus', @@ -222,6 +221,7 @@ 'scroll_on_output' : False, 'scrollback_lines' : 500, 'scrollback_infinite' : False, + 'disable_mousewheel_zoom': False, 'exit_action' : 'close', 'palette' : '#2e3436:#cc0000:#4e9a06:#c4a000:\ #3465a4:#75507b:#06989a:#d3d7cf:#555753:#ef2929:#8ae234:#fce94f:\ diff --git a/terminatorlib/preferences.glade b/terminatorlib/preferences.glade index 487de81c..3567fb34 100644 --- a/terminatorlib/preferences.glade +++ b/terminatorlib/preferences.glade @@ -552,24 +552,6 @@ 2 - - - Disable Ctrl+mousewheel zoom - False - True - True - False - 0.5 - True - True - - - - 0 - 7 - 2 - - True @@ -1644,6 +1626,23 @@ 5 + + + Disable Ctrl+mousewheel zoom + False + True + True + False + 0.5 + True + + + + False + False + 6 + + True @@ -1682,7 +1681,7 @@ False True - 6 + 7 diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index bbb06696..e8212197 100644 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -972,12 +972,13 @@ def on_buttonpress(self, widget, event): def on_mousewheel(self, widget, event): """Handler for modifier + mouse wheel scroll events""" - if self.config["disable_mousewheel_zoom"] is True: - return (True) SMOOTH_SCROLL_UP = event.direction == Gdk.ScrollDirection.SMOOTH and event.delta_y <= 0. SMOOTH_SCROLL_DOWN = event.direction == Gdk.ScrollDirection.SMOOTH and event.delta_y > 0. if event.state & Gdk.ModifierType.CONTROL_MASK == Gdk.ModifierType.CONTROL_MASK: - # Ctrl + mouse wheel up/down with Shift and Super additions + # Zoom the terminal(s) in or out if not disabled in config + if self.config["disable_mousewheel_zoom"] is True: + return (False) + # Choice of target terminals depends on Shift and Super modifiers if event.state & Gdk.ModifierType.MOD4_MASK == Gdk.ModifierType.MOD4_MASK: targets=self.terminator.terminals elif event.state & Gdk.ModifierType.SHIFT_MASK == Gdk.ModifierType.SHIFT_MASK: