aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2015-02-18 11:19:40 -0500
committerWilliam Hua <william.hua@canonical.com>2015-02-18 11:19:40 -0500
commitd63326c3ae6d8a66214756964196fa2afb7ab13a (patch)
tree2e3936330943fc6e598dee42151bbf5b3a1ad261 /lib
parenta8721bcb87bef4c18e501cf559af35926d11c0eb (diff)
downloadayatana-indicator-keyboard-d63326c3ae6d8a66214756964196fa2afb7ab13a.tar.gz
ayatana-indicator-keyboard-d63326c3ae6d8a66214756964196fa2afb7ab13a.tar.bz2
ayatana-indicator-keyboard-d63326c3ae6d8a66214756964196fa2afb7ab13a.zip
Use foreach when possible.
Diffstat (limited to 'lib')
-rw-r--r--lib/main.vala35
-rw-r--r--lib/source.vala8
2 files changed, 22 insertions, 21 deletions
diff --git a/lib/main.vala b/lib/main.vala
index 94a7f9ab..b589a3c4 100644
--- a/lib/main.vala
+++ b/lib/main.vala
@@ -305,15 +305,13 @@ public class Indicator.Keyboard.Service : Object {
Act.User? user = manager.get_user ((!) greeter_user);
if (user != null && ((!) user).is_loaded) {
- var outer = ((!) user).input_sources.iterator ();
+ foreach (var outer in ((!) user).input_sources) {
+ foreach (var inner in (!) outer) {
+ unowned string key;
+ unowned string value;
- VariantIter inner;
+ ((!) inner).get ("{&s&s}", out key, out value);
- while (outer.next ("a{ss}", out inner)) {
- unowned string key;
- unowned string value;
-
- while (inner.next ("{&s&s}", out key, out value)) {
if (key == "xkb") {
source = value;
break;
@@ -495,16 +493,15 @@ public class Indicator.Keyboard.Service : Object {
foreach (var user in users) {
if (user.is_loaded) {
- var outer = user.input_sources.iterator ();
var done = false;
- VariantIter inner;
+ foreach (var outer in user.input_sources) {
+ foreach (var inner in (!) outer) {
+ unowned string key;
+ unowned string source;
- while (outer.next ("a{ss}", out inner)) {
- unowned string key;
- unowned string source;
+ ((!) inner).get ("{&s&s}", out key, out source);
- while (inner.next ("{&s&s}", out key, out source)) {
if (key == "xkb") {
done = true;
@@ -723,15 +720,19 @@ public class Indicator.Keyboard.Service : Object {
}
}
- var iter = source_settings.get_value ("sources").iterator ();
+ var i = 0;
- unowned string source_type;
- unowned string source_name;
+ foreach (var pair in source_settings.get_value ("sources")) {
+ unowned string source_type;
+ unowned string source_name;
+
+ ((!) pair).get ("(&s&s)", out source_type, out source_name);
- for (var i = 0; iter.next ("(&s&s)", out source_type, out source_name); i++) {
if (source_name == name && source_type == type) {
return i;
}
+
+ i++;
}
}
}
diff --git a/lib/source.vala b/lib/source.vala
index 38a628c1..b7d7a971 100644
--- a/lib/source.vala
+++ b/lib/source.vala
@@ -100,12 +100,12 @@ public class Indicator.Keyboard.Source : Object {
fcitx = name;
}
} else if (variant.is_of_type (new VariantType ("a{ss}"))) {
- var iter = variant.iterator ();
+ foreach (var pair in variant) {
+ unowned string key;
+ unowned string value;
- unowned string key;
- unowned string value;
+ ((!) pair).get ("{&s&s}", out key, out value);
- while (iter.next ("{&s&s}", out key, out value)) {
if (key == "xkb") {
xkb = value;
} else if (key == "ibus") {