From 0fd1bff1e598b4cba4bee30589caf833ad3f2802 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Mon, 19 Aug 2019 22:20:46 -0400 Subject: [PATCH] Add basic mouse scroll options --- Settings.ui | 411 +++++++++++++++++- appIcons.js | 14 +- panel.js | 23 +- prefs.js | 82 ++++ ...shell.extensions.dash-to-panel.gschema.xml | 25 ++ 5 files changed, 538 insertions(+), 17 deletions(-) diff --git a/Settings.ui b/Settings.ui index 8ce762e..e599d3c 100644 --- a/Settings.ui +++ b/Settings.ui @@ -3134,6 +3134,182 @@ + + 2000 + 10 + 50 + + + True + False + vertical + + + True + False + none + + + True + True + + + True + False + 12 + 12 + 12 + 12 + 32 + + + True + True + end + center + 4 + 50 + scroll_icon_options_delay_adjustment + True + 50 + + + 1 + 0 + 2 + + + + + True + False + True + Delay between mouse scroll events (ms) + True + 0 + + + 0 + 0 + + + + + True + False + True + Use this value to limit the number of captured mouse scroll events. + True + 0 + + + + 0 + 1 + + + + + + + + + False + True + 0 + + + + + 2000 + 10 + 50 + + + True + False + vertical + + + True + False + none + + + True + True + + + True + False + 12 + 12 + 12 + 12 + 32 + + + True + True + end + center + 4 + 50 + scroll_panel_options_delay_adjustment + True + 50 + + + 1 + 0 + 2 + + + + + True + False + True + Delay between mouse scroll events (ms) + True + 0 + + + 0 + 0 + + + + + True + False + True + Use this value to limit the number of captured mouse scroll events. + True + 0 + + + + 0 + 1 + + + + + + + + + False + True + 0 + + + 10000 250 @@ -6093,6 +6269,32 @@ 0 + + + 2 + + + + + True + False + Behavior + + + 2 + False + + + + + True + False + 24 + 24 + 24 + 24 + vertical + 24 False @@ -6211,6 +6413,197 @@ + + False + True + 0 + + + + + False + 0 + in + + + True + False + 12 + 12 + 12 + 12 + 16 + 6 + + + True + False + vertical + + + True + False + True + Scroll panel action + 0 + + + False + True + 0 + + + + + True + False + True + Behavior when mouse scrolling over the panel. + True + 0 + + + + False + True + 1 + + + + + 0 + 0 + + + + + True + False + vertical + + + True + False + True + Scroll icon action + 0 + + + False + True + 0 + + + + + True + False + True + Behavior when mouse scrolling over an application icon. + True + 0 + + + + False + True + 1 + + + + + 0 + 1 + + + + + True + True + True + end + center + + + True + False + emblem-system-symbolic + + + + + + 1 + 0 + + + + + True + False + center + True + + Do nothing + Switch workspace + + + + 2 + 0 + + + + + True + False + center + True + + Do nothing + Cycle windows + + + + 2 + 1 + + + + + True + True + True + end + center + + + True + False + emblem-system-symbolic + + + + + + 1 + 1 + + + + + + + + False True @@ -6335,22 +6728,22 @@ False True - 2 + 3 - 2 + 3 - + True False - Behavior + Action - 2 + 3 False @@ -6873,7 +7266,7 @@ - 3 + 4 @@ -6884,7 +7277,7 @@ Fine-Tune - 3 + 4 False @@ -7095,7 +7488,7 @@ See the <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">G - 4 + 5 @@ -7105,7 +7498,7 @@ See the <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">G About - 4 + 5 False diff --git a/appIcons.js b/appIcons.js index a184742..ae0e72c 100644 --- a/appIcons.js +++ b/appIcons.js @@ -302,6 +302,11 @@ var taskbarAppIcon = Utils.defineClass({ this.actor.disconnect(this._scrollEventId); } + if (this._scrollIconDelayTimeoutId) { + Mainloop.source_remove(this._scrollIconDelayTimeoutId); + this._scrollIconDelayTimeoutId = 0; + } + for (let i = 0; i < this._dtpSettingsSignalIds.length; ++i) { this._dtpSettings.disconnect(this._dtpSettingsSignalIds[i]); } @@ -341,13 +346,18 @@ var taskbarAppIcon = Utils.defineClass({ }, _onMouseScroll: function(actor, event) { - if (!this.window && !this._nWindows) { + if (this._dtpSettings.get_string('scroll-icon-action') === 'NOTHING' || + (!this.window && !this._nWindows)) { return; } let direction = Utils.getMouseScrollDirection(event); - if (direction) { + if (direction && !this._scrollIconDelayTimeoutId) { + this._scrollIconDelayTimeoutId = Mainloop.timeout_add(this._dtpSettings.get_int('scroll-icon-delay'), () => { + this._scrollIconDelayTimeoutId = 0; + }); + let windows = this.getAppIconInterestingWindows(); windows.sort(Taskbar.sortWindowsCompareFunction); diff --git a/panel.js b/panel.js index 1579d34..5805124 100644 --- a/panel.js +++ b/panel.js @@ -292,6 +292,11 @@ var dtpPanelWrapper = Utils.defineClass({ this._showDesktopTimeoutId = 0; } + if (this._scrollPanelDelayTimeoutId) { + Mainloop.source_remove(this._scrollPanelDelayTimeoutId); + this._scrollPanelDelayTimeoutId = 0; + } + if (this.startDynamicTransparencyId) { Mainloop.source_remove(this.startDynamicTransparencyId); this.startDynamicTransparencyId = 0; @@ -751,15 +756,21 @@ var dtpPanelWrapper = Utils.defineClass({ }, _onPanelMouseScroll: function(actor, event) { - let direction = Utils.getMouseScrollDirection(event); + if (this._dtpSettings.get_string('scroll-panel-action') === 'SWITCH_WORKSPACE') { + let direction = Utils.getMouseScrollDirection(event); + + if (!event.get_source()._dtpIgnoreScroll && direction && !this._scrollPanelDelayTimeoutId) { + this._scrollPanelDelayTimeoutId = Mainloop.timeout_add(this._dtpSettings.get_int('scroll-panel-delay'), () => { + this._scrollPanelDelayTimeoutId = 0; + }); - if (!event.get_source()._dtpIgnoreScroll && direction) { - let args = [global.display]; + let args = [global.display]; - //gnome-shell < 3.30 needs an additional "screen" param - global.screen ? args.push(global.screen) : 0; + //gnome-shell < 3.30 needs an additional "screen" param + global.screen ? args.push(global.screen) : 0; - Main.wm._showWorkspaceSwitcher.apply(Main.wm, args.concat([0, { get_name: () => 'switch---' + direction }])); + Main.wm._showWorkspaceSwitcher.apply(Main.wm, args.concat([0, { get_name: () => 'switch---' + direction }])); + } } }, }); diff --git a/prefs.js b/prefs.js index 58c37ca..f7d26c5 100644 --- a/prefs.js +++ b/prefs.js @@ -1387,6 +1387,88 @@ const Settings = new Lang.Class({ })); + this._builder.get_object('scroll_panel_combo').set_active_id(this._settings.get_string('scroll-panel-action')); + this._builder.get_object('scroll_panel_combo').connect('changed', Lang.bind (this, function(widget) { + this._settings.set_string('scroll-panel-action', widget.get_active_id()); + })); + + this._builder.get_object('scroll_icon_combo').set_active_id(this._settings.get_string('scroll-icon-action')); + this._builder.get_object('scroll_icon_combo').connect('changed', Lang.bind (this, function(widget) { + this._settings.set_string('scroll-icon-action', widget.get_active_id()); + })); + + // Create dialog for panel scroll options + this._builder.get_object('scroll_panel_options_button').connect('clicked', Lang.bind(this, function() { + let dialog = new Gtk.Dialog({ title: _('Customize panel scroll behavior'), + transient_for: this.widget.get_toplevel(), + use_header_bar: true, + modal: true }); + + // GTK+ leaves positive values for application-defined response ids. + // Use +1 for the reset action + dialog.add_button(_('Reset to defaults'), 1); + + let box = this._builder.get_object('scroll_panel_options_box'); + dialog.get_content_area().add(box); + + this._builder.get_object('scroll_panel_options_delay_spinbutton').set_value(this._settings.get_int('scroll-panel-delay')); + this._builder.get_object('scroll_panel_options_delay_spinbutton').connect('value-changed', Lang.bind (this, function(widget) { + this._settings.set_int('scroll-panel-delay', widget.get_value()); + })); + + dialog.connect('response', Lang.bind(this, function(dialog, id) { + if (id == 1) { + // restore default settings + this._settings.set_value('scroll-panel-delay', this._settings.get_default_value('scroll-panel-delay')); + this._builder.get_object('scroll_panel_options_delay_spinbutton').set_value(this._settings.get_int('scroll-panel-delay')); + } else { + // remove the settings box so it doesn't get destroyed; + dialog.get_content_area().remove(box); + dialog.destroy(); + } + return; + })); + + dialog.show_all(); + + })); + + // Create dialog for icon scroll options + this._builder.get_object('scroll_icon_options_button').connect('clicked', Lang.bind(this, function() { + let dialog = new Gtk.Dialog({ title: _('Customize icon scroll behavior'), + transient_for: this.widget.get_toplevel(), + use_header_bar: true, + modal: true }); + + // GTK+ leaves positive values for application-defined response ids. + // Use +1 for the reset action + dialog.add_button(_('Reset to defaults'), 1); + + let box = this._builder.get_object('scroll_icon_options_box'); + dialog.get_content_area().add(box); + + this._builder.get_object('scroll_icon_options_delay_spinbutton').set_value(this._settings.get_int('scroll-icon-delay')); + this._builder.get_object('scroll_icon_options_delay_spinbutton').connect('value-changed', Lang.bind (this, function(widget) { + this._settings.set_int('scroll-icon-delay', widget.get_value()); + })); + + dialog.connect('response', Lang.bind(this, function(dialog, id) { + if (id == 1) { + // restore default settings + this._settings.set_value('scroll-icon-delay', this._settings.get_default_value('scroll-icon-delay')); + this._builder.get_object('scroll_icon_options_delay_spinbutton').set_value(this._settings.get_int('scroll-icon-delay')); + } else { + // remove the settings box so it doesn't get destroyed; + dialog.get_content_area().remove(box); + dialog.destroy(); + } + return; + })); + + dialog.show_all(); + + })); + this._settings.bind('hot-keys', this._builder.get_object('hot_keys_switch'), 'active', diff --git a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml index 2d5fa11..0f24b99 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -18,6 +18,11 @@ + + + + + @@ -574,6 +579,26 @@ Action when clicking on a running app Set the action that is executed when shift+middle-clicking on the icon of a running application + + 'SWITCH_WORKSPACE' + Action when scrolling over the panel + Set the action that is executed when scrolling over the panel + + + 0 + Delay between panel mouse scroll events + Set the minimum delay between panel mouse scroll events + + + 'CYCLE_WINDOWS' + Action when scrolling over a running app + Set the action that is executed when scrolling over a running application + + + 0 + Delay between icon mouse scroll events + Set the minimum delay between icon mouse scroll events + 100 Icon leave preview timeout