status/keyboard: Ensure we always have at least one input source
Most of the code handles the sources setting being empty and InputSourceManager.currentSource being null because previously the "model" (i.e. the sources list) was kept in gnome-settings-daemon. But this is fragile and since we're now the canonical place where the list lives we can force it to never be empty even if the gsetting is empty or contains only invalid entries. Adding the default keyboard layout in that case is the safest thing to do. https://bugzilla.gnome.org/show_bug.cgi?id=738303
This commit is contained in:
parent
aa3caff714
commit
72c6f0025d
@ -298,8 +298,7 @@ const InputSourceManager = new Lang.Class({
|
||||
this._inputSources = {};
|
||||
this._ibusSources = {};
|
||||
|
||||
let inputSourcesByShortName = {};
|
||||
|
||||
let infosList = [];
|
||||
for (let i = 0; i < nSources; i++) {
|
||||
let displayName;
|
||||
let shortName;
|
||||
@ -323,11 +322,24 @@ const InputSourceManager = new Lang.Class({
|
||||
}
|
||||
}
|
||||
|
||||
if (!exists)
|
||||
continue;
|
||||
if (exists)
|
||||
infosList.push({ type: type, id: id, displayName: displayName, shortName: shortName });
|
||||
}
|
||||
|
||||
let is = new InputSource(type, id, displayName, shortName, i);
|
||||
if (infosList.length == 0) {
|
||||
let type = INPUT_SOURCE_TYPE_XKB;
|
||||
let id = KeyboardManager.DEFAULT_LAYOUT;
|
||||
let [ , displayName, shortName, , ] = this._xkbInfo.get_layout_info(id);
|
||||
infosList.push({ type: type, id: id, displayName: displayName, shortName: shortName });
|
||||
}
|
||||
|
||||
let inputSourcesByShortName = {};
|
||||
for (let i = 0; i < infosList.length; i++) {
|
||||
let is = new InputSource(infosList[i].type,
|
||||
infosList[i].id,
|
||||
infosList[i].displayName,
|
||||
infosList[i].shortName,
|
||||
i);
|
||||
is.connect('activate', Lang.bind(this, this._activateInputSource));
|
||||
|
||||
if (!(is.shortName in inputSourcesByShortName))
|
||||
|
Loading…
Reference in New Issue
Block a user