[gnome-shell] keyboard: split out a function to udpate the MRU list



commit f81887772ac0e5adc4fac1c3a1839bbd8c87ff13
Author: Cosimo Cecchi <cosimo endlessm com>
Date:   Wed May 25 11:28:57 2016 -0700

    keyboard: split out a function to udpate the MRU list
    
    We're going to add saving of the MRU list in the function in a later
    commit.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=766826

 js/ui/status/keyboard.js |   46 +++++++++++++++++++++++++---------------------
 1 files changed, 25 insertions(+), 21 deletions(-)
---
diff --git a/js/ui/status/keyboard.js b/js/ui/status/keyboard.js
index 895b73c..8f45b0d 100644
--- a/js/ui/status/keyboard.js
+++ b/js/ui/status/keyboard.js
@@ -440,6 +440,30 @@ const InputSourceManager = new Lang.Class({
         this._currentInputSourceChanged(is);
     },
 
+    _updateMruSources: function() {
+        let sourcesList = [];
+        for (let i in this._inputSources)
+            sourcesList.push(this._inputSources[i]);
+
+        this._keyboardManager.setUserLayouts(sourcesList.map(function(x) { return x.xkbId; }));
+
+        if (!this._disableIBus && this._mruSourcesBackup) {
+            this._mruSources = this._mruSourcesBackup;
+            this._mruSourcesBackup = null;
+        }
+
+        let mruSources = [];
+        for (let i = 0; i < this._mruSources.length; i++) {
+            for (let j = 0; j < sourcesList.length; j++)
+                if (this._mruSources[i].type == sourcesList[j].type &&
+                    this._mruSources[i].id == sourcesList[j].id) {
+                    mruSources = mruSources.concat(sourcesList.splice(j, 1));
+                    break;
+                }
+        }
+        this._mruSources = mruSources.concat(sourcesList);
+    },
+
     _inputSourcesChanged: function() {
         let sources = this._settings.inputSources;
         let nSources = sources.length;
@@ -514,27 +538,7 @@ const InputSourceManager = new Lang.Class({
 
         this.emit('sources-changed');
 
-        let sourcesList = [];
-        for (let i in this._inputSources)
-            sourcesList.push(this._inputSources[i]);
-
-        this._keyboardManager.setUserLayouts(sourcesList.map(function(x) { return x.xkbId; }));
-
-        if (!this._disableIBus && this._mruSourcesBackup) {
-            this._mruSources = this._mruSourcesBackup;
-            this._mruSourcesBackup = null;
-        }
-
-        let mruSources = [];
-        for (let i = 0; i < this._mruSources.length; i++) {
-            for (let j = 0; j < sourcesList.length; j++)
-                if (this._mruSources[i].type == sourcesList[j].type &&
-                    this._mruSources[i].id == sourcesList[j].id) {
-                    mruSources = mruSources.concat(sourcesList.splice(j, 1));
-                    break;
-                }
-        }
-        this._mruSources = mruSources.concat(sourcesList);
+        this._updateMruSources();
 
         if (this._mruSources.length > 0)
             this._mruSources[0].activate();


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