Merge lp:~3v1n0/bamf/app-main-view into lp:bamf
- app-main-view
- Merge into trunk
Proposed by
Marco Trevisan (Treviño)
Status: | Merged |
---|---|
Approved by: | Brandon Schaefer |
Approved revision: | 609 |
Merged at revision: | 564 |
Proposed branch: | lp:~3v1n0/bamf/app-main-view |
Merge into: | lp:bamf |
Diff against target: |
1004 lines (+594/-125) 6 files modified
src/bamf-application.c (+216/-111) src/bamf-application.h (+18/-6) src/bamf-unity-webapps-application.c (+1/-1) src/bamf-unity-webapps-observer.c (+7/-1) tests/bamfdaemon/test-application.c (+338/-6) tests/bamfdaemon/test-bamf.c (+14/-0) |
To merge this branch: | bzr merge lp:~3v1n0/bamf/app-main-view |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Brandon Schaefer (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+175063@code.launchpad.net |
Commit message
BamfApplication: keep track of the application main-window and update name and icon accordingly
Applications without a .desktop file should update their name and icon based on their children.
So now we try to compute the main window children, and we update name and icon based on it.
Description of the change
Add a special "main_window" children to the BamfApplication, in this way we keep track of the child that is currently leading the application window group.
Thanks to this, we can update the application name and icon whenever they change.
To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Approve
(continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote : | # |
LGTM
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/bamf-application.c' | |||
2 | --- src/bamf-application.c 2013-07-16 00:25:51 +0000 | |||
3 | +++ src/bamf-application.c 2013-07-16 16:30:44 +0000 | |||
4 | @@ -38,12 +38,12 @@ | |||
5 | 38 | struct _BamfApplicationPrivate | 38 | struct _BamfApplicationPrivate |
6 | 39 | { | 39 | { |
7 | 40 | BamfDBusItemApplication *dbus_iface; | 40 | BamfDBusItemApplication *dbus_iface; |
8 | 41 | BamfApplicationType app_type; | ||
9 | 42 | BamfView * main_child; | ||
10 | 41 | char * desktop_file; | 43 | char * desktop_file; |
11 | 42 | GList * desktop_file_list; | 44 | GList * desktop_file_list; |
12 | 43 | char * app_type; | ||
13 | 44 | char * wmclass; | 45 | char * wmclass; |
14 | 45 | char ** mimes; | 46 | char ** mimes; |
15 | 46 | gboolean is_tab_container; | ||
16 | 47 | gboolean show_stubs; | 47 | gboolean show_stubs; |
17 | 48 | }; | 48 | }; |
18 | 49 | 49 | ||
19 | @@ -57,6 +57,8 @@ | |||
20 | 57 | 57 | ||
21 | 58 | #define STUB_KEY "X-Ayatana-Appmenu-Show-Stubs" | 58 | #define STUB_KEY "X-Ayatana-Appmenu-Show-Stubs" |
22 | 59 | 59 | ||
23 | 60 | static void on_main_child_name_changed (BamfView *, const gchar *, const gchar *, BamfApplication *); | ||
24 | 61 | |||
25 | 60 | void | 62 | void |
26 | 61 | bamf_application_supported_mime_types_changed (BamfApplication *application, | 63 | bamf_application_supported_mime_types_changed (BamfApplication *application, |
27 | 62 | const gchar **new_mimes) | 64 | const gchar **new_mimes) |
28 | @@ -136,23 +138,21 @@ | |||
29 | 136 | return g_strdupv (mimes); | 138 | return g_strdupv (mimes); |
30 | 137 | } | 139 | } |
31 | 138 | 140 | ||
33 | 139 | char * | 141 | BamfApplicationType |
34 | 140 | bamf_application_get_application_type (BamfApplication *application) | 142 | bamf_application_get_application_type (BamfApplication *application) |
35 | 141 | { | 143 | { |
37 | 142 | g_return_val_if_fail (BAMF_IS_APPLICATION (application), NULL); | 144 | g_return_val_if_fail (BAMF_IS_APPLICATION (application), BAMF_APPLICATION_UNKNOWN); |
38 | 143 | 145 | ||
40 | 144 | return g_strdup (application->priv->app_type); | 146 | return application->priv->app_type; |
41 | 145 | } | 147 | } |
42 | 146 | 148 | ||
43 | 147 | void | 149 | void |
45 | 148 | bamf_application_set_application_type (BamfApplication *application, const gchar *type) | 150 | bamf_application_set_application_type (BamfApplication *application, BamfApplicationType type) |
46 | 149 | { | 151 | { |
47 | 150 | g_return_if_fail (BAMF_IS_APPLICATION (application)); | 152 | g_return_if_fail (BAMF_IS_APPLICATION (application)); |
53 | 151 | 153 | g_return_if_fail (type >= 0 && type < BAMF_APPLICATION_UNKNOWN); | |
54 | 152 | if (application->priv->app_type) | 154 | |
55 | 153 | g_free (application->priv->app_type); | 155 | application->priv->app_type = type; |
51 | 154 | |||
52 | 155 | application->priv->app_type = g_strdup (type); | ||
56 | 156 | } | 156 | } |
57 | 157 | 157 | ||
58 | 158 | const char * | 158 | const char * |
59 | @@ -201,22 +201,24 @@ | |||
60 | 201 | } | 201 | } |
61 | 202 | 202 | ||
62 | 203 | static void | 203 | static void |
64 | 204 | bamf_application_setup_icon_and_name (BamfApplication *self) | 204 | bamf_application_setup_icon_and_name (BamfApplication *self, gboolean force) |
65 | 205 | { | 205 | { |
68 | 206 | BamfView *view; | 206 | BamfWindow *window; |
69 | 207 | BamfWindow *window = NULL; | 207 | BamfLegacyWindow *legacy_window; |
70 | 208 | GDesktopAppInfo *desktop; | 208 | GDesktopAppInfo *desktop; |
71 | 209 | GKeyFile * keyfile; | 209 | GKeyFile * keyfile; |
72 | 210 | GIcon *gicon; | 210 | GIcon *gicon; |
73 | 211 | GList *children, *l; | ||
74 | 212 | const char *class; | 211 | const char *class; |
75 | 213 | char *icon = NULL, *generic_icon = NULL, *name = NULL; | 212 | char *icon = NULL, *generic_icon = NULL, *name = NULL; |
76 | 214 | GError *error; | 213 | GError *error; |
77 | 215 | 214 | ||
78 | 216 | g_return_if_fail (BAMF_IS_APPLICATION (self)); | 215 | g_return_if_fail (BAMF_IS_APPLICATION (self)); |
79 | 217 | 216 | ||
82 | 218 | if (bamf_view_get_icon (BAMF_VIEW (self)) && bamf_view_get_name (BAMF_VIEW (self))) | 217 | if (!force) |
83 | 219 | return; | 218 | { |
84 | 219 | if (bamf_view_get_icon (BAMF_VIEW (self)) && bamf_view_get_name (BAMF_VIEW (self))) | ||
85 | 220 | return; | ||
86 | 221 | } | ||
87 | 220 | 222 | ||
88 | 221 | if (self->priv->desktop_file) | 223 | if (self->priv->desktop_file) |
89 | 222 | { | 224 | { |
90 | @@ -289,66 +291,57 @@ | |||
91 | 289 | g_object_unref (desktop); | 291 | g_object_unref (desktop); |
92 | 290 | g_key_file_free (keyfile); | 292 | g_key_file_free (keyfile); |
93 | 291 | } | 293 | } |
95 | 292 | else if ((children = bamf_view_get_children (BAMF_VIEW (self))) != NULL) | 294 | else if (BAMF_IS_WINDOW (self->priv->main_child)) |
96 | 293 | { | 295 | { |
155 | 294 | for (l = children; l && !icon; l = l->next) | 296 | name = g_strdup (bamf_view_get_name (self->priv->main_child)); |
156 | 295 | { | 297 | window = BAMF_WINDOW (self->priv->main_child); |
157 | 296 | view = l->data; | 298 | legacy_window = bamf_window_get_window (window); |
158 | 297 | if (!BAMF_IS_WINDOW (view)) | 299 | class = bamf_legacy_window_get_class_name (legacy_window); |
159 | 298 | continue; | 300 | |
160 | 299 | 301 | if (class) | |
161 | 300 | window = BAMF_WINDOW (view); | 302 | { |
162 | 301 | 303 | icon = g_utf8_strdown (class, -1); | |
163 | 302 | do | 304 | |
164 | 303 | { | 305 | if (icon_name_is_valid (icon)) |
165 | 304 | class = bamf_legacy_window_get_class_name (bamf_window_get_window (window)); | 306 | { |
166 | 305 | 307 | if (icon_name_is_generic (icon)) | |
167 | 306 | if (class) | 308 | { |
168 | 307 | { | 309 | generic_icon = icon; |
169 | 308 | icon = g_utf8_strdown (class, -1); | 310 | icon = NULL; |
170 | 309 | 311 | } | |
171 | 310 | if (icon_name_is_valid (icon)) | 312 | } |
172 | 311 | { | 313 | else |
173 | 312 | if (icon_name_is_generic (icon)) | 314 | { |
174 | 313 | { | 315 | g_free (icon); |
175 | 314 | generic_icon = g_strdup (icon); | 316 | icon = NULL; |
176 | 315 | } | 317 | } |
177 | 316 | else | 318 | } |
178 | 317 | { | 319 | |
179 | 318 | break; | 320 | if (!icon) |
180 | 319 | } | 321 | { |
181 | 320 | } | 322 | char *exec = bamf_legacy_window_get_exec_string (legacy_window); |
182 | 321 | } | 323 | icon = bamf_matcher_get_trimmed_exec (bamf_matcher_get_default (), exec); |
183 | 322 | 324 | g_free (exec); | |
184 | 323 | g_free (icon); | 325 | |
185 | 324 | char *exec = bamf_legacy_window_get_exec_string (bamf_window_get_window (window)); | 326 | if (icon_name_is_valid (icon)) |
186 | 325 | icon = bamf_matcher_get_trimmed_exec (bamf_matcher_get_default (), exec); | 327 | { |
187 | 326 | g_free (exec); | 328 | if (icon_name_is_generic (icon)) |
188 | 327 | 329 | { | |
189 | 328 | if (icon_name_is_valid (icon)) | 330 | g_free (generic_icon); |
190 | 329 | { | 331 | generic_icon = icon; |
191 | 330 | if (icon_name_is_generic (icon)) | 332 | icon = NULL; |
192 | 331 | { | 333 | } |
193 | 332 | generic_icon = g_strdup (icon); | 334 | } |
194 | 333 | } | 335 | else |
195 | 334 | else | 336 | { |
196 | 335 | { | 337 | g_free (icon); |
197 | 336 | break; | 338 | icon = NULL; |
198 | 337 | } | 339 | } |
199 | 338 | } | 340 | } |
200 | 339 | 341 | ||
201 | 340 | g_free (icon); | 342 | if (!icon) |
202 | 341 | icon = NULL; | 343 | { |
203 | 342 | } | 344 | icon = g_strdup (bamf_legacy_window_save_mini_icon (legacy_window)); |
146 | 343 | while (FALSE); | ||
147 | 344 | |||
148 | 345 | name = g_strdup (bamf_legacy_window_get_name (bamf_window_get_window (window))); | ||
149 | 346 | } | ||
150 | 347 | |||
151 | 348 | if (!icon) | ||
152 | 349 | { | ||
153 | 350 | if (window) | ||
154 | 351 | icon = g_strdup (bamf_legacy_window_save_mini_icon (bamf_window_get_window (window))); | ||
204 | 352 | 345 | ||
205 | 353 | if (!icon) | 346 | if (!icon) |
206 | 354 | { | 347 | { |
207 | @@ -381,15 +374,22 @@ | |||
208 | 381 | { | 374 | { |
209 | 382 | g_return_if_fail (BAMF_IS_APPLICATION (application)); | 375 | g_return_if_fail (BAMF_IS_APPLICATION (application)); |
210 | 383 | 376 | ||
213 | 384 | if (application->priv->desktop_file) | 377 | if (g_strcmp0 (application->priv->desktop_file, desktop_file) == 0) |
214 | 385 | g_free (application->priv->desktop_file); | 378 | return; |
215 | 379 | |||
216 | 380 | g_free (application->priv->desktop_file); | ||
217 | 381 | application->priv->desktop_file = NULL; | ||
218 | 386 | 382 | ||
219 | 387 | if (desktop_file && desktop_file[0] != '\0') | 383 | if (desktop_file && desktop_file[0] != '\0') |
220 | 388 | application->priv->desktop_file = g_strdup (desktop_file); | 384 | application->priv->desktop_file = g_strdup (desktop_file); |
225 | 389 | else | 385 | |
226 | 390 | application->priv->desktop_file = NULL; | 386 | if (application->priv->main_child) |
227 | 391 | 387 | { | |
228 | 392 | bamf_application_setup_icon_and_name (application); | 388 | g_signal_handlers_disconnect_by_func (application->priv->main_child, |
229 | 389 | on_main_child_name_changed, application); | ||
230 | 390 | } | ||
231 | 391 | |||
232 | 392 | bamf_application_setup_icon_and_name (application, TRUE); | ||
233 | 393 | } | 393 | } |
234 | 394 | 394 | ||
235 | 395 | gboolean | 395 | gboolean |
236 | @@ -632,25 +632,79 @@ | |||
237 | 632 | } | 632 | } |
238 | 633 | 633 | ||
239 | 634 | static void | 634 | static void |
240 | 635 | on_main_child_name_changed (BamfView *child, const gchar *old_name, | ||
241 | 636 | const gchar *new_name, BamfApplication *self) | ||
242 | 637 | { | ||
243 | 638 | bamf_view_set_name (BAMF_VIEW (self), new_name); | ||
244 | 639 | } | ||
245 | 640 | |||
246 | 641 | static void | ||
247 | 642 | bamf_application_set_main_child (BamfApplication *self, BamfView *child) | ||
248 | 643 | { | ||
249 | 644 | if (self->priv->main_child == child) | ||
250 | 645 | return; | ||
251 | 646 | |||
252 | 647 | if (self->priv->main_child) | ||
253 | 648 | { | ||
254 | 649 | g_object_remove_weak_pointer (G_OBJECT (self->priv->main_child), | ||
255 | 650 | (gpointer*) &self->priv->main_child); | ||
256 | 651 | g_signal_handlers_disconnect_by_func (self->priv->main_child, | ||
257 | 652 | on_main_child_name_changed, self); | ||
258 | 653 | } | ||
259 | 654 | |||
260 | 655 | self->priv->main_child = child; | ||
261 | 656 | |||
262 | 657 | if (self->priv->main_child) | ||
263 | 658 | { | ||
264 | 659 | g_object_add_weak_pointer (G_OBJECT (self->priv->main_child), | ||
265 | 660 | (gpointer*) &self->priv->main_child); | ||
266 | 661 | |||
267 | 662 | if (!self->priv->desktop_file) | ||
268 | 663 | { | ||
269 | 664 | g_signal_connect (child, "name-changed", | ||
270 | 665 | G_CALLBACK (on_main_child_name_changed), self); | ||
271 | 666 | } | ||
272 | 667 | } | ||
273 | 668 | } | ||
274 | 669 | |||
275 | 670 | BamfView * | ||
276 | 671 | bamf_application_get_main_child (BamfApplication *self) | ||
277 | 672 | { | ||
278 | 673 | g_return_val_if_fail (BAMF_IS_APPLICATION (self), NULL); | ||
279 | 674 | |||
280 | 675 | return self->priv->main_child; | ||
281 | 676 | } | ||
282 | 677 | |||
283 | 678 | static void | ||
284 | 635 | view_exported (BamfView *view, BamfApplication *self) | 679 | view_exported (BamfView *view, BamfApplication *self) |
285 | 636 | { | 680 | { |
286 | 637 | g_signal_emit_by_name (self, "window-added", bamf_view_get_path (view)); | 681 | g_signal_emit_by_name (self, "window-added", bamf_view_get_path (view)); |
287 | 682 | g_signal_handlers_disconnect_by_func (view, view_exported, self); | ||
288 | 638 | } | 683 | } |
289 | 639 | 684 | ||
290 | 640 | static void | 685 | static void |
291 | 641 | bamf_application_child_added (BamfView *view, BamfView *child) | 686 | bamf_application_child_added (BamfView *view, BamfView *child) |
292 | 642 | { | 687 | { |
293 | 643 | BamfApplication *application; | 688 | BamfApplication *application; |
294 | 689 | BamfWindow *window = NULL; | ||
295 | 690 | gboolean reset_emblems = FALSE; | ||
296 | 644 | 691 | ||
297 | 645 | application = BAMF_APPLICATION (view); | 692 | application = BAMF_APPLICATION (view); |
298 | 646 | 693 | ||
299 | 647 | if (BAMF_IS_WINDOW (child)) | 694 | if (BAMF_IS_WINDOW (child)) |
300 | 648 | { | 695 | { |
301 | 696 | window = BAMF_WINDOW (child); | ||
302 | 697 | |||
303 | 649 | if (bamf_view_is_on_bus (child)) | 698 | if (bamf_view_is_on_bus (child)) |
305 | 650 | g_signal_emit_by_name (BAMF_APPLICATION (view), "window-added", bamf_view_get_path (child)); | 699 | { |
306 | 700 | g_signal_emit_by_name (BAMF_APPLICATION (view), "window-added", | ||
307 | 701 | bamf_view_get_path (child)); | ||
308 | 702 | } | ||
309 | 651 | else | 703 | else |
312 | 652 | g_signal_connect (G_OBJECT (child), "exported", | 704 | { |
313 | 653 | (GCallback) view_exported, view); | 705 | g_signal_connect (G_OBJECT (child), "exported", |
314 | 706 | (GCallback) view_exported, view); | ||
315 | 707 | } | ||
316 | 654 | } | 708 | } |
317 | 655 | 709 | ||
318 | 656 | g_signal_connect (G_OBJECT (child), "active-changed", | 710 | g_signal_connect (G_OBJECT (child), "active-changed", |
319 | @@ -666,9 +720,30 @@ | |||
320 | 666 | (GCallback) view_xid_changed, view); | 720 | (GCallback) view_xid_changed, view); |
321 | 667 | } | 721 | } |
322 | 668 | 722 | ||
323 | 723 | if (application->priv->main_child) | ||
324 | 724 | { | ||
325 | 725 | if (window && BAMF_IS_WINDOW (application->priv->main_child)) | ||
326 | 726 | { | ||
327 | 727 | BamfWindow *main_window = BAMF_WINDOW (application->priv->main_child); | ||
328 | 728 | |||
329 | 729 | if (bamf_window_get_window_type (main_window) != BAMF_WINDOW_NORMAL && | ||
330 | 730 | bamf_window_get_window_type (window) == BAMF_WINDOW_NORMAL) | ||
331 | 731 | { | ||
332 | 732 | bamf_application_set_main_child (application, child); | ||
333 | 733 | } | ||
334 | 734 | } | ||
335 | 735 | } | ||
336 | 736 | else | ||
337 | 737 | { | ||
338 | 738 | bamf_application_set_main_child (application, child); | ||
339 | 739 | } | ||
340 | 740 | |||
341 | 669 | bamf_application_ensure_flags (BAMF_APPLICATION (view)); | 741 | bamf_application_ensure_flags (BAMF_APPLICATION (view)); |
342 | 670 | 742 | ||
344 | 671 | bamf_application_setup_icon_and_name (application); | 743 | if (!application->priv->desktop_file && application->priv->main_child == child) |
345 | 744 | reset_emblems = TRUE; | ||
346 | 745 | |||
347 | 746 | bamf_application_setup_icon_and_name (application, reset_emblems); | ||
348 | 672 | } | 747 | } |
349 | 673 | 748 | ||
350 | 674 | static char * | 749 | static char * |
351 | @@ -740,6 +815,8 @@ | |||
352 | 740 | bamf_application_child_removed (BamfView *view, BamfView *child) | 815 | bamf_application_child_removed (BamfView *view, BamfView *child) |
353 | 741 | { | 816 | { |
354 | 742 | BamfApplication *self = BAMF_APPLICATION (view); | 817 | BamfApplication *self = BAMF_APPLICATION (view); |
355 | 818 | GList *children, *l; | ||
356 | 819 | |||
357 | 743 | if (BAMF_IS_WINDOW (child)) | 820 | if (BAMF_IS_WINDOW (child)) |
358 | 744 | { | 821 | { |
359 | 745 | if (bamf_view_is_on_bus (child)) | 822 | if (bamf_view_is_on_bus (child)) |
360 | @@ -751,7 +828,35 @@ | |||
361 | 751 | 828 | ||
362 | 752 | bamf_application_ensure_flags (self); | 829 | bamf_application_ensure_flags (self); |
363 | 753 | 830 | ||
365 | 754 | if (!bamf_view_get_children (view) && bamf_application_get_close_when_empty (self)) | 831 | children = bamf_view_get_children (view); |
366 | 832 | |||
367 | 833 | if (self->priv->main_child == child) | ||
368 | 834 | { | ||
369 | 835 | /* Giving priority to older windows, and BamfView has a reversed list */ | ||
370 | 836 | children = g_list_last (children); | ||
371 | 837 | bamf_application_set_main_child (self, (children ? children->data : NULL)); | ||
372 | 838 | |||
373 | 839 | if (self->priv->app_type == BAMF_APPLICATION_SYSTEM) | ||
374 | 840 | { | ||
375 | 841 | /* We check if we have a better target in next windows */ | ||
376 | 842 | for (l = children; l; l = l->prev) | ||
377 | 843 | { | ||
378 | 844 | if (bamf_window_get_window_type (BAMF_WINDOW (l->data)) == BAMF_WINDOW_NORMAL) | ||
379 | 845 | { | ||
380 | 846 | bamf_application_set_main_child (self, l->data); | ||
381 | 847 | break; | ||
382 | 848 | } | ||
383 | 849 | } | ||
384 | 850 | } | ||
385 | 851 | |||
386 | 852 | if (self->priv->main_child) | ||
387 | 853 | { | ||
388 | 854 | gboolean reset_emblems = (!self->priv->desktop_file); | ||
389 | 855 | bamf_application_setup_icon_and_name (self, reset_emblems); | ||
390 | 856 | } | ||
391 | 857 | } | ||
392 | 858 | |||
393 | 859 | if (!children && bamf_application_get_close_when_empty (self)) | ||
394 | 755 | { | 860 | { |
395 | 756 | bamf_view_close (view); | 861 | bamf_view_close (view); |
396 | 757 | } | 862 | } |
397 | @@ -901,9 +1006,21 @@ | |||
398 | 901 | GDBusMethodInvocation *invocation, | 1006 | GDBusMethodInvocation *invocation, |
399 | 902 | BamfApplication *self) | 1007 | BamfApplication *self) |
400 | 903 | { | 1008 | { |
404 | 904 | const char *type = self->priv->app_type ? self->priv->app_type : ""; | 1009 | const char *type = ""; |
405 | 905 | g_dbus_method_invocation_return_value (invocation, | 1010 | |
406 | 906 | g_variant_new ("(s)", type)); | 1011 | switch (self->priv->app_type) |
407 | 1012 | { | ||
408 | 1013 | case BAMF_APPLICATION_SYSTEM: | ||
409 | 1014 | type = "system"; | ||
410 | 1015 | break; | ||
411 | 1016 | case BAMF_APPLICATION_WEB: | ||
412 | 1017 | type = "webapp"; | ||
413 | 1018 | break; | ||
414 | 1019 | default: | ||
415 | 1020 | type = "unknown"; | ||
416 | 1021 | } | ||
417 | 1022 | |||
418 | 1023 | g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", type)); | ||
419 | 907 | 1024 | ||
420 | 908 | return TRUE; | 1025 | return TRUE; |
421 | 909 | } | 1026 | } |
422 | @@ -929,18 +1046,20 @@ | |||
423 | 929 | priv->desktop_file_list = NULL; | 1046 | priv->desktop_file_list = NULL; |
424 | 930 | } | 1047 | } |
425 | 931 | 1048 | ||
426 | 932 | if (priv->app_type) | ||
427 | 933 | { | ||
428 | 934 | g_free (priv->app_type); | ||
429 | 935 | priv->app_type = NULL; | ||
430 | 936 | } | ||
431 | 937 | |||
432 | 938 | if (priv->wmclass) | 1049 | if (priv->wmclass) |
433 | 939 | { | 1050 | { |
434 | 940 | g_free (priv->wmclass); | 1051 | g_free (priv->wmclass); |
435 | 941 | priv->wmclass = NULL; | 1052 | priv->wmclass = NULL; |
436 | 942 | } | 1053 | } |
437 | 943 | 1054 | ||
438 | 1055 | if (priv->main_child) | ||
439 | 1056 | { | ||
440 | 1057 | g_object_remove_weak_pointer (G_OBJECT (priv->main_child), | ||
441 | 1058 | (gpointer*) &priv->main_child); | ||
442 | 1059 | g_signal_handlers_disconnect_by_data (priv->main_child, app); | ||
443 | 1060 | priv->main_child = NULL; | ||
444 | 1061 | } | ||
445 | 1062 | |||
446 | 944 | g_strfreev (priv->mimes); | 1063 | g_strfreev (priv->mimes); |
447 | 945 | priv->mimes = NULL; | 1064 | priv->mimes = NULL; |
448 | 946 | 1065 | ||
449 | @@ -967,10 +1086,8 @@ | |||
450 | 967 | BamfApplicationPrivate *priv; | 1086 | BamfApplicationPrivate *priv; |
451 | 968 | priv = self->priv = BAMF_APPLICATION_GET_PRIVATE (self); | 1087 | priv = self->priv = BAMF_APPLICATION_GET_PRIVATE (self); |
452 | 969 | 1088 | ||
455 | 970 | priv->is_tab_container = FALSE; | 1089 | priv->app_type = BAMF_APPLICATION_SYSTEM; |
454 | 971 | priv->app_type = g_strdup ("system"); | ||
456 | 972 | priv->show_stubs = TRUE; | 1090 | priv->show_stubs = TRUE; |
457 | 973 | priv->wmclass = NULL; | ||
458 | 974 | 1091 | ||
459 | 975 | /* Initializing the dbus interface */ | 1092 | /* Initializing the dbus interface */ |
460 | 976 | priv->dbus_iface = _bamf_dbus_item_application_skeleton_new (); | 1093 | priv->dbus_iface = _bamf_dbus_item_application_skeleton_new (); |
461 | @@ -1087,17 +1204,6 @@ | |||
462 | 1087 | return application; | 1204 | return application; |
463 | 1088 | } | 1205 | } |
464 | 1089 | 1206 | ||
465 | 1090 | /** | ||
466 | 1091 | bamf_application_get_show_stubs: | ||
467 | 1092 | @application: Application to check for menu stubs | ||
468 | 1093 | |||
469 | 1094 | Checks to see if the application should show menu stubs or not. | ||
470 | 1095 | This is specified with the "X-Ayatana-Appmenu-Show-Stubs" desktop | ||
471 | 1096 | file key. | ||
472 | 1097 | |||
473 | 1098 | Return Value: Defaults to TRUE, else FALSE if specified in | ||
474 | 1099 | .desktop file. | ||
475 | 1100 | */ | ||
476 | 1101 | gboolean | 1207 | gboolean |
477 | 1102 | bamf_application_get_show_stubs (BamfApplication *application) | 1208 | bamf_application_get_show_stubs (BamfApplication *application) |
478 | 1103 | { | 1209 | { |
479 | @@ -1105,7 +1211,6 @@ | |||
480 | 1105 | return application->priv->show_stubs; | 1211 | return application->priv->show_stubs; |
481 | 1106 | } | 1212 | } |
482 | 1107 | 1213 | ||
483 | 1108 | |||
484 | 1109 | gboolean | 1214 | gboolean |
485 | 1110 | bamf_application_get_close_when_empty (BamfApplication *application) | 1215 | bamf_application_get_close_when_empty (BamfApplication *application) |
486 | 1111 | { | 1216 | { |
487 | 1112 | 1217 | ||
488 | === modified file 'src/bamf-application.h' | |||
489 | --- src/bamf-application.h 2013-06-18 13:44:04 +0000 | |||
490 | +++ src/bamf-application.h 2013-07-16 16:30:44 +0000 | |||
491 | @@ -56,6 +56,13 @@ | |||
492 | 56 | BamfApplicationPrivate *priv; | 56 | BamfApplicationPrivate *priv; |
493 | 57 | }; | 57 | }; |
494 | 58 | 58 | ||
495 | 59 | typedef enum | ||
496 | 60 | { | ||
497 | 61 | BAMF_APPLICATION_SYSTEM, /* BamfWindow container */ | ||
498 | 62 | BAMF_APPLICATION_WEB, /* BamfTab container */ | ||
499 | 63 | BAMF_APPLICATION_UNKNOWN, | ||
500 | 64 | } BamfApplicationType; | ||
501 | 65 | |||
502 | 59 | GType bamf_application_get_type (void) G_GNUC_CONST; | 66 | GType bamf_application_get_type (void) G_GNUC_CONST; |
503 | 60 | 67 | ||
504 | 61 | void bamf_application_emit_supported_mime_types_changed (BamfApplication *application); | 68 | void bamf_application_emit_supported_mime_types_changed (BamfApplication *application); |
505 | @@ -64,7 +71,7 @@ | |||
506 | 64 | void bamf_application_set_desktop_file (BamfApplication *application, | 71 | void bamf_application_set_desktop_file (BamfApplication *application, |
507 | 65 | const char * desktop_file); | 72 | const char * desktop_file); |
508 | 66 | 73 | ||
510 | 67 | char ** bamf_application_get_supported_mime_types (BamfApplication *application); | 74 | char ** bamf_application_get_supported_mime_types (BamfApplication *application); |
511 | 68 | 75 | ||
512 | 69 | GVariant * bamf_application_get_xids (BamfApplication *application); | 76 | GVariant * bamf_application_get_xids (BamfApplication *application); |
513 | 70 | 77 | ||
514 | @@ -90,11 +97,16 @@ | |||
515 | 90 | 97 | ||
516 | 91 | BamfApplication * bamf_application_new_with_wmclass (const char *wmclass); | 98 | BamfApplication * bamf_application_new_with_wmclass (const char *wmclass); |
517 | 92 | 99 | ||
523 | 93 | void bamf_application_set_application_type (BamfApplication *application, const gchar *type); | 100 | void bamf_application_set_application_type (BamfApplication *application, |
524 | 94 | 101 | BamfApplicationType type); | |
525 | 95 | void bamf_application_get_application_menu (BamfApplication *application, gchar **name, gchar **object_path); | 102 | BamfApplicationType bamf_application_get_application_type (BamfApplication *application); |
526 | 96 | 103 | ||
527 | 97 | BamfView * bamf_application_get_focusable_child (BamfApplication *application); | 104 | void bamf_application_get_application_menu (BamfApplication *application, |
528 | 105 | gchar **name, gchar **object_path); | ||
529 | 106 | |||
530 | 107 | BamfView * bamf_application_get_focusable_child (BamfApplication *application); | ||
531 | 108 | |||
532 | 109 | BamfView * bamf_application_get_main_child (BamfApplication *application); | ||
533 | 98 | 110 | ||
534 | 99 | gboolean bamf_application_get_close_when_empty (BamfApplication *application); | 111 | gboolean bamf_application_get_close_when_empty (BamfApplication *application); |
535 | 100 | gboolean bamf_application_set_desktop_file_from_id (BamfApplication *application, const char *id); | 112 | gboolean bamf_application_set_desktop_file_from_id (BamfApplication *application, const char *id); |
536 | 101 | 113 | ||
537 | === modified file 'src/bamf-unity-webapps-application.c' | |||
538 | --- src/bamf-unity-webapps-application.c 2013-06-13 18:40:56 +0000 | |||
539 | +++ src/bamf-unity-webapps-application.c 2013-07-16 16:30:44 +0000 | |||
540 | @@ -267,7 +267,7 @@ | |||
541 | 267 | { | 267 | { |
542 | 268 | self->priv = BAMF_UNITY_WEBAPPS_APPLICATION_GET_PRIVATE (self); | 268 | self->priv = BAMF_UNITY_WEBAPPS_APPLICATION_GET_PRIVATE (self); |
543 | 269 | 269 | ||
545 | 270 | bamf_application_set_application_type (BAMF_APPLICATION (self), "webapp"); | 270 | bamf_application_set_application_type (BAMF_APPLICATION (self), BAMF_APPLICATION_WEB); |
546 | 271 | 271 | ||
547 | 272 | } | 272 | } |
548 | 273 | 273 | ||
549 | 274 | 274 | ||
550 | === modified file 'src/bamf-unity-webapps-observer.c' | |||
551 | --- src/bamf-unity-webapps-observer.c 2013-06-13 18:40:56 +0000 | |||
552 | +++ src/bamf-unity-webapps-observer.c 2013-07-16 16:30:44 +0000 | |||
553 | @@ -204,7 +204,10 @@ | |||
554 | 204 | 204 | ||
555 | 205 | g_hash_table_destroy (observer->priv->applications_by_context_name); | 205 | g_hash_table_destroy (observer->priv->applications_by_context_name); |
556 | 206 | 206 | ||
558 | 207 | g_bus_unwatch_name (observer->priv->service_watch_id); | 207 | if (observer->priv->service_watch_id) |
559 | 208 | { | ||
560 | 209 | g_bus_unwatch_name (observer->priv->service_watch_id); | ||
561 | 210 | } | ||
562 | 208 | 211 | ||
563 | 209 | if (observer->priv->service) | 212 | if (observer->priv->service) |
564 | 210 | { | 213 | { |
565 | @@ -225,6 +228,9 @@ | |||
566 | 225 | G_OBJECT_CLASS (bamf_unity_webapps_observer_parent_class)->constructed (object); | 228 | G_OBJECT_CLASS (bamf_unity_webapps_observer_parent_class)->constructed (object); |
567 | 226 | } | 229 | } |
568 | 227 | 230 | ||
569 | 231 | if (g_strcmp0 (g_getenv ("BAMF_TEST_MODE"), "TRUE") == 0) | ||
570 | 232 | return; | ||
571 | 233 | |||
572 | 228 | observer->priv->service_watch_id = g_bus_watch_name (G_BUS_TYPE_SESSION, | 234 | observer->priv->service_watch_id = g_bus_watch_name (G_BUS_TYPE_SESSION, |
573 | 229 | "com.canonical.Unity.Webapps.Service", | 235 | "com.canonical.Unity.Webapps.Service", |
574 | 230 | G_BUS_NAME_WATCHER_FLAGS_NONE, | 236 | G_BUS_NAME_WATCHER_FLAGS_NONE, |
575 | 231 | 237 | ||
576 | === modified file 'tests/bamfdaemon/test-application.c' | |||
577 | --- tests/bamfdaemon/test-application.c 2013-07-16 00:27:11 +0000 | |||
578 | +++ tests/bamfdaemon/test-application.c 2013-07-16 16:30:44 +0000 | |||
579 | @@ -27,7 +27,9 @@ | |||
580 | 27 | #include "bamf-legacy-window.h" | 27 | #include "bamf-legacy-window.h" |
581 | 28 | #include "bamf-legacy-window-test.h" | 28 | #include "bamf-legacy-window-test.h" |
582 | 29 | 29 | ||
584 | 30 | #define DESKTOP_FILE "/usr/share/applications/gnome-terminal.desktop" | 30 | #define DESKTOP_FILE TESTDIR"/data/test-bamf-app.desktop" |
585 | 31 | |||
586 | 32 | void ignore_fatal_errors (void); | ||
587 | 31 | 33 | ||
588 | 32 | static gboolean signal_seen = FALSE; | 34 | static gboolean signal_seen = FALSE; |
589 | 33 | static gboolean signal_result = FALSE; | 35 | static gboolean signal_result = FALSE; |
590 | @@ -66,7 +68,7 @@ | |||
591 | 66 | static void | 68 | static void |
592 | 67 | test_allocation (void) | 69 | test_allocation (void) |
593 | 68 | { | 70 | { |
595 | 69 | BamfApplication *application; | 71 | BamfApplication *application; |
596 | 70 | 72 | ||
597 | 71 | /* Check it allocates */ | 73 | /* Check it allocates */ |
598 | 72 | application = bamf_application_new (); | 74 | application = bamf_application_new (); |
599 | @@ -81,12 +83,47 @@ | |||
600 | 81 | } | 83 | } |
601 | 82 | 84 | ||
602 | 83 | static void | 85 | static void |
603 | 86 | test_type (void) | ||
604 | 87 | { | ||
605 | 88 | BamfApplication *application = bamf_application_new (); | ||
606 | 89 | g_assert_cmpuint (bamf_application_get_application_type (application), ==, BAMF_APPLICATION_SYSTEM); | ||
607 | 90 | |||
608 | 91 | g_object_unref (application); | ||
609 | 92 | } | ||
610 | 93 | |||
611 | 94 | static void | ||
612 | 95 | test_type_set (void) | ||
613 | 96 | { | ||
614 | 97 | BamfApplication *application = bamf_application_new (); | ||
615 | 98 | |||
616 | 99 | bamf_application_set_application_type (application, BAMF_APPLICATION_WEB); | ||
617 | 100 | g_assert_cmpuint (bamf_application_get_application_type (application), ==, BAMF_APPLICATION_WEB); | ||
618 | 101 | |||
619 | 102 | bamf_application_set_application_type (application, BAMF_APPLICATION_SYSTEM); | ||
620 | 103 | g_assert_cmpuint (bamf_application_get_application_type (application), ==, BAMF_APPLICATION_SYSTEM); | ||
621 | 104 | |||
622 | 105 | g_object_unref (application); | ||
623 | 106 | } | ||
624 | 107 | |||
625 | 108 | static void | ||
626 | 109 | test_type_set_invalid (void) | ||
627 | 110 | { | ||
628 | 111 | ignore_fatal_errors(); | ||
629 | 112 | BamfApplication *application = bamf_application_new (); | ||
630 | 113 | |||
631 | 114 | bamf_application_set_application_type (application, BAMF_APPLICATION_UNKNOWN); | ||
632 | 115 | g_assert_cmpuint (bamf_application_get_application_type (application), ==, BAMF_APPLICATION_SYSTEM); | ||
633 | 116 | |||
634 | 117 | bamf_application_set_application_type (application, -1); | ||
635 | 118 | g_assert_cmpuint (bamf_application_get_application_type (application), ==, BAMF_APPLICATION_SYSTEM); | ||
636 | 119 | |||
637 | 120 | g_object_unref (application); | ||
638 | 121 | } | ||
639 | 122 | |||
640 | 123 | static void | ||
641 | 84 | test_desktop_file (void) | 124 | test_desktop_file (void) |
642 | 85 | { | 125 | { |
647 | 86 | BamfApplication *application; | 126 | BamfApplication *application = bamf_application_new (); |
644 | 87 | |||
645 | 88 | /* Check it allocates */ | ||
646 | 89 | application = bamf_application_new (); | ||
648 | 90 | g_assert (bamf_application_get_desktop_file (application) == NULL); | 127 | g_assert (bamf_application_get_desktop_file (application) == NULL); |
649 | 91 | 128 | ||
650 | 92 | bamf_application_set_desktop_file (application, DESKTOP_FILE); | 129 | bamf_application_set_desktop_file (application, DESKTOP_FILE); |
651 | @@ -733,6 +770,7 @@ | |||
652 | 733 | 770 | ||
653 | 734 | g_object_unref (window); | 771 | g_object_unref (window); |
654 | 735 | g_object_unref (test); | 772 | g_object_unref (test); |
655 | 773 | g_object_unref (application); | ||
656 | 736 | } | 774 | } |
657 | 737 | 775 | ||
658 | 738 | static void | 776 | static void |
659 | @@ -777,6 +815,287 @@ | |||
660 | 777 | 815 | ||
661 | 778 | g_object_unref (window); | 816 | g_object_unref (window); |
662 | 779 | g_object_unref (test); | 817 | g_object_unref (test); |
663 | 818 | g_object_unref (application); | ||
664 | 819 | } | ||
665 | 820 | |||
666 | 821 | static void | ||
667 | 822 | test_desktop_app_main_child (void) | ||
668 | 823 | { | ||
669 | 824 | BamfApplication *application; | ||
670 | 825 | BamfLegacyWindowTest *lwin; | ||
671 | 826 | BamfWindow *win; | ||
672 | 827 | |||
673 | 828 | application = bamf_application_new_from_desktop_file (DESKTOP_FILE); | ||
674 | 829 | lwin = bamf_legacy_window_test_new (20, "window", "test-bamf-icon", "execution-binary"); | ||
675 | 830 | win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); | ||
676 | 831 | |||
677 | 832 | g_assert (!bamf_application_get_main_child (application)); | ||
678 | 833 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); | ||
679 | 834 | g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (win)); | ||
680 | 835 | |||
681 | 836 | g_object_unref (lwin); | ||
682 | 837 | g_object_unref (win); | ||
683 | 838 | g_object_unref (application); | ||
684 | 839 | } | ||
685 | 840 | |||
686 | 841 | static void | ||
687 | 842 | test_desktop_app_main_child_doesnt_match_emblems (void) | ||
688 | 843 | { | ||
689 | 844 | BamfApplication *application; | ||
690 | 845 | BamfLegacyWindowTest *lwin; | ||
691 | 846 | BamfWindow *win; | ||
692 | 847 | |||
693 | 848 | application = bamf_application_new_from_desktop_file (DESKTOP_FILE); | ||
694 | 849 | lwin = bamf_legacy_window_test_new (20, "window", "python", "execution-binary"); | ||
695 | 850 | win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); | ||
696 | 851 | |||
697 | 852 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); | ||
698 | 853 | g_assert_cmpstr (bamf_view_get_name (BAMF_VIEW (application)), !=, "window"); | ||
699 | 854 | g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), !=, "python"); | ||
700 | 855 | |||
701 | 856 | g_object_unref (lwin); | ||
702 | 857 | g_object_unref (win); | ||
703 | 858 | g_object_unref (application); | ||
704 | 859 | } | ||
705 | 860 | |||
706 | 861 | static void | ||
707 | 862 | test_desktop_app_main_child_doesnt_update_emblems (void) | ||
708 | 863 | { | ||
709 | 864 | BamfApplication *application; | ||
710 | 865 | BamfLegacyWindowTest *lwin; | ||
711 | 866 | BamfWindow *win; | ||
712 | 867 | |||
713 | 868 | application = bamf_application_new_from_desktop_file (DESKTOP_FILE); | ||
714 | 869 | lwin = bamf_legacy_window_test_new (20, "window", "python", "execution-binary"); | ||
715 | 870 | win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); | ||
716 | 871 | |||
717 | 872 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); | ||
718 | 873 | bamf_legacy_window_test_set_name (lwin, "New Window Name"); | ||
719 | 874 | g_assert_cmpstr (bamf_view_get_name (BAMF_VIEW (application)), !=, "New Window Name"); | ||
720 | 875 | |||
721 | 876 | bamf_legacy_window_test_set_name (lwin, "even-new-name"); | ||
722 | 877 | g_assert_cmpstr (bamf_view_get_name (BAMF_VIEW (application)), !=, "even-new-name"); | ||
723 | 878 | |||
724 | 879 | g_object_unref (lwin); | ||
725 | 880 | g_object_unref (win); | ||
726 | 881 | g_object_unref (application); | ||
727 | 882 | } | ||
728 | 883 | |||
729 | 884 | static void | ||
730 | 885 | test_app_main_child (void) | ||
731 | 886 | { | ||
732 | 887 | BamfApplication *application; | ||
733 | 888 | BamfLegacyWindowTest *lwin; | ||
734 | 889 | BamfWindow *win; | ||
735 | 890 | |||
736 | 891 | application = bamf_application_new (); | ||
737 | 892 | lwin = bamf_legacy_window_test_new (20, "window", "test-bamf-icon", "execution-binary"); | ||
738 | 893 | win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); | ||
739 | 894 | |||
740 | 895 | g_assert (!bamf_application_get_main_child (application)); | ||
741 | 896 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); | ||
742 | 897 | g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (win)); | ||
743 | 898 | |||
744 | 899 | g_object_unref (lwin); | ||
745 | 900 | g_object_unref (win); | ||
746 | 901 | |||
747 | 902 | g_assert (!bamf_application_get_main_child (application)); | ||
748 | 903 | g_object_unref (application); | ||
749 | 904 | } | ||
750 | 905 | |||
751 | 906 | static void | ||
752 | 907 | test_app_main_child_matches_emblems (void) | ||
753 | 908 | { | ||
754 | 909 | BamfApplication *application; | ||
755 | 910 | BamfLegacyWindowTest *lwin; | ||
756 | 911 | BamfWindow *win; | ||
757 | 912 | |||
758 | 913 | application = bamf_application_new (); | ||
759 | 914 | lwin = bamf_legacy_window_test_new (20, "window", "test-bamf-icon", "execution-binary"); | ||
760 | 915 | win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); | ||
761 | 916 | |||
762 | 917 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); | ||
763 | 918 | g_assert_cmpstr (bamf_view_get_name (BAMF_VIEW (application)), ==, "window"); | ||
764 | 919 | g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "test-bamf-icon"); | ||
765 | 920 | |||
766 | 921 | g_object_unref (lwin); | ||
767 | 922 | g_object_unref (win); | ||
768 | 923 | g_object_unref (application); | ||
769 | 924 | } | ||
770 | 925 | |||
771 | 926 | static void | ||
772 | 927 | test_app_main_child_updates_emblems (void) | ||
773 | 928 | { | ||
774 | 929 | BamfApplication *application; | ||
775 | 930 | BamfLegacyWindowTest *lwin; | ||
776 | 931 | BamfWindow *win; | ||
777 | 932 | |||
778 | 933 | application = bamf_application_new (); | ||
779 | 934 | lwin = bamf_legacy_window_test_new (20, "window", "test-bamf-icon", "execution-binary"); | ||
780 | 935 | win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); | ||
781 | 936 | |||
782 | 937 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); | ||
783 | 938 | bamf_legacy_window_test_set_name (lwin, "New Window Name"); | ||
784 | 939 | g_assert_cmpstr (bamf_view_get_name (BAMF_VIEW (application)), ==, "New Window Name"); | ||
785 | 940 | |||
786 | 941 | bamf_legacy_window_test_set_name (lwin, "even-new-name"); | ||
787 | 942 | g_assert_cmpstr (bamf_view_get_name (BAMF_VIEW (application)), ==, "even-new-name"); | ||
788 | 943 | |||
789 | 944 | g_object_unref (lwin); | ||
790 | 945 | g_object_unref (win); | ||
791 | 946 | g_object_unref (application); | ||
792 | 947 | } | ||
793 | 948 | |||
794 | 949 | static void | ||
795 | 950 | test_app_main_child_multiple_children (void) | ||
796 | 951 | { | ||
797 | 952 | BamfApplication *application; | ||
798 | 953 | BamfLegacyWindowTest *lwin; | ||
799 | 954 | BamfWindow *win1; | ||
800 | 955 | GList *wins = NULL; | ||
801 | 956 | GList *lwins = NULL; | ||
802 | 957 | int i; | ||
803 | 958 | |||
804 | 959 | application = bamf_application_new (); | ||
805 | 960 | lwin = bamf_legacy_window_test_new (20, "window", "test-bamf-icon", "execution-binary"); | ||
806 | 961 | win1 = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); | ||
807 | 962 | g_object_unref (lwin); | ||
808 | 963 | |||
809 | 964 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win1)); | ||
810 | 965 | |||
811 | 966 | for (i = 0; i < 10; ++i) | ||
812 | 967 | { | ||
813 | 968 | lwin = bamf_legacy_window_test_new (i, "other-window", "", "execution-binary"); | ||
814 | 969 | lwins = g_list_prepend (lwins, lwin); | ||
815 | 970 | wins = g_list_prepend (wins, bamf_window_new (BAMF_LEGACY_WINDOW (lwin))); | ||
816 | 971 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (wins->data)); | ||
817 | 972 | |||
818 | 973 | g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (win1)); | ||
819 | 974 | g_assert_cmpstr (bamf_view_get_name (BAMF_VIEW (application)), ==, "window"); | ||
820 | 975 | g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "test-bamf-icon"); | ||
821 | 976 | } | ||
822 | 977 | |||
823 | 978 | g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (win1)); | ||
824 | 979 | |||
825 | 980 | g_object_unref (win1); | ||
826 | 981 | g_object_unref (application); | ||
827 | 982 | g_list_free_full (wins, g_object_unref); | ||
828 | 983 | g_list_free_full (lwins, g_object_unref); | ||
829 | 984 | } | ||
830 | 985 | |||
831 | 986 | static void | ||
832 | 987 | test_app_main_child_normal_priority (void) | ||
833 | 988 | { | ||
834 | 989 | BamfApplication *application; | ||
835 | 990 | BamfLegacyWindowTest *lwin; | ||
836 | 991 | BamfWindow *dialog, *win; | ||
837 | 992 | |||
838 | 993 | application = bamf_application_new (); | ||
839 | 994 | lwin = bamf_legacy_window_test_new (10, "dialog", "python", "execution-binary"); | ||
840 | 995 | lwin->window_type = BAMF_WINDOW_DIALOG; | ||
841 | 996 | dialog = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); | ||
842 | 997 | g_object_unref (lwin); | ||
843 | 998 | |||
844 | 999 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (dialog)); | ||
845 | 1000 | g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (dialog)); | ||
846 | 1001 | |||
847 | 1002 | g_assert_cmpstr (bamf_view_get_name (BAMF_VIEW (application)), ==, "dialog"); | ||
848 | 1003 | g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "python"); | ||
849 | 1004 | |||
850 | 1005 | lwin = bamf_legacy_window_test_new (20, "window", "test-bamf-icon", "execution-binary"); | ||
851 | 1006 | win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); | ||
852 | 1007 | g_object_unref (lwin); | ||
853 | 1008 | |||
854 | 1009 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); | ||
855 | 1010 | g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (win)); | ||
856 | 1011 | |||
857 | 1012 | g_assert_cmpstr (bamf_view_get_name (BAMF_VIEW (application)), ==, "window"); | ||
858 | 1013 | g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "test-bamf-icon"); | ||
859 | 1014 | |||
860 | 1015 | g_object_unref (dialog); | ||
861 | 1016 | g_object_unref (win); | ||
862 | 1017 | g_object_unref (application); | ||
863 | 1018 | } | ||
864 | 1019 | |||
865 | 1020 | static void | ||
866 | 1021 | test_app_main_child_on_window_removal (void) | ||
867 | 1022 | { | ||
868 | 1023 | BamfApplication *application; | ||
869 | 1024 | BamfLegacyWindowTest *lwin; | ||
870 | 1025 | BamfWindow *win1, *win2, *win3, *win4, *dialog; | ||
871 | 1026 | |||
872 | 1027 | application = bamf_application_new (); | ||
873 | 1028 | lwin = bamf_legacy_window_test_new (10, "window1", NULL, "execution-binary"); | ||
874 | 1029 | win1 = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); | ||
875 | 1030 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win1)); | ||
876 | 1031 | g_object_unref (lwin); | ||
877 | 1032 | |||
878 | 1033 | lwin = bamf_legacy_window_test_new (20, "window2", NULL, "execution-binary"); | ||
879 | 1034 | win2 = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); | ||
880 | 1035 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win2)); | ||
881 | 1036 | g_object_unref (lwin); | ||
882 | 1037 | |||
883 | 1038 | lwin = bamf_legacy_window_test_new (21, "dialog", NULL, "execution-binary"); | ||
884 | 1039 | lwin->window_type = BAMF_WINDOW_DIALOG; | ||
885 | 1040 | dialog = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); | ||
886 | 1041 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (dialog)); | ||
887 | 1042 | g_object_unref (lwin); | ||
888 | 1043 | |||
889 | 1044 | lwin = bamf_legacy_window_test_new (30, "window3", NULL, "execution-binary"); | ||
890 | 1045 | win3 = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); | ||
891 | 1046 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win3)); | ||
892 | 1047 | g_object_unref (lwin); | ||
893 | 1048 | |||
894 | 1049 | lwin = bamf_legacy_window_test_new (40, "window4", NULL, "execution-binary"); | ||
895 | 1050 | win4 = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); | ||
896 | 1051 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win4)); | ||
897 | 1052 | g_object_unref (lwin); | ||
898 | 1053 | |||
899 | 1054 | g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (win1)); | ||
900 | 1055 | |||
901 | 1056 | bamf_view_remove_child (BAMF_VIEW (application), BAMF_VIEW (win4)); | ||
902 | 1057 | g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (win1)); | ||
903 | 1058 | |||
904 | 1059 | bamf_view_remove_child (BAMF_VIEW (application), BAMF_VIEW (win1)); | ||
905 | 1060 | g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (win2)); | ||
906 | 1061 | |||
907 | 1062 | bamf_view_remove_child (BAMF_VIEW (application), BAMF_VIEW (win2)); | ||
908 | 1063 | g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (win3)); | ||
909 | 1064 | |||
910 | 1065 | bamf_view_remove_child (BAMF_VIEW (application), BAMF_VIEW (win3)); | ||
911 | 1066 | g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (dialog)); | ||
912 | 1067 | |||
913 | 1068 | bamf_view_remove_child (BAMF_VIEW (application), BAMF_VIEW (dialog)); | ||
914 | 1069 | g_assert (!bamf_application_get_main_child (application)); | ||
915 | 1070 | |||
916 | 1071 | g_object_unref (win1); | ||
917 | 1072 | g_object_unref (win2); | ||
918 | 1073 | g_object_unref (win3); | ||
919 | 1074 | g_object_unref (win4); | ||
920 | 1075 | g_object_unref (dialog); | ||
921 | 1076 | g_object_unref (application); | ||
922 | 1077 | } | ||
923 | 1078 | |||
924 | 1079 | static void | ||
925 | 1080 | test_app_main_child_on_window_replace_on_removal (void) | ||
926 | 1081 | { | ||
927 | 1082 | BamfApplication *application; | ||
928 | 1083 | BamfLegacyWindowTest *lwin; | ||
929 | 1084 | BamfWindow *win; | ||
930 | 1085 | |||
931 | 1086 | application = bamf_application_new (); | ||
932 | 1087 | lwin = bamf_legacy_window_test_new (20, "window", "test-bamf-icon", "execution-binary"); | ||
933 | 1088 | win = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); | ||
934 | 1089 | |||
935 | 1090 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (win)); | ||
936 | 1091 | g_assert (bamf_application_get_main_child (application) == BAMF_VIEW (win)); | ||
937 | 1092 | bamf_view_remove_child (BAMF_VIEW (application), BAMF_VIEW (win)); | ||
938 | 1093 | g_assert (!bamf_application_get_main_child (application)); | ||
939 | 1094 | bamf_legacy_window_test_set_name (lwin, "don't crash here!"); | ||
940 | 1095 | |||
941 | 1096 | g_object_unref (lwin); | ||
942 | 1097 | g_object_unref (win); | ||
943 | 1098 | g_object_unref (application); | ||
944 | 780 | } | 1099 | } |
945 | 781 | 1100 | ||
946 | 782 | /* Initialize test suite */ | 1101 | /* Initialize test suite */ |
947 | @@ -789,6 +1108,9 @@ | |||
948 | 789 | gdbus_connection = connection; | 1108 | gdbus_connection = connection; |
949 | 790 | 1109 | ||
950 | 791 | g_test_add_func (DOMAIN"/Allocation", test_allocation); | 1110 | g_test_add_func (DOMAIN"/Allocation", test_allocation); |
951 | 1111 | g_test_add_func (DOMAIN"/Type", test_type); | ||
952 | 1112 | g_test_add_func (DOMAIN"/Type/Set", test_type_set); | ||
953 | 1113 | g_test_add_func (DOMAIN"/Type/Set/Invalid", test_type_set_invalid); | ||
954 | 792 | g_test_add_func (DOMAIN"/DesktopFile", test_desktop_file); | 1114 | g_test_add_func (DOMAIN"/DesktopFile", test_desktop_file); |
955 | 793 | g_test_add_func (DOMAIN"/DesktopFile/Icon", test_desktop_icon); | 1115 | g_test_add_func (DOMAIN"/DesktopFile/Icon", test_desktop_icon); |
956 | 794 | g_test_add_func (DOMAIN"/DesktopFile/Icon/Empty", test_desktop_icon_empty); | 1116 | g_test_add_func (DOMAIN"/DesktopFile/Icon/Empty", test_desktop_icon_empty); |
957 | @@ -797,12 +1119,22 @@ | |||
958 | 797 | g_test_add_func (DOMAIN"/DesktopFile/Icon/FullPath/Invalid", test_icon_full_path_invalid); | 1119 | g_test_add_func (DOMAIN"/DesktopFile/Icon/FullPath/Invalid", test_icon_full_path_invalid); |
959 | 798 | g_test_add_func (DOMAIN"/DesktopFile/MimeTypes/Valid", test_get_mime_types); | 1120 | g_test_add_func (DOMAIN"/DesktopFile/MimeTypes/Valid", test_get_mime_types); |
960 | 799 | g_test_add_func (DOMAIN"/DesktopFile/MimeTypes/None", test_get_mime_types_none); | 1121 | g_test_add_func (DOMAIN"/DesktopFile/MimeTypes/None", test_get_mime_types_none); |
961 | 1122 | g_test_add_func (DOMAIN"/DesktopFile/MainChild", test_desktop_app_main_child); | ||
962 | 1123 | g_test_add_func (DOMAIN"/DesktopFile/MainChild/NotMatchEmblems", test_desktop_app_main_child_doesnt_match_emblems); | ||
963 | 1124 | g_test_add_func (DOMAIN"/DesktopFile/MainChild/NotUpdatesEmblems", test_desktop_app_main_child_doesnt_update_emblems); | ||
964 | 800 | g_test_add_func (DOMAIN"/DesktopLess/Icon/ClassName", test_icon_class_name); | 1125 | g_test_add_func (DOMAIN"/DesktopLess/Icon/ClassName", test_icon_class_name); |
965 | 801 | g_test_add_func (DOMAIN"/DesktopLess/Icon/Exec", test_icon_exec_string); | 1126 | g_test_add_func (DOMAIN"/DesktopLess/Icon/Exec", test_icon_exec_string); |
966 | 802 | g_test_add_func (DOMAIN"/DesktopLess/Icon/Embedded", test_icon_embedded); | 1127 | g_test_add_func (DOMAIN"/DesktopLess/Icon/Embedded", test_icon_embedded); |
967 | 803 | g_test_add_func (DOMAIN"/DesktopLess/Icon/Priority", test_icon_priority); | 1128 | g_test_add_func (DOMAIN"/DesktopLess/Icon/Priority", test_icon_priority); |
968 | 804 | g_test_add_func (DOMAIN"/DesktopLess/Icon/Generic/Class", test_icon_generic_class); | 1129 | g_test_add_func (DOMAIN"/DesktopLess/Icon/Generic/Class", test_icon_generic_class); |
969 | 805 | g_test_add_func (DOMAIN"/DesktopLess/Icon/Generic/Exec", test_icon_generic_exec); | 1130 | g_test_add_func (DOMAIN"/DesktopLess/Icon/Generic/Exec", test_icon_generic_exec); |
970 | 1131 | g_test_add_func (DOMAIN"/DesktopLess/MainChild", test_app_main_child); | ||
971 | 1132 | g_test_add_func (DOMAIN"/DesktopLess/MainChild/MatchesEmblems", test_app_main_child_matches_emblems); | ||
972 | 1133 | g_test_add_func (DOMAIN"/DesktopLess/MainChild/UpdatesEmblems", test_app_main_child_updates_emblems); | ||
973 | 1134 | g_test_add_func (DOMAIN"/DesktopLess/MainChild/MultipleChildren", test_app_main_child_multiple_children); | ||
974 | 1135 | g_test_add_func (DOMAIN"/DesktopLess/MainChild/NormalPriority", test_app_main_child_normal_priority); | ||
975 | 1136 | g_test_add_func (DOMAIN"/DesktopLess/MainChild/Removal", test_app_main_child_on_window_removal); | ||
976 | 1137 | g_test_add_func (DOMAIN"/DesktopLess/MainChild/ReplaceOnRemoval", test_app_main_child_on_window_replace_on_removal); | ||
977 | 806 | g_test_add_func (DOMAIN"/ManagesXid", test_manages_xid); | 1138 | g_test_add_func (DOMAIN"/ManagesXid", test_manages_xid); |
978 | 807 | g_test_add_func (DOMAIN"/GetWindow", test_get_window); | 1139 | g_test_add_func (DOMAIN"/GetWindow", test_get_window); |
979 | 808 | g_test_add_func (DOMAIN"/Xids", test_get_xids); | 1140 | g_test_add_func (DOMAIN"/Xids", test_get_xids); |
980 | 809 | 1141 | ||
981 | === modified file 'tests/bamfdaemon/test-bamf.c' | |||
982 | --- tests/bamfdaemon/test-bamf.c 2013-06-21 20:58:53 +0000 | |||
983 | +++ tests/bamfdaemon/test-bamf.c 2013-07-16 16:30:44 +0000 | |||
984 | @@ -34,6 +34,20 @@ | |||
985 | 34 | 34 | ||
986 | 35 | static int result = 1; | 35 | static int result = 1; |
987 | 36 | 36 | ||
988 | 37 | static gboolean | ||
989 | 38 | not_fatal_log_handler (const gchar *log_domain, GLogLevelFlags log_level, | ||
990 | 39 | const gchar *message, gpointer user_data) | ||
991 | 40 | { | ||
992 | 41 | // Don't crash if used | ||
993 | 42 | return FALSE; | ||
994 | 43 | } | ||
995 | 44 | |||
996 | 45 | void | ||
997 | 46 | ignore_fatal_errors (void) | ||
998 | 47 | { | ||
999 | 48 | g_test_log_set_fatal_handler (not_fatal_log_handler, NULL); | ||
1000 | 49 | } | ||
1001 | 50 | |||
1002 | 37 | static void | 51 | static void |
1003 | 38 | on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer data) | 52 | on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer data) |
1004 | 39 | { | 53 | { |
PASSED: Continuous integration, rev:609 jenkins. qa.ubuntu. com/job/ bamf-ci/ 72/ jenkins. qa.ubuntu. com/job/ bamf-saucy- amd64-ci/ 53 jenkins. qa.ubuntu. com/job/ bamf-saucy- armhf-ci/ 54
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ bamf-ci/ 72/rebuild
http://