Merge lp:~jbicha/indicator-keyboard/drop-patches into lp:indicator-keyboard
- drop-patches
- Merge into trunk
Proposed by
Jeremy Bícha
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
William Hua (community) | Approve | ||
Review via email: mp+177306@code.launchpad.net |
Commit message
Description of the change
the upstream branch shouldn't need patches...
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === removed directory '.pc' | |||
2 | === removed file '.pc/.quilt_patches' | |||
3 | --- .pc/.quilt_patches 2013-06-22 20:26:13 +0000 | |||
4 | +++ .pc/.quilt_patches 1970-01-01 00:00:00 +0000 | |||
5 | @@ -1,1 +0,0 @@ | |||
6 | 1 | debian/patches | ||
7 | 2 | 0 | ||
8 | === removed file '.pc/.quilt_series' | |||
9 | --- .pc/.quilt_series 2013-06-22 20:26:13 +0000 | |||
10 | +++ .pc/.quilt_series 1970-01-01 00:00:00 +0000 | |||
11 | @@ -1,1 +0,0 @@ | |||
12 | 1 | series | ||
13 | 2 | 0 | ||
14 | === removed file '.pc/.version' | |||
15 | --- .pc/.version 2013-06-22 20:26:13 +0000 | |||
16 | +++ .pc/.version 1970-01-01 00:00:00 +0000 | |||
17 | @@ -1,1 +0,0 @@ | |||
18 | 1 | 2 | ||
19 | 2 | 0 | ||
20 | === removed file '.pc/applied-patches' | |||
21 | --- .pc/applied-patches 2013-07-17 20:06:48 +0000 | |||
22 | +++ .pc/applied-patches 1970-01-01 00:00:00 +0000 | |||
23 | @@ -1,3 +0,0 @@ | |||
24 | 1 | default-icon-colour.patch | ||
25 | 2 | disable-experimental-non-null.patch | ||
26 | 3 | relax-test-missing-ibus.patch | ||
27 | 4 | 0 | ||
28 | === removed directory '.pc/default-icon-colour.patch' | |||
29 | === removed directory '.pc/default-icon-colour.patch/lib' | |||
30 | === removed file '.pc/default-icon-colour.patch/lib/main.vala' | |||
31 | --- .pc/default-icon-colour.patch/lib/main.vala 2013-07-17 18:47:22 +0000 | |||
32 | +++ .pc/default-icon-colour.patch/lib/main.vala 1970-01-01 00:00:00 +0000 | |||
33 | @@ -1,754 +0,0 @@ | |||
34 | 1 | [DBus (name = "com.canonical.indicator.keyboard")] | ||
35 | 2 | public class Indicator.Keyboard.Service : Object { | ||
36 | 3 | |||
37 | 4 | private bool use_gtk; | ||
38 | 5 | private bool use_bamf; | ||
39 | 6 | private MainLoop? loop; | ||
40 | 7 | private Settings indicator_settings; | ||
41 | 8 | private Settings source_settings; | ||
42 | 9 | private Settings per_window_settings; | ||
43 | 10 | private Gnome.XkbInfo xkb_info; | ||
44 | 11 | private IBus.Bus? ibus; | ||
45 | 12 | private Bamf.Matcher? matcher; | ||
46 | 13 | private Gee.HashMap<string, uint>? window_sources; | ||
47 | 14 | |||
48 | 15 | private SimpleActionGroup? action_group; | ||
49 | 16 | private SimpleAction? indicator_action; | ||
50 | 17 | private MenuModel? menu_model; | ||
51 | 18 | private Menu? sources_menu; | ||
52 | 19 | |||
53 | 20 | private Icon?[]? icons; | ||
54 | 21 | private string[]? icon_strings; | ||
55 | 22 | private int[]? icon_string_uniques; | ||
56 | 23 | private uint[]? icon_string_subscripts; | ||
57 | 24 | |||
58 | 25 | [DBus (visible = false)] | ||
59 | 26 | public Service (ref unowned string[] args) { | ||
60 | 27 | Bus.own_name (BusType.SESSION, | ||
61 | 28 | "com.canonical.indicator.keyboard", | ||
62 | 29 | BusNameOwnerFlags.ALLOW_REPLACEMENT | ("--force" in args ? BusNameOwnerFlags.REPLACE : 0), | ||
63 | 30 | this.handle_bus_acquired, | ||
64 | 31 | null, | ||
65 | 32 | this.handle_name_lost); | ||
66 | 33 | |||
67 | 34 | this.use_gtk = "--use-gtk" in args; | ||
68 | 35 | this.use_bamf = "--use-bamf" in args; | ||
69 | 36 | |||
70 | 37 | if (this.use_gtk) { | ||
71 | 38 | this.use_gtk = Gtk.init_check (ref args); | ||
72 | 39 | } else { | ||
73 | 40 | Gdk.init (ref args); | ||
74 | 41 | } | ||
75 | 42 | |||
76 | 43 | this.indicator_settings = new Settings ("com.canonical.indicator.keyboard"); | ||
77 | 44 | this.indicator_settings.changed["visible"].connect (this.handle_changed_visible); | ||
78 | 45 | |||
79 | 46 | this.source_settings = new Settings ("org.gnome.desktop.input-sources"); | ||
80 | 47 | this.source_settings.changed["current"].connect (this.handle_changed_current); | ||
81 | 48 | this.source_settings.changed["sources"].connect (this.handle_changed_sources); | ||
82 | 49 | |||
83 | 50 | this.per_window_settings = new Settings ("org.gnome.libgnomekbd.desktop"); | ||
84 | 51 | this.per_window_settings.changed["group-per-window"].connect (this.handle_changed_group_per_window); | ||
85 | 52 | |||
86 | 53 | this.xkb_info = new Gnome.XkbInfo (); | ||
87 | 54 | |||
88 | 55 | migrate_keyboard_layouts (); | ||
89 | 56 | |||
90 | 57 | update_window_sources (); | ||
91 | 58 | |||
92 | 59 | this.loop = new MainLoop (); | ||
93 | 60 | ((!) this.loop).run (); | ||
94 | 61 | } | ||
95 | 62 | |||
96 | 63 | [DBus (visible = false)] | ||
97 | 64 | private IBus.Bus get_ibus () { | ||
98 | 65 | if (this.ibus == null) { | ||
99 | 66 | IBus.init (); | ||
100 | 67 | this.ibus = new IBus.Bus (); | ||
101 | 68 | } | ||
102 | 69 | |||
103 | 70 | return (!) this.ibus; | ||
104 | 71 | } | ||
105 | 72 | |||
106 | 73 | [DBus (visible = false)] | ||
107 | 74 | private void migrate_keyboard_layouts () { | ||
108 | 75 | if (!this.indicator_settings.get_boolean ("migrated")) { | ||
109 | 76 | var builder = new VariantBuilder (new VariantType ("a(ss)")); | ||
110 | 77 | var length = 0; | ||
111 | 78 | |||
112 | 79 | var layout_settings = new Settings ("org.gnome.libgnomekbd.keyboard"); | ||
113 | 80 | var layouts = layout_settings.get_strv ("layouts"); | ||
114 | 81 | |||
115 | 82 | foreach (var layout in layouts) { | ||
116 | 83 | var source = layout; | ||
117 | 84 | |||
118 | 85 | source = source.replace (" ", "+"); | ||
119 | 86 | source = source.replace ("\t", "+"); | ||
120 | 87 | |||
121 | 88 | builder.add ("(ss)", "xkb", source); | ||
122 | 89 | length++; | ||
123 | 90 | } | ||
124 | 91 | |||
125 | 92 | var engines = get_ibus ().list_active_engines (); | ||
126 | 93 | |||
127 | 94 | foreach (var engine in engines) { | ||
128 | 95 | if (length == 0 || engine.name.has_prefix ("xkb")) { | ||
129 | 96 | var source = "us"; | ||
130 | 97 | string? layout = engine.get_layout (); | ||
131 | 98 | string? variant = engine.get_layout_variant (); | ||
132 | 99 | |||
133 | 100 | if (layout != null && ((!) layout).length == 0) { | ||
134 | 101 | layout = null; | ||
135 | 102 | } | ||
136 | 103 | |||
137 | 104 | if (variant != null && ((!) variant).length == 0) { | ||
138 | 105 | variant = null; | ||
139 | 106 | } | ||
140 | 107 | |||
141 | 108 | if (layout != null && variant != null) { | ||
142 | 109 | source = @"$((!) layout)+$((!) variant)"; | ||
143 | 110 | } else if (layout != null) { | ||
144 | 111 | source = (!) layout; | ||
145 | 112 | } | ||
146 | 113 | |||
147 | 114 | builder.add ("(ss)", "xkb", source); | ||
148 | 115 | length++; | ||
149 | 116 | } | ||
150 | 117 | |||
151 | 118 | if (!engine.name.has_prefix ("xkb")) { | ||
152 | 119 | builder.add ("(ss)", "ibus", engine.name); | ||
153 | 120 | length++; | ||
154 | 121 | } | ||
155 | 122 | } | ||
156 | 123 | |||
157 | 124 | this.source_settings.set_value ("sources", builder.end ()); | ||
158 | 125 | |||
159 | 126 | this.indicator_settings.set_boolean ("migrated", true); | ||
160 | 127 | } | ||
161 | 128 | } | ||
162 | 129 | |||
163 | 130 | [DBus (visible = false)] | ||
164 | 131 | private void update_window_sources () { | ||
165 | 132 | if (this.use_bamf) { | ||
166 | 133 | var group_per_window = this.per_window_settings.get_boolean ("group-per-window"); | ||
167 | 134 | |||
168 | 135 | if (group_per_window != (this.window_sources != null)) { | ||
169 | 136 | if (group_per_window) { | ||
170 | 137 | this.window_sources = new Gee.HashMap<string, uint> (); | ||
171 | 138 | this.matcher = Bamf.Matcher.get_default (); | ||
172 | 139 | ((!) this.matcher).active_window_changed.connect (this.handle_active_window_changed); | ||
173 | 140 | } else { | ||
174 | 141 | ((!) this.matcher).active_window_changed.disconnect (this.handle_active_window_changed); | ||
175 | 142 | this.matcher = null; | ||
176 | 143 | this.window_sources = null; | ||
177 | 144 | } | ||
178 | 145 | } | ||
179 | 146 | } | ||
180 | 147 | } | ||
181 | 148 | |||
182 | 149 | [DBus (visible = false)] | ||
183 | 150 | private void handle_changed_group_per_window (string key) { | ||
184 | 151 | update_window_sources (); | ||
185 | 152 | } | ||
186 | 153 | |||
187 | 154 | [DBus (visible = false)] | ||
188 | 155 | private void handle_active_window_changed (Bamf.View? old_view, Bamf.View? new_view) { | ||
189 | 156 | if (old_view != null) { | ||
190 | 157 | ((!) this.window_sources)[((!) old_view).path] = this.source_settings.get_uint ("current"); | ||
191 | 158 | } | ||
192 | 159 | |||
193 | 160 | if (new_view != null) { | ||
194 | 161 | if (!((!) this.window_sources).has_key (((!) new_view).path)) { | ||
195 | 162 | var default_group = this.per_window_settings.get_int ("default-group"); | ||
196 | 163 | |||
197 | 164 | if (default_group >= 0) { | ||
198 | 165 | this.source_settings.set_uint ("current", (uint) default_group); | ||
199 | 166 | } | ||
200 | 167 | } else { | ||
201 | 168 | this.source_settings.set_uint ("current", ((!) this.window_sources)[((!) new_view).path]); | ||
202 | 169 | } | ||
203 | 170 | } | ||
204 | 171 | } | ||
205 | 172 | |||
206 | 173 | [DBus (visible = false)] | ||
207 | 174 | private Gtk.StyleContext? get_style_context () { | ||
208 | 175 | Gtk.StyleContext? context = null; | ||
209 | 176 | |||
210 | 177 | if (this.use_gtk) { | ||
211 | 178 | Gdk.Screen? screen = Gdk.Screen.get_default (); | ||
212 | 179 | |||
213 | 180 | if (screen != null) { | ||
214 | 181 | context = new Gtk.StyleContext (); | ||
215 | 182 | ((!) context).set_screen ((!) screen); | ||
216 | 183 | |||
217 | 184 | var path = new Gtk.WidgetPath (); | ||
218 | 185 | path.append_type (typeof (Gtk.MenuItem)); | ||
219 | 186 | ((!) context).set_path (path); | ||
220 | 187 | } | ||
221 | 188 | } | ||
222 | 189 | |||
223 | 190 | return context; | ||
224 | 191 | } | ||
225 | 192 | |||
226 | 193 | [DBus (visible = false)] | ||
227 | 194 | protected virtual Icon? create_icon (string? text, uint subscript) { | ||
228 | 195 | Icon? icon = null; | ||
229 | 196 | |||
230 | 197 | var style = get_style_context (); | ||
231 | 198 | |||
232 | 199 | if (style != null) { | ||
233 | 200 | const int W = 22; | ||
234 | 201 | const int H = 22; | ||
235 | 202 | const int w = 20; | ||
236 | 203 | const int h = 20; | ||
237 | 204 | const double R = 2.0; | ||
238 | 205 | const double TEXT_SIZE = 12.0; | ||
239 | 206 | const double SUBSCRIPT_SIZE = 8.0; | ||
240 | 207 | |||
241 | 208 | Pango.FontDescription description; | ||
242 | 209 | var colour = ((!) style).get_color (Gtk.StateFlags.NORMAL); | ||
243 | 210 | ((!) style).get (Gtk.StateFlags.NORMAL, Gtk.STYLE_PROPERTY_FONT, out description); | ||
244 | 211 | |||
245 | 212 | var surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, W, H); | ||
246 | 213 | var context = new Cairo.Context (surface); | ||
247 | 214 | |||
248 | 215 | context.translate (0.5 * (W - w), 0.5 * (H - h)); | ||
249 | 216 | |||
250 | 217 | context.new_sub_path (); | ||
251 | 218 | context.arc (R, R, R, Math.PI, -0.5 * Math.PI); | ||
252 | 219 | context.arc (w - R, R, R, -0.5 * Math.PI, 0); | ||
253 | 220 | context.arc (w - R, h - R, R, 0, 0.5 * Math.PI); | ||
254 | 221 | context.arc (R, h - R, R, 0.5 * Math.PI, Math.PI); | ||
255 | 222 | context.close_path (); | ||
256 | 223 | |||
257 | 224 | context.set_source_rgba (colour.red, colour.green, colour.blue, colour.alpha); | ||
258 | 225 | context.fill (); | ||
259 | 226 | context.set_operator (Cairo.Operator.CLEAR); | ||
260 | 227 | |||
261 | 228 | if (text != null) { | ||
262 | 229 | var text_layout = Pango.cairo_create_layout (context); | ||
263 | 230 | text_layout.set_alignment (Pango.Alignment.CENTER); | ||
264 | 231 | description.set_absolute_size (Pango.units_from_double (TEXT_SIZE)); | ||
265 | 232 | text_layout.set_font_description (description); | ||
266 | 233 | text_layout.set_text ((!) text, -1); | ||
267 | 234 | Pango.cairo_update_layout (context, text_layout); | ||
268 | 235 | int text_width; | ||
269 | 236 | int text_height; | ||
270 | 237 | text_layout.get_pixel_size (out text_width, out text_height); | ||
271 | 238 | |||
272 | 239 | if (subscript > 0) { | ||
273 | 240 | var subscript_layout = Pango.cairo_create_layout (context); | ||
274 | 241 | subscript_layout.set_alignment (Pango.Alignment.CENTER); | ||
275 | 242 | description.set_absolute_size (Pango.units_from_double (SUBSCRIPT_SIZE)); | ||
276 | 243 | subscript_layout.set_font_description (description); | ||
277 | 244 | subscript_layout.set_text (@"$subscript", -1); | ||
278 | 245 | Pango.cairo_update_layout (context, subscript_layout); | ||
279 | 246 | int subscript_width; | ||
280 | 247 | int subscript_height; | ||
281 | 248 | subscript_layout.get_pixel_size (out subscript_width, out subscript_height); | ||
282 | 249 | |||
283 | 250 | context.save (); | ||
284 | 251 | context.translate ((w - (text_width + subscript_width)) / 2, (h - text_height) / 2); | ||
285 | 252 | Pango.cairo_layout_path (context, text_layout); | ||
286 | 253 | context.fill (); | ||
287 | 254 | context.restore (); | ||
288 | 255 | |||
289 | 256 | context.save (); | ||
290 | 257 | context.translate ((w + (text_width - subscript_width)) / 2, (h + text_height) / 2 - subscript_height); | ||
291 | 258 | Pango.cairo_layout_path (context, subscript_layout); | ||
292 | 259 | context.fill (); | ||
293 | 260 | context.restore (); | ||
294 | 261 | } else { | ||
295 | 262 | context.save (); | ||
296 | 263 | context.translate ((w - text_width) / 2, (h - text_height) / 2); | ||
297 | 264 | Pango.cairo_layout_path (context, text_layout); | ||
298 | 265 | context.fill (); | ||
299 | 266 | context.restore (); | ||
300 | 267 | } | ||
301 | 268 | } | ||
302 | 269 | |||
303 | 270 | var buffer = new ByteArray (); | ||
304 | 271 | |||
305 | 272 | surface.write_to_png_stream ((data) => { | ||
306 | 273 | buffer.append (data); | ||
307 | 274 | return Cairo.Status.SUCCESS; | ||
308 | 275 | }); | ||
309 | 276 | |||
310 | 277 | icon = new BytesIcon (ByteArray.free_to_bytes ((owned) buffer)); | ||
311 | 278 | } | ||
312 | 279 | |||
313 | 280 | return icon; | ||
314 | 281 | } | ||
315 | 282 | |||
316 | 283 | [DBus (visible = false)] | ||
317 | 284 | private string get_icon_string (uint index) { | ||
318 | 285 | string? icon_string = null; | ||
319 | 286 | |||
320 | 287 | if (this.icon_strings == null) { | ||
321 | 288 | var array = this.source_settings.get_value ("sources"); | ||
322 | 289 | this.icon_strings = new string[array.n_children ()]; | ||
323 | 290 | } | ||
324 | 291 | |||
325 | 292 | if (index < ((!) this.icon_strings).length) { | ||
326 | 293 | icon_string = this.icon_strings[index]; | ||
327 | 294 | |||
328 | 295 | if (icon_string == null) { | ||
329 | 296 | var array = this.source_settings.get_value ("sources"); | ||
330 | 297 | |||
331 | 298 | string type; | ||
332 | 299 | string name; | ||
333 | 300 | |||
334 | 301 | array.get_child (index, "(ss)", out type, out name); | ||
335 | 302 | |||
336 | 303 | if (type == "xkb") { | ||
337 | 304 | string? short_name; | ||
338 | 305 | |||
339 | 306 | this.xkb_info.get_layout_info (name, null, out short_name, null, null); | ||
340 | 307 | |||
341 | 308 | if (short_name != null) { | ||
342 | 309 | this.icon_strings[index] = get_abbreviation ((!) short_name); | ||
343 | 310 | icon_string = this.icon_strings[index]; | ||
344 | 311 | } | ||
345 | 312 | } | ||
346 | 313 | } | ||
347 | 314 | } | ||
348 | 315 | |||
349 | 316 | if (icon_string == null) { | ||
350 | 317 | icon_string = ""; | ||
351 | 318 | } | ||
352 | 319 | |||
353 | 320 | return (!) icon_string; | ||
354 | 321 | } | ||
355 | 322 | |||
356 | 323 | [DBus (visible = false)] | ||
357 | 324 | private bool is_icon_string_unique (uint index) { | ||
358 | 325 | bool icon_string_unique = true; | ||
359 | 326 | |||
360 | 327 | if (this.icon_string_uniques == null) { | ||
361 | 328 | var array = this.source_settings.get_value ("sources"); | ||
362 | 329 | this.icon_string_uniques = new int[array.n_children ()]; | ||
363 | 330 | |||
364 | 331 | for (var i = 0; i < ((!) this.icon_string_uniques).length; i++) { | ||
365 | 332 | this.icon_string_uniques[i] = -1; | ||
366 | 333 | } | ||
367 | 334 | } | ||
368 | 335 | |||
369 | 336 | if (index < ((!) this.icon_string_uniques).length) { | ||
370 | 337 | if (this.icon_string_uniques[index] == -1) { | ||
371 | 338 | this.icon_string_uniques[index] = 1; | ||
372 | 339 | |||
373 | 340 | var icon_string = get_icon_string (index); | ||
374 | 341 | |||
375 | 342 | for (var i = 0; i < ((!) this.icon_string_uniques).length && this.icon_string_uniques[index] == 1; i++) { | ||
376 | 343 | if (i != index && get_icon_string (i) == icon_string) { | ||
377 | 344 | this.icon_string_uniques[index] = 0; | ||
378 | 345 | } | ||
379 | 346 | } | ||
380 | 347 | } | ||
381 | 348 | |||
382 | 349 | icon_string_unique = this.icon_string_uniques[index] != 0; | ||
383 | 350 | } | ||
384 | 351 | |||
385 | 352 | return icon_string_unique; | ||
386 | 353 | } | ||
387 | 354 | |||
388 | 355 | [DBus (visible = false)] | ||
389 | 356 | private uint get_icon_string_subscript (uint index) { | ||
390 | 357 | uint icon_string_subscript = 0; | ||
391 | 358 | |||
392 | 359 | if (this.icon_string_subscripts == null) { | ||
393 | 360 | var array = this.source_settings.get_value ("sources"); | ||
394 | 361 | this.icon_string_subscripts = new uint[array.n_children ()]; | ||
395 | 362 | } | ||
396 | 363 | |||
397 | 364 | if (index < ((!) this.icon_string_subscripts).length) { | ||
398 | 365 | icon_string_subscript = this.icon_string_subscripts[index]; | ||
399 | 366 | |||
400 | 367 | if (icon_string_subscript == 0) { | ||
401 | 368 | this.icon_string_subscripts[index] = 1; | ||
402 | 369 | |||
403 | 370 | for (var i = (int) index - 1; i >= 0 && this.icon_string_subscripts[index] == 1; i--) { | ||
404 | 371 | if (get_icon_string (i) == get_icon_string (index)) { | ||
405 | 372 | this.icon_string_subscripts[index] = get_icon_string_subscript (i) + 1; | ||
406 | 373 | } | ||
407 | 374 | } | ||
408 | 375 | |||
409 | 376 | icon_string_subscript = this.icon_string_subscripts[index]; | ||
410 | 377 | } | ||
411 | 378 | } | ||
412 | 379 | |||
413 | 380 | return icon_string_subscript; | ||
414 | 381 | } | ||
415 | 382 | |||
416 | 383 | [DBus (visible = false)] | ||
417 | 384 | private Icon? get_icon (uint index) { | ||
418 | 385 | Icon? icon = null; | ||
419 | 386 | |||
420 | 387 | if (this.icons == null) { | ||
421 | 388 | var array = this.source_settings.get_value ("sources"); | ||
422 | 389 | this.icons = new Icon?[array.n_children ()]; | ||
423 | 390 | } | ||
424 | 391 | |||
425 | 392 | if (index < ((!) this.icons).length) { | ||
426 | 393 | icon = this.icons[index]; | ||
427 | 394 | |||
428 | 395 | if (icon == null) { | ||
429 | 396 | var array = this.source_settings.get_value ("sources"); | ||
430 | 397 | |||
431 | 398 | string type; | ||
432 | 399 | string name; | ||
433 | 400 | |||
434 | 401 | array.get_child (index, "(ss)", out type, out name); | ||
435 | 402 | |||
436 | 403 | if (type == "xkb") { | ||
437 | 404 | var icon_string = get_icon_string (index); | ||
438 | 405 | var icon_unique = is_icon_string_unique (index); | ||
439 | 406 | var icon_subscript = get_icon_string_subscript (index); | ||
440 | 407 | |||
441 | 408 | if (icon_string.get_char () != '\0') { | ||
442 | 409 | string icon_name; | ||
443 | 410 | |||
444 | 411 | if (icon_unique) { | ||
445 | 412 | icon_name = @"indicator-keyboard-$((!) icon_string)"; | ||
446 | 413 | } else { | ||
447 | 414 | icon_name = @"indicator-keyboard-$((!) icon_string)-$icon_subscript"; | ||
448 | 415 | } | ||
449 | 416 | |||
450 | 417 | if (this.use_gtk) { | ||
451 | 418 | var icon_theme = Gtk.IconTheme.get_default (); | ||
452 | 419 | Gtk.IconInfo? icon_info = icon_theme.lookup_icon (icon_name, 22, 0); | ||
453 | 420 | |||
454 | 421 | if (icon_info != null) { | ||
455 | 422 | try { | ||
456 | 423 | this.icons[index] = Icon.new_for_string (((!) icon_info).get_filename ()); | ||
457 | 424 | } catch (Error error) { | ||
458 | 425 | this.icons[index] = null; | ||
459 | 426 | } | ||
460 | 427 | } | ||
461 | 428 | } else { | ||
462 | 429 | this.icons[index] = new ThemedIcon (icon_name); | ||
463 | 430 | } | ||
464 | 431 | } | ||
465 | 432 | |||
466 | 433 | if (this.icons[index] == null) { | ||
467 | 434 | if (icon_unique) { | ||
468 | 435 | this.icons[index] = create_icon (icon_string, 0); | ||
469 | 436 | } else { | ||
470 | 437 | this.icons[index] = create_icon (icon_string, icon_subscript); | ||
471 | 438 | } | ||
472 | 439 | } | ||
473 | 440 | } else if (type == "ibus") { | ||
474 | 441 | var names = new string[2]; | ||
475 | 442 | names[0] = name; | ||
476 | 443 | |||
477 | 444 | var engines = get_ibus ().get_engines_by_names (names); | ||
478 | 445 | |||
479 | 446 | if (engines.length > 0) { | ||
480 | 447 | var engine = engines[0]; | ||
481 | 448 | |||
482 | 449 | try { | ||
483 | 450 | this.icons[index] = Icon.new_for_string (engine.get_icon ()); | ||
484 | 451 | } catch (Error error) { | ||
485 | 452 | warning ("error: %s", error.message); | ||
486 | 453 | } | ||
487 | 454 | } | ||
488 | 455 | } | ||
489 | 456 | |||
490 | 457 | icon = this.icons[index]; | ||
491 | 458 | } | ||
492 | 459 | } | ||
493 | 460 | |||
494 | 461 | return icon; | ||
495 | 462 | } | ||
496 | 463 | |||
497 | 464 | [DBus (visible = false)] | ||
498 | 465 | protected virtual SimpleActionGroup create_action_group (Action root_action) { | ||
499 | 466 | var group = new SimpleActionGroup (); | ||
500 | 467 | |||
501 | 468 | group.insert (root_action); | ||
502 | 469 | group.insert (this.source_settings.create_action ("current")); | ||
503 | 470 | |||
504 | 471 | var action = new SimpleAction ("map", null); | ||
505 | 472 | action.activate.connect (this.handle_activate_map); | ||
506 | 473 | group.insert (action); | ||
507 | 474 | |||
508 | 475 | action = new SimpleAction ("chart", null); | ||
509 | 476 | action.activate.connect (this.handle_activate_chart); | ||
510 | 477 | group.insert (action); | ||
511 | 478 | |||
512 | 479 | action = new SimpleAction ("settings", null); | ||
513 | 480 | action.activate.connect (this.handle_activate_settings); | ||
514 | 481 | group.insert (action); | ||
515 | 482 | |||
516 | 483 | return group; | ||
517 | 484 | } | ||
518 | 485 | |||
519 | 486 | [DBus (visible = false)] | ||
520 | 487 | private void update_indicator_action () { | ||
521 | 488 | var visible = this.indicator_settings.get_boolean ("visible"); | ||
522 | 489 | var current = this.source_settings.get_uint ("current"); | ||
523 | 490 | var icon = get_icon (current); | ||
524 | 491 | Variant state; | ||
525 | 492 | |||
526 | 493 | if (icon != null) { | ||
527 | 494 | state = new Variant.parsed ("{ 'visible' : <%b>, 'icon' : %v }", visible, ((!) icon).serialize ()); | ||
528 | 495 | } else { | ||
529 | 496 | state = new Variant.parsed ("{ 'visible' : <%b> }", visible); | ||
530 | 497 | } | ||
531 | 498 | |||
532 | 499 | get_indicator_action ().set_state (state); | ||
533 | 500 | } | ||
534 | 501 | |||
535 | 502 | [DBus (visible = false)] | ||
536 | 503 | private SimpleAction get_indicator_action () { | ||
537 | 504 | if (this.indicator_action == null) { | ||
538 | 505 | var state = new Variant.parsed ("{ 'visible' : <false> }"); | ||
539 | 506 | this.indicator_action = new SimpleAction.stateful ("indicator", null, state); | ||
540 | 507 | update_indicator_action (); | ||
541 | 508 | } | ||
542 | 509 | |||
543 | 510 | return (!) this.indicator_action; | ||
544 | 511 | } | ||
545 | 512 | |||
546 | 513 | [DBus (visible = false)] | ||
547 | 514 | public SimpleActionGroup get_action_group () { | ||
548 | 515 | if (this.action_group == null) { | ||
549 | 516 | this.action_group = create_action_group (get_indicator_action ()); | ||
550 | 517 | } | ||
551 | 518 | |||
552 | 519 | return (!) this.action_group; | ||
553 | 520 | } | ||
554 | 521 | |||
555 | 522 | [DBus (visible = false)] | ||
556 | 523 | protected virtual MenuModel create_menu_model (MenuModel section_menu) { | ||
557 | 524 | var menu = new Menu (); | ||
558 | 525 | |||
559 | 526 | var submenu = new Menu (); | ||
560 | 527 | |||
561 | 528 | submenu.append_section (null, section_menu); | ||
562 | 529 | |||
563 | 530 | var section = new Menu (); | ||
564 | 531 | section.append (_ ("Character Map"), "indicator.map"); | ||
565 | 532 | section.append (_ ("Keyboard Layout Chart"), "indicator.chart"); | ||
566 | 533 | section.append (_ ("Text Entry Settings..."), "indicator.settings"); | ||
567 | 534 | submenu.append_section (null, section); | ||
568 | 535 | |||
569 | 536 | var indicator = new MenuItem.submenu ("x", submenu); | ||
570 | 537 | indicator.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.root"); | ||
571 | 538 | indicator.set_detailed_action ("indicator.indicator"); | ||
572 | 539 | menu.append_item (indicator); | ||
573 | 540 | |||
574 | 541 | return menu; | ||
575 | 542 | } | ||
576 | 543 | |||
577 | 544 | [DBus (visible = false)] | ||
578 | 545 | private string get_display_name (string layout) { | ||
579 | 546 | string? language = Xkl.get_language_name (layout); | ||
580 | 547 | string? country = Xkl.get_country_name (layout); | ||
581 | 548 | var has_language = language != null && ((!) language).get_char () != '\0'; | ||
582 | 549 | var has_country = country != null && ((!) country).get_char () != '\0'; | ||
583 | 550 | |||
584 | 551 | if (has_language && has_country) { | ||
585 | 552 | return @"$((!) language) ($((!) country))"; | ||
586 | 553 | } else if (has_language) { | ||
587 | 554 | return (!) language; | ||
588 | 555 | } else if (has_country) { | ||
589 | 556 | return (!) country; | ||
590 | 557 | } else { | ||
591 | 558 | return ""; | ||
592 | 559 | } | ||
593 | 560 | } | ||
594 | 561 | |||
595 | 562 | [DBus (visible = false)] | ||
596 | 563 | private void update_sources_menu () { | ||
597 | 564 | if (this.sources_menu != null) { | ||
598 | 565 | var menu = get_sources_menu (); | ||
599 | 566 | |||
600 | 567 | while (menu.get_n_items () > 0) | ||
601 | 568 | menu.remove (0); | ||
602 | 569 | |||
603 | 570 | VariantIter iter; | ||
604 | 571 | string type; | ||
605 | 572 | string name; | ||
606 | 573 | |||
607 | 574 | this.source_settings.get ("sources", "a(ss)", out iter); | ||
608 | 575 | |||
609 | 576 | for (var i = 0; iter.next ("(ss)", out type, out name); i++) { | ||
610 | 577 | if (type == "xkb") { | ||
611 | 578 | string? display_name; | ||
612 | 579 | string? layout_name; | ||
613 | 580 | |||
614 | 581 | this.xkb_info.get_layout_info (name, out display_name, null, out layout_name, null); | ||
615 | 582 | |||
616 | 583 | if (display_name != null) { | ||
617 | 584 | name = (!) display_name; | ||
618 | 585 | } else if (layout_name != null) { | ||
619 | 586 | name = get_display_name ((!) layout_name); | ||
620 | 587 | } | ||
621 | 588 | } | ||
622 | 589 | else if (type == "ibus") { | ||
623 | 590 | var names = new string[2]; | ||
624 | 591 | names[0] = name; | ||
625 | 592 | |||
626 | 593 | var engines = get_ibus ().get_engines_by_names (names); | ||
627 | 594 | |||
628 | 595 | if (engines.length > 0) { | ||
629 | 596 | var engine = engines[0]; | ||
630 | 597 | string? language = engine.get_language (); | ||
631 | 598 | string? display_name = engine.get_longname (); | ||
632 | 599 | |||
633 | 600 | if (language != null) { | ||
634 | 601 | language = Xkl.get_language_name ((!) language); | ||
635 | 602 | } | ||
636 | 603 | |||
637 | 604 | if (language != null && display_name != null) { | ||
638 | 605 | name = @"$((!) language) ($((!) display_name))"; | ||
639 | 606 | } else if (language != null) { | ||
640 | 607 | name = (!) language; | ||
641 | 608 | } else if (display_name != null) { | ||
642 | 609 | name = (!) display_name; | ||
643 | 610 | } | ||
644 | 611 | } | ||
645 | 612 | } | ||
646 | 613 | |||
647 | 614 | var menu_item = new MenuItem (name, "indicator.current"); | ||
648 | 615 | menu_item.set_attribute (Menu.ATTRIBUTE_TARGET, "u", i); | ||
649 | 616 | |||
650 | 617 | var icon = get_icon (i); | ||
651 | 618 | if (icon != null) { | ||
652 | 619 | menu_item.set_icon ((!) icon); | ||
653 | 620 | } | ||
654 | 621 | |||
655 | 622 | menu.append_item (menu_item); | ||
656 | 623 | } | ||
657 | 624 | } else { | ||
658 | 625 | get_sources_menu (); | ||
659 | 626 | } | ||
660 | 627 | } | ||
661 | 628 | |||
662 | 629 | [DBus (visible = false)] | ||
663 | 630 | private Menu get_sources_menu () { | ||
664 | 631 | if (this.sources_menu == null) { | ||
665 | 632 | this.sources_menu = new Menu (); | ||
666 | 633 | update_sources_menu (); | ||
667 | 634 | } | ||
668 | 635 | |||
669 | 636 | return (!) this.sources_menu; | ||
670 | 637 | } | ||
671 | 638 | |||
672 | 639 | [DBus (visible = false)] | ||
673 | 640 | public MenuModel get_menu_model () { | ||
674 | 641 | if (this.menu_model == null) { | ||
675 | 642 | this.menu_model = create_menu_model (get_sources_menu ()); | ||
676 | 643 | } | ||
677 | 644 | |||
678 | 645 | return (!) this.menu_model; | ||
679 | 646 | } | ||
680 | 647 | |||
681 | 648 | [DBus (visible = false)] | ||
682 | 649 | private void handle_changed_visible (string key) { | ||
683 | 650 | update_indicator_action (); | ||
684 | 651 | } | ||
685 | 652 | |||
686 | 653 | [DBus (visible = false)] | ||
687 | 654 | private void handle_changed_current (string key) { | ||
688 | 655 | update_indicator_action (); | ||
689 | 656 | } | ||
690 | 657 | |||
691 | 658 | [DBus (visible = false)] | ||
692 | 659 | private void handle_changed_sources (string key) { | ||
693 | 660 | this.icon_string_subscripts = null; | ||
694 | 661 | this.icon_string_uniques = null; | ||
695 | 662 | this.icon_strings = null; | ||
696 | 663 | this.icons = null; | ||
697 | 664 | |||
698 | 665 | update_sources_menu (); | ||
699 | 666 | update_indicator_action (); | ||
700 | 667 | } | ||
701 | 668 | |||
702 | 669 | [DBus (visible = false)] | ||
703 | 670 | private void handle_activate_map (Variant? parameter) { | ||
704 | 671 | try { | ||
705 | 672 | Process.spawn_command_line_async ("gucharmap"); | ||
706 | 673 | } catch (SpawnError error) { | ||
707 | 674 | warning ("error: %s", error.message); | ||
708 | 675 | } | ||
709 | 676 | } | ||
710 | 677 | |||
711 | 678 | [DBus (visible = false)] | ||
712 | 679 | private void handle_activate_chart (Variant? parameter) { | ||
713 | 680 | var layout = "us"; | ||
714 | 681 | string? variant = null; | ||
715 | 682 | |||
716 | 683 | var current = this.source_settings.get_uint ("current"); | ||
717 | 684 | var array = this.source_settings.get_value ("sources"); | ||
718 | 685 | |||
719 | 686 | if (current < array.n_children ()) { | ||
720 | 687 | string type; | ||
721 | 688 | string name; | ||
722 | 689 | |||
723 | 690 | array.get_child (current, "(ss)", out type, out name); | ||
724 | 691 | |||
725 | 692 | if (type == "xkb") { | ||
726 | 693 | this.xkb_info.get_layout_info (name, null, null, out layout, out variant); | ||
727 | 694 | } else if (type == "ibus") { | ||
728 | 695 | var names = new string[2]; | ||
729 | 696 | names[0] = name; | ||
730 | 697 | |||
731 | 698 | var engines = get_ibus ().get_engines_by_names (names); | ||
732 | 699 | |||
733 | 700 | if (engines.length > 0) { | ||
734 | 701 | var engine = engines[0]; | ||
735 | 702 | |||
736 | 703 | layout = engine.get_layout (); | ||
737 | 704 | variant = engine.get_layout_variant (); | ||
738 | 705 | } | ||
739 | 706 | } | ||
740 | 707 | } | ||
741 | 708 | |||
742 | 709 | try { | ||
743 | 710 | string command; | ||
744 | 711 | |||
745 | 712 | if (variant != null && ((!) variant).get_char () != '\0') { | ||
746 | 713 | command = @"gkbd-keyboard-display -l \"$layout\t$((!) variant)\""; | ||
747 | 714 | } else { | ||
748 | 715 | command = @"gkbd-keyboard-display -l $layout"; | ||
749 | 716 | } | ||
750 | 717 | |||
751 | 718 | Process.spawn_command_line_async (command); | ||
752 | 719 | } catch (SpawnError error) { | ||
753 | 720 | warning ("error: %s", error.message); | ||
754 | 721 | } | ||
755 | 722 | } | ||
756 | 723 | |||
757 | 724 | [DBus (visible = false)] | ||
758 | 725 | private void handle_activate_settings (Variant? parameter) { | ||
759 | 726 | try { | ||
760 | 727 | Process.spawn_command_line_async ("gnome-control-center region layouts"); | ||
761 | 728 | } catch (SpawnError error) { | ||
762 | 729 | warning ("error: %s", error.message); | ||
763 | 730 | } | ||
764 | 731 | } | ||
765 | 732 | |||
766 | 733 | [DBus (visible = false)] | ||
767 | 734 | private void handle_bus_acquired (DBusConnection connection, string name) { | ||
768 | 735 | try { | ||
769 | 736 | connection.export_action_group ("/com/canonical/indicator/keyboard", get_action_group ()); | ||
770 | 737 | connection.export_menu_model ("/com/canonical/indicator/keyboard/desktop", get_menu_model ()); | ||
771 | 738 | } catch (Error error) { | ||
772 | 739 | warning ("error: %s", error.message); | ||
773 | 740 | } | ||
774 | 741 | } | ||
775 | 742 | |||
776 | 743 | [DBus (visible = false)] | ||
777 | 744 | private void handle_name_lost (DBusConnection? connection, string name) { | ||
778 | 745 | ((!) this.loop).quit (); | ||
779 | 746 | this.loop = null; | ||
780 | 747 | } | ||
781 | 748 | |||
782 | 749 | [DBus (visible = false)] | ||
783 | 750 | public static int main (string[] args) { | ||
784 | 751 | new Service (ref args); | ||
785 | 752 | return 0; | ||
786 | 753 | } | ||
787 | 754 | } | ||
788 | 755 | 0 | ||
789 | === removed directory '.pc/disable-experimental-non-null.patch' | |||
790 | === removed directory '.pc/disable-experimental-non-null.patch/tests' | |||
791 | === removed file '.pc/disable-experimental-non-null.patch/tests/Makefile.am' | |||
792 | --- .pc/disable-experimental-non-null.patch/tests/Makefile.am 2013-07-17 19:17:32 +0000 | |||
793 | +++ .pc/disable-experimental-non-null.patch/tests/Makefile.am 1970-01-01 00:00:00 +0000 | |||
794 | @@ -1,18 +0,0 @@ | |||
795 | 1 | TESTS = indicator-keyboard-test | ||
796 | 2 | |||
797 | 3 | check_PROGRAMS = indicator-keyboard-tests | ||
798 | 4 | |||
799 | 5 | AM_CFLAGS = -w | ||
800 | 6 | AM_LDFLAGS = -lm | ||
801 | 7 | AM_VALAFLAGS = --enable-experimental-non-null \ | ||
802 | 8 | --metadatadir $(top_srcdir)/deps \ | ||
803 | 9 | --vapidir $(top_srcdir)/deps | ||
804 | 10 | |||
805 | 11 | indicator_keyboard_tests_SOURCES = main.vala \ | ||
806 | 12 | config.vala | ||
807 | 13 | indicator_keyboard_tests_VALAFLAGS = $(AM_VALAFLAGS) \ | ||
808 | 14 | --pkg gio-2.0 | ||
809 | 15 | indicator_keyboard_tests_CFLAGS = $(AM_CFLAGS) \ | ||
810 | 16 | $(GIO_CFLAGS) | ||
811 | 17 | indicator_keyboard_tests_LDFLAGS = $(AM_LDFLAGS) \ | ||
812 | 18 | $(GIO_LIBS) | ||
813 | 19 | 0 | ||
814 | === removed file '.pc/disable-experimental-non-null.patch/tests/main.vala' | |||
815 | --- .pc/disable-experimental-non-null.patch/tests/main.vala 2013-07-04 04:12:14 +0000 | |||
816 | +++ .pc/disable-experimental-non-null.patch/tests/main.vala 1970-01-01 00:00:00 +0000 | |||
817 | @@ -1,675 +0,0 @@ | |||
818 | 1 | const int TIMEOUT_S = 1; | ||
819 | 2 | const int TIMEOUT_MS = 1000; | ||
820 | 3 | |||
821 | 4 | [DBus (name = "com.canonical.indicator.keyboard.test")] | ||
822 | 5 | public class Service : Object { | ||
823 | 6 | |||
824 | 7 | [DBus (visible = false)] | ||
825 | 8 | private string? _command; | ||
826 | 9 | |||
827 | 10 | [DBus (visible = false)] | ||
828 | 11 | public string? command { | ||
829 | 12 | get { return _command; } | ||
830 | 13 | } | ||
831 | 14 | |||
832 | 15 | public void execute (string command) { | ||
833 | 16 | this._command = command; | ||
834 | 17 | |||
835 | 18 | var pspec = this.get_class ().find_property ("command"); | ||
836 | 19 | |||
837 | 20 | if (pspec != null) { | ||
838 | 21 | this.notify["command"] ((!) pspec); | ||
839 | 22 | } | ||
840 | 23 | } | ||
841 | 24 | } | ||
842 | 25 | |||
843 | 26 | struct Fixture { | ||
844 | 27 | TestDBus? bus; | ||
845 | 28 | uint service_name; | ||
846 | 29 | DBusConnection? connection; | ||
847 | 30 | Service? service; | ||
848 | 31 | uint object_name; | ||
849 | 32 | } | ||
850 | 33 | |||
851 | 34 | static void start_service (Fixture *fixture) { | ||
852 | 35 | if (fixture.connection != null) { | ||
853 | 36 | try { | ||
854 | 37 | fixture.service = new Service (); | ||
855 | 38 | fixture.object_name = ((!) fixture.connection).register_object ("/com/canonical/indicator/keyboard/test", fixture.service); | ||
856 | 39 | } catch (IOError error) { | ||
857 | 40 | fixture.connection = null; | ||
858 | 41 | fixture.service = null; | ||
859 | 42 | fixture.object_name = 0; | ||
860 | 43 | |||
861 | 44 | Test.message ("error: %s", error.message); | ||
862 | 45 | Test.fail (); | ||
863 | 46 | } | ||
864 | 47 | } | ||
865 | 48 | } | ||
866 | 49 | |||
867 | 50 | static void begin_test (void *data) { | ||
868 | 51 | var fixture = (Fixture *) data; | ||
869 | 52 | |||
870 | 53 | fixture.bus = new TestDBus (TestDBusFlags.NONE); | ||
871 | 54 | ((!) fixture.bus).add_service_dir (SERVICE_DIR); | ||
872 | 55 | ((!) fixture.bus).up (); | ||
873 | 56 | |||
874 | 57 | var loop = new MainLoop (null, false); | ||
875 | 58 | |||
876 | 59 | fixture.service_name = Bus.own_name (BusType.SESSION, | ||
877 | 60 | "com.canonical.indicator.keyboard.test", | ||
878 | 61 | BusNameOwnerFlags.ALLOW_REPLACEMENT | BusNameOwnerFlags.REPLACE, | ||
879 | 62 | (connection, name) => { | ||
880 | 63 | if (loop.is_running ()) { | ||
881 | 64 | fixture.connection = connection; | ||
882 | 65 | |||
883 | 66 | start_service (fixture); | ||
884 | 67 | |||
885 | 68 | loop.quit (); | ||
886 | 69 | } | ||
887 | 70 | }, | ||
888 | 71 | null, | ||
889 | 72 | (connection, name) => { | ||
890 | 73 | if (loop.is_running ()) { | ||
891 | 74 | fixture.connection = null; | ||
892 | 75 | fixture.service = null; | ||
893 | 76 | fixture.object_name = 0; | ||
894 | 77 | |||
895 | 78 | loop.quit (); | ||
896 | 79 | } | ||
897 | 80 | }); | ||
898 | 81 | |||
899 | 82 | loop.run (); | ||
900 | 83 | |||
901 | 84 | if (fixture.connection == null) { | ||
902 | 85 | Test.message ("error: Unable to connect to com.canonical.indicator.keyboard.test."); | ||
903 | 86 | Test.fail (); | ||
904 | 87 | } | ||
905 | 88 | } | ||
906 | 89 | |||
907 | 90 | static void end_test (void *data) { | ||
908 | 91 | var fixture = (Fixture *) data; | ||
909 | 92 | |||
910 | 93 | if (fixture.object_name != 0) { | ||
911 | 94 | ((!) fixture.connection).unregister_object (fixture.object_name); | ||
912 | 95 | fixture.object_name = 0; | ||
913 | 96 | } | ||
914 | 97 | |||
915 | 98 | if (fixture.service_name != 0) { | ||
916 | 99 | Bus.unown_name (fixture.service_name); | ||
917 | 100 | fixture.service_name = 0; | ||
918 | 101 | } | ||
919 | 102 | |||
920 | 103 | fixture.service = null; | ||
921 | 104 | fixture.connection = null; | ||
922 | 105 | |||
923 | 106 | if (fixture.bus != null) { | ||
924 | 107 | ((!) fixture.bus).down (); | ||
925 | 108 | fixture.bus = null; | ||
926 | 109 | } | ||
927 | 110 | } | ||
928 | 111 | |||
929 | 112 | static void test_activate_input_source (void *data) { | ||
930 | 113 | var fixture = (Fixture *) data; | ||
931 | 114 | |||
932 | 115 | if (fixture.object_name == 0) { | ||
933 | 116 | Test.message ("error: Test fixture not initialized."); | ||
934 | 117 | Test.fail (); | ||
935 | 118 | return; | ||
936 | 119 | } | ||
937 | 120 | |||
938 | 121 | try { | ||
939 | 122 | var current = 0; | ||
940 | 123 | var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]"; | ||
941 | 124 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); | ||
942 | 125 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); | ||
943 | 126 | } catch (SpawnError error) { | ||
944 | 127 | Test.message ("error: %s", error.message); | ||
945 | 128 | Test.fail (); | ||
946 | 129 | return; | ||
947 | 130 | } | ||
948 | 131 | |||
949 | 132 | var action_group = DBusActionGroup.get ((!) fixture.connection, | ||
950 | 133 | "com.canonical.indicator.keyboard", | ||
951 | 134 | "/com/canonical/indicator/keyboard"); | ||
952 | 135 | var loop = new MainLoop (null, false); | ||
953 | 136 | var signal_name = action_group.action_state_changed["current"].connect ((action, state) => { | ||
954 | 137 | loop.quit (); | ||
955 | 138 | }); | ||
956 | 139 | |||
957 | 140 | action_group.list_actions (); | ||
958 | 141 | action_group.activate_action ("current", new Variant.uint32 (2)); | ||
959 | 142 | |||
960 | 143 | var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
961 | 144 | loop.run (); | ||
962 | 145 | Source.remove (source); | ||
963 | 146 | action_group.disconnect (signal_name); | ||
964 | 147 | |||
965 | 148 | var state = action_group.get_action_state ("current"); | ||
966 | 149 | var current = ((!) state).get_uint32 (); | ||
967 | 150 | assert (current == 2); | ||
968 | 151 | |||
969 | 152 | try { | ||
970 | 153 | string output; | ||
971 | 154 | Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output); | ||
972 | 155 | assert (strcmp (output, "uint32 2\n") == 0); | ||
973 | 156 | } catch (SpawnError error) { | ||
974 | 157 | Test.message ("error: %s", error.message); | ||
975 | 158 | Test.fail (); | ||
976 | 159 | return; | ||
977 | 160 | } | ||
978 | 161 | } | ||
979 | 162 | |||
980 | 163 | static void test_activate_character_map (void *data) { | ||
981 | 164 | var fixture = (Fixture *) data; | ||
982 | 165 | |||
983 | 166 | if (fixture.object_name == 0) { | ||
984 | 167 | Test.message ("error: Test fixture not initialized."); | ||
985 | 168 | Test.fail (); | ||
986 | 169 | return; | ||
987 | 170 | } | ||
988 | 171 | |||
989 | 172 | var action_group = DBusActionGroup.get ((!) fixture.connection, | ||
990 | 173 | "com.canonical.indicator.keyboard", | ||
991 | 174 | "/com/canonical/indicator/keyboard"); | ||
992 | 175 | var loop = new MainLoop (null, false); | ||
993 | 176 | var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => { | ||
994 | 177 | loop.quit (); | ||
995 | 178 | }); | ||
996 | 179 | |||
997 | 180 | action_group.activate_action ("map", null); | ||
998 | 181 | |||
999 | 182 | var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
1000 | 183 | loop.run (); | ||
1001 | 184 | Source.remove (source); | ||
1002 | 185 | ((!) fixture.service).disconnect (signal_name); | ||
1003 | 186 | |||
1004 | 187 | assert (strcmp ((!) ((!) fixture.service).command, "'gucharmap '") == 0); | ||
1005 | 188 | } | ||
1006 | 189 | |||
1007 | 190 | static void test_activate_keyboard_layout_chart (void *data) { | ||
1008 | 191 | var fixture = (Fixture *) data; | ||
1009 | 192 | |||
1010 | 193 | if (fixture.object_name == 0) { | ||
1011 | 194 | Test.message ("error: Test fixture not initialized."); | ||
1012 | 195 | Test.fail (); | ||
1013 | 196 | return; | ||
1014 | 197 | } | ||
1015 | 198 | |||
1016 | 199 | try { | ||
1017 | 200 | var current = 1; | ||
1018 | 201 | var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]"; | ||
1019 | 202 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); | ||
1020 | 203 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); | ||
1021 | 204 | } catch (SpawnError error) { | ||
1022 | 205 | Test.message ("error: %s", error.message); | ||
1023 | 206 | Test.fail (); | ||
1024 | 207 | return; | ||
1025 | 208 | } | ||
1026 | 209 | |||
1027 | 210 | var action_group = DBusActionGroup.get ((!) fixture.connection, | ||
1028 | 211 | "com.canonical.indicator.keyboard", | ||
1029 | 212 | "/com/canonical/indicator/keyboard"); | ||
1030 | 213 | var loop = new MainLoop (null, false); | ||
1031 | 214 | var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => { | ||
1032 | 215 | loop.quit (); | ||
1033 | 216 | }); | ||
1034 | 217 | |||
1035 | 218 | action_group.activate_action ("chart", null); | ||
1036 | 219 | |||
1037 | 220 | var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
1038 | 221 | loop.run (); | ||
1039 | 222 | Source.remove (source); | ||
1040 | 223 | ((!) fixture.service).disconnect (signal_name); | ||
1041 | 224 | |||
1042 | 225 | assert (strcmp ((!) ((!) fixture.service).command, "'gkbd-keyboard-display -l ca\teng'") == 0); | ||
1043 | 226 | } | ||
1044 | 227 | |||
1045 | 228 | static void test_activate_text_entry_settings (void *data) { | ||
1046 | 229 | var fixture = (Fixture *) data; | ||
1047 | 230 | |||
1048 | 231 | if (fixture.object_name == 0) { | ||
1049 | 232 | Test.message ("error: Test fixture not initialized."); | ||
1050 | 233 | Test.fail (); | ||
1051 | 234 | return; | ||
1052 | 235 | } | ||
1053 | 236 | |||
1054 | 237 | var action_group = DBusActionGroup.get ((!) fixture.connection, | ||
1055 | 238 | "com.canonical.indicator.keyboard", | ||
1056 | 239 | "/com/canonical/indicator/keyboard"); | ||
1057 | 240 | var loop = new MainLoop (null, false); | ||
1058 | 241 | var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => { | ||
1059 | 242 | loop.quit (); | ||
1060 | 243 | }); | ||
1061 | 244 | |||
1062 | 245 | action_group.activate_action ("settings", null); | ||
1063 | 246 | |||
1064 | 247 | var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
1065 | 248 | loop.run (); | ||
1066 | 249 | Source.remove (source); | ||
1067 | 250 | ((!) fixture.service).disconnect (signal_name); | ||
1068 | 251 | |||
1069 | 252 | assert (strcmp ((!) ((!) fixture.service).command, "'gnome-control-center region layouts'") == 0); | ||
1070 | 253 | } | ||
1071 | 254 | |||
1072 | 255 | static void test_migration (void *data) { | ||
1073 | 256 | var fixture = (Fixture *) data; | ||
1074 | 257 | |||
1075 | 258 | if (fixture.object_name == 0) { | ||
1076 | 259 | Test.message ("error: Test fixture not initialized."); | ||
1077 | 260 | Test.fail (); | ||
1078 | 261 | return; | ||
1079 | 262 | } | ||
1080 | 263 | |||
1081 | 264 | try { | ||
1082 | 265 | var migrated = false; | ||
1083 | 266 | var sources = "[('xkb', 'us')]"; | ||
1084 | 267 | var layouts = "['us', 'ca\teng', 'epo']"; | ||
1085 | 268 | Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard migrated $migrated"); | ||
1086 | 269 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); | ||
1087 | 270 | Process.spawn_command_line_sync (@"gsettings set org.gnome.libgnomekbd.keyboard layouts \"$layouts\""); | ||
1088 | 271 | } catch (SpawnError error) { | ||
1089 | 272 | Test.message ("error: %s", error.message); | ||
1090 | 273 | Test.fail (); | ||
1091 | 274 | return; | ||
1092 | 275 | } | ||
1093 | 276 | |||
1094 | 277 | try { | ||
1095 | 278 | var cancellable = new Cancellable (); | ||
1096 | 279 | |||
1097 | 280 | var source = Timeout.add_seconds (TIMEOUT_S, () => { cancellable.cancel (); return false; }); | ||
1098 | 281 | |||
1099 | 282 | var dbus_proxy = new DBusProxy.sync ((!) fixture.connection, | ||
1100 | 283 | DBusProxyFlags.NONE, | ||
1101 | 284 | null, | ||
1102 | 285 | "org.freedesktop.DBus", | ||
1103 | 286 | "/", | ||
1104 | 287 | "org.freedesktop.DBus", | ||
1105 | 288 | cancellable); | ||
1106 | 289 | |||
1107 | 290 | Source.remove (source); | ||
1108 | 291 | |||
1109 | 292 | if (cancellable.is_cancelled ()) { | ||
1110 | 293 | Test.message ("error: Unable to connect to org.freedesktop.DBus."); | ||
1111 | 294 | Test.fail (); | ||
1112 | 295 | return; | ||
1113 | 296 | } | ||
1114 | 297 | |||
1115 | 298 | dbus_proxy.call_sync ("StartServiceByName", new Variant ("(su)", "com.canonical.indicator.keyboard", 0), DBusCallFlags.NONE, TIMEOUT_MS); | ||
1116 | 299 | } catch (Error error) { | ||
1117 | 300 | Test.message ("error: %s", error.message); | ||
1118 | 301 | Test.fail (); | ||
1119 | 302 | return; | ||
1120 | 303 | } | ||
1121 | 304 | |||
1122 | 305 | try { | ||
1123 | 306 | string sources; | ||
1124 | 307 | Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources sources", out sources); | ||
1125 | 308 | assert (strcmp (sources, "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo')]\n") == 0); | ||
1126 | 309 | } catch (SpawnError error) { | ||
1127 | 310 | Test.message ("error: %s", error.message); | ||
1128 | 311 | Test.fail (); | ||
1129 | 312 | return; | ||
1130 | 313 | } | ||
1131 | 314 | } | ||
1132 | 315 | |||
1133 | 316 | static void test_no_migration (void *data) { | ||
1134 | 317 | var fixture = (Fixture *) data; | ||
1135 | 318 | |||
1136 | 319 | if (fixture.object_name == 0) { | ||
1137 | 320 | Test.message ("error: Test fixture not initialized."); | ||
1138 | 321 | Test.fail (); | ||
1139 | 322 | return; | ||
1140 | 323 | } | ||
1141 | 324 | |||
1142 | 325 | try { | ||
1143 | 326 | var migrated = true; | ||
1144 | 327 | var sources = "[('xkb', 'us')]"; | ||
1145 | 328 | var layouts = "['us', 'ca\teng', 'epo']"; | ||
1146 | 329 | Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard migrated $migrated"); | ||
1147 | 330 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); | ||
1148 | 331 | Process.spawn_command_line_sync (@"gsettings set org.gnome.libgnomekbd.keyboard layouts \"$layouts\""); | ||
1149 | 332 | } catch (SpawnError error) { | ||
1150 | 333 | Test.message ("error: %s", error.message); | ||
1151 | 334 | Test.fail (); | ||
1152 | 335 | return; | ||
1153 | 336 | } | ||
1154 | 337 | |||
1155 | 338 | try { | ||
1156 | 339 | var cancellable = new Cancellable (); | ||
1157 | 340 | |||
1158 | 341 | var source = Timeout.add_seconds (TIMEOUT_S, () => { cancellable.cancel (); return false; }); | ||
1159 | 342 | |||
1160 | 343 | var dbus_proxy = new DBusProxy.sync ((!) fixture.connection, | ||
1161 | 344 | DBusProxyFlags.NONE, | ||
1162 | 345 | null, | ||
1163 | 346 | "org.freedesktop.DBus", | ||
1164 | 347 | "/", | ||
1165 | 348 | "org.freedesktop.DBus", | ||
1166 | 349 | cancellable); | ||
1167 | 350 | |||
1168 | 351 | Source.remove (source); | ||
1169 | 352 | |||
1170 | 353 | if (cancellable.is_cancelled ()) { | ||
1171 | 354 | Test.message ("error: Unable to connect to org.freedesktop.DBus."); | ||
1172 | 355 | Test.fail (); | ||
1173 | 356 | return; | ||
1174 | 357 | } | ||
1175 | 358 | |||
1176 | 359 | dbus_proxy.call_sync ("StartServiceByName", new Variant ("(su)", "com.canonical.indicator.keyboard", 0), DBusCallFlags.NONE, TIMEOUT_MS); | ||
1177 | 360 | } catch (Error error) { | ||
1178 | 361 | Test.message ("error: %s", error.message); | ||
1179 | 362 | Test.fail (); | ||
1180 | 363 | return; | ||
1181 | 364 | } | ||
1182 | 365 | |||
1183 | 366 | try { | ||
1184 | 367 | string sources; | ||
1185 | 368 | Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources sources", out sources); | ||
1186 | 369 | assert (strcmp (sources, "[('xkb', 'us')]\n") == 0); | ||
1187 | 370 | } catch (SpawnError error) { | ||
1188 | 371 | Test.message ("error: %s", error.message); | ||
1189 | 372 | Test.fail (); | ||
1190 | 373 | return; | ||
1191 | 374 | } | ||
1192 | 375 | } | ||
1193 | 376 | |||
1194 | 377 | static void test_update_visible (void *data) { | ||
1195 | 378 | var fixture = (Fixture *) data; | ||
1196 | 379 | |||
1197 | 380 | if (fixture.object_name == 0) { | ||
1198 | 381 | Test.message ("error: Test fixture not initialized."); | ||
1199 | 382 | Test.fail (); | ||
1200 | 383 | return; | ||
1201 | 384 | } | ||
1202 | 385 | |||
1203 | 386 | bool visible; | ||
1204 | 387 | |||
1205 | 388 | try { | ||
1206 | 389 | visible = true; | ||
1207 | 390 | Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible"); | ||
1208 | 391 | } catch (SpawnError error) { | ||
1209 | 392 | Test.message ("error: %s", error.message); | ||
1210 | 393 | Test.fail (); | ||
1211 | 394 | return; | ||
1212 | 395 | } | ||
1213 | 396 | |||
1214 | 397 | var action_group = DBusActionGroup.get ((!) fixture.connection, | ||
1215 | 398 | "com.canonical.indicator.keyboard", | ||
1216 | 399 | "/com/canonical/indicator/keyboard"); | ||
1217 | 400 | var loop = new MainLoop (null, false); | ||
1218 | 401 | var signal_name = action_group.action_added["indicator"].connect ((action) => { | ||
1219 | 402 | loop.quit (); | ||
1220 | 403 | }); | ||
1221 | 404 | |||
1222 | 405 | action_group.list_actions (); | ||
1223 | 406 | |||
1224 | 407 | var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
1225 | 408 | loop.run (); | ||
1226 | 409 | Source.remove (source); | ||
1227 | 410 | action_group.disconnect (signal_name); | ||
1228 | 411 | |||
1229 | 412 | var state = action_group.get_action_state ("indicator"); | ||
1230 | 413 | assert (((!) state).lookup ("visible", "b", out visible)); | ||
1231 | 414 | assert (visible); | ||
1232 | 415 | |||
1233 | 416 | loop = new MainLoop (null, false); | ||
1234 | 417 | signal_name = action_group.action_state_changed["indicator"].connect ((action, state) => { | ||
1235 | 418 | loop.quit (); | ||
1236 | 419 | }); | ||
1237 | 420 | |||
1238 | 421 | try { | ||
1239 | 422 | visible = false; | ||
1240 | 423 | Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible"); | ||
1241 | 424 | } catch (SpawnError error) { | ||
1242 | 425 | Test.message ("error: %s", error.message); | ||
1243 | 426 | Test.fail (); | ||
1244 | 427 | return; | ||
1245 | 428 | } | ||
1246 | 429 | |||
1247 | 430 | source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
1248 | 431 | loop.run (); | ||
1249 | 432 | Source.remove (source); | ||
1250 | 433 | action_group.disconnect (signal_name); | ||
1251 | 434 | |||
1252 | 435 | state = action_group.get_action_state ("indicator"); | ||
1253 | 436 | assert (((!) state).lookup ("visible", "b", out visible)); | ||
1254 | 437 | assert (!visible); | ||
1255 | 438 | |||
1256 | 439 | loop = new MainLoop (null, false); | ||
1257 | 440 | signal_name = action_group.action_state_changed["indicator"].connect ((action, state) => { | ||
1258 | 441 | loop.quit (); | ||
1259 | 442 | }); | ||
1260 | 443 | |||
1261 | 444 | try { | ||
1262 | 445 | visible = true; | ||
1263 | 446 | Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible"); | ||
1264 | 447 | } catch (SpawnError error) { | ||
1265 | 448 | Test.message ("error: %s", error.message); | ||
1266 | 449 | Test.fail (); | ||
1267 | 450 | return; | ||
1268 | 451 | } | ||
1269 | 452 | |||
1270 | 453 | source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
1271 | 454 | loop.run (); | ||
1272 | 455 | Source.remove (source); | ||
1273 | 456 | action_group.disconnect (signal_name); | ||
1274 | 457 | |||
1275 | 458 | state = action_group.get_action_state ("indicator"); | ||
1276 | 459 | assert (((!) state).lookup ("visible", "b", out visible)); | ||
1277 | 460 | assert (visible); | ||
1278 | 461 | } | ||
1279 | 462 | |||
1280 | 463 | static void test_update_input_source (void *data) { | ||
1281 | 464 | var fixture = (Fixture *) data; | ||
1282 | 465 | |||
1283 | 466 | if (fixture.object_name == 0) { | ||
1284 | 467 | Test.message ("error: Test fixture not initialized."); | ||
1285 | 468 | Test.fail (); | ||
1286 | 469 | return; | ||
1287 | 470 | } | ||
1288 | 471 | |||
1289 | 472 | try { | ||
1290 | 473 | var current = 0; | ||
1291 | 474 | var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]"; | ||
1292 | 475 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); | ||
1293 | 476 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); | ||
1294 | 477 | } catch (SpawnError error) { | ||
1295 | 478 | Test.message ("error: %s", error.message); | ||
1296 | 479 | Test.fail (); | ||
1297 | 480 | return; | ||
1298 | 481 | } | ||
1299 | 482 | |||
1300 | 483 | var action_group = DBusActionGroup.get ((!) fixture.connection, | ||
1301 | 484 | "com.canonical.indicator.keyboard", | ||
1302 | 485 | "/com/canonical/indicator/keyboard"); | ||
1303 | 486 | var loop = new MainLoop (null, false); | ||
1304 | 487 | var signal_name = action_group.action_state_changed["current"].connect ((action, state) => { | ||
1305 | 488 | loop.quit (); | ||
1306 | 489 | }); | ||
1307 | 490 | |||
1308 | 491 | action_group.list_actions (); | ||
1309 | 492 | |||
1310 | 493 | try { | ||
1311 | 494 | var current = 1; | ||
1312 | 495 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); | ||
1313 | 496 | } catch (SpawnError error) { | ||
1314 | 497 | Test.message ("error: %s", error.message); | ||
1315 | 498 | Test.fail (); | ||
1316 | 499 | return; | ||
1317 | 500 | } | ||
1318 | 501 | |||
1319 | 502 | var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
1320 | 503 | loop.run (); | ||
1321 | 504 | Source.remove (source); | ||
1322 | 505 | action_group.disconnect (signal_name); | ||
1323 | 506 | |||
1324 | 507 | var state = action_group.get_action_state ("current"); | ||
1325 | 508 | var current = ((!) state).get_uint32 (); | ||
1326 | 509 | assert (current == 1); | ||
1327 | 510 | |||
1328 | 511 | try { | ||
1329 | 512 | string output; | ||
1330 | 513 | Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output); | ||
1331 | 514 | assert (strcmp (output, "uint32 1\n") == 0); | ||
1332 | 515 | } catch (SpawnError error) { | ||
1333 | 516 | Test.message ("error: %s", error.message); | ||
1334 | 517 | Test.fail (); | ||
1335 | 518 | return; | ||
1336 | 519 | } | ||
1337 | 520 | |||
1338 | 521 | loop = new MainLoop (null, false); | ||
1339 | 522 | signal_name = action_group.action_state_changed["current"].connect ((action, state) => { | ||
1340 | 523 | loop.quit (); | ||
1341 | 524 | }); | ||
1342 | 525 | |||
1343 | 526 | try { | ||
1344 | 527 | current = 0; | ||
1345 | 528 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); | ||
1346 | 529 | } catch (SpawnError error) { | ||
1347 | 530 | Test.message ("error: %s", error.message); | ||
1348 | 531 | Test.fail (); | ||
1349 | 532 | return; | ||
1350 | 533 | } | ||
1351 | 534 | |||
1352 | 535 | source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
1353 | 536 | loop.run (); | ||
1354 | 537 | Source.remove (source); | ||
1355 | 538 | action_group.disconnect (signal_name); | ||
1356 | 539 | |||
1357 | 540 | state = action_group.get_action_state ("current"); | ||
1358 | 541 | current = ((!) state).get_uint32 (); | ||
1359 | 542 | assert (current == 0); | ||
1360 | 543 | |||
1361 | 544 | try { | ||
1362 | 545 | string output; | ||
1363 | 546 | Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output); | ||
1364 | 547 | assert (strcmp (output, "uint32 0\n") == 0); | ||
1365 | 548 | } catch (SpawnError error) { | ||
1366 | 549 | Test.message ("error: %s", error.message); | ||
1367 | 550 | Test.fail (); | ||
1368 | 551 | return; | ||
1369 | 552 | } | ||
1370 | 553 | } | ||
1371 | 554 | |||
1372 | 555 | static void test_update_input_sources (void *data) { | ||
1373 | 556 | var fixture = (Fixture *) data; | ||
1374 | 557 | |||
1375 | 558 | if (fixture.object_name == 0) { | ||
1376 | 559 | Test.message ("error: Test fixture not initialized."); | ||
1377 | 560 | Test.fail (); | ||
1378 | 561 | return; | ||
1379 | 562 | } | ||
1380 | 563 | |||
1381 | 564 | try { | ||
1382 | 565 | var current = 0; | ||
1383 | 566 | var sources = "[('xkb', 'us')]"; | ||
1384 | 567 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); | ||
1385 | 568 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); | ||
1386 | 569 | } catch (SpawnError error) { | ||
1387 | 570 | Test.message ("error: %s", error.message); | ||
1388 | 571 | Test.fail (); | ||
1389 | 572 | return; | ||
1390 | 573 | } | ||
1391 | 574 | |||
1392 | 575 | var menu_model = DBusMenuModel.get ((!) fixture.connection, | ||
1393 | 576 | "com.canonical.indicator.keyboard", | ||
1394 | 577 | "/com/canonical/indicator/keyboard/desktop"); | ||
1395 | 578 | var loop = new MainLoop (null, false); | ||
1396 | 579 | var signal_name = menu_model.items_changed.connect ((position, removed, added) => { | ||
1397 | 580 | loop.quit (); | ||
1398 | 581 | }); | ||
1399 | 582 | |||
1400 | 583 | menu_model.get_n_items (); | ||
1401 | 584 | |||
1402 | 585 | var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
1403 | 586 | loop.run (); | ||
1404 | 587 | Source.remove (source); | ||
1405 | 588 | menu_model.disconnect (signal_name); | ||
1406 | 589 | |||
1407 | 590 | var menu = menu_model.get_item_link (0, Menu.LINK_SUBMENU); | ||
1408 | 591 | loop = new MainLoop (null, false); | ||
1409 | 592 | signal_name = menu.items_changed.connect ((position, removed, added) => { | ||
1410 | 593 | loop.quit (); | ||
1411 | 594 | }); | ||
1412 | 595 | |||
1413 | 596 | menu.get_n_items (); | ||
1414 | 597 | |||
1415 | 598 | source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
1416 | 599 | loop.run (); | ||
1417 | 600 | Source.remove (source); | ||
1418 | 601 | menu.disconnect (signal_name); | ||
1419 | 602 | |||
1420 | 603 | var section = menu.get_item_link (0, Menu.LINK_SECTION); | ||
1421 | 604 | loop = new MainLoop (null, false); | ||
1422 | 605 | signal_name = section.items_changed.connect ((position, removed, added) => { | ||
1423 | 606 | loop.quit (); | ||
1424 | 607 | }); | ||
1425 | 608 | |||
1426 | 609 | section.get_n_items (); | ||
1427 | 610 | |||
1428 | 611 | source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
1429 | 612 | loop.run (); | ||
1430 | 613 | Source.remove (source); | ||
1431 | 614 | section.disconnect (signal_name); | ||
1432 | 615 | |||
1433 | 616 | string label; | ||
1434 | 617 | |||
1435 | 618 | assert (section.get_n_items () == 1); | ||
1436 | 619 | section.get_item_attribute (0, Menu.ATTRIBUTE_LABEL, "s", out label); | ||
1437 | 620 | assert (strcmp (label, "English (US)") == 0); | ||
1438 | 621 | |||
1439 | 622 | loop = new MainLoop (null, false); | ||
1440 | 623 | signal_name = section.items_changed.connect ((position, removed, added) => { | ||
1441 | 624 | if (section.get_n_items () == 4) { | ||
1442 | 625 | loop.quit (); | ||
1443 | 626 | } | ||
1444 | 627 | }); | ||
1445 | 628 | |||
1446 | 629 | try { | ||
1447 | 630 | var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]"; | ||
1448 | 631 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); | ||
1449 | 632 | } catch (SpawnError error) { | ||
1450 | 633 | Test.message ("error: %s", error.message); | ||
1451 | 634 | Test.fail (); | ||
1452 | 635 | return; | ||
1453 | 636 | } | ||
1454 | 637 | |||
1455 | 638 | source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
1456 | 639 | loop.run (); | ||
1457 | 640 | Source.remove (source); | ||
1458 | 641 | section.disconnect (signal_name); | ||
1459 | 642 | |||
1460 | 643 | assert (section.get_n_items () == 4); | ||
1461 | 644 | section.get_item_attribute (0, Menu.ATTRIBUTE_LABEL, "s", out label); | ||
1462 | 645 | assert (strcmp (label, "English (US)") == 0); | ||
1463 | 646 | section.get_item_attribute (1, Menu.ATTRIBUTE_LABEL, "s", out label); | ||
1464 | 647 | assert (strcmp (label, "English (Canada)") == 0); | ||
1465 | 648 | section.get_item_attribute (2, Menu.ATTRIBUTE_LABEL, "s", out label); | ||
1466 | 649 | assert (strcmp (label, "Esperanto") == 0); | ||
1467 | 650 | section.get_item_attribute (3, Menu.ATTRIBUTE_LABEL, "s", out label); | ||
1468 | 651 | assert (strcmp (label, "Pinyin") == 0); | ||
1469 | 652 | } | ||
1470 | 653 | |||
1471 | 654 | public int main (string[] args) { | ||
1472 | 655 | Environment.set_variable ("DCONF_PROFILE", DCONF_PROFILE, true); | ||
1473 | 656 | Environment.set_variable ("LC_ALL", "C", true); | ||
1474 | 657 | |||
1475 | 658 | Test.init (ref args, null); | ||
1476 | 659 | |||
1477 | 660 | var suite = new TestSuite ("indicator-keyboard"); | ||
1478 | 661 | |||
1479 | 662 | suite.add (new TestCase ("activate-input-source", begin_test, test_activate_input_source, end_test, sizeof (Fixture))); | ||
1480 | 663 | suite.add (new TestCase ("activate-character-map", begin_test, test_activate_character_map, end_test, sizeof (Fixture))); | ||
1481 | 664 | suite.add (new TestCase ("activate-keyboard-layout-chart", begin_test, test_activate_keyboard_layout_chart, end_test, sizeof (Fixture))); | ||
1482 | 665 | suite.add (new TestCase ("activate-text-entry-settings", begin_test, test_activate_text_entry_settings, end_test, sizeof (Fixture))); | ||
1483 | 666 | suite.add (new TestCase ("migration", begin_test, test_migration, end_test, sizeof (Fixture))); | ||
1484 | 667 | suite.add (new TestCase ("no-migration", begin_test, test_no_migration, end_test, sizeof (Fixture))); | ||
1485 | 668 | suite.add (new TestCase ("update-visible", begin_test, test_update_visible, end_test, sizeof (Fixture))); | ||
1486 | 669 | suite.add (new TestCase ("update-input-source", begin_test, test_update_input_source, end_test, sizeof (Fixture))); | ||
1487 | 670 | suite.add (new TestCase ("update-input-sources", begin_test, test_update_input_sources, end_test, sizeof (Fixture))); | ||
1488 | 671 | |||
1489 | 672 | TestSuite.get_root ().add_suite (suite); | ||
1490 | 673 | |||
1491 | 674 | return Test.run (); | ||
1492 | 675 | } | ||
1493 | 676 | 0 | ||
1494 | === removed directory '.pc/relax-test-missing-ibus.patch' | |||
1495 | === removed directory '.pc/relax-test-missing-ibus.patch/tests' | |||
1496 | === removed file '.pc/relax-test-missing-ibus.patch/tests/main.vala' | |||
1497 | --- .pc/relax-test-missing-ibus.patch/tests/main.vala 2013-07-17 20:06:48 +0000 | |||
1498 | +++ .pc/relax-test-missing-ibus.patch/tests/main.vala 1970-01-01 00:00:00 +0000 | |||
1499 | @@ -1,675 +0,0 @@ | |||
1500 | 1 | const int TIMEOUT_S = 1; | ||
1501 | 2 | const int TIMEOUT_MS = 1000; | ||
1502 | 3 | |||
1503 | 4 | [DBus (name = "com.canonical.indicator.keyboard.test")] | ||
1504 | 5 | public class Service : Object { | ||
1505 | 6 | |||
1506 | 7 | [DBus (visible = false)] | ||
1507 | 8 | private string? _command; | ||
1508 | 9 | |||
1509 | 10 | [DBus (visible = false)] | ||
1510 | 11 | public string? command { | ||
1511 | 12 | get { return _command; } | ||
1512 | 13 | } | ||
1513 | 14 | |||
1514 | 15 | public void execute (string command) { | ||
1515 | 16 | this._command = command; | ||
1516 | 17 | |||
1517 | 18 | var pspec = this.get_class ().find_property ("command"); | ||
1518 | 19 | |||
1519 | 20 | if (pspec != null) { | ||
1520 | 21 | this.notify["command"] ((!) pspec); | ||
1521 | 22 | } | ||
1522 | 23 | } | ||
1523 | 24 | } | ||
1524 | 25 | |||
1525 | 26 | struct Fixture { | ||
1526 | 27 | TestDBus? bus; | ||
1527 | 28 | uint service_name; | ||
1528 | 29 | DBusConnection? connection; | ||
1529 | 30 | Service? service; | ||
1530 | 31 | uint object_name; | ||
1531 | 32 | } | ||
1532 | 33 | |||
1533 | 34 | static void start_service (Fixture *fixture) { | ||
1534 | 35 | if (fixture.connection != null) { | ||
1535 | 36 | try { | ||
1536 | 37 | fixture.service = new Service (); | ||
1537 | 38 | fixture.object_name = ((!) fixture.connection).register_object ("/com/canonical/indicator/keyboard/test", fixture.service); | ||
1538 | 39 | } catch (IOError error) { | ||
1539 | 40 | fixture.connection = null; | ||
1540 | 41 | fixture.service = null; | ||
1541 | 42 | fixture.object_name = 0; | ||
1542 | 43 | |||
1543 | 44 | Test.message ("error: %s", error.message); | ||
1544 | 45 | Test.fail (); | ||
1545 | 46 | } | ||
1546 | 47 | } | ||
1547 | 48 | } | ||
1548 | 49 | |||
1549 | 50 | static void begin_test (void *data) { | ||
1550 | 51 | var fixture = (Fixture *) data; | ||
1551 | 52 | |||
1552 | 53 | fixture.bus = new TestDBus (TestDBusFlags.NONE); | ||
1553 | 54 | ((!) fixture.bus).add_service_dir (SERVICE_DIR); | ||
1554 | 55 | ((!) fixture.bus).up (); | ||
1555 | 56 | |||
1556 | 57 | var loop = new MainLoop (null, false); | ||
1557 | 58 | |||
1558 | 59 | fixture.service_name = Bus.own_name (BusType.SESSION, | ||
1559 | 60 | "com.canonical.indicator.keyboard.test", | ||
1560 | 61 | BusNameOwnerFlags.ALLOW_REPLACEMENT | BusNameOwnerFlags.REPLACE, | ||
1561 | 62 | (connection, name) => { | ||
1562 | 63 | if (loop.is_running ()) { | ||
1563 | 64 | fixture.connection = connection; | ||
1564 | 65 | |||
1565 | 66 | start_service (fixture); | ||
1566 | 67 | |||
1567 | 68 | loop.quit (); | ||
1568 | 69 | } | ||
1569 | 70 | }, | ||
1570 | 71 | null, | ||
1571 | 72 | (connection, name) => { | ||
1572 | 73 | if (loop.is_running ()) { | ||
1573 | 74 | fixture.connection = null; | ||
1574 | 75 | fixture.service = null; | ||
1575 | 76 | fixture.object_name = 0; | ||
1576 | 77 | |||
1577 | 78 | loop.quit (); | ||
1578 | 79 | } | ||
1579 | 80 | }); | ||
1580 | 81 | |||
1581 | 82 | loop.run (); | ||
1582 | 83 | |||
1583 | 84 | if (fixture.connection == null) { | ||
1584 | 85 | Test.message ("error: Unable to connect to com.canonical.indicator.keyboard.test."); | ||
1585 | 86 | Test.fail (); | ||
1586 | 87 | } | ||
1587 | 88 | } | ||
1588 | 89 | |||
1589 | 90 | static void end_test (void *data) { | ||
1590 | 91 | var fixture = (Fixture *) data; | ||
1591 | 92 | |||
1592 | 93 | if (fixture.object_name != 0) { | ||
1593 | 94 | ((!) fixture.connection).unregister_object (fixture.object_name); | ||
1594 | 95 | fixture.object_name = 0; | ||
1595 | 96 | } | ||
1596 | 97 | |||
1597 | 98 | if (fixture.service_name != 0) { | ||
1598 | 99 | Bus.unown_name (fixture.service_name); | ||
1599 | 100 | fixture.service_name = 0; | ||
1600 | 101 | } | ||
1601 | 102 | |||
1602 | 103 | fixture.service = null; | ||
1603 | 104 | fixture.connection = null; | ||
1604 | 105 | |||
1605 | 106 | if (fixture.bus != null) { | ||
1606 | 107 | ((!) fixture.bus).down (); | ||
1607 | 108 | fixture.bus = null; | ||
1608 | 109 | } | ||
1609 | 110 | } | ||
1610 | 111 | |||
1611 | 112 | static void test_activate_input_source (void *data) { | ||
1612 | 113 | var fixture = (Fixture *) data; | ||
1613 | 114 | |||
1614 | 115 | if (fixture.object_name == 0) { | ||
1615 | 116 | Test.message ("error: Test fixture not initialized."); | ||
1616 | 117 | Test.fail (); | ||
1617 | 118 | return; | ||
1618 | 119 | } | ||
1619 | 120 | |||
1620 | 121 | try { | ||
1621 | 122 | var current = 0; | ||
1622 | 123 | var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]"; | ||
1623 | 124 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); | ||
1624 | 125 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); | ||
1625 | 126 | } catch (SpawnError error) { | ||
1626 | 127 | Test.message ("error: %s", error.message); | ||
1627 | 128 | Test.fail (); | ||
1628 | 129 | return; | ||
1629 | 130 | } | ||
1630 | 131 | |||
1631 | 132 | var action_group = DBusActionGroup.get ((!) fixture.connection, | ||
1632 | 133 | "com.canonical.indicator.keyboard", | ||
1633 | 134 | "/com/canonical/indicator/keyboard"); | ||
1634 | 135 | var loop = new MainLoop (null, false); | ||
1635 | 136 | var signal_name = action_group.action_state_changed["current"].connect ((action, state) => { | ||
1636 | 137 | loop.quit (); | ||
1637 | 138 | }); | ||
1638 | 139 | |||
1639 | 140 | action_group.list_actions (); | ||
1640 | 141 | action_group.activate_action ("current", new Variant.uint32 (2)); | ||
1641 | 142 | |||
1642 | 143 | var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
1643 | 144 | loop.run (); | ||
1644 | 145 | Source.remove (source); | ||
1645 | 146 | action_group.disconnect (signal_name); | ||
1646 | 147 | |||
1647 | 148 | var state = action_group.get_action_state ("current"); | ||
1648 | 149 | var current = state.get_uint32 (); | ||
1649 | 150 | assert (current == 2); | ||
1650 | 151 | |||
1651 | 152 | try { | ||
1652 | 153 | string output; | ||
1653 | 154 | Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output); | ||
1654 | 155 | assert (strcmp (output, "uint32 2\n") == 0); | ||
1655 | 156 | } catch (SpawnError error) { | ||
1656 | 157 | Test.message ("error: %s", error.message); | ||
1657 | 158 | Test.fail (); | ||
1658 | 159 | return; | ||
1659 | 160 | } | ||
1660 | 161 | } | ||
1661 | 162 | |||
1662 | 163 | static void test_activate_character_map (void *data) { | ||
1663 | 164 | var fixture = (Fixture *) data; | ||
1664 | 165 | |||
1665 | 166 | if (fixture.object_name == 0) { | ||
1666 | 167 | Test.message ("error: Test fixture not initialized."); | ||
1667 | 168 | Test.fail (); | ||
1668 | 169 | return; | ||
1669 | 170 | } | ||
1670 | 171 | |||
1671 | 172 | var action_group = DBusActionGroup.get ((!) fixture.connection, | ||
1672 | 173 | "com.canonical.indicator.keyboard", | ||
1673 | 174 | "/com/canonical/indicator/keyboard"); | ||
1674 | 175 | var loop = new MainLoop (null, false); | ||
1675 | 176 | var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => { | ||
1676 | 177 | loop.quit (); | ||
1677 | 178 | }); | ||
1678 | 179 | |||
1679 | 180 | action_group.activate_action ("map", null); | ||
1680 | 181 | |||
1681 | 182 | var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
1682 | 183 | loop.run (); | ||
1683 | 184 | Source.remove (source); | ||
1684 | 185 | ((!) fixture.service).disconnect (signal_name); | ||
1685 | 186 | |||
1686 | 187 | assert (strcmp ((!) ((!) fixture.service).command, "'gucharmap '") == 0); | ||
1687 | 188 | } | ||
1688 | 189 | |||
1689 | 190 | static void test_activate_keyboard_layout_chart (void *data) { | ||
1690 | 191 | var fixture = (Fixture *) data; | ||
1691 | 192 | |||
1692 | 193 | if (fixture.object_name == 0) { | ||
1693 | 194 | Test.message ("error: Test fixture not initialized."); | ||
1694 | 195 | Test.fail (); | ||
1695 | 196 | return; | ||
1696 | 197 | } | ||
1697 | 198 | |||
1698 | 199 | try { | ||
1699 | 200 | var current = 1; | ||
1700 | 201 | var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]"; | ||
1701 | 202 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); | ||
1702 | 203 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); | ||
1703 | 204 | } catch (SpawnError error) { | ||
1704 | 205 | Test.message ("error: %s", error.message); | ||
1705 | 206 | Test.fail (); | ||
1706 | 207 | return; | ||
1707 | 208 | } | ||
1708 | 209 | |||
1709 | 210 | var action_group = DBusActionGroup.get ((!) fixture.connection, | ||
1710 | 211 | "com.canonical.indicator.keyboard", | ||
1711 | 212 | "/com/canonical/indicator/keyboard"); | ||
1712 | 213 | var loop = new MainLoop (null, false); | ||
1713 | 214 | var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => { | ||
1714 | 215 | loop.quit (); | ||
1715 | 216 | }); | ||
1716 | 217 | |||
1717 | 218 | action_group.activate_action ("chart", null); | ||
1718 | 219 | |||
1719 | 220 | var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
1720 | 221 | loop.run (); | ||
1721 | 222 | Source.remove (source); | ||
1722 | 223 | ((!) fixture.service).disconnect (signal_name); | ||
1723 | 224 | |||
1724 | 225 | assert (strcmp ((!) ((!) fixture.service).command, "'gkbd-keyboard-display -l ca\teng'") == 0); | ||
1725 | 226 | } | ||
1726 | 227 | |||
1727 | 228 | static void test_activate_text_entry_settings (void *data) { | ||
1728 | 229 | var fixture = (Fixture *) data; | ||
1729 | 230 | |||
1730 | 231 | if (fixture.object_name == 0) { | ||
1731 | 232 | Test.message ("error: Test fixture not initialized."); | ||
1732 | 233 | Test.fail (); | ||
1733 | 234 | return; | ||
1734 | 235 | } | ||
1735 | 236 | |||
1736 | 237 | var action_group = DBusActionGroup.get ((!) fixture.connection, | ||
1737 | 238 | "com.canonical.indicator.keyboard", | ||
1738 | 239 | "/com/canonical/indicator/keyboard"); | ||
1739 | 240 | var loop = new MainLoop (null, false); | ||
1740 | 241 | var signal_name = ((!) fixture.service).notify["command"].connect ((pspec) => { | ||
1741 | 242 | loop.quit (); | ||
1742 | 243 | }); | ||
1743 | 244 | |||
1744 | 245 | action_group.activate_action ("settings", null); | ||
1745 | 246 | |||
1746 | 247 | var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
1747 | 248 | loop.run (); | ||
1748 | 249 | Source.remove (source); | ||
1749 | 250 | ((!) fixture.service).disconnect (signal_name); | ||
1750 | 251 | |||
1751 | 252 | assert (strcmp ((!) ((!) fixture.service).command, "'gnome-control-center region layouts'") == 0); | ||
1752 | 253 | } | ||
1753 | 254 | |||
1754 | 255 | static void test_migration (void *data) { | ||
1755 | 256 | var fixture = (Fixture *) data; | ||
1756 | 257 | |||
1757 | 258 | if (fixture.object_name == 0) { | ||
1758 | 259 | Test.message ("error: Test fixture not initialized."); | ||
1759 | 260 | Test.fail (); | ||
1760 | 261 | return; | ||
1761 | 262 | } | ||
1762 | 263 | |||
1763 | 264 | try { | ||
1764 | 265 | var migrated = false; | ||
1765 | 266 | var sources = "[('xkb', 'us')]"; | ||
1766 | 267 | var layouts = "['us', 'ca\teng', 'epo']"; | ||
1767 | 268 | Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard migrated $migrated"); | ||
1768 | 269 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); | ||
1769 | 270 | Process.spawn_command_line_sync (@"gsettings set org.gnome.libgnomekbd.keyboard layouts \"$layouts\""); | ||
1770 | 271 | } catch (SpawnError error) { | ||
1771 | 272 | Test.message ("error: %s", error.message); | ||
1772 | 273 | Test.fail (); | ||
1773 | 274 | return; | ||
1774 | 275 | } | ||
1775 | 276 | |||
1776 | 277 | try { | ||
1777 | 278 | var cancellable = new Cancellable (); | ||
1778 | 279 | |||
1779 | 280 | var source = Timeout.add_seconds (TIMEOUT_S, () => { cancellable.cancel (); return false; }); | ||
1780 | 281 | |||
1781 | 282 | var dbus_proxy = new DBusProxy.sync ((!) fixture.connection, | ||
1782 | 283 | DBusProxyFlags.NONE, | ||
1783 | 284 | null, | ||
1784 | 285 | "org.freedesktop.DBus", | ||
1785 | 286 | "/", | ||
1786 | 287 | "org.freedesktop.DBus", | ||
1787 | 288 | cancellable); | ||
1788 | 289 | |||
1789 | 290 | Source.remove (source); | ||
1790 | 291 | |||
1791 | 292 | if (cancellable.is_cancelled ()) { | ||
1792 | 293 | Test.message ("error: Unable to connect to org.freedesktop.DBus."); | ||
1793 | 294 | Test.fail (); | ||
1794 | 295 | return; | ||
1795 | 296 | } | ||
1796 | 297 | |||
1797 | 298 | dbus_proxy.call_sync ("StartServiceByName", new Variant ("(su)", "com.canonical.indicator.keyboard", 0), DBusCallFlags.NONE, TIMEOUT_MS); | ||
1798 | 299 | } catch (Error error) { | ||
1799 | 300 | Test.message ("error: %s", error.message); | ||
1800 | 301 | Test.fail (); | ||
1801 | 302 | return; | ||
1802 | 303 | } | ||
1803 | 304 | |||
1804 | 305 | try { | ||
1805 | 306 | string sources; | ||
1806 | 307 | Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources sources", out sources); | ||
1807 | 308 | assert (strcmp (sources, "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo')]\n") == 0); | ||
1808 | 309 | } catch (SpawnError error) { | ||
1809 | 310 | Test.message ("error: %s", error.message); | ||
1810 | 311 | Test.fail (); | ||
1811 | 312 | return; | ||
1812 | 313 | } | ||
1813 | 314 | } | ||
1814 | 315 | |||
1815 | 316 | static void test_no_migration (void *data) { | ||
1816 | 317 | var fixture = (Fixture *) data; | ||
1817 | 318 | |||
1818 | 319 | if (fixture.object_name == 0) { | ||
1819 | 320 | Test.message ("error: Test fixture not initialized."); | ||
1820 | 321 | Test.fail (); | ||
1821 | 322 | return; | ||
1822 | 323 | } | ||
1823 | 324 | |||
1824 | 325 | try { | ||
1825 | 326 | var migrated = true; | ||
1826 | 327 | var sources = "[('xkb', 'us')]"; | ||
1827 | 328 | var layouts = "['us', 'ca\teng', 'epo']"; | ||
1828 | 329 | Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard migrated $migrated"); | ||
1829 | 330 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); | ||
1830 | 331 | Process.spawn_command_line_sync (@"gsettings set org.gnome.libgnomekbd.keyboard layouts \"$layouts\""); | ||
1831 | 332 | } catch (SpawnError error) { | ||
1832 | 333 | Test.message ("error: %s", error.message); | ||
1833 | 334 | Test.fail (); | ||
1834 | 335 | return; | ||
1835 | 336 | } | ||
1836 | 337 | |||
1837 | 338 | try { | ||
1838 | 339 | var cancellable = new Cancellable (); | ||
1839 | 340 | |||
1840 | 341 | var source = Timeout.add_seconds (TIMEOUT_S, () => { cancellable.cancel (); return false; }); | ||
1841 | 342 | |||
1842 | 343 | var dbus_proxy = new DBusProxy.sync ((!) fixture.connection, | ||
1843 | 344 | DBusProxyFlags.NONE, | ||
1844 | 345 | null, | ||
1845 | 346 | "org.freedesktop.DBus", | ||
1846 | 347 | "/", | ||
1847 | 348 | "org.freedesktop.DBus", | ||
1848 | 349 | cancellable); | ||
1849 | 350 | |||
1850 | 351 | Source.remove (source); | ||
1851 | 352 | |||
1852 | 353 | if (cancellable.is_cancelled ()) { | ||
1853 | 354 | Test.message ("error: Unable to connect to org.freedesktop.DBus."); | ||
1854 | 355 | Test.fail (); | ||
1855 | 356 | return; | ||
1856 | 357 | } | ||
1857 | 358 | |||
1858 | 359 | dbus_proxy.call_sync ("StartServiceByName", new Variant ("(su)", "com.canonical.indicator.keyboard", 0), DBusCallFlags.NONE, TIMEOUT_MS); | ||
1859 | 360 | } catch (Error error) { | ||
1860 | 361 | Test.message ("error: %s", error.message); | ||
1861 | 362 | Test.fail (); | ||
1862 | 363 | return; | ||
1863 | 364 | } | ||
1864 | 365 | |||
1865 | 366 | try { | ||
1866 | 367 | string sources; | ||
1867 | 368 | Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources sources", out sources); | ||
1868 | 369 | assert (strcmp (sources, "[('xkb', 'us')]\n") == 0); | ||
1869 | 370 | } catch (SpawnError error) { | ||
1870 | 371 | Test.message ("error: %s", error.message); | ||
1871 | 372 | Test.fail (); | ||
1872 | 373 | return; | ||
1873 | 374 | } | ||
1874 | 375 | } | ||
1875 | 376 | |||
1876 | 377 | static void test_update_visible (void *data) { | ||
1877 | 378 | var fixture = (Fixture *) data; | ||
1878 | 379 | |||
1879 | 380 | if (fixture.object_name == 0) { | ||
1880 | 381 | Test.message ("error: Test fixture not initialized."); | ||
1881 | 382 | Test.fail (); | ||
1882 | 383 | return; | ||
1883 | 384 | } | ||
1884 | 385 | |||
1885 | 386 | bool visible; | ||
1886 | 387 | |||
1887 | 388 | try { | ||
1888 | 389 | visible = true; | ||
1889 | 390 | Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible"); | ||
1890 | 391 | } catch (SpawnError error) { | ||
1891 | 392 | Test.message ("error: %s", error.message); | ||
1892 | 393 | Test.fail (); | ||
1893 | 394 | return; | ||
1894 | 395 | } | ||
1895 | 396 | |||
1896 | 397 | var action_group = DBusActionGroup.get ((!) fixture.connection, | ||
1897 | 398 | "com.canonical.indicator.keyboard", | ||
1898 | 399 | "/com/canonical/indicator/keyboard"); | ||
1899 | 400 | var loop = new MainLoop (null, false); | ||
1900 | 401 | var signal_name = action_group.action_added["indicator"].connect ((action) => { | ||
1901 | 402 | loop.quit (); | ||
1902 | 403 | }); | ||
1903 | 404 | |||
1904 | 405 | action_group.list_actions (); | ||
1905 | 406 | |||
1906 | 407 | var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
1907 | 408 | loop.run (); | ||
1908 | 409 | Source.remove (source); | ||
1909 | 410 | action_group.disconnect (signal_name); | ||
1910 | 411 | |||
1911 | 412 | var state = action_group.get_action_state ("indicator"); | ||
1912 | 413 | assert (state.lookup ("visible", "b", out visible)); | ||
1913 | 414 | assert (visible); | ||
1914 | 415 | |||
1915 | 416 | loop = new MainLoop (null, false); | ||
1916 | 417 | signal_name = action_group.action_state_changed["indicator"].connect ((action, state) => { | ||
1917 | 418 | loop.quit (); | ||
1918 | 419 | }); | ||
1919 | 420 | |||
1920 | 421 | try { | ||
1921 | 422 | visible = false; | ||
1922 | 423 | Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible"); | ||
1923 | 424 | } catch (SpawnError error) { | ||
1924 | 425 | Test.message ("error: %s", error.message); | ||
1925 | 426 | Test.fail (); | ||
1926 | 427 | return; | ||
1927 | 428 | } | ||
1928 | 429 | |||
1929 | 430 | source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
1930 | 431 | loop.run (); | ||
1931 | 432 | Source.remove (source); | ||
1932 | 433 | action_group.disconnect (signal_name); | ||
1933 | 434 | |||
1934 | 435 | state = action_group.get_action_state ("indicator"); | ||
1935 | 436 | assert (state.lookup ("visible", "b", out visible)); | ||
1936 | 437 | assert (!visible); | ||
1937 | 438 | |||
1938 | 439 | loop = new MainLoop (null, false); | ||
1939 | 440 | signal_name = action_group.action_state_changed["indicator"].connect ((action, state) => { | ||
1940 | 441 | loop.quit (); | ||
1941 | 442 | }); | ||
1942 | 443 | |||
1943 | 444 | try { | ||
1944 | 445 | visible = true; | ||
1945 | 446 | Process.spawn_command_line_sync (@"gsettings set com.canonical.indicator.keyboard visible $visible"); | ||
1946 | 447 | } catch (SpawnError error) { | ||
1947 | 448 | Test.message ("error: %s", error.message); | ||
1948 | 449 | Test.fail (); | ||
1949 | 450 | return; | ||
1950 | 451 | } | ||
1951 | 452 | |||
1952 | 453 | source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
1953 | 454 | loop.run (); | ||
1954 | 455 | Source.remove (source); | ||
1955 | 456 | action_group.disconnect (signal_name); | ||
1956 | 457 | |||
1957 | 458 | state = action_group.get_action_state ("indicator"); | ||
1958 | 459 | assert (state.lookup ("visible", "b", out visible)); | ||
1959 | 460 | assert (visible); | ||
1960 | 461 | } | ||
1961 | 462 | |||
1962 | 463 | static void test_update_input_source (void *data) { | ||
1963 | 464 | var fixture = (Fixture *) data; | ||
1964 | 465 | |||
1965 | 466 | if (fixture.object_name == 0) { | ||
1966 | 467 | Test.message ("error: Test fixture not initialized."); | ||
1967 | 468 | Test.fail (); | ||
1968 | 469 | return; | ||
1969 | 470 | } | ||
1970 | 471 | |||
1971 | 472 | try { | ||
1972 | 473 | var current = 0; | ||
1973 | 474 | var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]"; | ||
1974 | 475 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); | ||
1975 | 476 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); | ||
1976 | 477 | } catch (SpawnError error) { | ||
1977 | 478 | Test.message ("error: %s", error.message); | ||
1978 | 479 | Test.fail (); | ||
1979 | 480 | return; | ||
1980 | 481 | } | ||
1981 | 482 | |||
1982 | 483 | var action_group = DBusActionGroup.get ((!) fixture.connection, | ||
1983 | 484 | "com.canonical.indicator.keyboard", | ||
1984 | 485 | "/com/canonical/indicator/keyboard"); | ||
1985 | 486 | var loop = new MainLoop (null, false); | ||
1986 | 487 | var signal_name = action_group.action_state_changed["current"].connect ((action, state) => { | ||
1987 | 488 | loop.quit (); | ||
1988 | 489 | }); | ||
1989 | 490 | |||
1990 | 491 | action_group.list_actions (); | ||
1991 | 492 | |||
1992 | 493 | try { | ||
1993 | 494 | var current = 1; | ||
1994 | 495 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); | ||
1995 | 496 | } catch (SpawnError error) { | ||
1996 | 497 | Test.message ("error: %s", error.message); | ||
1997 | 498 | Test.fail (); | ||
1998 | 499 | return; | ||
1999 | 500 | } | ||
2000 | 501 | |||
2001 | 502 | var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
2002 | 503 | loop.run (); | ||
2003 | 504 | Source.remove (source); | ||
2004 | 505 | action_group.disconnect (signal_name); | ||
2005 | 506 | |||
2006 | 507 | var state = action_group.get_action_state ("current"); | ||
2007 | 508 | var current = state.get_uint32 (); | ||
2008 | 509 | assert (current == 1); | ||
2009 | 510 | |||
2010 | 511 | try { | ||
2011 | 512 | string output; | ||
2012 | 513 | Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output); | ||
2013 | 514 | assert (strcmp (output, "uint32 1\n") == 0); | ||
2014 | 515 | } catch (SpawnError error) { | ||
2015 | 516 | Test.message ("error: %s", error.message); | ||
2016 | 517 | Test.fail (); | ||
2017 | 518 | return; | ||
2018 | 519 | } | ||
2019 | 520 | |||
2020 | 521 | loop = new MainLoop (null, false); | ||
2021 | 522 | signal_name = action_group.action_state_changed["current"].connect ((action, state) => { | ||
2022 | 523 | loop.quit (); | ||
2023 | 524 | }); | ||
2024 | 525 | |||
2025 | 526 | try { | ||
2026 | 527 | current = 0; | ||
2027 | 528 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); | ||
2028 | 529 | } catch (SpawnError error) { | ||
2029 | 530 | Test.message ("error: %s", error.message); | ||
2030 | 531 | Test.fail (); | ||
2031 | 532 | return; | ||
2032 | 533 | } | ||
2033 | 534 | |||
2034 | 535 | source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
2035 | 536 | loop.run (); | ||
2036 | 537 | Source.remove (source); | ||
2037 | 538 | action_group.disconnect (signal_name); | ||
2038 | 539 | |||
2039 | 540 | state = action_group.get_action_state ("current"); | ||
2040 | 541 | current = state.get_uint32 (); | ||
2041 | 542 | assert (current == 0); | ||
2042 | 543 | |||
2043 | 544 | try { | ||
2044 | 545 | string output; | ||
2045 | 546 | Process.spawn_command_line_sync ("gsettings get org.gnome.desktop.input-sources current", out output); | ||
2046 | 547 | assert (strcmp (output, "uint32 0\n") == 0); | ||
2047 | 548 | } catch (SpawnError error) { | ||
2048 | 549 | Test.message ("error: %s", error.message); | ||
2049 | 550 | Test.fail (); | ||
2050 | 551 | return; | ||
2051 | 552 | } | ||
2052 | 553 | } | ||
2053 | 554 | |||
2054 | 555 | static void test_update_input_sources (void *data) { | ||
2055 | 556 | var fixture = (Fixture *) data; | ||
2056 | 557 | |||
2057 | 558 | if (fixture.object_name == 0) { | ||
2058 | 559 | Test.message ("error: Test fixture not initialized."); | ||
2059 | 560 | Test.fail (); | ||
2060 | 561 | return; | ||
2061 | 562 | } | ||
2062 | 563 | |||
2063 | 564 | try { | ||
2064 | 565 | var current = 0; | ||
2065 | 566 | var sources = "[('xkb', 'us')]"; | ||
2066 | 567 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources current $current"); | ||
2067 | 568 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); | ||
2068 | 569 | } catch (SpawnError error) { | ||
2069 | 570 | Test.message ("error: %s", error.message); | ||
2070 | 571 | Test.fail (); | ||
2071 | 572 | return; | ||
2072 | 573 | } | ||
2073 | 574 | |||
2074 | 575 | var menu_model = DBusMenuModel.get ((!) fixture.connection, | ||
2075 | 576 | "com.canonical.indicator.keyboard", | ||
2076 | 577 | "/com/canonical/indicator/keyboard/desktop"); | ||
2077 | 578 | var loop = new MainLoop (null, false); | ||
2078 | 579 | var signal_name = menu_model.items_changed.connect ((position, removed, added) => { | ||
2079 | 580 | loop.quit (); | ||
2080 | 581 | }); | ||
2081 | 582 | |||
2082 | 583 | menu_model.get_n_items (); | ||
2083 | 584 | |||
2084 | 585 | var source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
2085 | 586 | loop.run (); | ||
2086 | 587 | Source.remove (source); | ||
2087 | 588 | menu_model.disconnect (signal_name); | ||
2088 | 589 | |||
2089 | 590 | var menu = menu_model.get_item_link (0, Menu.LINK_SUBMENU); | ||
2090 | 591 | loop = new MainLoop (null, false); | ||
2091 | 592 | signal_name = menu.items_changed.connect ((position, removed, added) => { | ||
2092 | 593 | loop.quit (); | ||
2093 | 594 | }); | ||
2094 | 595 | |||
2095 | 596 | menu.get_n_items (); | ||
2096 | 597 | |||
2097 | 598 | source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
2098 | 599 | loop.run (); | ||
2099 | 600 | Source.remove (source); | ||
2100 | 601 | menu.disconnect (signal_name); | ||
2101 | 602 | |||
2102 | 603 | var section = menu.get_item_link (0, Menu.LINK_SECTION); | ||
2103 | 604 | loop = new MainLoop (null, false); | ||
2104 | 605 | signal_name = section.items_changed.connect ((position, removed, added) => { | ||
2105 | 606 | loop.quit (); | ||
2106 | 607 | }); | ||
2107 | 608 | |||
2108 | 609 | section.get_n_items (); | ||
2109 | 610 | |||
2110 | 611 | source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
2111 | 612 | loop.run (); | ||
2112 | 613 | Source.remove (source); | ||
2113 | 614 | section.disconnect (signal_name); | ||
2114 | 615 | |||
2115 | 616 | string label; | ||
2116 | 617 | |||
2117 | 618 | assert (section.get_n_items () == 1); | ||
2118 | 619 | section.get_item_attribute (0, Menu.ATTRIBUTE_LABEL, "s", out label); | ||
2119 | 620 | assert (strcmp (label, "English (US)") == 0); | ||
2120 | 621 | |||
2121 | 622 | loop = new MainLoop (null, false); | ||
2122 | 623 | signal_name = section.items_changed.connect ((position, removed, added) => { | ||
2123 | 624 | if (section.get_n_items () == 4) { | ||
2124 | 625 | loop.quit (); | ||
2125 | 626 | } | ||
2126 | 627 | }); | ||
2127 | 628 | |||
2128 | 629 | try { | ||
2129 | 630 | var sources = "[('xkb', 'us'), ('xkb', 'ca+eng'), ('xkb', 'epo'), ('ibus', 'pinyin')]"; | ||
2130 | 631 | Process.spawn_command_line_sync (@"gsettings set org.gnome.desktop.input-sources sources \"$sources\""); | ||
2131 | 632 | } catch (SpawnError error) { | ||
2132 | 633 | Test.message ("error: %s", error.message); | ||
2133 | 634 | Test.fail (); | ||
2134 | 635 | return; | ||
2135 | 636 | } | ||
2136 | 637 | |||
2137 | 638 | source = Timeout.add_seconds (TIMEOUT_S, () => { loop.quit (); return false; }); | ||
2138 | 639 | loop.run (); | ||
2139 | 640 | Source.remove (source); | ||
2140 | 641 | section.disconnect (signal_name); | ||
2141 | 642 | |||
2142 | 643 | assert (section.get_n_items () == 4); | ||
2143 | 644 | section.get_item_attribute (0, Menu.ATTRIBUTE_LABEL, "s", out label); | ||
2144 | 645 | assert (strcmp (label, "English (US)") == 0); | ||
2145 | 646 | section.get_item_attribute (1, Menu.ATTRIBUTE_LABEL, "s", out label); | ||
2146 | 647 | assert (strcmp (label, "English (Canada)") == 0); | ||
2147 | 648 | section.get_item_attribute (2, Menu.ATTRIBUTE_LABEL, "s", out label); | ||
2148 | 649 | assert (strcmp (label, "Esperanto") == 0); | ||
2149 | 650 | section.get_item_attribute (3, Menu.ATTRIBUTE_LABEL, "s", out label); | ||
2150 | 651 | assert (strcmp (label, "Pinyin") == 0); | ||
2151 | 652 | } | ||
2152 | 653 | |||
2153 | 654 | public int main (string[] args) { | ||
2154 | 655 | Environment.set_variable ("DCONF_PROFILE", DCONF_PROFILE, true); | ||
2155 | 656 | Environment.set_variable ("LC_ALL", "C", true); | ||
2156 | 657 | |||
2157 | 658 | Test.init (ref args, null); | ||
2158 | 659 | |||
2159 | 660 | var suite = new TestSuite ("indicator-keyboard"); | ||
2160 | 661 | |||
2161 | 662 | suite.add (new TestCase ("activate-input-source", begin_test, test_activate_input_source, end_test, sizeof (Fixture))); | ||
2162 | 663 | suite.add (new TestCase ("activate-character-map", begin_test, test_activate_character_map, end_test, sizeof (Fixture))); | ||
2163 | 664 | suite.add (new TestCase ("activate-keyboard-layout-chart", begin_test, test_activate_keyboard_layout_chart, end_test, sizeof (Fixture))); | ||
2164 | 665 | suite.add (new TestCase ("activate-text-entry-settings", begin_test, test_activate_text_entry_settings, end_test, sizeof (Fixture))); | ||
2165 | 666 | suite.add (new TestCase ("migration", begin_test, test_migration, end_test, sizeof (Fixture))); | ||
2166 | 667 | suite.add (new TestCase ("no-migration", begin_test, test_no_migration, end_test, sizeof (Fixture))); | ||
2167 | 668 | suite.add (new TestCase ("update-visible", begin_test, test_update_visible, end_test, sizeof (Fixture))); | ||
2168 | 669 | suite.add (new TestCase ("update-input-source", begin_test, test_update_input_source, end_test, sizeof (Fixture))); | ||
2169 | 670 | suite.add (new TestCase ("update-input-sources", begin_test, test_update_input_sources, end_test, sizeof (Fixture))); | ||
2170 | 671 | |||
2171 | 672 | TestSuite.get_root ().add_suite (suite); | ||
2172 | 673 | |||
2173 | 674 | return Test.run (); | ||
2174 | 675 | } | ||
2175 | 676 | 0 | ||
2176 | === removed directory 'debian/patches' | |||
2177 | === removed file 'debian/patches/default-icon-colour.patch' | |||
2178 | --- debian/patches/default-icon-colour.patch 2013-07-17 18:47:22 +0000 | |||
2179 | +++ debian/patches/default-icon-colour.patch 1970-01-01 00:00:00 +0000 | |||
2180 | @@ -1,10 +0,0 @@ | |||
2181 | 1 | --- a/lib/main.vala | ||
2182 | 2 | +++ b/lib/main.vala | ||
2183 | 3 | @@ -207,6 +207,7 @@ | ||
2184 | 4 | |||
2185 | 5 | Pango.FontDescription description; | ||
2186 | 6 | var colour = ((!) style).get_color (Gtk.StateFlags.NORMAL); | ||
2187 | 7 | + colour = { 0.5, 0.5, 0.5, 1.0 }; | ||
2188 | 8 | ((!) style).get (Gtk.StateFlags.NORMAL, Gtk.STYLE_PROPERTY_FONT, out description); | ||
2189 | 9 | |||
2190 | 10 | var surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, W, H); | ||
2191 | 11 | 0 | ||
2192 | === removed file 'debian/patches/disable-experimental-non-null.patch' | |||
2193 | --- debian/patches/disable-experimental-non-null.patch 2013-07-17 19:17:32 +0000 | |||
2194 | +++ debian/patches/disable-experimental-non-null.patch 1970-01-01 00:00:00 +0000 | |||
2195 | @@ -1,68 +0,0 @@ | |||
2196 | 1 | --- a/tests/Makefile.am | ||
2197 | 2 | +++ b/tests/Makefile.am | ||
2198 | 3 | @@ -4,8 +4,7 @@ | ||
2199 | 4 | |||
2200 | 5 | AM_CFLAGS = -w | ||
2201 | 6 | AM_LDFLAGS = -lm | ||
2202 | 7 | -AM_VALAFLAGS = --enable-experimental-non-null \ | ||
2203 | 8 | - --metadatadir $(top_srcdir)/deps \ | ||
2204 | 9 | +AM_VALAFLAGS = --metadatadir $(top_srcdir)/deps \ | ||
2205 | 10 | --vapidir $(top_srcdir)/deps | ||
2206 | 11 | |||
2207 | 12 | indicator_keyboard_tests_SOURCES = main.vala \ | ||
2208 | 13 | --- a/tests/main.vala | ||
2209 | 14 | +++ b/tests/main.vala | ||
2210 | 15 | @@ -146,7 +146,7 @@ | ||
2211 | 16 | action_group.disconnect (signal_name); | ||
2212 | 17 | |||
2213 | 18 | var state = action_group.get_action_state ("current"); | ||
2214 | 19 | - var current = ((!) state).get_uint32 (); | ||
2215 | 20 | + var current = state.get_uint32 (); | ||
2216 | 21 | assert (current == 2); | ||
2217 | 22 | |||
2218 | 23 | try { | ||
2219 | 24 | @@ -410,7 +410,7 @@ | ||
2220 | 25 | action_group.disconnect (signal_name); | ||
2221 | 26 | |||
2222 | 27 | var state = action_group.get_action_state ("indicator"); | ||
2223 | 28 | - assert (((!) state).lookup ("visible", "b", out visible)); | ||
2224 | 29 | + assert (state.lookup ("visible", "b", out visible)); | ||
2225 | 30 | assert (visible); | ||
2226 | 31 | |||
2227 | 32 | loop = new MainLoop (null, false); | ||
2228 | 33 | @@ -433,7 +433,7 @@ | ||
2229 | 34 | action_group.disconnect (signal_name); | ||
2230 | 35 | |||
2231 | 36 | state = action_group.get_action_state ("indicator"); | ||
2232 | 37 | - assert (((!) state).lookup ("visible", "b", out visible)); | ||
2233 | 38 | + assert (state.lookup ("visible", "b", out visible)); | ||
2234 | 39 | assert (!visible); | ||
2235 | 40 | |||
2236 | 41 | loop = new MainLoop (null, false); | ||
2237 | 42 | @@ -456,7 +456,7 @@ | ||
2238 | 43 | action_group.disconnect (signal_name); | ||
2239 | 44 | |||
2240 | 45 | state = action_group.get_action_state ("indicator"); | ||
2241 | 46 | - assert (((!) state).lookup ("visible", "b", out visible)); | ||
2242 | 47 | + assert (state.lookup ("visible", "b", out visible)); | ||
2243 | 48 | assert (visible); | ||
2244 | 49 | } | ||
2245 | 50 | |||
2246 | 51 | @@ -505,7 +505,7 @@ | ||
2247 | 52 | action_group.disconnect (signal_name); | ||
2248 | 53 | |||
2249 | 54 | var state = action_group.get_action_state ("current"); | ||
2250 | 55 | - var current = ((!) state).get_uint32 (); | ||
2251 | 56 | + var current = state.get_uint32 (); | ||
2252 | 57 | assert (current == 1); | ||
2253 | 58 | |||
2254 | 59 | try { | ||
2255 | 60 | @@ -538,7 +538,7 @@ | ||
2256 | 61 | action_group.disconnect (signal_name); | ||
2257 | 62 | |||
2258 | 63 | state = action_group.get_action_state ("current"); | ||
2259 | 64 | - current = ((!) state).get_uint32 (); | ||
2260 | 65 | + current = state.get_uint32 (); | ||
2261 | 66 | assert (current == 0); | ||
2262 | 67 | |||
2263 | 68 | try { | ||
2264 | 69 | 0 | ||
2265 | === removed file 'debian/patches/relax-test-missing-ibus.patch' | |||
2266 | --- debian/patches/relax-test-missing-ibus.patch 2013-07-17 20:06:48 +0000 | |||
2267 | +++ debian/patches/relax-test-missing-ibus.patch 1970-01-01 00:00:00 +0000 | |||
2268 | @@ -1,11 +0,0 @@ | |||
2269 | 1 | --- a/tests/main.vala | ||
2270 | 2 | +++ b/tests/main.vala | ||
2271 | 3 | @@ -648,7 +648,7 @@ | ||
2272 | 4 | section.get_item_attribute (2, Menu.ATTRIBUTE_LABEL, "s", out label); | ||
2273 | 5 | assert (strcmp (label, "Esperanto") == 0); | ||
2274 | 6 | section.get_item_attribute (3, Menu.ATTRIBUTE_LABEL, "s", out label); | ||
2275 | 7 | - assert (strcmp (label, "Pinyin") == 0); | ||
2276 | 8 | + assert (label.ascii_casecmp ("Pinyin") == 0); | ||
2277 | 9 | } | ||
2278 | 10 | |||
2279 | 11 | public int main (string[] args) { | ||
2280 | 12 | 0 | ||
2281 | === removed file 'debian/patches/series' | |||
2282 | --- debian/patches/series 2013-07-17 20:06:48 +0000 | |||
2283 | +++ debian/patches/series 1970-01-01 00:00:00 +0000 | |||
2284 | @@ -1,3 +0,0 @@ | |||
2285 | 1 | default-icon-colour.patch | ||
2286 | 2 | disable-experimental-non-null.patch | ||
2287 | 3 | relax-test-missing-ibus.patch |
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...