Merge lp:~attente/indicator-keyboard/lightdm-layout-fallback into lp:indicator-keyboard

Proposed by William Hua
Status: Merged
Approved by: Lars Karlitski
Approved revision: 121
Merged at revision: 115
Proposed branch: lp:~attente/indicator-keyboard/lightdm-layout-fallback
Merge into: lp:indicator-keyboard
Diff against target: 162 lines (+80/-22)
2 files modified
lib/main.vala (+79/-21)
po/indicator-keyboard.pot (+1/-1)
To merge this branch: bzr merge lp:~attente/indicator-keyboard/lightdm-layout-fallback
Reviewer Review Type Date Requested Status
Lars Karlitski (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+186907@code.launchpad.net

Commit message

Fall-back on old unity-greeter keyboard layouts in case migration hasn't occurred.

Description of the change

indicator-keyboard should fall-back on the old unity-greeter keyboard layouts in the case that their layouts haven't yet been migrated into accountsservice (this can potentially happen if they haven't done an upgrade in a long time).

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
120. By William Hua

Always add the default layout.

121. By William Hua

Prevent index out of bounds.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Lars Karlitski (larsu) wrote :

Code looks good to me and is working. Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/main.vala'
--- lib/main.vala 2013-08-29 02:22:25 +0000
+++ lib/main.vala 2013-09-21 16:21:16 +0000
@@ -41,6 +41,8 @@
41 private MenuModel? menu_model;41 private MenuModel? menu_model;
42 private Menu? sources_menu;42 private Menu? sources_menu;
4343
44 private uint lightdm_current;
45
44 [DBus (visible = false)]46 [DBus (visible = false)]
45 public Service (ref unowned string[] args) {47 public Service (ref unowned string[] args) {
46 force = "--force" in args;48 force = "--force" in args;
@@ -112,7 +114,9 @@
112 [DBus (visible = false)]114 [DBus (visible = false)]
113 private void migrate_keyboard_layouts () {115 private void migrate_keyboard_layouts () {
114 if (is_login_user ()) {116 if (is_login_user ()) {
115 Act.UserManager manager = Act.UserManager.get_default ();117 lightdm_current = source_settings.get_uint ("current");
118
119 var manager = Act.UserManager.get_default ();
116120
117 if (manager.is_loaded) {121 if (manager.is_loaded) {
118 users = manager.list_users ();122 users = manager.list_users ();
@@ -147,6 +151,15 @@
147 }151 }
148 });152 });
149 }153 }
154
155 var user_list = LightDM.UserList.get_instance ();
156
157 user_list.user_added.connect ((user) => { migrate_input_sources (); });
158 user_list.user_changed.connect ((user) => { migrate_input_sources (); });
159 user_list.user_removed.connect ((user) => { migrate_input_sources (); });
160
161 /* Force the loading of the user list. */
162 user_list.get_user_by_name ("");
150 } else {163 } else {
151 if (!indicator_settings.get_boolean ("migrated")) {164 if (!indicator_settings.get_boolean ("migrated")) {
152 var builder = new VariantBuilder (new VariantType ("a(ss)"));165 var builder = new VariantBuilder (new VariantType ("a(ss)"));
@@ -209,12 +222,12 @@
209222
210 foreach (var user in users) {223 foreach (var user in users) {
211 if (user.is_loaded) {224 if (user.is_loaded) {
212 var sources = user.input_sources;225 var done = false;
213 var layouts = user.xkeyboard_layouts;
214226
215 VariantIter outer;227 VariantIter outer;
216 VariantIter inner;228 VariantIter inner;
217229
230 var sources = user.input_sources;
218 sources.get ("aa{ss}", out outer);231 sources.get ("aa{ss}", out outer);
219232
220 while (outer.next ("a{ss}", out inner)) {233 while (outer.next ("a{ss}", out inner)) {
@@ -223,31 +236,76 @@
223236
224 while (inner.next ("{&s&s}", out key, out source)) {237 while (inner.next ("{&s&s}", out key, out source)) {
225 if (key == "xkb") {238 if (key == "xkb") {
226 if (!added.contains (source)) {239 done = true;
227 list.add (source);240
228 added.add (source);241 if (!added.contains (source)) {
229 }242 list.add (source);
230 }243 added.add (source);
231 }244 }
232 }245 }
233246 }
234 foreach (var layout in layouts) {247 }
235 var source = layout;248
236 source = source.replace (" ", "+");249 if (!done) {
237 source = source.replace ("\t", "+");250 var layouts = user.xkeyboard_layouts;
238251 foreach (var layout in layouts) {
239 if (!added.contains (source)) {252 done = true;
240 list.add (source);253
241 added.add (source);254 var source = layout;
255 source = source.replace (" ", "+");
256 source = source.replace ("\t", "+");
257
258 if (!added.contains (source)) {
259 list.add (source);
260 added.add (source);
261 }
262 }
263 }
264
265 if (!done) {
266 var user_list = LightDM.UserList.get_instance ();
267 LightDM.User? light_user = user_list.get_user_by_name (user.user_name);
268
269 if (light_user != null) {
270 var layouts = ((!) light_user).get_layouts ();
271 foreach (var layout in layouts) {
272 done = true;
273
274 var source = layout;
275 source = source.replace (" ", "+");
276 source = source.replace ("\t", "+");
277
278 if (!added.contains (source)) {
279 list.add (source);
280 added.add (source);
281 }
282 }
242 }283 }
243 }284 }
244 }285 }
245 }286 }
246287
288 var layout = LightDM.get_layout ();
289
290 var source = layout.name;
291 source = source.replace (" ", "+");
292 source = source.replace ("\t", "+");
293
294 if (!added.contains (source)) {
295 list.add (source);
296 added.add (source);
297 }
298
247 var builder = new VariantBuilder (new VariantType ("a(ss)"));299 var builder = new VariantBuilder (new VariantType ("a(ss)"));
248300
249 foreach (var layout in list) {301 foreach (var name in list) {
250 builder.add ("(ss)", "xkb", layout);302 builder.add ("(ss)", "xkb", name);
303 }
304
305 if (lightdm_current < list.size) {
306 source_settings.set_uint ("current", lightdm_current);
307 } else {
308 source_settings.set_uint ("current", list.size - 1);
251 }309 }
252310
253 source_settings.set_value ("sources", builder.end ());311 source_settings.set_value ("sources", builder.end ());
254312
=== modified file 'po/indicator-keyboard.pot'
--- po/indicator-keyboard.pot 2013-08-29 02:22:25 +0000
+++ po/indicator-keyboard.pot 2013-09-21 16:21:16 +0000
@@ -8,7 +8,7 @@
8msgstr ""8msgstr ""
9"Project-Id-Version: PACKAGE VERSION\n"9"Project-Id-Version: PACKAGE VERSION\n"
10"Report-Msgid-Bugs-To: \n"10"Report-Msgid-Bugs-To: \n"
11"POT-Creation-Date: 2013-08-29 10:20+0800\n"11"POT-Creation-Date: 2013-09-20 20:56-0400\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n"14"Language-Team: LANGUAGE <LL@li.org>\n"

Subscribers

People subscribed via source and target branches

to all changes: