Merge lp:~brandontschaefer/bamf/desktop-file-default-icon into lp:bamf/0.4
- desktop-file-default-icon
- Merge into 0.4
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Marco Trevisan (Treviño) | ||||
Approved revision: | 475 | ||||
Merged at revision: | 475 | ||||
Proposed branch: | lp:~brandontschaefer/bamf/desktop-file-default-icon | ||||
Merge into: | lp:bamf/0.4 | ||||
Diff against target: |
557 lines (+128/-100) 4 files modified
src/bamf-application.c (+25/-19) tests/bamfdaemon/Makefile.am (+1/-1) tests/bamfdaemon/data/no-icon.desktop (+7/-0) tests/bamfdaemon/test-application.c (+95/-80) |
||||
To merge this branch: | bzr merge lp:~brandontschaefer/bamf/desktop-file-default-icon | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Marco Trevisan (Treviño) | Approve | ||
Review via email: mp+114501@code.launchpad.net |
Commit message
Daemon, BamfApplication: Use the default icon if there is not one defined in the desktop file.
Description of the change
=== Problem ===
If an application is opened and its desktop file does not have an icon defined a blank icon will appear.
=== Fix ===
If no icon is found just use the default icon
Unity Merger (unity-merger) wrote : | # |
The Jenkins job https:/
Not merging it.
Unity Merger (unity-merger) wrote : | # |
The Jenkins job https:/
Not merging it.
Unity Merger (unity-merger) wrote : | # |
The Jenkins job https:/
Not merging it.
- 475. By Brandon Schaefer
-
* Fix test, and indent
Preview Diff
1 | === modified file 'src/bamf-application.c' |
2 | --- src/bamf-application.c 2012-05-15 17:33:43 +0000 |
3 | +++ src/bamf-application.c 2012-07-17 19:05:22 +0000 |
4 | @@ -140,7 +140,13 @@ |
5 | name = g_strdup (g_app_info_get_display_name (G_APP_INFO (desktop))); |
6 | |
7 | if (gicon) |
8 | - icon = g_icon_to_string (gicon); |
9 | + { |
10 | + icon = g_icon_to_string (gicon); |
11 | + } |
12 | + else |
13 | + { |
14 | + icon = g_strdup ("application-default-icon"); |
15 | + } |
16 | |
17 | if (g_key_file_has_key(keyfile, G_KEY_FILE_DESKTOP_GROUP, STUB_KEY, NULL)) |
18 | { |
19 | @@ -151,12 +157,12 @@ |
20 | G_KEY_FILE_DESKTOP_GROUP, |
21 | STUB_KEY, NULL); |
22 | } |
23 | - |
24 | + |
25 | if (g_key_file_has_key (keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-GNOME-FullName", NULL)) |
26 | { |
27 | /* Grab the better name if its available */ |
28 | gchar *fullname = NULL; |
29 | - error = NULL; |
30 | + error = NULL; |
31 | fullname = g_key_file_get_locale_string (keyfile, |
32 | G_KEY_FILE_DESKTOP_GROUP, |
33 | "X-GNOME-FullName", NULL, |
34 | @@ -184,9 +190,9 @@ |
35 | view = l->data; |
36 | if (!BAMF_IS_WINDOW (view)) |
37 | continue; |
38 | - |
39 | + |
40 | window = BAMF_WINDOW (view); |
41 | - |
42 | + |
43 | do |
44 | { |
45 | class = bamf_legacy_window_get_class_name (bamf_window_get_window (window)); |
46 | @@ -208,14 +214,14 @@ |
47 | |
48 | name = g_strdup (bamf_legacy_window_get_name (bamf_window_get_window (window))); |
49 | } |
50 | - |
51 | + |
52 | if (!icon) |
53 | { |
54 | if (window) |
55 | { |
56 | icon = g_strdup (bamf_legacy_window_save_mini_icon (bamf_window_get_window (window))); |
57 | } |
58 | - |
59 | + |
60 | if (!icon) |
61 | { |
62 | icon = g_strdup ("application-default-icon"); |
63 | @@ -394,10 +400,10 @@ |
64 | if (!BAMF_IS_WINDOW (child)) |
65 | continue; |
66 | |
67 | - return g_strdup_printf ("application%s", |
68 | + return g_strdup_printf ("application%s", |
69 | bamf_legacy_window_get_class_name (bamf_window_get_window (BAMF_WINDOW (child)))); |
70 | } |
71 | - |
72 | + |
73 | return g_strdup_printf ("application%p", view); |
74 | } |
75 | |
76 | @@ -416,7 +422,7 @@ |
77 | continue; |
78 | |
79 | running = TRUE; |
80 | - |
81 | + |
82 | if (BAMF_IS_INDICATOR (view)) |
83 | visible = TRUE; |
84 | |
85 | @@ -504,7 +510,7 @@ |
86 | |
87 | matcher = bamf_matcher_get_default (); |
88 | favs = bamf_matcher_get_favorites (matcher); |
89 | - |
90 | + |
91 | if (favs) |
92 | { |
93 | for (l = favs; l; l = l->next) |
94 | @@ -549,7 +555,7 @@ |
95 | priv->desktop_file_list = g_list_reverse (priv->desktop_file_list); |
96 | |
97 | desktop_file = bamf_application_favorite_from_list (self, priv->desktop_file_list); |
98 | - |
99 | + |
100 | /* items, after reversing them, are in priority order */ |
101 | if (!desktop_file) |
102 | desktop_file = list->data; |
103 | @@ -583,10 +589,10 @@ |
104 | matcher_favorites_changed (BamfMatcher *matcher, BamfApplication *self) |
105 | { |
106 | char *new_desktop_file = NULL; |
107 | - |
108 | + |
109 | g_return_if_fail (BAMF_IS_APPLICATION (self)); |
110 | g_return_if_fail (BAMF_IS_MATCHER (matcher)); |
111 | - |
112 | + |
113 | new_desktop_file = bamf_application_favorite_from_list (self, self->priv->desktop_file_list); |
114 | |
115 | if (new_desktop_file) |
116 | @@ -670,7 +676,7 @@ |
117 | g_free (priv->desktop_file); |
118 | priv->desktop_file = NULL; |
119 | } |
120 | - |
121 | + |
122 | if (priv->desktop_file_list) |
123 | { |
124 | g_list_free_full (priv->desktop_file_list, g_free); |
125 | @@ -748,7 +754,7 @@ |
126 | bamf_dbus_item_object_skeleton_set_application (BAMF_DBUS_ITEM_OBJECT_SKELETON (self), |
127 | priv->dbus_iface); |
128 | |
129 | - g_signal_connect (G_OBJECT (bamf_matcher_get_default ()), "favorites-changed", |
130 | + g_signal_connect (G_OBJECT (bamf_matcher_get_default ()), "favorites-changed", |
131 | (GCallback) matcher_favorites_changed, self); |
132 | } |
133 | |
134 | @@ -800,10 +806,10 @@ |
135 | { |
136 | BamfApplication *application; |
137 | application = (BamfApplication *) g_object_new (BAMF_TYPE_APPLICATION, NULL); |
138 | - |
139 | + |
140 | bamf_application_set_desktop_file_from_list (application, desktop_files); |
141 | - |
142 | - return application; |
143 | + |
144 | + return application; |
145 | } |
146 | |
147 | BamfApplication * |
148 | |
149 | === modified file 'tests/bamfdaemon/Makefile.am' |
150 | --- tests/bamfdaemon/Makefile.am 2012-01-19 19:39:46 +0000 |
151 | +++ tests/bamfdaemon/Makefile.am 2012-07-17 19:05:22 +0000 |
152 | @@ -63,7 +63,7 @@ |
153 | -I$(top_srcdir)/src \ |
154 | -I$(top_builddir)/src \ |
155 | -DWNCK_I_KNOW_THIS_IS_UNSTABLE \ |
156 | - -DTESTDIR=\""$(top_srcdir)/tests/unit"\" \ |
157 | + -DTESTDIR=\""$(top_srcdir)/tests"\" \ |
158 | $(GCC_FLAGS) \ |
159 | $(GTK_CFLAGS) \ |
160 | $(GLIB_CFLAGS) \ |
161 | |
162 | === added directory 'tests/bamfdaemon/data' |
163 | === added file 'tests/bamfdaemon/data/no-icon.desktop' |
164 | --- tests/bamfdaemon/data/no-icon.desktop 1970-01-01 00:00:00 +0000 |
165 | +++ tests/bamfdaemon/data/no-icon.desktop 2012-07-17 19:05:22 +0000 |
166 | @@ -0,0 +1,7 @@ |
167 | +[Desktop Entry] |
168 | +Name=Default |
169 | +Comment=Interactive viewer for a Default icon! |
170 | +Exec=gedit |
171 | +Terminal=false |
172 | +Type=Application |
173 | +Categories=GTK;Science;Graphics; |
174 | |
175 | === modified file 'tests/bamfdaemon/test-application.c' |
176 | --- tests/bamfdaemon/test-application.c 2011-12-23 11:27:28 +0000 |
177 | +++ tests/bamfdaemon/test-application.c 2012-07-17 19:05:22 +0000 |
178 | @@ -2,7 +2,7 @@ |
179 | * Copyright (C) 2009-2011 Canonical Ltd |
180 | * |
181 | * This program is free software: you can redistribute it and/or modify |
182 | - * it under the terms of the GNU General Public License version 3 as |
183 | + * it under the terms of the GNU General Public License version 3 as |
184 | * published by the Free Software Foundation. |
185 | * |
186 | * This program is distributed in the hope that it will be useful, |
187 | @@ -30,6 +30,7 @@ |
188 | |
189 | static void test_allocation (void); |
190 | static void test_desktop_file (void); |
191 | +static void test_desktop_no_icon (void); |
192 | static void test_urgent (void); |
193 | static void test_active (void); |
194 | static void test_get_xids (void); |
195 | @@ -53,6 +54,7 @@ |
196 | |
197 | g_test_add_func (DOMAIN"/Allocation", test_allocation); |
198 | g_test_add_func (DOMAIN"/DesktopFile", test_desktop_file); |
199 | + g_test_add_func (DOMAIN"/DesktopFile/NoIcon", test_desktop_no_icon); |
200 | g_test_add_func (DOMAIN"/ManagesXid", test_manages_xid); |
201 | g_test_add_func (DOMAIN"/Xids", test_get_xids); |
202 | g_test_add_func (DOMAIN"/Events/Active", test_active); |
203 | @@ -102,6 +104,19 @@ |
204 | } |
205 | |
206 | static void |
207 | +test_desktop_no_icon (void) |
208 | +{ |
209 | + BamfApplication *application; |
210 | + const char no_icon_desktop[] = TESTDIR"/bamfdaemon/data/no-icon.desktop"; |
211 | + |
212 | + application = bamf_application_new_from_desktop_file (no_icon_desktop); |
213 | + g_assert (g_strcmp0 (bamf_application_get_desktop_file (application), no_icon_desktop) == 0); |
214 | + |
215 | + g_assert (g_strcmp0(bamf_view_get_icon(BAMF_VIEW(application)), "application-default-icon") == 0); |
216 | + g_object_unref (application); |
217 | +} |
218 | + |
219 | +static void |
220 | on_urgent_changed (BamfApplication *application, gboolean result, gpointer data) |
221 | { |
222 | signal_seen = TRUE; |
223 | @@ -112,53 +127,53 @@ |
224 | test_urgent (void) |
225 | { |
226 | signal_seen = FALSE; |
227 | - |
228 | + |
229 | BamfApplication *application; |
230 | BamfWindow *window1, *window2; |
231 | BamfLegacyWindowTest *test1, *test2; |
232 | - |
233 | + |
234 | application = bamf_application_new (); |
235 | - |
236 | + |
237 | g_signal_connect (G_OBJECT (application), "urgent-changed", (GCallback) on_urgent_changed, NULL); |
238 | - |
239 | + |
240 | test1 = bamf_legacy_window_test_new (20, "Window X", "class", "exec"); |
241 | test2 = bamf_legacy_window_test_new (20, "Window Y", "class", "exec"); |
242 | - |
243 | + |
244 | window1 = bamf_window_new (BAMF_LEGACY_WINDOW (test1)); |
245 | window2 = bamf_window_new (BAMF_LEGACY_WINDOW (test2)); |
246 | - |
247 | + |
248 | // Ensure we are not visible with no windows |
249 | g_assert (!bamf_view_is_urgent (BAMF_VIEW (application))); |
250 | - |
251 | + |
252 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window1)); |
253 | - |
254 | + |
255 | // Test that when added, we signaled properly |
256 | g_assert (!bamf_view_is_urgent (BAMF_VIEW (application))); |
257 | g_assert (!signal_seen); |
258 | - |
259 | + |
260 | bamf_view_remove_child (BAMF_VIEW (application), BAMF_VIEW (window1)); |
261 | - |
262 | + |
263 | // Test that we unset and signal properly |
264 | g_assert (!bamf_view_is_urgent (BAMF_VIEW (application))); |
265 | g_assert (!signal_seen); |
266 | - |
267 | + |
268 | bamf_legacy_window_test_set_attention (test1, TRUE); |
269 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window1)); |
270 | - |
271 | - // Ensure that when adding a skip-tasklist window, we dont set this to visible |
272 | + |
273 | + // Ensure that when adding a skip-tasklist window, we dont set this to visible |
274 | g_assert (bamf_view_is_urgent (BAMF_VIEW (application))); |
275 | g_assert (signal_seen); |
276 | g_assert (signal_result); |
277 | - |
278 | + |
279 | signal_seen = FALSE; |
280 | |
281 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window2)); |
282 | - |
283 | + |
284 | g_assert (bamf_view_is_urgent (BAMF_VIEW (application))); |
285 | g_assert (!signal_seen); |
286 | - |
287 | + |
288 | bamf_legacy_window_test_set_attention (test1, FALSE); |
289 | - |
290 | + |
291 | g_assert (!bamf_view_is_urgent (BAMF_VIEW (application))); |
292 | g_assert (signal_seen); |
293 | g_assert (!signal_result); |
294 | @@ -175,53 +190,53 @@ |
295 | test_active (void) |
296 | { |
297 | signal_seen = FALSE; |
298 | - |
299 | + |
300 | BamfApplication *application; |
301 | BamfWindow *window1, *window2; |
302 | BamfLegacyWindowTest *test1, *test2; |
303 | - |
304 | + |
305 | application = bamf_application_new (); |
306 | - |
307 | + |
308 | g_signal_connect (G_OBJECT (application), "active-changed", (GCallback) on_active_changed, NULL); |
309 | - |
310 | + |
311 | test1 = bamf_legacy_window_test_new (20, "Window X", "class", "exec"); |
312 | test2 = bamf_legacy_window_test_new (20, "Window Y", "class", "exec"); |
313 | - |
314 | + |
315 | window1 = bamf_window_new (BAMF_LEGACY_WINDOW (test1)); |
316 | window2 = bamf_window_new (BAMF_LEGACY_WINDOW (test2)); |
317 | - |
318 | + |
319 | // Ensure we are not active with no windows |
320 | g_assert (!bamf_view_is_active (BAMF_VIEW (application))); |
321 | - |
322 | + |
323 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window1)); |
324 | - |
325 | + |
326 | // Test that when added, we signaled properly |
327 | g_assert (!bamf_view_is_active (BAMF_VIEW (application))); |
328 | g_assert (!signal_seen); |
329 | - |
330 | + |
331 | bamf_view_remove_child (BAMF_VIEW (application), BAMF_VIEW (window1)); |
332 | - |
333 | + |
334 | // Test that we unset and signal properly |
335 | g_assert (!bamf_view_is_active (BAMF_VIEW (application))); |
336 | g_assert (!signal_seen); |
337 | - |
338 | + |
339 | bamf_legacy_window_test_set_active (test1, TRUE); |
340 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window1)); |
341 | - |
342 | - // Ensure that when adding a skip-tasklist window, we dont set this to visible |
343 | + |
344 | + // Ensure that when adding a skip-tasklist window, we dont set this to visible |
345 | g_assert (bamf_view_is_active (BAMF_VIEW (application))); |
346 | g_assert (signal_seen); |
347 | g_assert (signal_result); |
348 | - |
349 | + |
350 | signal_seen = FALSE; |
351 | |
352 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window2)); |
353 | - |
354 | + |
355 | g_assert (bamf_view_is_active (BAMF_VIEW (application))); |
356 | g_assert (!signal_seen); |
357 | - |
358 | + |
359 | bamf_legacy_window_test_set_active (test1, FALSE); |
360 | - |
361 | + |
362 | g_assert (!bamf_view_is_active (BAMF_VIEW (application))); |
363 | g_assert (signal_seen); |
364 | g_assert (!signal_result); |
365 | @@ -239,7 +254,7 @@ |
366 | guint32 xid; |
367 | |
368 | application = bamf_application_new (); |
369 | - |
370 | + |
371 | lwin1 = bamf_legacy_window_test_new (25, "window1", "class", "exec"); |
372 | lwin2 = bamf_legacy_window_test_new (50, "window2", "class", "exec"); |
373 | window1 = bamf_window_new (BAMF_LEGACY_WINDOW (lwin1)); |
374 | @@ -289,7 +304,7 @@ |
375 | |
376 | g_variant_iter_free (xids); |
377 | g_variant_unref (container); |
378 | - |
379 | + |
380 | g_object_unref (lwin1); |
381 | g_object_unref (lwin2); |
382 | g_object_unref (window1); |
383 | @@ -328,59 +343,59 @@ |
384 | test_user_visible (void) |
385 | { |
386 | signal_seen = FALSE; |
387 | - |
388 | + |
389 | BamfApplication *application; |
390 | BamfWindow *window1, *window2; |
391 | BamfLegacyWindowTest *test1, *test2; |
392 | - |
393 | + |
394 | application = bamf_application_new (); |
395 | - |
396 | + |
397 | g_signal_connect (G_OBJECT (application), "user-visible-changed", (GCallback) on_user_visible_changed, NULL); |
398 | - |
399 | + |
400 | test1 = bamf_legacy_window_test_new (20, "Window X", "class", "exec"); |
401 | test2 = bamf_legacy_window_test_new (20, "Window Y", "class", "exec"); |
402 | - |
403 | + |
404 | window1 = bamf_window_new (BAMF_LEGACY_WINDOW (test1)); |
405 | window2 = bamf_window_new (BAMF_LEGACY_WINDOW (test2)); |
406 | - |
407 | + |
408 | // Ensure we are not visible with no windows |
409 | g_assert (!bamf_view_user_visible (BAMF_VIEW (application))); |
410 | - |
411 | + |
412 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window1)); |
413 | - |
414 | + |
415 | // Test that when added, we signaled properly |
416 | g_assert (bamf_view_user_visible (BAMF_VIEW (application))); |
417 | g_assert (signal_seen); |
418 | g_assert (signal_result); |
419 | - |
420 | + |
421 | signal_seen = FALSE; |
422 | - |
423 | + |
424 | bamf_view_remove_child (BAMF_VIEW (application), BAMF_VIEW (window1)); |
425 | - |
426 | + |
427 | // Test that we unset and signal properly |
428 | g_assert (!bamf_view_user_visible (BAMF_VIEW (application))); |
429 | g_assert (signal_seen); |
430 | g_assert (!signal_result); |
431 | - |
432 | + |
433 | signal_seen = FALSE; |
434 | - |
435 | + |
436 | bamf_legacy_window_test_set_skip (test1, TRUE); |
437 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window1)); |
438 | - |
439 | - // Ensure that when adding a skip-tasklist window, we dont set this to visible |
440 | + |
441 | + // Ensure that when adding a skip-tasklist window, we dont set this to visible |
442 | g_assert (!bamf_view_user_visible (BAMF_VIEW (application))); |
443 | g_assert (!signal_seen); |
444 | - |
445 | + |
446 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window2)); |
447 | - |
448 | + |
449 | g_assert (bamf_view_user_visible (BAMF_VIEW (application))); |
450 | g_assert (signal_seen); |
451 | g_assert (signal_result); |
452 | - |
453 | + |
454 | signal_seen = FALSE; |
455 | - |
456 | + |
457 | bamf_legacy_window_test_set_skip (test2, TRUE); |
458 | - |
459 | + |
460 | g_assert (!bamf_view_user_visible (BAMF_VIEW (window1))); |
461 | g_assert (!bamf_view_user_visible (BAMF_VIEW (application))); |
462 | g_assert (signal_seen); |
463 | @@ -398,35 +413,35 @@ |
464 | test_window_added (void) |
465 | { |
466 | signal_seen = FALSE; |
467 | - |
468 | + |
469 | BamfApplication *application; |
470 | BamfWindow *window; |
471 | BamfLegacyWindowTest *test; |
472 | const char *path; |
473 | - |
474 | + |
475 | application = bamf_application_new (); |
476 | - |
477 | + |
478 | g_signal_connect (G_OBJECT (application), "window-added", (GCallback) on_window_added, NULL); |
479 | - |
480 | + |
481 | test = bamf_legacy_window_test_new (20, "Window X", "class", "exec"); |
482 | window = bamf_window_new (BAMF_LEGACY_WINDOW (test)); |
483 | - |
484 | + |
485 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window)); |
486 | - |
487 | + |
488 | // Ensure we dont signal things that are not on the bus |
489 | g_assert (!signal_seen); |
490 | - |
491 | + |
492 | bamf_view_remove_child (BAMF_VIEW (application), BAMF_VIEW (window)); |
493 | - |
494 | + |
495 | path = bamf_view_export_on_bus (BAMF_VIEW (window), gdbus_connection); |
496 | - |
497 | + |
498 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window)); |
499 | - |
500 | + |
501 | g_assert (signal_seen); |
502 | g_assert_cmpstr (signal_window, ==, path); |
503 | - |
504 | + |
505 | signal_seen = FALSE; |
506 | - |
507 | + |
508 | g_object_unref (window); |
509 | g_object_unref (test); |
510 | } |
511 | @@ -442,35 +457,35 @@ |
512 | test_window_removed (void) |
513 | { |
514 | signal_seen = FALSE; |
515 | - |
516 | + |
517 | BamfApplication *application; |
518 | BamfWindow *window; |
519 | BamfLegacyWindowTest *test; |
520 | const char *path; |
521 | - |
522 | + |
523 | application = bamf_application_new (); |
524 | - |
525 | + |
526 | g_signal_connect (G_OBJECT (application), "window-removed", (GCallback) on_window_removed, NULL); |
527 | - |
528 | + |
529 | test = bamf_legacy_window_test_new (20, "Window X", "class", "exec"); |
530 | window = bamf_window_new (BAMF_LEGACY_WINDOW (test)); |
531 | - |
532 | + |
533 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window)); |
534 | bamf_view_remove_child (BAMF_VIEW (application), BAMF_VIEW (window)); |
535 | - |
536 | + |
537 | // Ensure we dont signal things that are not on the bus |
538 | g_assert (!signal_seen); |
539 | - |
540 | + |
541 | path = bamf_view_export_on_bus (BAMF_VIEW (window), gdbus_connection); |
542 | - |
543 | + |
544 | bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (window)); |
545 | bamf_view_remove_child (BAMF_VIEW (application), BAMF_VIEW (window)); |
546 | - |
547 | + |
548 | g_assert (signal_seen); |
549 | g_assert (g_strcmp0 (signal_window, path) == 0); |
550 | - |
551 | + |
552 | signal_seen = FALSE; |
553 | - |
554 | + |
555 | g_object_unref (window); |
556 | g_object_unref (test); |
557 | } |
I would have probably always set a NULL icon when we have no icon, instead of setting the default one, but since the code was inconsistent and this fixes the inconsistency (and an unity related bug), I'm ok with it.