status/keyboard: Handle IBus engines which don't specify a symbol

In this case, fall back to the 2 or 3 letter language code or, failing
that, to a keyboard symbol.

https://bugzilla.gnome.org/show_bug.cgi?id=683613
This commit is contained in:
Rui Matos 2012-09-09 22:44:25 +02:00
parent 4fe604bfe8
commit 409af28cb7

View File

@ -245,7 +245,7 @@ const InputSourceIndicator = new Lang.Class({
info.exists = true; info.exists = true;
info.displayName = language + ' (' + engineDesc.get_longname() + ')'; info.displayName = language + ' (' + engineDesc.get_longname() + ')';
info.shortName = engineDesc.get_symbol(); info.shortName = this._makeEngineShortName(engineDesc);
} }
} }
@ -320,6 +320,18 @@ const InputSourceIndicator = new Lang.Class({
Util.spawn(['gkbd-keyboard-display', '-l', description]); Util.spawn(['gkbd-keyboard-display', '-l', description]);
}, },
_makeEngineShortName: function(engineDesc) {
let symbol = engineDesc.get_symbol();
if (symbol && symbol[0])
return symbol;
let langCode = engineDesc.get_language().split('_', 1)[0];
if (langCode.length == 2 || langCode.length == 3)
return langCode.toLowerCase();
return String.fromCharCode(0x2328); // keyboard glyph
},
_containerGetPreferredWidth: function(container, for_height, alloc) { _containerGetPreferredWidth: function(container, for_height, alloc) {
// Here, and in _containerGetPreferredHeight, we need to query // Here, and in _containerGetPreferredHeight, we need to query
// for the height of all children, but we ignore the results // for the height of all children, but we ignore the results