diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/main.vala | 52 |
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 (); + } } } |