aboutsummaryrefslogtreecommitdiff
path: root/lib/main.vala
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2013-06-21 13:56:38 -0400
committerWilliam Hua <william.hua@canonical.com>2013-06-21 13:56:38 -0400
commitb7c785a8f7b5c071c6a55419286cb24d19735331 (patch)
tree2cf96ac1f76c17f6102dd48f0b224c47345d3723 /lib/main.vala
parent9d174c31bda88ec1abe97f20f34a62928c920d71 (diff)
downloadayatana-indicator-keyboard-b7c785a8f7b5c071c6a55419286cb24d19735331.tar.gz
ayatana-indicator-keyboard-b7c785a8f7b5c071c6a55419286cb24d19735331.tar.bz2
ayatana-indicator-keyboard-b7c785a8f7b5c071c6a55419286cb24d19735331.zip
Simplify abbreviations.
Diffstat (limited to 'lib/main.vala')
-rw-r--r--lib/main.vala30
1 files changed, 21 insertions, 9 deletions
diff --git a/lib/main.vala b/lib/main.vala
index b9560459..d0986d03 100644
--- a/lib/main.vala
+++ b/lib/main.vala
@@ -259,16 +259,10 @@ public class Indicator.Keyboard.Service : Object {
array.get_child (index, "(ss)", out type, out name);
if (type == "xkb") {
- string display_name;
- string layout_name;
-
- this.xkb_info.get_layout_info (name, out display_name, null, out layout_name, null);
-
- if (display_name == null) {
- display_name = get_display_name (layout_name);
- }
+ string short_name;
- this.icon_strings[index] = get_abbreviation (display_name);
+ this.xkb_info.get_layout_info (name, null, out short_name, null, null);
+ this.icon_strings[index] = get_abbreviation (short_name);
icon_string = this.icon_strings[index];
}
}
@@ -504,6 +498,24 @@ public class Indicator.Keyboard.Service : Object {
}
[DBus (visible = false)]
+ private string get_display_name (string layout) {
+ var language = Xkl.get_language_name (layout);
+ var country = Xkl.get_country_name (layout);
+ var has_language = language != null && language.get_char () != '\0';
+ var has_country = country != null && country.get_char () != '\0';
+
+ if (has_language && has_country) {
+ return @"$language ($country)";
+ } else if (has_language) {
+ return language;
+ } else if (has_country) {
+ return country;
+ } else {
+ return "";
+ }
+ }
+
+ [DBus (visible = false)]
private void update_sources_menu () {
if (this.sources_menu != null) {
var menu = get_sources_menu ();