[gnome-shell-extensions/extension-live-disable: 6/11] alternate-tab: port to new extension API



commit e4c977146aa80752ae6140277271e30500fb5c64
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Tue Aug 2 23:31:46 2011 +0200

    alternate-tab: port to new extension API
    
    main() has been	replaced by init(), enable() and disable()
    at the same time, ensure that all keybindings are correctly taken
    (even though alt-tab and alt-shift-tab have the same effect right
    now)

 extensions/alternate-tab/extension.js |   36 ++++++++++++++++++++++----------
 1 files changed, 25 insertions(+), 11 deletions(-)
---
diff --git a/extensions/alternate-tab/extension.js b/extensions/alternate-tab/extension.js
index b71f17a..ce44965 100644
--- a/extensions/alternate-tab/extension.js
+++ b/extensions/alternate-tab/extension.js
@@ -541,19 +541,33 @@ WindowList.prototype = {
     }
 };
 
-function main(metadata) {
+function init(metadata) {
     imports.gettext.bindtextdomain('gnome-shell-extensions', metadata.localedir);
+}
 
-    Main.wm.setKeybindingHandler('switch_windows', function() {
-        let settings = new Gio.Settings({ schema: SETTINGS_SCHEMA });
+function doAltTab(shellwm, binding, window, backwards) {
+    let settings = new Gio.Settings({ schema: SETTINGS_SCHEMA });
 
-        if(settings.get_boolean(SETTINGS_FIRST_TIME_KEY)) {
-           new AltTabSettingsDialog().open();
-        } else {
-            let behaviour = settings.get_string(SETTINGS_BEHAVIOUR_KEY);
-            if(behaviour in MODES) {
-                MODES[behaviour]();
-            }
+    if(settings.get_boolean(SETTINGS_FIRST_TIME_KEY)) {
+        new AltTabSettingsDialog().open();
+    } else {
+        let behaviour = settings.get_string(SETTINGS_BEHAVIOUR_KEY);
+        if(behaviour in MODES) {
+            MODES[behaviour](binding, backwards);
         }
-    });
+    }
 }
+
+function enable() {
+    Main.wm.setKeybindingHandler('switch_windows', doAltTab);
+    Main.wm.setKeybindingHandler('switch_group', doAltTab);
+    Main.wm.setKeybindingHandler('switch_windows_backward', doAltTab);
+    Main.wm.setKeybindingHandler('switch_group_backward', doAltTab);
+}
+
+function disable() {
+    Main.wm.setKeybindingHandler('switch_windows', Lang.bind(Main.wm, Main.wm._startAppSwitcher));
+    Main.wm.setKeybindingHandler('switch_group', Lang.bind(Main.wm, Main.wm._startAppSwitcher));
+    Main.wm.setKeybindingHandler('switch_windows_backward', Lang.bind(Main.wm, Main.wm._startAppSwitcher));
+    Main.wm.setKeybindingHandler('switch_group_backward', Lang.bind(Main.wm, Main.wm._startAppSwitcher));
+}
\ No newline at end of file



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]