From 5202181a4d55ecdb7821438993969de6cd9606fd Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 12 Jul 2017 18:37:18 +0200 Subject: [PATCH] padOsd: Disallow help/switch monitor actions on rings/strips It does not make sense to map those actions to non-buttons. Set the actions insensitive in the combobox to disallow this from the UI. https://bugzilla.gnome.org/show_bug.cgi?id=782033 --- js/ui/padOsd.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/js/ui/padOsd.js b/js/ui/padOsd.js index e143fa899..fc0ad45de 100644 --- a/js/ui/padOsd.js +++ b/js/ui/padOsd.js @@ -154,9 +154,16 @@ const ActionComboBox = new Lang.Class({ this._actionLabels.set(GDesktopEnums.PadButtonAction.SWITCH_MONITOR, _("Switch monitor")); this._actionLabels.set(GDesktopEnums.PadButtonAction.KEYBINDING, _("Assign keystroke")); + this._buttonItems = []; + for (let [action, label] of this._actionLabels.entries()) { let selectedAction = action; - this._editMenu.addAction(label, Lang.bind(this, function() { this._onActionSelected(selectedAction) })); + let item = this._editMenu.addAction(label, Lang.bind(this, function() { this._onActionSelected(selectedAction) })); + + /* These actions only apply to pad buttons */ + if (selectedAction == GDesktopEnums.PadButtonAction.HELP || + selectedAction == GDesktopEnums.PadButtonAction.SWITCH_MONITOR) + this._buttonItems.push(item); } this.setAction(GDesktopEnums.PadButtonAction.NONE); @@ -185,6 +192,10 @@ const ActionComboBox = new Lang.Class({ this.popup(); else this.popdown(); + }, + + setButtonActionsActive: function (active) { + this._buttonItems.forEach(item => { item.setSensitive(active); }); } }); Signals.addSignalMethods(ActionComboBox.prototype); @@ -223,13 +234,16 @@ const ActionEditor = new Lang.Class({ } }, - setSettings: function (settings) { + setSettings: function (settings, action) { this._buttonSettings = settings; this._currentAction = this._buttonSettings.get_enum('action'); this._currentKeybinding = this._buttonSettings.get_string('keybinding'); this._actionComboBox.setAction(this._currentAction); this._updateKeybindingEntryState(); + + let isButton = (action == Meta.PadActionType.BUTTON); + this._actionComboBox.setButtonActionsActive(isButton); }, close: function() { @@ -879,7 +893,7 @@ const PadOsd = new Lang.Class({ let settingsPath = this._settings.path + key + '/'; this._editedActionSettings = Gio.Settings.new_with_path('org.gnome.desktop.peripherals.tablet.pad-button', settingsPath); - this._actionEditor.setSettings(this._editedActionSettings); + this._actionEditor.setSettings(this._editedActionSettings, type); this._padDiagram.startEdition(type, number, dir); },