Add basic mouse scroll options

This commit is contained in:
Charles Gagnon
2019-08-19 22:20:46 -04:00
parent 1ce645f787
commit 0fd1bff1e5
5 changed files with 538 additions and 17 deletions

View File

@@ -3134,6 +3134,182 @@
</object>
</child>
</object>
<object class="GtkAdjustment" id="scroll_icon_options_delay_adjustment">
<property name="upper">2000</property>
<property name="step_increment">10</property>
<property name="page_increment">50</property>
</object>
<object class="GtkBox" id="scroll_icon_options_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkListBox" id="scroll_icon_options_listbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
<child>
<object class="GtkListBoxRow" id="listboxrow_scroll_icon_options_delay">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkGrid" id="grid_scroll_icon_options_delay">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="column_spacing">32</property>
<child>
<object class="GtkSpinButton" id="scroll_icon_options_delay_spinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
<property name="width_chars">4</property>
<property name="text">50</property>
<property name="adjustment">scroll_icon_options_delay_adjustment</property>
<property name="numeric">True</property>
<property name="value">50</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="height">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="scroll_icon_options_delay_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Delay between mouse scroll events (ms)</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="scroll_icon_options_delay_description">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Use this value to limit the number of captured mouse scroll events.</property>
<property name="wrap">True</property>
<property name="xalign">0</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<object class="GtkAdjustment" id="scroll_panel_options_delay_adjustment">
<property name="upper">2000</property>
<property name="step_increment">10</property>
<property name="page_increment">50</property>
</object>
<object class="GtkBox" id="scroll_panel_options_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkListBox" id="scroll_panel_options_listbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
<child>
<object class="GtkListBoxRow" id="listboxrow_scroll_panel_options_delay">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkGrid" id="grid_scroll_panel_options_delay">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="column_spacing">32</property>
<child>
<object class="GtkSpinButton" id="scroll_panel_options_delay_spinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
<property name="width_chars">4</property>
<property name="text">50</property>
<property name="adjustment">scroll_panel_options_delay_adjustment</property>
<property name="numeric">True</property>
<property name="value">50</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="height">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="scroll_panel_options_delay_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Delay between mouse scroll events (ms)</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="scroll_panel_options_delay_description">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Use this value to limit the number of captured mouse scroll events.</property>
<property name="wrap">True</property>
<property name="xalign">0</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<object class="GtkAdjustment" id="shortcut_time_adjustment">
<property name="upper">10000</property>
<property name="step_increment">250</property>
@@ -6093,6 +6269,32 @@
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="behaviour_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Behavior</property>
</object>
<packing>
<property name="position">2</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<object class="GtkBox" id="action">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">24</property>
<property name="margin_right">24</property>
<property name="margin_top">24</property>
<property name="margin_bottom">24</property>
<property name="orientation">vertical</property>
<property name="spacing">24</property>
<child>
<object class="GtkFrame" id="built_in_theme_frame3">
<property name="can_focus">False</property>
@@ -6211,6 +6413,197 @@
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="scroll_action_frame">
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkGrid" id="scroll_action_grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="row_spacing">16</property>
<property name="column_spacing">6</property>
<child>
<object class="GtkBox" id="scroll_panel_description_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="scroll_panel_description_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Scroll panel action</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="scroll_panel_description">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Behavior when mouse scrolling over the panel.</property>
<property name="wrap">True</property>
<property name="xalign">0</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="scroll_icon_description_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="scroll_icon_description_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Scroll icon action</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="scroll_icon_description">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Behavior when mouse scrolling over an application icon.</property>
<property name="wrap">True</property>
<property name="xalign">0</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="scroll_panel_options_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
<child>
<object class="GtkImage" id="scroll_panel_options_button_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">emblem-system-symbolic</property>
</object>
</child>
<style>
<class name="circular"/>
</style>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="scroll_panel_combo">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<items>
<item id="NOTHING" translatable="yes">Do nothing</item>
<item id="SWITCH_WORKSPACE" translatable="yes">Switch workspace</item>
</items>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="scroll_icon_combo">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<items>
<item id="NOTHING" translatable="yes">Do nothing</item>
<item id="CYCLE_WINDOWS" translatable="yes">Cycle windows</item>
</items>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="scroll_icon_options_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
<child>
<object class="GtkImage" id="scroll_icon_options_button_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">emblem-system-symbolic</property>
</object>
</child>
<style>
<class name="circular"/>
</style>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
@@ -6335,22 +6728,22 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="position">2</property>
<property name="position">3</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="behaviour_label">
<object class="GtkLabel" id="action_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Behavior</property>
<property name="label" translatable="yes">Action</property>
</object>
<packing>
<property name="position">2</property>
<property name="position">3</property>
<property name="tab_fill">False</property>
</packing>
</child>
@@ -6873,7 +7266,7 @@
</child>
</object>
<packing>
<property name="position">3</property>
<property name="position">4</property>
</packing>
</child>
<child type="tab">
@@ -6884,7 +7277,7 @@
<property name="label" translatable="yes">Fine-Tune</property>
</object>
<packing>
<property name="position">3</property>
<property name="position">4</property>
<property name="tab_fill">False</property>
</packing>
</child>
@@ -7095,7 +7488,7 @@ See the &lt;a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html"&gt;G
</child>
</object>
<packing>
<property name="position">4</property>
<property name="position">5</property>
</packing>
</child>
<child type="tab">
@@ -7105,7 +7498,7 @@ See the &lt;a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html"&gt;G
<property name="label" translatable="yes">About</property>
</object>
<packing>
<property name="position">4</property>
<property name="position">5</property>
<property name="tab_fill">False</property>
</packing>
</child>

View File

@@ -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);

View File

@@ -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 }]));
}
}
},
});

View File

@@ -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',

View File

@@ -18,6 +18,11 @@
<value value='5' nick='QUIT'/>
<value value='6' nick='TOGGLE-SHOWPREVIEW'/>
</enum>
<enum id='org.gnome.shell.extensions.dash-to-panel.scrollAction'>
<value value='0' nick='NOTHING'/>
<value value='1' nick='SWITCH_WORKSPACE'/>
<value value='2' nick='CYCLE_WINDOWS'/>
</enum>
<enum id='org.gnome.shell.extensions.dash-to-panel.statusAreaPosition'>
<value value='0' nick='BUTTONSLEFT'/>
<value value='1' nick='STATUSLEFT'/>
@@ -574,6 +579,26 @@
<summary>Action when clicking on a running app</summary>
<description>Set the action that is executed when shift+middle-clicking on the icon of a running application</description>
</key>
<key name="scroll-panel-action" enum="org.gnome.shell.extensions.dash-to-panel.scrollAction">
<default>'SWITCH_WORKSPACE'</default>
<summary>Action when scrolling over the panel</summary>
<description>Set the action that is executed when scrolling over the panel</description>
</key>
<key type="i" name="scroll-panel-delay">
<default>0</default>
<summary>Delay between panel mouse scroll events</summary>
<description>Set the minimum delay between panel mouse scroll events</description>
</key>
<key name="scroll-icon-action" enum="org.gnome.shell.extensions.dash-to-panel.scrollAction">
<default>'CYCLE_WINDOWS'</default>
<summary>Action when scrolling over a running app</summary>
<description>Set the action that is executed when scrolling over a running application</description>
</key>
<key type="i" name="scroll-icon-delay">
<default>0</default>
<summary>Delay between icon mouse scroll events</summary>
<description>Set the minimum delay between icon mouse scroll events</description>
</key>
<key type="i" name="leave-timeout">
<default>100</default>
<summary>Icon leave preview timeout</summary>