[gnome-shell] KeyboardStatus: disambiguate duplicate short descriptions
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] KeyboardStatus: disambiguate duplicate short descriptions
- Date: Fri, 26 Aug 2011 14:53:34 +0000 (UTC)
commit f99b4da4ecfbe5aa3b8853f514a866e22531d9ae
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Sun May 15 19:31:02 2011 +0200
KeyboardStatus: disambiguate duplicate short descriptions
If two layouts have the same short description (for example, english
(US) and english (dvorak)), add a subscript for disambiguating
among them.
https://bugzilla.gnome.org/show_bug.cgi?id=650128
js/ui/status/keyboard.js | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/status/keyboard.js b/js/ui/status/keyboard.js
index 1db0d82..7b425a4 100644
--- a/js/ui/status/keyboard.js
+++ b/js/ui/status/keyboard.js
@@ -79,6 +79,28 @@ XKBIndicator.prototype = {
});
},
+ _adjust_group_names: function(names) {
+ // Disambiguate duplicate names with a subscript
+ // This is O(N^2) to avoid sorting names
+ // but N <= 4 so who cares?
+
+ for (let i = 0; i < names.length; i++) {
+ let name = names[i];
+ let cnt = 0;
+ for (let j = i + 1; j < names.length; j++) {
+ if (names[j] == name) {
+ cnt++;
+ // U+2081 SUBSCRIPT ONE
+ names[j] = name + String.fromCharCode(0x2081 + cnt);
+ }
+ }
+ if (cnt != 0)
+ names[i] = name + '\u2081';
+ }
+
+ return names;
+ },
+
_sync_config: function() {
this._showFlags = this._config.if_flags_shown();
if (this._showFlags) {
@@ -101,7 +123,7 @@ XKBIndicator.prototype = {
for (let i = 0; i < this._labelActors.length; i++)
this._labelActors[i].destroy();
- let short_names = this._config.get_short_group_names();
+ let short_names = this._adjust_group_names(this._config.get_short_group_names());
this._selectedLayout = null;
this._layoutItems = [ ];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]