Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added options for enabling or disabling the switch-windows and switch… #180

Merged
merged 1 commit into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions CoverflowAltTab@dmo60.de/keybinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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));
}
}
}
2 changes: 1 addition & 1 deletion CoverflowAltTab@dmo60.de/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
18 changes: 18 additions & 0 deletions CoverflowAltTab@dmo60.de/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}

Expand Down Expand Up @@ -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);

Expand All @@ -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 = [
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions CoverflowAltTab@dmo60.de/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Binary file modified CoverflowAltTab@dmo60.de/schemas/gschemas.compiled
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,15 @@
<summary>In Coverflow Switcher, scales the previews as they spread out to the sides in </summary>
<description>Define the scale factor successively applied each step away from the current preview.</description>
</key>
<key type="b" name="bind-to-switch-applications">
<default>true</default>
<summary>Bind to 'switch-applications' keybinding</summary>
<description>Whether or not to bind to the 'switch-applications' keybinding.</description>
</key>
<key type="b" name="bind-to-switch-windows">
<default>true</default>
<summary>Bind to 'switch-windows' keybinding</summary>
<description>Whether or not to bind to the 'switch-windows' keybinding.</description>
</key>
</schema>
</schemalist>