keyboard: save the MRU input sources list when switching
And restore it when reloading the current list of sources, if appropriate. https://bugzilla.gnome.org/show_bug.cgi?id=766826
This commit is contained in:
parent
5c0eba7d3b
commit
2ea6ae05e5
@ -159,6 +159,14 @@ const InputSourceSettings = new Lang.Class({
|
|||||||
return [];
|
return [];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get mruSources() {
|
||||||
|
return [];
|
||||||
|
},
|
||||||
|
|
||||||
|
set mruSources(sourcesList) {
|
||||||
|
// do nothing
|
||||||
|
},
|
||||||
|
|
||||||
get keyboardOptions() {
|
get keyboardOptions() {
|
||||||
return [];
|
return [];
|
||||||
},
|
},
|
||||||
@ -251,6 +259,7 @@ const InputSourceSessionSettings = new Lang.Class({
|
|||||||
|
|
||||||
_DESKTOP_INPUT_SOURCES_SCHEMA: 'org.gnome.desktop.input-sources',
|
_DESKTOP_INPUT_SOURCES_SCHEMA: 'org.gnome.desktop.input-sources',
|
||||||
_KEY_INPUT_SOURCES: 'sources',
|
_KEY_INPUT_SOURCES: 'sources',
|
||||||
|
_KEY_MRU_SOURCES: 'mru-sources',
|
||||||
_KEY_KEYBOARD_OPTIONS: 'xkb-options',
|
_KEY_KEYBOARD_OPTIONS: 'xkb-options',
|
||||||
_KEY_PER_WINDOW: 'per-window',
|
_KEY_PER_WINDOW: 'per-window',
|
||||||
|
|
||||||
@ -277,6 +286,15 @@ const InputSourceSessionSettings = new Lang.Class({
|
|||||||
return this._getSourcesList(this._KEY_INPUT_SOURCES);
|
return this._getSourcesList(this._KEY_INPUT_SOURCES);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get mruSources() {
|
||||||
|
return this._getSourcesList(this._KEY_MRU_SOURCES);
|
||||||
|
},
|
||||||
|
|
||||||
|
set mruSources(sourcesList) {
|
||||||
|
let sources = GLib.Variant.new('a(ss)', sourcesList);
|
||||||
|
this._settings.set_value(this._KEY_MRU_SOURCES, sources);
|
||||||
|
},
|
||||||
|
|
||||||
get keyboardOptions() {
|
get keyboardOptions() {
|
||||||
return this._settings.get_strv(this._KEY_KEYBOARD_OPTIONS);
|
return this._settings.get_strv(this._KEY_KEYBOARD_OPTIONS);
|
||||||
},
|
},
|
||||||
@ -404,6 +422,25 @@ const InputSourceManager = new Lang.Class({
|
|||||||
this._keyboardManager.reapply();
|
this._keyboardManager.reapply();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_updateMruSettings: function() {
|
||||||
|
// If IBus is not ready we don't have a full picture of all
|
||||||
|
// the available sources, so don't update the setting
|
||||||
|
if (!this._ibusReady)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// If IBus is temporarily disabled, don't update the setting
|
||||||
|
if (this._disableIBus)
|
||||||
|
return;
|
||||||
|
|
||||||
|
let sourcesList = [];
|
||||||
|
for (let i = 0; i < this._mruSources.length; ++i) {
|
||||||
|
let source = this._mruSources[i];
|
||||||
|
sourcesList.push([source.type, source.id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._settings.mruSources = sourcesList;
|
||||||
|
},
|
||||||
|
|
||||||
_currentInputSourceChanged: function(newSource) {
|
_currentInputSourceChanged: function(newSource) {
|
||||||
let oldSource;
|
let oldSource;
|
||||||
[oldSource, this._currentSource] = [this._currentSource, newSource];
|
[oldSource, this._currentSource] = [this._currentSource, newSource];
|
||||||
@ -438,6 +475,9 @@ const InputSourceManager = new Lang.Class({
|
|||||||
|
|
||||||
this._ibusManager.setEngine(engine, KeyboardManager.releaseKeyboard);
|
this._ibusManager.setEngine(engine, KeyboardManager.releaseKeyboard);
|
||||||
this._currentInputSourceChanged(is);
|
this._currentInputSourceChanged(is);
|
||||||
|
|
||||||
|
if (interactive)
|
||||||
|
this._updateMruSettings();
|
||||||
},
|
},
|
||||||
|
|
||||||
_updateMruSources: function() {
|
_updateMruSources: function() {
|
||||||
@ -452,6 +492,27 @@ const InputSourceManager = new Lang.Class({
|
|||||||
this._mruSourcesBackup = null;
|
this._mruSourcesBackup = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize from settings when we have no MRU sources list
|
||||||
|
if (this._mruSources.length == 0) {
|
||||||
|
let mruSettings = this._settings.mruSources;
|
||||||
|
for (let i = 0; i < mruSettings.length; i++) {
|
||||||
|
let mruSettingSource = mruSettings[i];
|
||||||
|
let mruSource = null;
|
||||||
|
|
||||||
|
for (let j = 0; j < sourcesList.length; j++) {
|
||||||
|
let source = sourcesList[j];
|
||||||
|
if (source.type == mruSettingSource.type &&
|
||||||
|
source.id == mruSettingSource.id) {
|
||||||
|
mruSource = source;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mruSource)
|
||||||
|
this._mruSources.push(mruSource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mruSources = [];
|
let mruSources = [];
|
||||||
for (let i = 0; i < this._mruSources.length; i++) {
|
for (let i = 0; i < this._mruSources.length; i++) {
|
||||||
for (let j = 0; j < sourcesList.length; j++)
|
for (let j = 0; j < sourcesList.length; j++)
|
||||||
|
Loading…
Reference in New Issue
Block a user