From 09e7ddff39d0683b51b63ab95525a9e58897c44b Mon Sep 17 00:00:00 2001 From: Daniel Sheeler Date: Fri, 18 Nov 2022 22:48:25 -0600 Subject: [PATCH] Added options for enabling or disabling the switch-windows and switch-applications keybindings --- CoverflowAltTab@dmo60.de/keybinder.js | 37 +++++++++++++++--- CoverflowAltTab@dmo60.de/manager.js | 2 +- CoverflowAltTab@dmo60.de/platform.js | 18 +++++++++ CoverflowAltTab@dmo60.de/prefs.js | 2 + .../schemas/gschemas.compiled | Bin 1980 -> 2116 bytes ...ell.extensions.coverflowalttab.gschema.xml | 10 +++++ 6 files changed, 63 insertions(+), 6 deletions(-) diff --git a/CoverflowAltTab@dmo60.de/keybinder.js b/CoverflowAltTab@dmo60.de/keybinder.js index 6b3ee1a..826fde6 100644 --- a/CoverflowAltTab@dmo60.de/keybinder.js +++ b/CoverflowAltTab@dmo60.de/keybinder.js @@ -36,15 +36,22 @@ class AbstractKeybinder { } var Keybinder330Api = class Keybinder330Api extends AbstractKeybinder { - enable(startAppSwitcherBind) { + constructor(...args) { + super(...args); + + this._startAppSwitcherBind = null; + } + + enable(startAppSwitcherBind, platform) { let Shell = imports.gi.Shell; let mode = Shell.ActionMode ? Shell.ActionMode : Shell.KeyBindingMode; - Main.wm.setCustomKeybindingHandler('switch-applications', mode.NORMAL, startAppSwitcherBind); - Main.wm.setCustomKeybindingHandler('switch-windows', mode.NORMAL, startAppSwitcherBind); + + this._startAppSwitcherBind = startAppSwitcherBind; + + platform.addSettingsChangedCallback(this._onSettingsChanged.bind(this)); + Main.wm.setCustomKeybindingHandler('switch-group', mode.NORMAL, startAppSwitcherBind); Main.wm.setCustomKeybindingHandler('switch-panels', mode.NORMAL, startAppSwitcherBind); - Main.wm.setCustomKeybindingHandler('switch-applications-backward', mode.NORMAL, startAppSwitcherBind); - Main.wm.setCustomKeybindingHandler('switch-windows-backward', mode.NORMAL, startAppSwitcherBind); Main.wm.setCustomKeybindingHandler('switch-group-backward', mode.NORMAL, startAppSwitcherBind); } @@ -59,4 +66,24 @@ var Keybinder330Api = class Keybinder330Api extends AbstractKeybinder { Main.wm.setCustomKeybindingHandler('switch-windows-backward', mode.NORMAL, Main.wm._startSwitcher.bind(Main.wm)); Main.wm.setCustomKeybindingHandler('switch-group-backward', mode.NORMAL, Main.wm._startSwitcher.bind(Main.wm)); } + + _onSettingsChanged(settings) { + let Shell = imports.gi.Shell; + let mode = Shell.ActionMode ? Shell.ActionMode : Shell.KeyBindingMode; + if (settings.get_boolean('bind-to-switch-applications')) { + Main.wm.setCustomKeybindingHandler('switch-applications', mode.NORMAL, this._startAppSwitcherBind); + Main.wm.setCustomKeybindingHandler('switch-applications-backward', mode.NORMAL, this._startAppSwitcherBind); + } else { + Main.wm.setCustomKeybindingHandler('switch-applications', mode.NORMAL, Main.wm._startSwitcher.bind(Main.wm)); + Main.wm.setCustomKeybindingHandler('switch-applications-backward', mode.NORMAL, Main.wm._startSwitcher.bind(Main.wm)); + } + if (settings.get_boolean('bind-to-switch-windows')) { + log("binding to switch windows"); + Main.wm.setCustomKeybindingHandler('switch-windows', mode.NORMAL, this._startAppSwitcherBind); + Main.wm.setCustomKeybindingHandler('switch-windows-backward', mode.NORMAL, this._startAppSwitcherBind); + } else { + Main.wm.setCustomKeybindingHandler('switch-windows', mode.NORMAL, Main.wm._startSwitcher.bind(Main.wm)); + Main.wm.setCustomKeybindingHandler('switch-windows-backward', mode.NORMAL, Main.wm._startSwitcher.bind(Main.wm)); + } + } } diff --git a/CoverflowAltTab@dmo60.de/manager.js b/CoverflowAltTab@dmo60.de/manager.js index 457715c..5e86550 100644 --- a/CoverflowAltTab@dmo60.de/manager.js +++ b/CoverflowAltTab@dmo60.de/manager.js @@ -65,7 +65,7 @@ var Manager = class Manager { enable() { this.platform.enable(); - this.keybinder.enable(this._startWindowSwitcher.bind(this)); + this.keybinder.enable(this._startWindowSwitcher.bind(this), this.platform); } disable() { diff --git a/CoverflowAltTab@dmo60.de/platform.js b/CoverflowAltTab@dmo60.de/platform.js index 622a9f2..54eef26 100644 --- a/CoverflowAltTab@dmo60.de/platform.js +++ b/CoverflowAltTab@dmo60.de/platform.js @@ -84,6 +84,8 @@ class AbstractPlatform { switch_per_monitor: false, preview_to_monitor_ratio: 50, preview_scaling_factor: 75, + bind_to_switch_applications: true, + bind_to_switch_windows: true, }; } @@ -115,11 +117,14 @@ var PlatformGnomeShell = class PlatformGnomeShell extends AbstractPlatform { this._connections = null; this._extensionSettings = null; this._desktopSettings = null; + this._settings_changed_callbacks = null; } enable() { this.disable(); + this._settings_changed_callbacks = []; + if (this._extensionSettings == null) this._extensionSettings = ExtensionImports.lib.getSettings(SHELL_SCHEMA); @@ -144,6 +149,8 @@ var PlatformGnomeShell = class PlatformGnomeShell extends AbstractPlatform { "switcher-style", "preview-to-monitor-ratio", "preview-scaling-factor", + "bind-to-switch-applications", + "bind-to-switch-windows", ]; let dkeys = [ @@ -198,10 +205,19 @@ var PlatformGnomeShell = class PlatformGnomeShell extends AbstractPlatform { return this._settings; } + addSettingsChangedCallback(cb) { + cb(this._extensionSettings); + this._settings_changed_callbacks.push(cb); + } + _onSettingsChanged() { this._settings = null; + for (let cb of this._settings_changed_callbacks) { + cb(this._extensionSettings); + } } + _loadSettings() { try { let settings = this._extensionSettings; @@ -226,6 +242,8 @@ var PlatformGnomeShell = class PlatformGnomeShell extends AbstractPlatform { switch_per_monitor: settings.get_boolean("switch-per-monitor"), preview_to_monitor_ratio: clamp(settings.get_int("preview-to-monitor-ratio") / 100, 0, 1), preview_scaling_factor: clamp(settings.get_int("preview-scaling-factor") / 100, 0, 1), + bind_to_switch_applications: settings.get_boolean("bind-to-switch-applications"), + bind_to_switch_windows: settings.get_boolean("bind-to-switch-windows"), }; } catch (e) { global.log(e); diff --git a/CoverflowAltTab@dmo60.de/prefs.js b/CoverflowAltTab@dmo60.de/prefs.js index 6136052..ca550d7 100644 --- a/CoverflowAltTab@dmo60.de/prefs.js +++ b/CoverflowAltTab@dmo60.de/prefs.js @@ -129,6 +129,8 @@ function buildPrefsWidget() { }] frame.append(buildComboBox("current-workspace-only", options, _("Show windows from current or all workspaces"))); frame.append(buildSwitcher("switch-per-monitor", _("Only switch between windows on current monitor"))); + frame.append(buildSwitcher("bind-to-switch-applications", _("Bind to switch-applications keybinding"))); + frame.append(buildSwitcher("bind-to-switch-windows", _("Bind to switch-windows keybinding"))); return frame; } diff --git a/CoverflowAltTab@dmo60.de/schemas/gschemas.compiled b/CoverflowAltTab@dmo60.de/schemas/gschemas.compiled index dbdb6165bd266e80a43adbe8077461702cc3cb5c..ce59a420f451d0351b74c1c957ab9d859904c592 100644 GIT binary patch literal 2116 zcmZWqO>Z1U5N#728wV1{B*ch|K|-2En%#&~q<|C=BoG*Jzye=#=$-BLHlCfHO!s=T zk%)|h#0?})AP^El7W@Wt;g|z($O#b22Op9TKn`4zD6qWO^RZ)Z%WtdZb#+ZuO?COD zH)W<};zY5QA=h&~c%a~BAg^_=?ND;>8S%1s5AsJC%$^itjP?9H2(c>8LB0r>Y@@l6 zn7(S-o{Hn9y5v-1wMlF#~`cgRy;0KWox7SNy0 z{Y0MnW8l{zF95fmy?&QGb@G=Ww}G-Q)L9qG?|{E%{(h47)K9^Fj~sCO&PV@{r+y4P z6CZ>4^3)%SJoOXcmr;xr;M;eu9AVw5&w>vi-vZwFB3+?9b;grI?gICp`(T$mb>?*y z@_XQ2b#;k6^`qc#Lhb=OhyJ@op89d{0)?LkR$o2q?WrFIzX-VueEi$#*Jw|D8T@I; zGr-f|+<2cn^(VluLtX&>T>J0_dFqU(2l+X$d-?V%dFu1vzlQu7h(G)4SMt;u=N{x! z=(AUT2!AI}opn0{$zIH4(lLE~S%osued*A7q0@b3VVkd@-LOOLqF$J)EbN;^JCk7x zd`I`gu8jDM&mqWiE$}DM!6?wW(P*@F(g~dj3ok=FnqldGhJMmaZD}u#Xo3zK8zNjx055i(UlS$LwqNH_{U9^(BD!;uyfid&!eS|7$BiC7S_pj2oEE{q0k9SMOyzs7z;Cj~zynR7K`P!k@uldb*y#eqb=HI9a! ztZ~KpDO>Ot2O1NqW}BZU$*`tkn6hUcIzw(XTOTaR8dv6U&=!1KMw?UTJvn`T$`+fR>)yA}+YO8*Ru^4L2hiX9uR3XQk3WIlpQy!LAdj`pAMSU% zR{3_ypUbO@`(2ENFyj;{@9lxhFVi&EksmYp1n}|rs#-USl{k;jZ}Iu7`&ANUuCM1` z0&lP7m>R3|oBD!r&h%^dbIqi*1;n`AggRH%Cm%}~Z9ahWYBnA~~ YGhV3t_#}GLhPEd$;P^tnQ13$fAC3486#xJL literal 1980 zcmZWqO^g&p6s`pq)?H;`1zB%+>oMt>4JQ*h5DCHH8cEz34qj?|YIch4>1w)ab{G;3 z1kY$pNYH4aF&n+P7ZXD~aOC8HqcI5n+*A%G28nU_zUrUp+3CzT-dl$A zWu|4~MDZ+x&*yfqr_g4=cRP2t$sBu0ye8fUe-4M)BSMVue77HhSQX^&0h4VsHxkoR zP1{v*+*FsGN~|`CZANBGWu4dzWbB+==R6TS=Sc{zN$f2!3nuo}z@?rB<_kOvJ^(BN z2Z1Hv;iHfKW(?-ID7M57_?xGM_+#yZpQ+QHhkhIU4{+h95TjNID+SQ0#LfAA@TUrf5XTqLIG*S;U z9*@9%V9t%MZmTeriHh?)XLw$w)3K`h3-NwsAREcpU*O^#$~bnQUDORzm6Z$S@%+A3 z(lJ?tbuzr1Y&hwG_43J>IKKe)`t*}3q9&*nMzzZFxjR}C6YBsj4CViaSo+WzAG8?In Coverflow Switcher, scales the previews as they spread out to the sides in Define the scale factor successively applied each step away from the current preview. + + true + Bind to 'switch-applications' keybinding + Whether or not to bind to the 'switch-applications' keybinding. + + + true + Bind to 'switch-windows' keybinding + Whether or not to bind to the 'switch-windows' keybinding. +