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
This commit is contained in:
parent
9aa3d864dc
commit
f81887772a
@ -440,6 +440,30 @@ const InputSourceManager = new Lang.Class({
|
|||||||
this._currentInputSourceChanged(is);
|
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() {
|
_inputSourcesChanged: function() {
|
||||||
let sources = this._settings.inputSources;
|
let sources = this._settings.inputSources;
|
||||||
let nSources = sources.length;
|
let nSources = sources.length;
|
||||||
@ -514,27 +538,7 @@ const InputSourceManager = new Lang.Class({
|
|||||||
|
|
||||||
this.emit('sources-changed');
|
this.emit('sources-changed');
|
||||||
|
|
||||||
let sourcesList = [];
|
this._updateMruSources();
|
||||||
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);
|
|
||||||
|
|
||||||
if (this._mruSources.length > 0)
|
if (this._mruSources.length > 0)
|
||||||
this._mruSources[0].activate();
|
this._mruSources[0].activate();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user