aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2013-06-24 10:43:05 -0400
committerWilliam Hua <william.hua@canonical.com>2013-06-24 10:43:05 -0400
commit0a4f042f3cbed0359c46c3da702821fd6244be2b (patch)
treedd3106b16853d010e5ae027241e40635d740717f /lib
parent8212d680ba3a21cddfd521f05fca73cfb73bb697 (diff)
downloadayatana-indicator-keyboard-0a4f042f3cbed0359c46c3da702821fd6244be2b.tar.gz
ayatana-indicator-keyboard-0a4f042f3cbed0359c46c3da702821fd6244be2b.tar.bz2
ayatana-indicator-keyboard-0a4f042f3cbed0359c46c3da702821fd6244be2b.zip
Check if at least one IBus engine.
Diffstat (limited to 'lib')
-rw-r--r--lib/main.vala52
1 files changed, 32 insertions, 20 deletions
diff --git a/lib/main.vala b/lib/main.vala
index b49d9f3b..c74dfc05 100644
--- a/lib/main.vala
+++ b/lib/main.vala
@@ -410,13 +410,17 @@ public class Indicator.Keyboard.Service : Object {
} else if (type == "ibus") {
var names = new string[2];
names[0] = name;
+
var engines = get_ibus ().get_engines_by_names (names);
- var engine = engines[0];
- try {
- this.icons[index] = Icon.new_for_string (engine.get_icon ());
- } catch {
- warn_if_reached ();
+ if (engines.length > 0) {
+ var engine = engines[0];
+
+ try {
+ this.icons[index] = Icon.new_for_string (engine.get_icon ());
+ } catch {
+ warn_if_reached ();
+ }
}
}
@@ -555,21 +559,25 @@ public class Indicator.Keyboard.Service : Object {
else if (type == "ibus") {
var names = new string[2];
names[0] = name;
+
var engines = get_ibus ().get_engines_by_names (names);
- var engine = engines[0];
- string? language = engine.get_language ();
- string? display_name = engine.get_longname ();
- if (language != null) {
- language = Xkl.get_language_name ((!) language);
- }
+ if (engines.length > 0) {
+ var engine = engines[0];
+ string? language = engine.get_language ();
+ string? display_name = engine.get_longname ();
- if (language != null && display_name != null) {
- name = @"$((!) language) ($((!) display_name))";
- } else if (language != null) {
- name = (!) language;
- } else if (display_name != null) {
- name = (!) display_name;
+ if (language != null) {
+ language = Xkl.get_language_name ((!) language);
+ }
+
+ if (language != null && display_name != null) {
+ name = @"$((!) language) ($((!) display_name))";
+ } else if (language != null) {
+ name = (!) language;
+ } else if (display_name != null) {
+ name = (!) display_name;
+ }
}
}
@@ -656,11 +664,15 @@ public class Indicator.Keyboard.Service : Object {
} else if (type == "ibus") {
var names = new string[2];
names[0] = name;
+
var engines = get_ibus ().get_engines_by_names (names);
- var engine = engines[0];
- layout = engine.get_layout ();
- variant = engine.get_layout_variant ();
+ if (engines.length > 0) {
+ var engine = engines[0];
+
+ layout = engine.get_layout ();
+ variant = engine.get_layout_variant ();
+ }
}
}