Merge lp:~jbicha/indicator-keyboard/drop-patches into lp:indicator-keyboard

Proposed by Jeremy Bicha
Status: Merged
Approved by: William Hua
Approved revision: 93
Merged at revision: 94
Proposed branch: lp:~jbicha/indicator-keyboard/drop-patches
Merge into: lp:indicator-keyboard
Diff against target: 2287 lines (+0/-2220)
12 files modified
.pc/.quilt_patches (+0/-1)
.pc/.quilt_series (+0/-1)
.pc/.version (+0/-1)
.pc/applied-patches (+0/-3)
.pc/default-icon-colour.patch/lib/main.vala (+0/-754)
.pc/disable-experimental-non-null.patch/tests/Makefile.am (+0/-18)
.pc/disable-experimental-non-null.patch/tests/main.vala (+0/-675)
.pc/relax-test-missing-ibus.patch/tests/main.vala (+0/-675)
debian/patches/default-icon-colour.patch (+0/-10)
debian/patches/disable-experimental-non-null.patch (+0/-68)
debian/patches/relax-test-missing-ibus.patch (+0/-11)
debian/patches/series (+0/-3)
To merge this branch: bzr merge lp:~jbicha/indicator-keyboard/drop-patches
Reviewer Review Type Date Requested Status
William Hua (community) Approve
Review via email: mp+177306@code.launchpad.net

Description of the change

the upstream branch shouldn't need patches...

To post a comment you must log in.
Revision history for this message
William Hua (attente) wrote :

