aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2013-10-02 14:53:12 -0400
committerWilliam Hua <william.hua@canonical.com>2013-10-02 14:53:12 -0400
commit62e536eb83d30df39da4afe5e17e94a7625762ea (patch)
treeef7155125444cf7ce9a4e25bbf4181028168e8d1
parentd5dab6b801cd8d3ab4519cbf45ae37c27feb3943 (diff)
downloadayatana-indicator-keyboard-62e536eb83d30df39da4afe5e17e94a7625762ea.tar.gz
ayatana-indicator-keyboard-62e536eb83d30df39da4afe5e17e94a7625762ea.tar.bz2
ayatana-indicator-keyboard-62e536eb83d30df39da4afe5e17e94a7625762ea.zip
Switch to default layout for non-users in unity-greeter.
-rw-r--r--lib/main.vala60
1 files changed, 39 insertions, 21 deletions
diff --git a/lib/main.vala b/lib/main.vala
index c40cc112..190276f8 100644
--- a/lib/main.vala
+++ b/lib/main.vala
@@ -135,6 +135,8 @@ public class Indicator.Keyboard.Service : Object {
}
}
+ string? source = null;
+
if (greeter_user != null) {
var manager = Act.UserManager.get_default ();
@@ -142,8 +144,6 @@ public class Indicator.Keyboard.Service : Object {
Act.User? user = manager.get_user ((!) greeter_user);
if (user != null && ((!) user).is_loaded) {
- string? source = null;
-
VariantIter outer;
VariantIter inner;
@@ -184,22 +184,35 @@ public class Indicator.Keyboard.Service : Object {
source = ((!) source).replace ("\t", "+");
}
}
+ }
+ }
+ }
- if (source != null) {
- var array = source_settings.get_value ("sources");
+ if (source == null) {
+ LightDM.Layout? layout = LightDM.get_layout ();
- for (int i = 0; i < array.n_children (); i++) {
- unowned string type;
- unowned string name;
+ if (layout != null) {
+ source = ((!) layout).name;
- array.get_child (i, "(&s&s)", out type, out name);
+ if (source != null) {
+ source = ((!) source).replace (" ", "+");
+ source = ((!) source).replace ("\t", "+");
+ }
+ }
+ }
- if (type == "xkb" && name == (!) source) {
- source_settings.set_uint ("current", i);
- break;
- }
- }
- }
+ if (source != null) {
+ var array = source_settings.get_value ("sources");
+
+ for (int i = 0; i < array.n_children (); i++) {
+ unowned string type;
+ unowned string name;
+
+ array.get_child (i, "(&s&s)", out type, out name);
+
+ if (type == "xkb" && name == (!) source) {
+ source_settings.set_uint ("current", i);
+ break;
}
}
}
@@ -388,15 +401,20 @@ public class Indicator.Keyboard.Service : Object {
}
}
- var layout = LightDM.get_layout ();
+ LightDM.Layout? layout = LightDM.get_layout ();
+
+ if (layout != null) {
+ string? source = ((!) layout).name;
- var source = layout.name;
- source = source.replace (" ", "+");
- source = source.replace ("\t", "+");
+ if (source != null) {
+ source = ((!) source).replace (" ", "+");
+ source = ((!) source).replace ("\t", "+");
- if (!added.contains (source)) {
- list.add (source);
- added.add (source);
+ if (!added.contains ((!) source)) {
+ list.add ((!) source);
+ added.add ((!) source);
+ }
+ }
}
var builder = new VariantBuilder (new VariantType ("a(ss)"));