diff options
author | William Hua <william.hua@canonical.com> | 2013-04-03 16:48:54 -0400 |
---|---|---|
committer | William Hua <william.hua@canonical.com> | 2013-04-03 16:48:54 -0400 |
commit | 0aa2d2eba11ba136ec220a550a28ac77e06aa240 (patch) | |
tree | 42919f0649a327568c9beaac71216491c401851e /lib/main.vala | |
parent | 7c1581a198a1fc5e7fdf3305c05a00c03b0a324c (diff) | |
download | ayatana-indicator-keyboard-0aa2d2eba11ba136ec220a550a28ac77e06aa240.tar.gz ayatana-indicator-keyboard-0aa2d2eba11ba136ec220a550a28ac77e06aa240.tar.bz2 ayatana-indicator-keyboard-0aa2d2eba11ba136ec220a550a28ac77e06aa240.zip |
Don't check for null settings.
Diffstat (limited to 'lib/main.vala')
-rw-r--r-- | lib/main.vala | 99 |
1 files changed, 46 insertions, 53 deletions
diff --git a/lib/main.vala b/lib/main.vala index b5b735b5..0990b95c 100644 --- a/lib/main.vala +++ b/lib/main.vala @@ -34,19 +34,16 @@ public class Indicator.Keyboard.Service : Object { [DBus (visible = false)] private void handle_activate_chart (Variant? parameter) { var layout = "us"; + Variant array; + string type; + string name; - if (this.settings != null) { - Variant array; - string type; - string name; + var current = this.settings.get_uint ("current"); + this.settings.get ("sources", "@a(ss)", out array); + array.get_child (current, "(ss)", out type, out name); - var current = this.settings.get_uint ("current"); - this.settings.get ("sources", "@a(ss)", out array); - array.get_child (current, "(ss)", out type, out name); - - if (type == "xkb") { - layout = name; - } + if (type == "xkb") { + layout = name; } try { @@ -84,9 +81,7 @@ public class Indicator.Keyboard.Service : Object { var action = new SimpleAction.stateful ("indicator", null, state); group.insert (action); - if (this.settings != null) { - group.insert (this.settings.create_action ("current")); - } + group.insert (this.settings.create_action ("current")); action = new SimpleAction ("map", null); action.activate.connect (this.handle_activate_map); @@ -111,48 +106,46 @@ public class Indicator.Keyboard.Service : Object { var section = new Menu (); - if (this.settings != null) { - VariantIter iter; - string type; - string name; - - this.settings.get ("sources", "a(ss)", out iter); - - for (var i = 0; iter.next ("(ss)", out type, out name); i++) { - if (type == "xkb") { - var language = Xkl.get_language_name (name); - var country = Xkl.get_country_name (name); - - if (language != null && country != null) { - name = @"$language ($country)"; - } else if (language != null) { - name = language; - } else if (country != null) { - name = country; - } + VariantIter iter; + string type; + string name; + + this.settings.get ("sources", "a(ss)", out iter); + + for (var i = 0; iter.next ("(ss)", out type, out name); i++) { + if (type == "xkb") { + var language = Xkl.get_language_name (name); + var country = Xkl.get_country_name (name); + + if (language != null && country != null) { + name = @"$language ($country)"; + } else if (language != null) { + name = language; + } else if (country != null) { + name = country; } - else if (type == "ibus") { - var ibus = get_ibus (); - string[] names = { name, null }; - var engines = ibus.get_engines_by_names (names); - var engine = engines[0]; - var longname = engine.longname; - var language = Xkl.get_language_name (engine.language); - var country = Xkl.get_country_name (engine.language); - - if (language != null) { - name = @"$language ($longname)"; - } else if (country != null) { - name = @"$country ($longname)"; - } else { - name = longname; - } + } + else if (type == "ibus") { + var ibus = get_ibus (); + string[] names = { name, null }; + var engines = ibus.get_engines_by_names (names); + var engine = engines[0]; + var longname = engine.longname; + var language = Xkl.get_language_name (engine.language); + var country = Xkl.get_country_name (engine.language); + + if (language != null) { + name = @"$language ($longname)"; + } else if (country != null) { + name = @"$country ($longname)"; + } else { + name = longname; } - - var menu_item = new MenuItem (name, "indicator.current"); - menu_item.set_attribute (Menu.ATTRIBUTE_TARGET, "u", i); - section.append_item (menu_item); } + + var menu_item = new MenuItem (name, "indicator.current"); + menu_item.set_attribute (Menu.ATTRIBUTE_TARGET, "u", i); + section.append_item (menu_item); } submenu.append_section (null, section); |