[gnome-shell/wip/is-switch-fixes: 2/4] status/keyboard: Switch input source on special modifiers accelerator



commit b733e30a4ae3aa96ca049f64184ce01802fb8f1b
Author: Rui Matos <tiagomatos gmail com>
Date:   Fri Mar 29 02:35:32 2013 +0100

    status/keyboard: Switch input source on special modifiers accelerator
    
    This simply mimics the X server's layout switching behavior by
    advancing to the next input source and wrapping around.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=697008

 js/ui/status/keyboard.js |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/status/keyboard.js b/js/ui/status/keyboard.js
index 0aaf90c..a0503ac 100644
--- a/js/ui/status/keyboard.js
+++ b/js/ui/status/keyboard.js
@@ -400,6 +400,7 @@ const InputSourceIndicator = new Lang.Class({
                                                              if (error)
                                                                  log(error.message);
                                                          });
+        global.display.connect('modifiers-accelerator-activated', Lang.bind(this, this._modifiersSwitcher));
 
         this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
         this._showLayoutItem = this.menu.addAction(_("Show Keyboard Layout"), Lang.bind(this, 
this._showLayout));
@@ -434,6 +435,27 @@ const InputSourceIndicator = new Lang.Class({
         this._inputSourcesChanged();
     },
 
+    _modifiersSwitcher: function() {
+        let sourceIndexes = Object.keys(this._inputSources);
+        if (sourceIndexes.length == 0) {
+            releaseKeyboard();
+            return;
+        }
+
+        let is = this._currentSource;
+        if (!is)
+            is = this._inputSources[sourceIndexes[0]];
+
+        let nextIndex = is.index + 1;
+        if (nextIndex > sourceIndexes[sourceIndexes.length - 1])
+            nextIndex = 0;
+
+        while (!(is = this._inputSources[nextIndex]))
+            nextIndex += 1;
+
+        is.activate();
+    },
+
     _switchInputSource: function(display, screen, window, binding) {
         if (this._mruSources.length < 2)
             return;


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