Move set_action_handler

This commit is contained in:
Ole Jørgen Brønner
2017-09-21 18:06:24 +02:00
parent 94cfaa8419
commit 9c3931f429
2 changed files with 28 additions and 27 deletions
+28
View File
@@ -1,4 +1,5 @@
const Extension = imports.misc.extensionUtils.getCurrentExtension();
const convenience = Extension.imports.convenience;
const Tiling = Extension.imports.tiling;
const utils = Extension.utils;
const Gio = imports.gi.Gio;
@@ -87,3 +88,30 @@ function enable() {
function disable() {
}
function set_action_handler(action_name, handler) {
// Ripped from https://github.com/negesti/gnome-shell-extensions-negesti
// Handles multiple gnome-shell versions
if (Main.wm.addKeybinding && Shell.ActionMode){ // introduced in 3.16
Main.wm.addKeybinding(action_name,
convenience.getSettings(), Meta.KeyBindingFlags.NONE,
Shell.ActionMode.NORMAL,
handler
);
} else if (Main.wm.addKeybinding && Shell.KeyBindingMode) { // introduced in 3.7.5
// Shell.KeyBindingMode.NORMAL | Shell.KeyBindingMode.MESSAGE_TRAY,
Main.wm.addKeybinding(action_name,
convenience.getSettings(), Meta.KeyBindingFlags.NONE,
Shell.KeyBindingMode.NORMAL,
handler
);
} else {
global.display.add_keybinding(
action_name,
convenience.getSettings(),
Meta.KeyBindingFlags.NONE,
handler
);
}
}
-27
View File
@@ -9,7 +9,6 @@ const Main = imports.ui.main;
const Shell = imports.gi.Shell;
const Gio = imports.gi.Gio;
const utils = Extension.imports.utils;
const convenience = Extension.imports.convenience;
// Gap between windows
window_gap = 10
@@ -626,30 +625,4 @@ preview_navigate = (display, screen, meta_window, binding) => {
tabPopup.show(binding.is_reversed(), binding.get_name(), binding.get_mask())
}
set_action_handler = function(action_name, handler) {
// Ripped from https://github.com/negesti/gnome-shell-extensions-negesti
// Handles multiple gnome-shell versions
if (Main.wm.addKeybinding && Shell.ActionMode){ // introduced in 3.16
Main.wm.addKeybinding(action_name,
convenience.getSettings(), Meta.KeyBindingFlags.NONE,
Shell.ActionMode.NORMAL,
handler
);
} else if (Main.wm.addKeybinding && Shell.KeyBindingMode) { // introduced in 3.7.5
// Shell.KeyBindingMode.NORMAL | Shell.KeyBindingMode.MESSAGE_TRAY,
Main.wm.addKeybinding(action_name,
convenience.getSettings(), Meta.KeyBindingFlags.NONE,
Shell.KeyBindingMode.NORMAL,
handler
);
} else {
global.display.add_keybinding(
action_name,
convenience.getSettings(),
Meta.KeyBindingFlags.NONE,
handler
);
}
}