windowManager: Add switch-to-application-n keybindings
Having Unity-like shortcuts for activating the first nine applications in the dash has been a long requested feature, but somehow nobody got around to implement it. As the shortcut is most useful outside the overview where the dash is not visible, only consider favorite apps as they have a predictable order. https://bugzilla.gnome.org/show_bug.cgi?id=648000
This commit is contained in:

committed by
Florian Müllner

parent
15e7625c80
commit
4590094605
@ -12,6 +12,7 @@ const Shell = imports.gi.Shell;
|
||||
const Signals = imports.signals;
|
||||
|
||||
const AltTab = imports.ui.altTab;
|
||||
const AppFavorites = imports.ui.appFavorites;
|
||||
const Dialog = imports.ui.dialog;
|
||||
const WorkspaceSwitcherPopup = imports.ui.workspaceSwitcherPopup;
|
||||
const InhibitShortcutsDialog = imports.ui.inhibitShortcutsDialog;
|
||||
@ -938,6 +939,69 @@ var WindowManager = class {
|
||||
Shell.ActionMode.POPUP,
|
||||
this._toggleCalendar.bind(this));
|
||||
|
||||
this.addKeybinding('switch-to-application-1',
|
||||
new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
|
||||
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
|
||||
Shell.ActionMode.NORMAL |
|
||||
Shell.ActionMode.OVERVIEW,
|
||||
this._switchToApplication.bind(this));
|
||||
|
||||
this.addKeybinding('switch-to-application-2',
|
||||
new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
|
||||
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
|
||||
Shell.ActionMode.NORMAL |
|
||||
Shell.ActionMode.OVERVIEW,
|
||||
this._switchToApplication.bind(this));
|
||||
|
||||
this.addKeybinding('switch-to-application-3',
|
||||
new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
|
||||
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
|
||||
Shell.ActionMode.NORMAL |
|
||||
Shell.ActionMode.OVERVIEW,
|
||||
this._switchToApplication.bind(this));
|
||||
|
||||
this.addKeybinding('switch-to-application-4',
|
||||
new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
|
||||
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
|
||||
Shell.ActionMode.NORMAL |
|
||||
Shell.ActionMode.OVERVIEW,
|
||||
this._switchToApplication.bind(this));
|
||||
|
||||
this.addKeybinding('switch-to-application-5',
|
||||
new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
|
||||
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
|
||||
Shell.ActionMode.NORMAL |
|
||||
Shell.ActionMode.OVERVIEW,
|
||||
this._switchToApplication.bind(this));
|
||||
|
||||
this.addKeybinding('switch-to-application-6',
|
||||
new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
|
||||
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
|
||||
Shell.ActionMode.NORMAL |
|
||||
Shell.ActionMode.OVERVIEW,
|
||||
this._switchToApplication.bind(this));
|
||||
|
||||
this.addKeybinding('switch-to-application-7',
|
||||
new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
|
||||
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
|
||||
Shell.ActionMode.NORMAL |
|
||||
Shell.ActionMode.OVERVIEW,
|
||||
this._switchToApplication.bind(this));
|
||||
|
||||
this.addKeybinding('switch-to-application-8',
|
||||
new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
|
||||
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
|
||||
Shell.ActionMode.NORMAL |
|
||||
Shell.ActionMode.OVERVIEW,
|
||||
this._switchToApplication.bind(this));
|
||||
|
||||
this.addKeybinding('switch-to-application-9',
|
||||
new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
|
||||
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
|
||||
Shell.ActionMode.NORMAL |
|
||||
Shell.ActionMode.OVERVIEW,
|
||||
this._switchToApplication.bind(this));
|
||||
|
||||
global.display.connect('show-resize-popup', this._showResizePopup.bind(this));
|
||||
global.display.connect('show-pad-osd', this._showPadOsd.bind(this));
|
||||
global.display.connect('show-osd', (display, monitorIndex, iconName, label) => {
|
||||
@ -2012,6 +2076,14 @@ var WindowManager = class {
|
||||
Main.ctrlAltTabManager.popup(binding.is_reversed(), binding.get_name(), binding.get_mask());
|
||||
}
|
||||
|
||||
_switchToApplication(display, window, binding) {
|
||||
let [,,,target] = binding.get_name().split('-');
|
||||
let apps = AppFavorites.getAppFavorites().getFavorites();
|
||||
let app = apps[target - 1];
|
||||
if (app)
|
||||
app.activate();
|
||||
}
|
||||
|
||||
_toggleAppMenu(display, window, event, binding) {
|
||||
Main.panel.toggleAppMenu();
|
||||
}
|
||||
|
Reference in New Issue
Block a user