Did this with the intention of keeping workarounds to certain problems isolated in their respective patches, but guess it was more trouble than it was worth...

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== removed directory '.pc'
=== removed file '.pc/.quilt_patches'
--- .pc/.quilt_patches 2013-06-22 20:26:13 +0000
+++ .pc/.quilt_patches 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1debian/patches
20
=== removed file '.pc/.quilt_series'
--- .pc/.quilt_series 2013-06-22 20:26:13 +0000
+++ .pc/.quilt_series 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1series
20
=== removed file '.pc/.version'
--- .pc/.version 2013-06-22 20:26:13 +0000
+++ .pc/.version 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
12
20
=== removed file '.pc/applied-patches'
--- .pc/applied-patches 2013-07-17 20:06:48 +0000
+++ .pc/applied-patches 1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
1default-icon-colour.patch
2disable-experimental-non-null.patch
3relax-test-missing-ibus.patch
40
=== removed directory '.pc/default-icon-colour.patch'
=== removed directory '.pc/default-icon-colour.patch/lib'
=== removed file '.pc/default-icon-colour.patch/lib/main.vala'
--- .pc/default-icon-colour.patch/lib/main.vala 2013-07-17 18:47:22 +0000
+++ .pc/default-icon-colour.patch/lib/main.vala 1970-01-01 00:00:00 +0000
@@ -1,754 +0,0 @@
1[DBus (name = "com.canonical.indicator.keyboard")]
2public class Indicator.Keyboard.Service : Object {
3
4 private bool use_gtk;
5 private bool use_bamf;
6 private MainLoop? loop;
7 private Settings indicator_settings;
8 private Settings source_settings;
9 private Settings per_window_settings;
10 private Gnome.XkbInfo xkb_info;
11 private IBus.Bus? ibus;
12 private Bamf.Matcher? matcher;
13 private Gee.HashMap<string, uint>? window_sources;
14
15 private SimpleActionGroup? action_group;
16 private SimpleAction? indicator_action;
17 private MenuModel? menu_model;
18 private Menu? sources_menu;
19
20 private Icon?[]? icons;
21 private string[]? icon_strings;
22 private int[]? icon_string_uniques;
23 private uint[]? icon_string_subscripts;
24
25 [DBus (visible = false)]
26 public Service (ref unowned string[] args) {
27 Bus.own_name (BusType.SESSION,
28 "com.canonical.indicator.keyboard",
29 BusNameOwnerFlags.ALLOW_REPLACEMENT | ("--force" in args ? BusNameOwnerFlags.REPLACE : 0),
30 this.handle_bus_acquired,
31 null,
32 this.handle_name_lost);
33
34 this.use_gtk = "--use-gtk" in args;
35 this.use_bamf = "--use-bamf" in args;
36
37 if (this.use_gtk) {
38 this.use_gtk = Gtk.init_check (ref args);
39 } else {
40 Gdk.init (ref args);
41 }
42
43 this.indicator_settings = new Settings ("com.canonical.indicator.keyboard");
44 this.indicator_settings.changed["visible"].connect (this.handle_changed_visible);
45
46 this.source_settings = new Settings ("org.gnome.desktop.input-sources");
47 this.source_settings.changed["current"].connect (this.handle_changed_current);
48 this.source_settings.changed["sources"].connect (this.handle_changed_sources);
49
50 this.per_window_settings = new Settings ("org.gnome.libgnomekbd.desktop");
51 this.per_window_settings.changed["group-per-window"].connect (this.handle_changed_group_per_window);
52
53 this.xkb_info = new Gnome.XkbInfo ();
54
55 migrate_keyboard_layouts ();
56
57 update_window_sources ();
58
59 this.loop = new MainLoop ();
60 ((!) this.loop).run ();
61 }
62
63 [DBus (visible = false)]
64 private IBus.Bus get_ibus () {
65 if (this.ibus == null) {
66 IBus.init ();
67 this.ibus = new IBus.Bus ();
68 }
69
70 return (!) this.ibus;
71 }
72
73 [DBus (visible = false)]
74 private void migrate_keyboard_layouts () {
75 if (!this.indicator_settings.get_boolean ("migrated")) {
76 var builder = new VariantBuilder (new VariantType ("a(ss)"));
77 var length = 0;
78
79 var layout_settings = new Settings ("org.gnome.libgnomekbd.keyboard");
80 var layouts = layout_settings.get_strv ("layouts");
81
82 foreach (var layout in layouts) {
83 var source = layout;
84
85 source = source.replace (" ", "+");
86 source = source.replace ("\t", "+");
87
88 builder.add ("(ss)", "xkb", source);
89 length++;
90 }
91
92 var engines = get_ibus ().list_active_engines ();
93
94 foreach (var engine in engines) {
95 if (length == 0 || engine.name.has_prefix ("xkb")) {
96 var source = "us";
97 string? layout = engine.get_layout ();
98 string? variant = engine.get_layout_variant ();
99
100 if (layout != null && ((!) layout).length == 0) {
101 layout = null;
102 }
103
104 if (variant != null && ((!) variant).length == 0) {
105 variant = null;
106 }
107
108 if (layout != null && variant != null) {
109 source = @"$((!) layout)+$((!) variant)";
110 } else if (layout != null) {
111 source = (!) layout;
112 }
113
114 builder.add ("(ss)", "xkb", source);
115 length++;
116 }
117
118 if (!engine.name.has_prefix ("xkb")) {
119 builder.add ("(ss)", "ibus", engine.name);
120 length++;
121 }
122 }
123
124 this.source_settings.set_value ("sources", builder.end ());
125
126 this.indicator_settings.set_boolean ("migrated", true);
127 }
128 }
129
130 [DBus (visible = false)]
131 private void update_window_sources () {
132 if (this.use_bamf) {
133 var group_per_window = this.per_window_settings.get_boolean ("group-per-window");
134
135 if (group_per_window != (this.window_sources != null)) {
136 if (group_per_window) {
137 this.window_sources = new Gee.HashMap<string, uint> ();
138 this.matcher = Bamf.Matcher.get_default ();
139 ((!) this.matcher).active_window_changed.connect (this.handle_active_window_changed);
140 } else {
141 ((!) this.matcher).active_window_changed.disconnect (this.handle_active_window_changed);
142 this.matcher = null;
143 this.window_sources = null;
144 }
145 }
146 }
147 }
148
149 [DBus (visible = false)]
150 private void handle_changed_group_per_window (string key) {
151 update_window_sources ();
152 }
153
154 [DBus (visible = false)]
155 private void handle_active_window_changed (Bamf.View? old_view, Bamf.View? new_view) {
156 if (old_view != null) {
157 ((!) this.window_sources)[((!) old_view).path] = this.source_settings.get_uint ("current");
158 }
159
160 if (new_view != null) {
161 if (!((!) this.window_sources).has_key (((!) new_view).path)) {
162 var default_group = this.per_window_settings.get_int ("default-group");
163
164 if (default_group >= 0) {
165 this.source_settings.set_uint ("current", (uint) default_group);
166 }
167 } else {
168 this.source_settings.set_uint ("current", ((!) this.window_sources)[((!) new_view).path]);
169 }
170 }
171 }
172
173 [DBus (visible = false)]
174 private Gtk.StyleContext? get_style_context () {
175 Gtk.StyleContext? context = null;
176
177 if (this.use_gtk) {
178 Gdk.Screen? screen = Gdk.Screen.get_default ();
179
180 if (screen != null) {
181 context = new Gtk.StyleContext ();
182 ((!) context).set_screen ((!) screen);
183
184 var path = new Gtk.WidgetPath ();
185 path.append_type (typeof (Gtk.MenuItem));
186 ((!) context).set_path (path);
187 }
188 }
189
190 return context;
191 }
192
193 [DBus (visible = false)]
194 protected virtual Icon? create_icon (string? text, uint subscript) {
195 Icon? icon = null;
196
197 var style = get_style_context ();
198
199 if (style != null) {
200 const int W = 22;
201 const int H = 22;
202 const int w = 20;
203 const int h = 20;
204 const double R = 2.0;
205 const double TEXT_SIZE = 12.0;
206 const double SUBSCRIPT_SIZE = 8.0;
207
208 Pango.FontDescription description;
209 var colour = ((!) style).get_color (Gtk.StateFlags.NORMAL);
210 ((!) style).get (Gtk.StateFlags.NORMAL, Gtk.STYLE_PROPERTY_FONT, out description);
211
212 var surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, W, H);
213 var context = new Cairo.Context (surface);
214
215 context.translate (0.5 * (W - w), 0.5 * (H - h));
216
217 context.new_sub_path ();
218 context.arc (R, R, R, Math.PI, -0.5 * Math.PI);
219 context.arc (w - R, R, R, -0.5 * Math.PI, 0);
220 context.arc (w - R, h - R, R, 0, 0.5 * Math.PI);
221 context.arc (R, h - R, R, 0.5 * Math.PI, Math.PI);
222 context.close_path ();
223
224 context.set_source_rgba (colour.red, colour.green, colour.blue, colour.alpha);
225 context.fill ();
226 context.set_operator (Cairo.Operator.CLEAR);
227
228 if (text != null) {
229 var text_layout = Pango.cairo_create_layout (context);
230 text_layout.set_alignment (Pango.Alignment.CENTER);
231 description.set_absolute_size (Pango.units_from_double (TEXT_SIZE));
232 text_layout.set_font_description (description);
233 text_layout.set_text ((!) text, -1);
234 Pango.cairo_update_layout (context, text_layout);
235 int text_width;
236 int text_height;
237 text_layout.get_pixel_size (out text_width, out text_height);
238
239 if (subscript > 0) {
240 var subscript_layout = Pango.cairo_create_layout (context);
241 subscript_layout.set_alignment (Pango.Alignment.CENTER);
242 description.set_absolute_size (Pango.units_from_double (SUBSCRIPT_SIZE));
243 subscript_layout.set_font_description (description);
244 subscript_layout.set_text (@"$subscript", -1);
245 Pango.cairo_update_layout (context, subscript_layout);
246 int subscript_width;
247 int subscript_height;
248 subscript_layout.get_pixel_size (out subscript_width, out subscript_height);
249
250 context.save ();
251 context.translate ((w - (text_width + subscript_width)) / 2, (h - text_height) / 2);
252 Pango.cairo_layout_path (context, text_layout);
253 context.fill ();
254 context.restore ();
255
256 context.save ();
257 context.translate ((w + (text_width - subscript_width)) / 2, (h + text_height) / 2 - subscript_height);
258 Pango.cairo_layout_path (context, subscript_layout);
259 context.fill ();
260 context.restore ();
261 } else {
262 context.save ();
263 context.translate ((w - text_width) / 2, (h - text_height) / 2);
264 Pango.cairo_layout_path (context, text_layout);
265 context.fill ();
266 context.restore ();
267 }
268 }
269
270 var buffer = new ByteArray ();
271
272 surface.write_to_png_stream ((data) => {
273 buffer.append (data);
274 return Cairo.Status.SUCCESS;
275 });
276
277 icon = new BytesIcon (ByteArray.free_to_bytes ((owned) buffer));
278 }
279
280 return icon;
281 }
282
283 [DBus (visible = false)]
284 private string get_icon_string (uint index) {
285 string? icon_string = null;
286
287 if (this.icon_strings == null) {
288 var array = this.source_settings.get_value ("sources");
289 this.icon_strings = new string[array.n_children ()];
290 }
291
292 if (index < ((!) this.icon_strings).length) {
293 icon_string = this.icon_strings[index];
294
295 if (icon_string == null) {
296 var array = this.source_settings.get_value ("sources");
297
298 string type;
299 string name;
300
301 array.get_child (index, "(ss)", out type, out name);
302
303 if (type == "xkb") {
304 string? short_name;
305
306 this.xkb_info.get_layout_info (name, null, out short_name, null, null);
307
308 if (short_name != null) {
309 this.icon_strings[index] = get_abbreviation ((!) short_name);
310 icon_string = this.icon_strings[index];
311 }
312 }
313 }
314 }
315
316 if (icon_string == null) {
317 icon_string = "";
318 }
319
320 return (!) icon_string;
321 }
322
323 [DBus (visible = false)]
324 private bool is_icon_string_unique (uint index) {
325 bool icon_string_unique = true;
326
327 if (this.icon_string_uniques == null) {
328 var array = this.source_settings.get_value ("sources");
329 this.icon_string_uniques = new int[array.n_children ()];
330
331 for (var i = 0; i < ((!) this.icon_string_uniques).length; i++) {
332 this.icon_string_uniques[i] = -1;
333 }
334 }
335
336 if (index < ((!) this.icon_string_uniques).length) {
337 if (this.icon_string_uniques[index] == -1) {
338 this.icon_string_uniques[index] = 1;
339
340 var icon_string = get_icon_string (index);
341
342 for (var i = 0; i < ((!) this.icon_string_uniques).length && this.icon_string_uniques[index] == 1; i++) {
343 if (i != index && get_icon_string (i) == icon_string) {
344 this.icon_string_uniques[index] = 0;
345 }
346 }
347 }
348
349 icon_string_unique = this.icon_string_uniques[index] != 0;
350 }
351
352 return icon_string_unique;
353 }
354
355 [DBus (visible = false)]
356 private uint get_icon_string_subscript (uint index) {
357 uint icon_string_subscript = 0;
358
359 if (this.icon_string_subscripts == null) {
360 var array = this.source_settings.get_value ("sources");
361 this.icon_string_subscripts = new uint[array.n_children ()];
362 }
363
364 if (index < ((!) this.icon_string_subscripts).length) {
365 icon_string_subscript = this.icon_string_subscripts[index];
366
367 if (icon_string_subscript == 0) {
368 this.icon_string_subscripts[index] = 1;
369
370 for (var i = (int) index - 1; i >= 0 && this.icon_string_subscripts[index] == 1; i--) {
371 if (get_icon_string (i) == get_icon_string (index)) {
372 this.icon_string_subscripts[index] = get_icon_string_subscript (i) + 1;
373 }
374 }
375
376 icon_string_subscript = this.icon_string_subscripts[index];
377 }
378 }
379
380 return icon_string_subscript;
381 }
382
383 [DBus (visible = false)]
384 private Icon? get_icon (uint index) {
385 Icon? icon = null;
386
387 if (this.icons == null) {
388 var array = this.source_settings.get_value ("sources");
389 this.icons = new Icon?[array.n_children ()];
390 }
391
392 if (index < ((!) this.icons).length) {
393 icon = this.icons[index];
394
395 if (icon == null) {
396 var array = this.source_settings.get_value ("sources");
397
398 string type;
399 string name;
400
401 array.get_child (index, "(ss)", out type, out name);
402
403 if (type == "xkb") {
404 var icon_string = get_icon_string (index);
405 var icon_unique = is_icon_string_unique (index);
406 var icon_subscript = get_icon_string_subscript (index);
407
408 if (icon_string.get_char () != '\0') {
409 string icon_name;
410
411 if (icon_unique) {
412 icon_name = @"indicator-keyboard-$((!) icon_string)";
413 } else {
414 icon_name = @"indicator-keyboard-$((!) icon_string)-$icon_subscript";
415 }
416
417 if (this.use_gtk) {
418 var icon_theme = Gtk.IconTheme.get_default ();
419 Gtk.IconInfo? icon_info = icon_theme.lookup_icon (icon_name, 22, 0);
420
421 if (icon_info != null) {
422 try {
423 this.icons[index] = Icon.new_for_string (((!) icon_info).get_filename ());
424 } catch (Error error) {
425 this.icons[index] = null;
426 }
427 }
428 } else {
429 this.icons[index] = new ThemedIcon (icon_name);
430 }
431 }
432
433 if (this.icons[index] == null) {
434 if (icon_unique) {
435 this.icons[index] = create_icon (icon_string, 0);
436 } else {
437 this.icons[index] = create_icon (icon_string, icon_subscript);
438 }
439 }
440 } else if (type == "ibus") {
441 var names = new string[2];
442 names[0] = name;
443
444 var engines = get_ibus ().get_engines_by_names (names);
445
446 if (engines.length > 0) {
447 var engine = engines[0];
448
449 try {
450 this.icons[index] = Icon.new_for_string (engine.get_icon ());
451 } catch (Error error) {
452 warning ("error: %s", error.message);
453 }
454 }
455 }
456
457 icon = this.icons[index];
458 }
459 }
460
461 return icon;
462 }
463
464 [DBus (visible = false)]
465 protected virtual SimpleActionGroup create_action_group (Action root_action) {
466 var group = new SimpleActionGroup ();
467
468 group.insert (root_action);
469 group.insert (this.source_settings.create_action ("current"));
470
471 var action = new SimpleAction ("map", null);
472 action.activate.connect (this.handle_activate_map);
473 group.insert (action);
474
475 action = new SimpleAction ("chart", null);
476 action.activate.connect (this.handle_activate_chart);
477 group.insert (action);
478
479 action = new SimpleAction ("settings", null);
480 action.activate.connect (this.handle_activate_settings);
481 group.insert (action);
482
483 return group;
484 }
485
486 [DBus (visible = false)]
487 private void update_indicator_action () {
488 var visible = this.indicator_settings.get_boolean ("visible");
489 var current = this.source_settings.get_uint ("current");
490 var icon = get_icon (current);
491 Variant state;
492
493 if (icon != null) {
494 state = new Variant.parsed ("{ 'visible' : <%b>, 'icon' : %v }", visible, ((!) icon).serialize ());
495 } else {
496 state = new Variant.parsed ("{ 'visible' : <%b> }", visible);
497 }
498
499 get_indicator_action ().set_state (state);
500 }
501
502 [DBus (visible = false)]
503 private SimpleAction get_indicator_action () {
504 if (this.indicator_action == null) {
505 var state = new Variant.parsed ("{ 'visible' : <false> }");
506 this.indicator_action = new SimpleAction.stateful ("indicator", null, state);
507 update_indicator_action ();
508 }
509
510 return (!) this.indicator_action;
511 }
512
513 [DBus (visible = false)]
514 public SimpleActionGroup get_action_group () {
515 if (this.action_group == null) {
516 this.action_group = create_action_group (get_indicator_action ());
517 }
518
519 return (!) this.action_group;
520 }
521
522 [DBus (visible = false)]
523 protected virtual MenuModel create_menu_model (MenuModel section_menu) {
524 var menu = new Menu ();
525
526 var submenu = new Menu ();
527
528 submenu.append_section (null, section_menu);
529
530 var section = new Menu ();
531 section.append (_ ("Character Map"), "indicator.map");
532 section.append (_ ("Keyboard Layout Chart"), "indicator.chart");
533 section.append (_ ("Text Entry Settings..."), "indicator.settings");
534 submenu.append_section (null, section);
535
536 var indicator = new MenuItem.submenu ("x", submenu);
537 indicator.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.root");
538 indicator.set_detailed_action ("indicator.indicator");
539 menu.append_item (indicator);
540
541 return menu;
542 }
543
544 [DBus (visible = false)]
545 private string get_display_name (string layout) {
546 string? language = Xkl.get_language_name (layout);
547 string? country = Xkl.get_country_name (layout);
548 var has_language = language != null && ((!) language).get_char () != '\0';
549 var has_country = country != null && ((!) country).get_char () != '\0';
550
551 if (has_language && has_country) {
552 return @"$((!) language) ($((!) country))";
553 } else if (has_language) {
554 return (!) language;
555 } else if (has_country) {
556 return (!) country;
557 } else {
558 return "";
559 }
560 }
561
562 [DBus (visible = false)]
563 private void update_sources_menu () {
564 if (this.sources_menu != null) {
565 var menu = get_sources_menu ();
566
567 while (menu.get_n_items () > 0)
568 menu.remove (0);
569
570 VariantIter iter;
571 string type;
572 string name;
573
574 this.source_settings.get ("sources", "a(ss)", out iter);
575
576 for (var i = 0; iter.next ("(ss)", out type, out name); i++) {
577 if (type == "xkb") {
578 string? display_name;
579 string? layout_name;
580
581 this.xkb_info.get_layout_info (name, out display_name, null, out layout_name, null);
582
583 if (display_name != null) {
584 name = (!) display_name;
585 } else if (layout_name != null) {
586 name = get_display_name ((!) layout_name);
587 }
588 }
589 else if (type == "ibus") {
590 var names = new string[2];
591 names[0] = name;
592
593 var engines = get_ibus ().get_engines_by_names (names);
594
595 if (engines.length > 0) {
596 var engine = engines[0];
597 string? language = engine.get_language ();
598 string? display_name = engine.get_longname ();
599
600 if (language != null) {
601 language = Xkl.get_language_name ((!) language);
602 }
603
604 if (language != null && display_name != null) {
605 name = @"$((!) language) ($((!) display_name))";
606 } else if (language != null) {
607 name = (!) language;
608 } else if (display_name != null) {
609 name = (!) display_name;
610 }
611 }
612 }
613
614 var menu_item = new MenuItem (name, "indicator.current");
615 menu_item.set_attribute (Menu.ATTRIBUTE_TARGET, "u", i);
616
617 var icon = get_icon (i);
618 if (icon != null) {
619 menu_item.set_icon ((!) icon);
620 }
621
622 menu.append_item (menu_item);
623 }
624 } else {
625 get_sources_menu ();
626 }
627 }
628
629 [DBus (visible = false)]
630 private Menu get_sources_menu () {
631 if (this.sources_menu == null) {
632 this.sources_menu = new Menu ();
633 update_sources_menu ();
634 }
635
636 return (!) this.sources_menu;
637 }
638
639 [DBus (visible = false)]
640 public MenuModel get_menu_model () {
641 if (this.menu_model == null) {
642 this.menu_model = create_menu_model (get_sources_menu ());
643 }
644
645 return (!) this.menu_model;
646 }
647
648 [DBus (visible = false)]
649 private void handle_changed_visible (string key) {
650 update_indicator_action ();
651 }
652
653 [DBus (visible = false)]
654 private void handle_changed_current (string key) {
655 update_indicator_action ();
656 }
657
658 [DBus (visible = false)]
659 private void handle_changed_sources (string key) {
660 this.icon_string_subscripts = null;
661 this.icon_string_uniques = null;
662 this.icon_strings = null;
663 this.icons = null;
664
665 update_sources_menu ();
666 update_indicator_action ();
667 }
668
669 [DBus (visible = false)]
670 private void handle_activate_map (Variant? parameter) {
671 try {
672 Process.spawn_command_line_async ("gucharmap");
673 } catch (SpawnError error) {
674 warning ("error: %s", error.message);
675 }
676 }
677
678 [DBus (visible = false)]
679 private void handle_activate_chart (Variant? parameter) {
680 var layout = "us";
681 string? variant = null;
682
683 var current = this.source_settings.get_uint ("current");
684 var array = this.source_settings.get_value ("sources");
685
686 if (current < array.n_children ()) {
687 string type;
688 string name;
689
690 array.get_child (current, "(ss)", out type, out name);
691
692 if (type == "xkb") {
693 this.xkb_info.get_layout_info (name, null, null, out layout, out variant);
694 } else if (type == "ibus") {
695 var names = new string[2];
696 names[0] = name;
697
698 var engines = get_ibus ().get_engines_by_names (names);
699
700 if (engines.length > 0) {
701 var engine = engines[0];
702
703 layout = engine.get_layout ();
704 variant = engine.get_layout_variant ();
705 }
706 }
707 }
708
709 try {
710 string command;
711
712 if (variant != null && ((!) variant).get_char () != '\0') {
713 command = @"gkbd-keyboard-display -l \"$layout\t$((!) variant)\"";
714 } else {
715 command = @"gkbd-keyboard-display -l $layout";
716 }
717
718 Process.spawn_command_line_async (command);
719 } catch (SpawnError error) {
720 warning ("error: %s", error.message);
721 }
722 }
723
724 [DBus (visible = false)]
725 private void handle_activate_settings (Variant? parameter) {
726 try {
727 Process.spawn_command_line_async ("gnome-control-center region layouts");
728 } catch (SpawnError error) {
729 warning ("error: %s", error.message);
730 }
731 }
732
733 [DBus (visible = false)]
734 private void handle_bus_acquired (DBusConnection connection, string name) {
735 try {
736 connection.export_action_group ("/com/canonical/indicator/keyboard", get_action_group ());
737 connection.export_menu_model ("/com/canonical/indicator/keyboard/desktop", get_menu_model ());
738 } catch (Error error) {
739 warning ("error: %s", error.message);
740 }
741 }
742
743 [DBus (visible = false)]
744 private void handle_name_lost (DBusConnection? connection, string name) {
745 ((!) this.loop).quit ();
746 this.loop = null;
747 }
748
749 [DBus (visible = false)]
750 public static int main (string[] args) {
751 new Service (ref args);
752 return 0;
753 }
754}
7550
=== removed directory '.pc/disable-experimental-non-null.patch'
=== removed directory '.pc/disable-experimental-non-null.patch/tests'
=== removed file '.pc/disable-experimental-non-null.patch/tests/Makefile.am'
--- .pc/disable-experimental-non-null.patch/tests/Makefile.am 2013-07-17 19:17:32 +0000
+++ .pc/disable-experimental-non-null.patch/tests/Makefile.am 1970-01-01 00:00:00 +0000
@@ -1,18 +0,0 @@
1TESTS = indicator-keyboard-test
2
3check_PROGRAMS = indicator-keyboard-tests
4
5AM_CFLAGS = -w
6AM_LDFLAGS = -lm
7AM_VALAFLAGS = --enable-experimental-non-null \
8 --metadatadir $(top_srcdir)/deps \
9 --vapidir $(top_srcdir)/deps
10
11indicator_keyboard_tests_SOURCES = main.vala \
12 config.vala
13indicator_keyboard_tests_VALAFLAGS = $(AM_VALAFLAGS) \
14 --pkg gio-2.0
15indicator_keyboard_tests_CFLAGS = $(AM_CFLAGS) \
16 $(GIO_CFLAGS)
17indicator_keyboard_tests_LDFLAGS = $(AM_LDFLAGS) \
18 $(GIO_LIBS)
190
=== removed file '.pc/disable-experimental-non-null.patch/tests/main.vala'
--- .pc/disable-experimental-non-null.patch/tests/main.vala 2013-07-04 04:12:14 +0000
+++ .pc/disable-experimental-non-null.patch/tests/main.vala 1970-01-01 00:00:00 +0000
@@ -1,675 +0,0 @@
1const int TIMEOUT_S = 1;
2const int TIMEOUT_MS = 1000;
3
4[DBus (name = "com.canonical.indicator.keyboard.test")]
5public class Service : Object {
6
7 [DBus (visible = false)]
8 private string? _command;
9
10 [DBus (visible = false)]
11 public string? command {
12 get { return _command; }
13 }
14
15 public void execute (string command) {
16 this._command = command;
17
18 var pspec = this.get_class ().find_property ("command");
19
20 if (pspec != null) {
21 this.notify["command"] ((!) pspec);
22 }
23 }
24}
25
26struct Fixture {
27 TestDBus? bus;
28 uint service_name;
29 DBusConnection? connection;
30 Service? service;
31 uint object_name;
32}
33
34static void start_service (Fixture *fixture) {
35 if (fixture.connection != null) {
36 try {
37 fixture.service = new Service ();
38 fixture.object_name = ((!) fixture.connection).register_object ("/com/canonical/indicator/keyboard/test", fixture.service);
39 } catch (IOError error) {
40 fixture.connection = null;
41 fixture.service = null;
42 fixture.object_name = 0;
43
44 Test.message ("error: %s", error.message);
45 Test.fail ();
46 }
47 }
48}
49
50static void begin_test (void *data) {
51 var fixture = (Fixture *) data;
52
53 fixture.bus = new TestDBus (TestDBusFlags.NONE);
54 ((!) fixture.bus).add_service_dir (SERVICE_DIR);
55 ((!) fixture.bus).up ();
56
57 var loop = new MainLoop (null, false);
58
59 fixture.service_name = Bus.own_name (BusType.SESSION,
60 "com.canonical.indicator.keyboard.test",
61 BusNameOwnerFlags.ALLOW_REPLACEMENT | BusNameOwnerFlags.REPLACE,
62 (connection, name) => {
63 if (loop.is_running ()) {
64 fixture.connection = connection;
65
66 start_service (fixture);
67
68 loop.quit ();
69 }
70 },
71 null,
72 (connection, name) => {
73 if (loop.is_running ()) {
74 fixture.connection = null;
75 fixture.service = null;
76 fixture.object_name = 0;
77
78 loop.quit ();
79 }
80 });
81
82 loop.run ();
83
84 if (fixture.connection == null) {
85 Test.message ("error: Unable to connect to com.canonical.indicator.keyboard.test.");
86 Test.fail ();
87 }
88}
89
90static void end_test (void *data) {
91 var fixture = (Fixture *) data;
92
93 if (fixture.object_name != 0) {
94 ((!) fixture.connection).unregister_object (fixture.object_name);
95 fixture.object_name = 0;
96 }
97
98 if (fixture.service_name != 0) {
99 Bus.unown_name (fixture.service_name);
100 fixture.service_name = 0;
101 }
102
103 fixture.service = null;
104 fixture.connection = null;
105
106 if (fixture.bus != null) {
107 ((!) fixture.bus).down ();
108 fixture.bus = null;
109 }
110}
111
112static void test_activate_input_source (void *data) {
113 var fixture = (Fixture *) data;
114
115 if (fixture.object_name == 0) {
116 Test.message ("error: Test fixture not initialized.");
117 Test.fail ();
118 return;
119 }
120
121 try {
122 var current = 0;
123 var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]";
124 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current");
125 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\"");
126 } catch (SpawnError error) {
127 Test.message ("error: %s", error.message);
128 Test.fail ();
129 return;
130 }
131
132 var action_group = DBusActionGroup.get ((!) fixture.connection,
133 "com.canonical.indicator.keyboard",
134 "/com/canonical/indicator/keyboard");
135 var loop = new MainLoop (null, false);
136 var signal_name = action_group.action_state_changed["current"].connect ((action, state) => {
137 loop.quit ();
138 });
139
140 action_group.list_actions ();
141 action_group.activate_action ("current", new Variant.uint32 (2));
142
143 var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
144 loop.run ();
145 Source.remove (source);
146 action_group.disconnect (signal_name);
147
148 var state = action_group.get_action_state ("current");
149 var current = ((!) state).get_uint32 ();
150 assert (current == 2);
151
152 try {
153 string output;
154 Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output);
155 assert (strcmp (output, "uint32 2\n") == 0);
156 } catch (SpawnError error) {
157 Test.message ("error: %s", error.message);
158 Test.fail ();
159 return;
160 }
161}
162
163static void test_activate_character_map (void *data) {
164 var fixture = (Fixture *) data;
165
166 if (fixture.object_name == 0) {
167 Test.message ("error: Test fixture not initialized.");
168 Test.fail ();
169 return;
170 }
171
172 var action_group = DBusActionGroup.get ((!) fixture.connection,
173 "com.canonical.indicator.keyboard",
174 "/com/canonical/indicator/keyboard");
175 var loop = new MainLoop (null, false);
176 var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => {
177 loop.quit ();
178 });
179
180 action_group.activate_action ("map", null);
181
182 var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
183 loop.run ();
184 Source.remove (source);
185 ((!) fixture.service).disconnect (signal_name);
186
187 assert (strcmp ((!) ((!) fixture.service).command, "'gucharmap '") == 0);
188}
189
190static void test_activate_keyboard_layout_chart (void *data) {
191 var fixture = (Fixture *) data;
192
193 if (fixture.object_name == 0) {
194 Test.message ("error: Test fixture not initialized.");
195 Test.fail ();
196 return;
197 }
198
199 try {
200 var current = 1;
201 var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]";
202 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current");
203 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\"");
204 } catch (SpawnError error) {
205 Test.message ("error: %s", error.message);
206 Test.fail ();
207 return;
208 }
209
210 var action_group = DBusActionGroup.get ((!) fixture.connection,
211 "com.canonical.indicator.keyboard",
212 "/com/canonical/indicator/keyboard");
213 var loop = new MainLoop (null, false);
214 var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => {
215 loop.quit ();
216 });
217
218 action_group.activate_action ("chart", null);
219
220 var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
221 loop.run ();
222 Source.remove (source);
223 ((!) fixture.service).disconnect (signal_name);
224
225 assert (strcmp ((!) ((!) fixture.service).command, "'gkbd-keyboard-display -l ca\teng'") == 0);
226}
227
228static void test_activate_text_entry_settings (void *data) {
229 var fixture = (Fixture *) data;
230
231 if (fixture.object_name == 0) {
232 Test.message ("error: Test fixture not initialized.");
233 Test.fail ();
234 return;
235 }
236
237 var action_group = DBusActionGroup.get ((!) fixture.connection,
238 "com.canonical.indicator.keyboard",
239 "/com/canonical/indicator/keyboard");
240 var loop = new MainLoop (null, false);
241 var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => {
242 loop.quit ();
243 });
244
245 action_group.activate_action ("settings", null);
246
247 var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
248 loop.run ();
249 Source.remove (source);
250 ((!) fixture.service).disconnect (signal_name);
251
252 assert (strcmp ((!) ((!) fixture.service).command, "'gnome-control-center region layouts'") == 0);
253}
254
255static void test_migration (void *data) {
256 var fixture = (Fixture *) data;
257
258 if (fixture.object_name == 0) {
259 Test.message ("error: Test fixture not initialized.");
260 Test.fail ();
261 return;
262 }
263
264 try {
265 var migrated = false;
266 var sources = "[('xkb', 'us')]";
267 var layouts = "['us', 'ca\teng', 'epo']";
268 Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard migrated $migrated");
269 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\"");
270 Process.spawn_command_line_sync (@"gsettings set org.gnome.libgnomekbd.keyboard layouts \"$layouts\"");
271 } catch (SpawnError error) {
272 Test.message ("error: %s", error.message);
273 Test.fail ();
274 return;
275 }
276
277 try {
278 var cancellable = new Cancellable ();
279
280 var source = Timeout.add_seconds (TIMEOUT_S, () => { cancellable.cancel (); return false; });
281
282 var dbus_proxy = new DBusProxy.sync ((!) fixture.connection,
283 DBusProxyFlags.NONE,
284 null,
285 "org.freedesktop.DBus",
286 "/",
287 "org.freedesktop.DBus",
288 cancellable);
289
290 Source.remove (source);
291
292 if (cancellable.is_cancelled ()) {
293 Test.message ("error: Unable to connect to org.freedesktop.DBus.");
294 Test.fail ();
295 return;
296 }
297
298 dbus_proxy.call_sync ("StartServiceByName", new Variant ("(su)", "com.canonical.indicator.keyboard", 0), DBusCallFlags.NONE, TIMEOUT_MS);
299 } catch (Error error) {
300 Test.message ("error: %s", error.message);
301 Test.fail ();
302 return;
303 }
304
305 try {
306 string sources;
307 Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources sources", out sources);
308 assert (strcmp (sources, "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo')]\n") == 0);
309 } catch (SpawnError error) {
310 Test.message ("error: %s", error.message);
311 Test.fail ();
312 return;
313 }
314}
315
316static void test_no_migration (void *data) {
317 var fixture = (Fixture *) data;
318
319 if (fixture.object_name == 0) {
320 Test.message ("error: Test fixture not initialized.");
321 Test.fail ();
322 return;
323 }
324
325 try {
326 var migrated = true;
327 var sources = "[('xkb', 'us')]";
328 var layouts = "['us', 'ca\teng', 'epo']";
329 Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard migrated $migrated");
330 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\"");
331 Process.spawn_command_line_sync (@"gsettings set org.gnome.libgnomekbd.keyboard layouts \"$layouts\"");
332 } catch (SpawnError error) {
333 Test.message ("error: %s", error.message);
334 Test.fail ();
335 return;
336 }
337
338 try {
339 var cancellable = new Cancellable ();
340
341 var source = Timeout.add_seconds (TIMEOUT_S, () => { cancellable.cancel (); return false; });
342
343 var dbus_proxy = new DBusProxy.sync ((!) fixture.connection,
344 DBusProxyFlags.NONE,
345 null,
346 "org.freedesktop.DBus",
347 "/",
348 "org.freedesktop.DBus",
349 cancellable);
350
351 Source.remove (source);
352
353 if (cancellable.is_cancelled ()) {
354 Test.message ("error: Unable to connect to org.freedesktop.DBus.");
355 Test.fail ();
356 return;
357 }
358
359 dbus_proxy.call_sync ("StartServiceByName", new Variant ("(su)", "com.canonical.indicator.keyboard", 0), DBusCallFlags.NONE, TIMEOUT_MS);
360 } catch (Error error) {
361 Test.message ("error: %s", error.message);
362 Test.fail ();
363 return;
364 }
365
366 try {
367 string sources;
368 Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources sources", out sources);
369 assert (strcmp (sources, "[('xkb', 'us')]\n") == 0);
370 } catch (SpawnError error) {
371 Test.message ("error: %s", error.message);
372 Test.fail ();
373 return;
374 }
375}
376
377static void test_update_visible (void *data) {
378 var fixture = (Fixture *) data;
379
380 if (fixture.object_name == 0) {
381 Test.message ("error: Test fixture not initialized.");
382 Test.fail ();
383 return;
384 }
385
386 bool visible;
387
388 try {
389 visible = true;
390 Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible");
391 } catch (SpawnError error) {
392 Test.message ("error: %s", error.message);
393 Test.fail ();
394 return;
395 }
396
397 var action_group = DBusActionGroup.get ((!) fixture.connection,
398 "com.canonical.indicator.keyboard",
399 "/com/canonical/indicator/keyboard");
400 var loop = new MainLoop (null, false);
401 var signal_name = action_group.action_added["indicator"].connect ((action) => {
402 loop.quit ();
403 });
404
405 action_group.list_actions ();
406
407 var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
408 loop.run ();
409 Source.remove (source);
410 action_group.disconnect (signal_name);
411
412 var state = action_group.get_action_state ("indicator");
413 assert (((!) state).lookup ("visible", "b", out visible));
414 assert (visible);
415
416 loop = new MainLoop (null, false);
417 signal_name = action_group.action_state_changed["indicator"].connect ((action, state) => {
418 loop.quit ();
419 });
420
421 try {
422 visible = false;
423 Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible");
424 } catch (SpawnError error) {
425 Test.message ("error: %s", error.message);
426 Test.fail ();
427 return;
428 }
429
430 source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
431 loop.run ();
432 Source.remove (source);
433 action_group.disconnect (signal_name);
434
435 state = action_group.get_action_state ("indicator");
436 assert (((!) state).lookup ("visible", "b", out visible));
437 assert (!visible);
438
439 loop = new MainLoop (null, false);
440 signal_name = action_group.action_state_changed["indicator"].connect ((action, state) => {
441 loop.quit ();
442 });
443
444 try {
445 visible = true;
446 Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible");
447 } catch (SpawnError error) {
448 Test.message ("error: %s", error.message);
449 Test.fail ();
450 return;
451 }
452
453 source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
454 loop.run ();
455 Source.remove (source);
456 action_group.disconnect (signal_name);
457
458 state = action_group.get_action_state ("indicator");
459 assert (((!) state).lookup ("visible", "b", out visible));
460 assert (visible);
461}
462
463static void test_update_input_source (void *data) {
464 var fixture = (Fixture *) data;
465
466 if (fixture.object_name == 0) {
467 Test.message ("error: Test fixture not initialized.");
468 Test.fail ();
469 return;
470 }
471
472 try {
473 var current = 0;
474 var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]";
475 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current");
476 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\"");
477 } catch (SpawnError error) {
478 Test.message ("error: %s", error.message);
479 Test.fail ();
480 return;
481 }
482
483 var action_group = DBusActionGroup.get ((!) fixture.connection,
484 "com.canonical.indicator.keyboard",
485 "/com/canonical/indicator/keyboard");
486 var loop = new MainLoop (null, false);
487 var signal_name = action_group.action_state_changed["current"].connect ((action, state) => {
488 loop.quit ();
489 });
490
491 action_group.list_actions ();
492
493 try {
494 var current = 1;
495 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current");
496 } catch (SpawnError error) {
497 Test.message ("error: %s", error.message);
498 Test.fail ();
499 return;
500 }
501
502 var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
503 loop.run ();
504 Source.remove (source);
505 action_group.disconnect (signal_name);
506
507 var state = action_group.get_action_state ("current");
508 var current = ((!) state).get_uint32 ();
509 assert (current == 1);
510
511 try {
512 string output;
513 Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output);
514 assert (strcmp (output, "uint32 1\n") == 0);
515 } catch (SpawnError error) {
516 Test.message ("error: %s", error.message);
517 Test.fail ();
518 return;
519 }
520
521 loop = new MainLoop (null, false);
522 signal_name = action_group.action_state_changed["current"].connect ((action, state) => {
523 loop.quit ();
524 });
525
526 try {
527 current = 0;
528 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current");
529 } catch (SpawnError error) {
530 Test.message ("error: %s", error.message);
531 Test.fail ();
532 return;
533 }
534
535 source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
536 loop.run ();
537 Source.remove (source);
538 action_group.disconnect (signal_name);
539
540 state = action_group.get_action_state ("current");
541 current = ((!) state).get_uint32 ();
542 assert (current == 0);
543
544 try {
545 string output;
546 Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output);
547 assert (strcmp (output, "uint32 0\n") == 0);
548 } catch (SpawnError error) {
549 Test.message ("error: %s", error.message);
550 Test.fail ();
551 return;
552 }
553}
554
555static void test_update_input_sources (void *data) {
556 var fixture = (Fixture *) data;
557
558 if (fixture.object_name == 0) {
559 Test.message ("error: Test fixture not initialized.");
560 Test.fail ();
561 return;
562 }
563
564 try {
565 var current = 0;
566 var sources = "[('xkb', 'us')]";
567 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current");
568 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\"");
569 } catch (SpawnError error) {
570 Test.message ("error: %s", error.message);
571 Test.fail ();
572 return;
573 }
574
575 var menu_model = DBusMenuModel.get ((!) fixture.connection,
576 "com.canonical.indicator.keyboard",
577 "/com/canonical/indicator/keyboard/desktop");
578 var loop = new MainLoop (null, false);
579 var signal_name = menu_model.items_changed.connect ((position, removed, added) => {
580 loop.quit ();
581 });
582
583 menu_model.get_n_items ();
584
585 var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
586 loop.run ();
587 Source.remove (source);
588 menu_model.disconnect (signal_name);
589
590 var menu = menu_model.get_item_link (0, Menu.LINK_SUBMENU);
591 loop = new MainLoop (null, false);
592 signal_name = menu.items_changed.connect ((position, removed, added) => {
593 loop.quit ();
594 });
595
596 menu.get_n_items ();
597
598 source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
599 loop.run ();
600 Source.remove (source);
601 menu.disconnect (signal_name);
602
603 var section = menu.get_item_link (0, Menu.LINK_SECTION);
604 loop = new MainLoop (null, false);
605 signal_name = section.items_changed.connect ((position, removed, added) => {
606 loop.quit ();
607 });
608
609 section.get_n_items ();
610
611 source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
612 loop.run ();
613 Source.remove (source);
614 section.disconnect (signal_name);
615
616 string label;
617
618 assert (section.get_n_items () == 1);
619 section.get_item_attribute (0, Menu.ATTRIBUTE_LABEL, "s", out label);
620 assert (strcmp (label, "English (US)") == 0);
621
622 loop = new MainLoop (null, false);
623 signal_name = section.items_changed.connect ((position, removed, added) => {
624 if (section.get_n_items () == 4) {
625 loop.quit ();
626 }
627 });
628
629 try {
630 var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]";
631 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\"");
632 } catch (SpawnError error) {
633 Test.message ("error: %s", error.message);
634 Test.fail ();
635 return;
636 }
637
638 source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
639 loop.run ();
640 Source.remove (source);
641 section.disconnect (signal_name);
642
643 assert (section.get_n_items () == 4);
644 section.get_item_attribute (0, Menu.ATTRIBUTE_LABEL, "s", out label);
645 assert (strcmp (label, "English (US)") == 0);
646 section.get_item_attribute (1, Menu.ATTRIBUTE_LABEL, "s", out label);
647 assert (strcmp (label, "English (Canada)") == 0);
648 section.get_item_attribute (2, Menu.ATTRIBUTE_LABEL, "s", out label);
649 assert (strcmp (label, "Esperanto") == 0);
650 section.get_item_attribute (3, Menu.ATTRIBUTE_LABEL, "s", out label);
651 assert (strcmp (label, "Pinyin") == 0);
652}
653
654public int main (string[] args) {
655 Environment.set_variable ("DCONF_PROFILE", DCONF_PROFILE, true);
656 Environment.set_variable ("LC_ALL", "C", true);
657
658 Test.init (ref args, null);
659
660 var suite = new TestSuite ("indicator-keyboard");
661
662 suite.add (new TestCase ("activate-input-source", begin_test, test_activate_input_source, end_test, sizeof (Fixture)));
663 suite.add (new TestCase ("activate-character-map", begin_test, test_activate_character_map, end_test, sizeof (Fixture)));
664 suite.add (new TestCase ("activate-keyboard-layout-chart", begin_test, test_activate_keyboard_layout_chart, end_test, sizeof (Fixture)));
665 suite.add (new TestCase ("activate-text-entry-settings", begin_test, test_activate_text_entry_settings, end_test, sizeof (Fixture)));
666 suite.add (new TestCase ("migration", begin_test, test_migration, end_test, sizeof (Fixture)));
667 suite.add (new TestCase ("no-migration", begin_test, test_no_migration, end_test, sizeof (Fixture)));
668 suite.add (new TestCase ("update-visible", begin_test, test_update_visible, end_test, sizeof (Fixture)));
669 suite.add (new TestCase ("update-input-source", begin_test, test_update_input_source, end_test, sizeof (Fixture)));
670 suite.add (new TestCase ("update-input-sources", begin_test, test_update_input_sources, end_test, sizeof (Fixture)));
671
672 TestSuite.get_root ().add_suite (suite);
673
674 return Test.run ();
675}
6760
=== removed directory '.pc/relax-test-missing-ibus.patch'
=== removed directory '.pc/relax-test-missing-ibus.patch/tests'
=== removed file '.pc/relax-test-missing-ibus.patch/tests/main.vala'
--- .pc/relax-test-missing-ibus.patch/tests/main.vala 2013-07-17 20:06:48 +0000
+++ .pc/relax-test-missing-ibus.patch/tests/main.vala 1970-01-01 00:00:00 +0000
@@ -1,675 +0,0 @@
1const int TIMEOUT_S = 1;
2const int TIMEOUT_MS = 1000;
3
4[DBus (name = "com.canonical.indicator.keyboard.test")]
5public class Service : Object {
6
7 [DBus (visible = false)]
8 private string? _command;
9
10 [DBus (visible = false)]
11 public string? command {
12 get { return _command; }
13 }
14
15 public void execute (string command) {
16 this._command = command;
17
18 var pspec = this.get_class ().find_property ("command");
19
20 if (pspec != null) {
21 this.notify["command"] ((!) pspec);
22 }
23 }
24}
25
26struct Fixture {
27 TestDBus? bus;
28 uint service_name;
29 DBusConnection? connection;
30 Service? service;
31 uint object_name;
32}
33
34static void start_service (Fixture *fixture) {
35 if (fixture.connection != null) {
36 try {
37 fixture.service = new Service ();
38 fixture.object_name = ((!) fixture.connection).register_object ("/com/canonical/indicator/keyboard/test", fixture.service);
39 } catch (IOError error) {
40 fixture.connection = null;
41 fixture.service = null;
42 fixture.object_name = 0;
43
44 Test.message ("error: %s", error.message);
45 Test.fail ();
46 }
47 }
48}
49
50static void begin_test (void *data) {
51 var fixture = (Fixture *) data;
52
53 fixture.bus = new TestDBus (TestDBusFlags.NONE);
54 ((!) fixture.bus).add_service_dir (SERVICE_DIR);
55 ((!) fixture.bus).up ();
56
57 var loop = new MainLoop (null, false);
58
59 fixture.service_name = Bus.own_name (BusType.SESSION,
60 "com.canonical.indicator.keyboard.test",
61 BusNameOwnerFlags.ALLOW_REPLACEMENT | BusNameOwnerFlags.REPLACE,
62 (connection, name) => {
63 if (loop.is_running ()) {
64 fixture.connection = connection;
65
66 start_service (fixture);
67
68 loop.quit ();
69 }
70 },
71 null,
72 (connection, name) => {
73 if (loop.is_running ()) {
74 fixture.connection = null;
75 fixture.service = null;
76 fixture.object_name = 0;
77
78 loop.quit ();
79 }
80 });
81
82 loop.run ();
83
84 if (fixture.connection == null) {
85 Test.message ("error: Unable to connect to com.canonical.indicator.keyboard.test.");
86 Test.fail ();
87 }
88}
89
90static void end_test (void *data) {
91 var fixture = (Fixture *) data;
92
93 if (fixture.object_name != 0) {
94 ((!) fixture.connection).unregister_object (fixture.object_name);
95 fixture.object_name = 0;
96 }
97
98 if (fixture.service_name != 0) {
99 Bus.unown_name (fixture.service_name);
100 fixture.service_name = 0;
101 }
102
103 fixture.service = null;
104 fixture.connection = null;
105
106 if (fixture.bus != null) {
107 ((!) fixture.bus).down ();
108 fixture.bus = null;
109 }
110}
111
112static void test_activate_input_source (void *data) {
113 var fixture = (Fixture *) data;
114
115 if (fixture.object_name == 0) {
116 Test.message ("error: Test fixture not initialized.");
117 Test.fail ();
118 return;
119 }
120
121 try {
122 var current = 0;
123 var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]";
124 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current");
125 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\"");
126 } catch (SpawnError error) {
127 Test.message ("error: %s", error.message);
128 Test.fail ();
129 return;
130 }
131
132 var action_group = DBusActionGroup.get ((!) fixture.connection,
133 "com.canonical.indicator.keyboard",
134 "/com/canonical/indicator/keyboard");
135 var loop = new MainLoop (null, false);
136 var signal_name = action_group.action_state_changed["current"].connect ((action, state) => {
137 loop.quit ();
138 });
139
140 action_group.list_actions ();
141 action_group.activate_action ("current", new Variant.uint32 (2));
142
143 var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
144 loop.run ();
145 Source.remove (source);
146 action_group.disconnect (signal_name);
147
148 var state = action_group.get_action_state ("current");
149 var current = state.get_uint32 ();
150 assert (current == 2);
151
152 try {
153 string output;
154 Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output);
155 assert (strcmp (output, "uint32 2\n") == 0);
156 } catch (SpawnError error) {
157 Test.message ("error: %s", error.message);
158 Test.fail ();
159 return;
160 }
161}
162
163static void test_activate_character_map (void *data) {
164 var fixture = (Fixture *) data;
165
166 if (fixture.object_name == 0) {
167 Test.message ("error: Test fixture not initialized.");
168 Test.fail ();
169 return;
170 }
171
172 var action_group = DBusActionGroup.get ((!) fixture.connection,
173 "com.canonical.indicator.keyboard",
174 "/com/canonical/indicator/keyboard");
175 var loop = new MainLoop (null, false);
176 var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => {
177 loop.quit ();
178 });
179
180 action_group.activate_action ("map", null);
181
182 var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
183 loop.run ();
184 Source.remove (source);
185 ((!) fixture.service).disconnect (signal_name);
186
187 assert (strcmp ((!) ((!) fixture.service).command, "'gucharmap '") == 0);
188}
189
190static void test_activate_keyboard_layout_chart (void *data) {
191 var fixture = (Fixture *) data;
192
193 if (fixture.object_name == 0) {
194 Test.message ("error: Test fixture not initialized.");
195 Test.fail ();
196 return;
197 }
198
199 try {
200 var current = 1;
201 var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]";
202 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current");
203 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\"");
204 } catch (SpawnError error) {
205 Test.message ("error: %s", error.message);
206 Test.fail ();
207 return;
208 }
209
210 var action_group = DBusActionGroup.get ((!) fixture.connection,
211 "com.canonical.indicator.keyboard",
212 "/com/canonical/indicator/keyboard");
213 var loop = new MainLoop (null, false);
214 var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => {
215 loop.quit ();
216 });
217
218 action_group.activate_action ("chart", null);
219
220 var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
221 loop.run ();
222 Source.remove (source);
223 ((!) fixture.service).disconnect (signal_name);
224
225 assert (strcmp ((!) ((!) fixture.service).command, "'gkbd-keyboard-display -l ca\teng'") == 0);
226}
227
228static void test_activate_text_entry_settings (void *data) {
229 var fixture = (Fixture *) data;
230
231 if (fixture.object_name == 0) {
232 Test.message ("error: Test fixture not initialized.");
233 Test.fail ();
234 return;
235 }
236
237 var action_group = DBusActionGroup.get ((!) fixture.connection,
238 "com.canonical.indicator.keyboard",
239 "/com/canonical/indicator/keyboard");
240 var loop = new MainLoop (null, false);
241 var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => {
242 loop.quit ();
243 });
244
245 action_group.activate_action ("settings", null);
246
247 var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
248 loop.run ();
249 Source.remove (source);
250 ((!) fixture.service).disconnect (signal_name);
251
252 assert (strcmp ((!) ((!) fixture.service).command, "'gnome-control-center region layouts'") == 0);
253}
254
255static void test_migration (void *data) {
256 var fixture = (Fixture *) data;
257
258 if (fixture.object_name == 0) {
259 Test.message ("error: Test fixture not initialized.");
260 Test.fail ();
261 return;
262 }
263
264 try {
265 var migrated = false;
266 var sources = "[('xkb', 'us')]";
267 var layouts = "['us', 'ca\teng', 'epo']";
268 Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard migrated $migrated");
269 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\"");
270 Process.spawn_command_line_sync (@"gsettings set org.gnome.libgnomekbd.keyboard layouts \"$layouts\"");
271 } catch (SpawnError error) {
272 Test.message ("error: %s", error.message);
273 Test.fail ();
274 return;
275 }
276
277 try {
278 var cancellable = new Cancellable ();
279
280 var source = Timeout.add_seconds (TIMEOUT_S, () => { cancellable.cancel (); return false; });
281
282 var dbus_proxy = new DBusProxy.sync ((!) fixture.connection,
283 DBusProxyFlags.NONE,
284 null,
285 "org.freedesktop.DBus",
286 "/",
287 "org.freedesktop.DBus",
288 cancellable);
289
290 Source.remove (source);
291
292 if (cancellable.is_cancelled ()) {
293 Test.message ("error: Unable to connect to org.freedesktop.DBus.");
294 Test.fail ();
295 return;
296 }
297
298 dbus_proxy.call_sync ("StartServiceByName", new Variant ("(su)", "com.canonical.indicator.keyboard", 0), DBusCallFlags.NONE, TIMEOUT_MS);
299 } catch (Error error) {
300 Test.message ("error: %s", error.message);
301 Test.fail ();
302 return;
303 }
304
305 try {
306 string sources;
307 Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources sources", out sources);
308 assert (strcmp (sources, "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo')]\n") == 0);
309 } catch (SpawnError error) {
310 Test.message ("error: %s", error.message);
311 Test.fail ();
312 return;
313 }
314}
315
316static void test_no_migration (void *data) {
317 var fixture = (Fixture *) data;
318
319 if (fixture.object_name == 0) {
320 Test.message ("error: Test fixture not initialized.");
321 Test.fail ();
322 return;
323 }
324
325 try {
326 var migrated = true;
327 var sources = "[('xkb', 'us')]";
328 var layouts = "['us', 'ca\teng', 'epo']";
329 Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard migrated $migrated");
330 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\"");
331 Process.spawn_command_line_sync (@"gsettings set org.gnome.libgnomekbd.keyboard layouts \"$layouts\"");
332 } catch (SpawnError error) {
333 Test.message ("error: %s", error.message);
334 Test.fail ();
335 return;
336 }
337
338 try {
339 var cancellable = new Cancellable ();
340
341 var source = Timeout.add_seconds (TIMEOUT_S, () => { cancellable.cancel (); return false; });
342
343 var dbus_proxy = new DBusProxy.sync ((!) fixture.connection,
344 DBusProxyFlags.NONE,
345 null,
346 "org.freedesktop.DBus",
347 "/",
348 "org.freedesktop.DBus",
349 cancellable);
350
351 Source.remove (source);
352
353 if (cancellable.is_cancelled ()) {
354 Test.message ("error: Unable to connect to org.freedesktop.DBus.");
355 Test.fail ();
356 return;
357 }
358
359 dbus_proxy.call_sync ("StartServiceByName", new Variant ("(su)", "com.canonical.indicator.keyboard", 0), DBusCallFlags.NONE, TIMEOUT_MS);
360 } catch (Error error) {
361 Test.message ("error: %s", error.message);
362 Test.fail ();
363 return;
364 }
365
366 try {
367 string sources;
368 Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources sources", out sources);
369 assert (strcmp (sources, "[('xkb', 'us')]\n") == 0);
370 } catch (SpawnError error) {
371 Test.message ("error: %s", error.message);
372 Test.fail ();
373 return;
374 }
375}
376
377static void test_update_visible (void *data) {
378 var fixture = (Fixture *) data;
379
380 if (fixture.object_name == 0) {
381 Test.message ("error: Test fixture not initialized.");
382 Test.fail ();
383 return;
384 }
385
386 bool visible;
387
388 try {
389 visible = true;
390 Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible");
391 } catch (SpawnError error) {
392 Test.message ("error: %s", error.message);
393 Test.fail ();
394 return;
395 }
396
397 var action_group = DBusActionGroup.get ((!) fixture.connection,
398 "com.canonical.indicator.keyboard",
399 "/com/canonical/indicator/keyboard");
400 var loop = new MainLoop (null, false);
401 var signal_name = action_group.action_added["indicator"].connect ((action) => {
402 loop.quit ();
403 });
404
405 action_group.list_actions ();
406
407 var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
408 loop.run ();
409 Source.remove (source);
410 action_group.disconnect (signal_name);
411
412 var state = action_group.get_action_state ("indicator");
413 assert (state.lookup ("visible", "b", out visible));
414 assert (visible);
415
416 loop = new MainLoop (null, false);
417 signal_name = action_group.action_state_changed["indicator"].connect ((action, state) => {
418 loop.quit ();
419 });
420
421 try {
422 visible = false;
423 Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible");
424 } catch (SpawnError error) {
425 Test.message ("error: %s", error.message);
426 Test.fail ();
427 return;
428 }
429
430 source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
431 loop.run ();
432 Source.remove (source);
433 action_group.disconnect (signal_name);
434
435 state = action_group.get_action_state ("indicator");
436 assert (state.lookup ("visible", "b", out visible));
437 assert (!visible);
438
439 loop = new MainLoop (null, false);
440 signal_name = action_group.action_state_changed["indicator"].connect ((action, state) => {
441 loop.quit ();
442 });
443
444 try {
445 visible = true;
446 Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible");
447 } catch (SpawnError error) {
448 Test.message ("error: %s", error.message);
449 Test.fail ();
450 return;
451 }
452
453 source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
454 loop.run ();
455 Source.remove (source);
456 action_group.disconnect (signal_name);
457
458 state = action_group.get_action_state ("indicator");
459 assert (state.lookup ("visible", "b", out visible));
460 assert (visible);
461}
462
463static void test_update_input_source (void *data) {
464 var fixture = (Fixture *) data;
465
466 if (fixture.object_name == 0) {
467 Test.message ("error: Test fixture not initialized.");
468 Test.fail ();
469 return;
470 }
471
472 try {
473 var current = 0;
474 var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]";
475 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current");
476 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\"");
477 } catch (SpawnError error) {
478 Test.message ("error: %s", error.message);
479 Test.fail ();
480 return;
481 }
482
483 var action_group = DBusActionGroup.get ((!) fixture.connection,
484 "com.canonical.indicator.keyboard",
485 "/com/canonical/indicator/keyboard");
486 var loop = new MainLoop (null, false);
487 var signal_name = action_group.action_state_changed["current"].connect ((action, state) => {
488 loop.quit ();
489 });
490
491 action_group.list_actions ();
492
493 try {
494 var current = 1;
495 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current");
496 } catch (SpawnError error) {
497 Test.message ("error: %s", error.message);
498 Test.fail ();
499 return;
500 }
501
502 var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
503 loop.run ();
504 Source.remove (source);
505 action_group.disconnect (signal_name);
506
507 var state = action_group.get_action_state ("current");
508 var current = state.get_uint32 ();
509 assert (current == 1);
510
511 try {
512 string output;
513 Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output);
514 assert (strcmp (output, "uint32 1\n") == 0);
515 } catch (SpawnError error) {
516 Test.message ("error: %s", error.message);
517 Test.fail ();
518 return;
519 }
520
521 loop = new MainLoop (null, false);
522 signal_name = action_group.action_state_changed["current"].connect ((action, state) => {
523 loop.quit ();
524 });
525
526 try {
527 current = 0;
528 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current");
529 } catch (SpawnError error) {
530 Test.message ("error: %s", error.message);
531 Test.fail ();
532 return;
533 }
534
535 source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
536 loop.run ();
537 Source.remove (source);
538 action_group.disconnect (signal_name);
539
540 state = action_group.get_action_state ("current");
541 current = state.get_uint32 ();
542 assert (current == 0);
543
544 try {
545 string output;
546 Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output);
547 assert (strcmp (output, "uint32 0\n") == 0);
548 } catch (SpawnError error) {
549 Test.message ("error: %s", error.message);
550 Test.fail ();
551 return;
552 }
553}
554
555static void test_update_input_sources (void *data) {
556 var fixture = (Fixture *) data;
557
558 if (fixture.object_name == 0) {
559 Test.message ("error: Test fixture not initialized.");
560 Test.fail ();
561 return;
562 }
563
564 try {
565 var current = 0;
566 var sources = "[('xkb', 'us')]";
567 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current");
568 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\"");
569 } catch (SpawnError error) {
570 Test.message ("error: %s", error.message);
571 Test.fail ();
572 return;
573 }
574
575 var menu_model = DBusMenuModel.get ((!) fixture.connection,
576 "com.canonical.indicator.keyboard",
577 "/com/canonical/indicator/keyboard/desktop");
578 var loop = new MainLoop (null, false);
579 var signal_name = menu_model.items_changed.connect ((position, removed, added) => {
580 loop.quit ();
581 });
582
583 menu_model.get_n_items ();
584
585 var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
586 loop.run ();
587 Source.remove (source);
588 menu_model.disconnect (signal_name);
589
590 var menu = menu_model.get_item_link (0, Menu.LINK_SUBMENU);
591 loop = new MainLoop (null, false);
592 signal_name = menu.items_changed.connect ((position, removed, added) => {
593 loop.quit ();
594 });
595
596 menu.get_n_items ();
597
598 source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
599 loop.run ();
600 Source.remove (source);
601 menu.disconnect (signal_name);
602
603 var section = menu.get_item_link (0, Menu.LINK_SECTION);
604 loop = new MainLoop (null, false);
605 signal_name = section.items_changed.connect ((position, removed, added) => {
606 loop.quit ();
607 });
608
609 section.get_n_items ();
610
611 source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
612 loop.run ();
613 Source.remove (source);
614 section.disconnect (signal_name);
615
616 string label;
617
618 assert (section.get_n_items () == 1);
619 section.get_item_attribute (0, Menu.ATTRIBUTE_LABEL, "s", out label);
620 assert (strcmp (label, "English (US)") == 0);
621
622 loop = new MainLoop (null, false);
623 signal_name = section.items_changed.connect ((position, removed, added) => {
624 if (section.get_n_items () == 4) {
625 loop.quit ();
626 }
627 });
628
629 try {
630 var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]";
631 Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\"");
632 } catch (SpawnError error) {
633 Test.message ("error: %s", error.message);
634 Test.fail ();
635 return;
636 }
637
638 source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; });
639 loop.run ();
640 Source.remove (source);
641 section.disconnect (signal_name);
642
643 assert (section.get_n_items () == 4);
644 section.get_item_attribute (0, Menu.ATTRIBUTE_LABEL, "s", out label);
645 assert (strcmp (label, "English (US)") == 0);
646 section.get_item_attribute (1, Menu.ATTRIBUTE_LABEL, "s", out label);
647 assert (strcmp (label, "English (Canada)") == 0);
648 section.get_item_attribute (2, Menu.ATTRIBUTE_LABEL, "s", out label);
649 assert (strcmp (label, "Esperanto") == 0);
650 section.get_item_attribute (3, Menu.ATTRIBUTE_LABEL, "s", out label);
651 assert (strcmp (label, "Pinyin") == 0);
652}
653
654public int main (string[] args) {
655 Environment.set_variable ("DCONF_PROFILE", DCONF_PROFILE, true);
656 Environment.set_variable ("LC_ALL", "C", true);
657
658 Test.init (ref args, null);
659
660 var suite = new TestSuite ("indicator-keyboard");
661
662 suite.add (new TestCase ("activate-input-source", begin_test, test_activate_input_source, end_test, sizeof (Fixture)));
663 suite.add (new TestCase ("activate-character-map", begin_test, test_activate_character_map, end_test, sizeof (Fixture)));
664 suite.add (new TestCase ("activate-keyboard-layout-chart", begin_test, test_activate_keyboard_layout_chart, end_test, sizeof (Fixture)));
665 suite.add (new TestCase ("activate-text-entry-settings", begin_test, test_activate_text_entry_settings, end_test, sizeof (Fixture)));
666 suite.add (new TestCase ("migration", begin_test, test_migration, end_test, sizeof (Fixture)));
667 suite.add (new TestCase ("no-migration", begin_test, test_no_migration, end_test, sizeof (Fixture)));
668 suite.add (new TestCase ("update-visible", begin_test, test_update_visible, end_test, sizeof (Fixture)));
669 suite.add (new TestCase ("update-input-source", begin_test, test_update_input_source, end_test, sizeof (Fixture)));
670 suite.add (new TestCase ("update-input-sources", begin_test, test_update_input_sources, end_test, sizeof (Fixture)));
671
672 TestSuite.get_root ().add_suite (suite);
673
674 return Test.run ();
675}
6760
=== removed directory 'debian/patches'
=== removed file 'debian/patches/default-icon-colour.patch'
--- debian/patches/default-icon-colour.patch 2013-07-17 18:47:22 +0000
+++ debian/patches/default-icon-colour.patch 1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
1--- a/lib/main.vala
2+++ b/lib/main.vala
3@@ -207,6 +207,7 @@
4
5 Pango.FontDescription description;
6 var colour = ((!) style).get_color (Gtk.StateFlags.NORMAL);
7+ colour = { 0.5, 0.5, 0.5, 1.0 };
8 ((!) style).get (Gtk.StateFlags.NORMAL, Gtk.STYLE_PROPERTY_FONT, out description);
9
10 var surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, W, H);
110
=== removed file 'debian/patches/disable-experimental-non-null.patch'
--- debian/patches/disable-experimental-non-null.patch 2013-07-17 19:17:32 +0000
+++ debian/patches/disable-experimental-non-null.patch 1970-01-01 00:00:00 +0000
@@ -1,68 +0,0 @@
1--- a/tests/Makefile.am
2+++ b/tests/Makefile.am
3@@ -4,8 +4,7 @@
4
5 AM_CFLAGS = -w
6 AM_LDFLAGS = -lm
7-AM_VALAFLAGS = --enable-experimental-non-null \
8- --metadatadir $(top_srcdir)/deps \
9+AM_VALAFLAGS = --metadatadir $(top_srcdir)/deps \
10 --vapidir $(top_srcdir)/deps
11
12 indicator_keyboard_tests_SOURCES = main.vala \
13--- a/tests/main.vala
14+++ b/tests/main.vala
15@@ -146,7 +146,7 @@
16 action_group.disconnect (signal_name);
17
18 var state = action_group.get_action_state ("current");
19- var current = ((!) state).get_uint32 ();
20+ var current = state.get_uint32 ();
21 assert (current == 2);
22
23 try {
24@@ -410,7 +410,7 @@
25 action_group.disconnect (signal_name);
26
27 var state = action_group.get_action_state ("indicator");
28- assert (((!) state).lookup ("visible", "b", out visible));
29+ assert (state.lookup ("visible", "b", out visible));
30 assert (visible);
31
32 loop = new MainLoop (null, false);
33@@ -433,7 +433,7 @@
34 action_group.disconnect (signal_name);
35
36 state = action_group.get_action_state ("indicator");
37- assert (((!) state).lookup ("visible", "b", out visible));
38+ assert (state.lookup ("visible", "b", out visible));
39 assert (!visible);
40
41 loop = new MainLoop (null, false);
42@@ -456,7 +456,7 @@
43 action_group.disconnect (signal_name);
44
45 state = action_group.get_action_state ("indicator");
46- assert (((!) state).lookup ("visible", "b", out visible));
47+ assert (state.lookup ("visible", "b", out visible));
48 assert (visible);
49 }
50
51@@ -505,7 +505,7 @@
52 action_group.disconnect (signal_name);
53
54 var state = action_group.get_action_state ("current");
55- var current = ((!) state).get_uint32 ();
56+ var current = state.get_uint32 ();
57 assert (current == 1);
58
59 try {
60@@ -538,7 +538,7 @@
61 action_group.disconnect (signal_name);
62
63 state = action_group.get_action_state ("current");
64- current = ((!) state).get_uint32 ();
65+ current = state.get_uint32 ();
66 assert (current == 0);
67
68 try {
690
=== removed file 'debian/patches/relax-test-missing-ibus.patch'
--- debian/patches/relax-test-missing-ibus.patch 2013-07-17 20:06:48 +0000
+++ debian/patches/relax-test-missing-ibus.patch 1970-01-01 00:00:00 +0000
@@ -1,11 +0,0 @@
1--- a/tests/main.vala
2+++ b/tests/main.vala
3@@ -648,7 +648,7 @@
4 section.get_item_attribute (2, Menu.ATTRIBUTE_LABEL, "s", out label);
5 assert (strcmp (label, "Esperanto") == 0);
6 section.get_item_attribute (3, Menu.ATTRIBUTE_LABEL, "s", out label);
7- assert (strcmp (label, "Pinyin") == 0);
8+ assert (label.ascii_casecmp ("Pinyin") == 0);
9 }
10
11 public int main (string[] args) {
120
=== removed file 'debian/patches/series'
--- debian/patches/series 2013-07-17 20:06:48 +0000
+++ debian/patches/series 1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
1default-icon-colour.patch
2disable-experimental-non-null.patch
3relax-test-missing-ibus.patch

Subscribers

People subscribed via source and target branches

to all changes: