gnome-shell/0002-keyboard-split-out-a-function-to-udpate-the-MRU-list.patch

81 lines
2.9 KiB
Diff
Raw Normal View History

From f81887772ac0e5adc4fac1c3a1839bbd8c87ff13 Mon Sep 17 00:00:00 2001
From: Cosimo Cecchi <cosimo@endlessm.com>
Date: Wed, 25 May 2016 11:28:57 -0700
Subject: [PATCH 2/4] 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 file 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();
--
2.7.4