Merge lp:~3v1n0/bamf/view-icon-property into lp:bamf
- view-icon-property
- Merge into trunk
Proposed by
Marco Trevisan (Treviño)
Status: | Merged |
---|---|
Approved by: | Brandon Schaefer |
Approved revision: | 577 |
Merged at revision: | 557 |
Proposed branch: | lp:~3v1n0/bamf/view-icon-property |
Merge into: | lp:bamf |
Diff against target: |
873 lines (+254/-139) 11 files modified
lib/libbamf-private/bamf-private.h (+6/-0) lib/libbamf-private/org.ayatana.bamf.view.xml (+2/-0) lib/libbamf/bamf-application.c (+2/-7) lib/libbamf/bamf-view-private.h (+1/-1) lib/libbamf/bamf-view.c (+42/-28) lib/libbamf/bamf-view.h (+2/-1) src/bamf-application.c (+13/-36) src/bamf-view.c (+34/-17) src/bamf-view.h (+10/-9) tests/bamfdaemon/test-view.c (+140/-39) tests/libbamf/test-application.c (+2/-1) |
To merge this branch: | bzr merge lp:~3v1n0/bamf/view-icon-property |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Brandon Schaefer (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+170434@code.launchpad.net |
Commit message
BamfDaemon, LibBamf: add icon property to store the BamfView icon and notify about its changes.
New tests added.
Description of the change
Move icon of BamfView to a property, so that it can change and we can our clients about it... It will allow to fix bugs such as #1007383
To post a comment you must log in.
- 577. By Marco Trevisan (Treviño)
-
BamfView: remove the useless getters from Class
Also properly initialize signals adding default handlers
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Approve
(continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:577
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
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 'lib/libbamf-private/bamf-private.h' |
2 | --- lib/libbamf-private/bamf-private.h 2013-06-18 14:43:55 +0000 |
3 | +++ lib/libbamf-private/bamf-private.h 2013-06-19 20:08:28 +0000 |
4 | @@ -31,6 +31,12 @@ |
5 | |
6 | #define BAMF_DBUS_DEFAULT_TIMEOUT 500 |
7 | |
8 | +/* GLib doesn't provide this by default */ |
9 | +#ifndef G_KEY_FILE_DESKTOP_KEY_FULLNAME |
10 | +#define G_KEY_FILE_DESKTOP_KEY_FULLNAME "X-GNOME-FullName" |
11 | +#endif |
12 | + |
13 | +#define BAMF_APPLICATION_DEFAULT_ICON "application-default-icon" |
14 | |
15 | /* GCC Macros to handle warnings |
16 | * Authored by: Patrick Horgan <patrick@dbp-consulting.com> |
17 | |
18 | === modified file 'lib/libbamf-private/org.ayatana.bamf.view.xml' |
19 | --- lib/libbamf-private/org.ayatana.bamf.view.xml 2013-06-19 16:19:46 +0000 |
20 | +++ lib/libbamf-private/org.ayatana.bamf.view.xml 2013-06-19 20:08:28 +0000 |
21 | @@ -6,6 +6,7 @@ |
22 | <arg name="view_type" type="s" direction="out"/> |
23 | </method> |
24 | <method name="Icon"> |
25 | + <annotation name="org.freedesktop.DBus.Deprecated" value="true"/> |
26 | <arg name="name" type="s" direction="out"/> |
27 | </method> |
28 | <method name="Name"> |
29 | @@ -64,6 +65,7 @@ |
30 | <signal name="Closed"> |
31 | </signal> |
32 | <property name="Name" type="s" access="read"/> |
33 | + <property name="Icon" type="s" access="read"/> |
34 | <property name="UserVisible" type="b" access="read"/> |
35 | <property name="Running" type="b" access="read"/> |
36 | <property name="Urgent" type="b" access="read"/> |
37 | |
38 | === modified file 'lib/libbamf/bamf-application.c' |
39 | --- lib/libbamf/bamf-application.c 2013-06-19 13:35:50 +0000 |
40 | +++ lib/libbamf/bamf-application.c 2013-06-19 20:08:28 +0000 |
41 | @@ -621,11 +621,6 @@ |
42 | |
43 | name = g_strdup (g_app_info_get_name (G_APP_INFO (desktop_info))); |
44 | |
45 | -/* GLib doesn't provide this by default */ |
46 | -#ifndef G_KEY_FILE_DESKTOP_KEY_FULLNAME |
47 | -#define G_KEY_FILE_DESKTOP_KEY_FULLNAME "X-GNOME-FullName" |
48 | -#endif |
49 | - |
50 | /* Grab the better name if its available */ |
51 | fullname = g_key_file_get_locale_string (keyfile, G_KEY_FILE_DESKTOP_GROUP, |
52 | G_KEY_FILE_DESKTOP_KEY_FULLNAME, NULL, NULL); |
53 | @@ -648,9 +643,9 @@ |
54 | icon = gicon ? g_icon_to_string (gicon) : NULL; |
55 | |
56 | if (!icon) |
57 | - icon = g_strdup ("application-default-icon"); |
58 | + icon = g_strdup (BAMF_APPLICATION_DEFAULT_ICON); |
59 | |
60 | - _bamf_view_set_icon (BAMF_VIEW (self), icon); |
61 | + _bamf_view_set_cached_icon (BAMF_VIEW (self), icon); |
62 | |
63 | self->priv->cached_mimes = g_key_file_get_string_list (keyfile, G_KEY_FILE_DESKTOP_GROUP, |
64 | G_KEY_FILE_DESKTOP_KEY_MIME_TYPE, NULL, NULL); |
65 | |
66 | === modified file 'lib/libbamf/bamf-view-private.h' |
67 | --- lib/libbamf/bamf-view-private.h 2013-06-19 13:35:50 +0000 |
68 | +++ lib/libbamf/bamf-view-private.h 2013-06-19 20:08:28 +0000 |
69 | @@ -45,7 +45,7 @@ |
70 | |
71 | void _bamf_view_set_cached_name (BamfView *view, const char *name); |
72 | |
73 | -void _bamf_view_set_icon (BamfView *view, const char *icon); |
74 | +void _bamf_view_set_cached_icon (BamfView *view, const char *icon); |
75 | |
76 | void _bamf_view_set_closed (BamfView *view, gboolean closed); |
77 | |
78 | |
79 | === modified file 'lib/libbamf/bamf-view.c' |
80 | --- lib/libbamf/bamf-view.c 2013-06-19 13:35:50 +0000 |
81 | +++ lib/libbamf/bamf-view.c 2013-06-19 20:08:28 +0000 |
82 | @@ -59,6 +59,7 @@ |
83 | URGENT_CHANGED, |
84 | VISIBLE_CHANGED, |
85 | NAME_CHANGED, |
86 | + ICON_CHANGED, |
87 | LAST_SIGNAL |
88 | }; |
89 | |
90 | @@ -82,8 +83,8 @@ |
91 | BamfDBusItemView *proxy; |
92 | GCancellable *cancellable; |
93 | gchar *type; |
94 | - gchar *local_icon; |
95 | gchar *cached_name; |
96 | + gchar *cached_icon; |
97 | GList *cached_children; |
98 | gboolean reload_children; |
99 | gboolean is_closed; |
100 | @@ -282,16 +283,19 @@ |
101 | } |
102 | |
103 | void |
104 | -_bamf_view_set_icon (BamfView *view, const char *icon) |
105 | +_bamf_view_set_cached_icon (BamfView *view, const char *icon) |
106 | { |
107 | g_return_if_fail (BAMF_IS_VIEW (view)); |
108 | |
109 | - g_free (view->priv->local_icon); |
110 | - view->priv->local_icon = NULL; |
111 | + if (!icon || g_strcmp0 (icon, view->priv->cached_icon) == 0) |
112 | + return; |
113 | + |
114 | + g_free (view->priv->cached_icon); |
115 | + view->priv->cached_icon = NULL; |
116 | |
117 | if (icon && icon[0] != '\0') |
118 | { |
119 | - view->priv->local_icon = g_strdup (icon); |
120 | + view->priv->cached_icon = g_strdup (icon); |
121 | } |
122 | } |
123 | |
124 | @@ -336,8 +340,6 @@ |
125 | bamf_view_get_icon (BamfView *self) |
126 | { |
127 | BamfViewPrivate *priv; |
128 | - char *icon = NULL; |
129 | - GError *error = NULL; |
130 | |
131 | g_return_val_if_fail (BAMF_IS_VIEW (self), NULL); |
132 | priv = self->priv; |
133 | @@ -346,20 +348,9 @@ |
134 | return BAMF_VIEW_GET_CLASS (self)->get_icon (self); |
135 | |
136 | if (!_bamf_view_remote_ready (self)) |
137 | - return g_strdup (priv->local_icon); |
138 | - |
139 | - if (!_bamf_dbus_item_view_call_icon_sync (priv->proxy, &icon, CANCELLABLE (self), &error)) |
140 | - { |
141 | - g_warning ("Failed to fetch icon: %s", error ? error->message : ""); |
142 | - g_error_free (error); |
143 | - |
144 | - return NULL; |
145 | - } |
146 | - |
147 | - _bamf_view_set_icon (self, icon); |
148 | - g_free (icon); |
149 | - |
150 | - return g_strdup (priv->local_icon); |
151 | + return g_strdup (priv->cached_icon); |
152 | + |
153 | + return _bamf_dbus_item_view_dup_icon (priv->proxy); |
154 | } |
155 | |
156 | /** |
157 | @@ -372,7 +363,6 @@ |
158 | bamf_view_get_name (BamfView *self) |
159 | { |
160 | BamfViewPrivate *priv; |
161 | - gchar *name; |
162 | |
163 | g_return_val_if_fail (BAMF_IS_VIEW (self), NULL); |
164 | priv = self->priv; |
165 | @@ -383,9 +373,7 @@ |
166 | if (!_bamf_view_remote_ready (self)) |
167 | return g_strdup (priv->cached_name); |
168 | |
169 | - name = _bamf_dbus_item_view_dup_name (priv->proxy); |
170 | - |
171 | - return name; |
172 | + return _bamf_dbus_item_view_dup_name (priv->proxy); |
173 | } |
174 | |
175 | gboolean |
176 | @@ -536,6 +524,12 @@ |
177 | g_signal_emit (G_OBJECT (self), view_signals[NAME_CHANGED], 0, NULL, cached_name); |
178 | } |
179 | |
180 | + if (self->priv->cached_icon) |
181 | + { |
182 | + const char *cached_icon = self->priv->cached_icon; |
183 | + g_signal_emit (G_OBJECT (self), view_signals[ICON_CHANGED], 0, cached_icon); |
184 | + } |
185 | + |
186 | _bamf_view_set_closed (self, TRUE); |
187 | g_signal_emit (G_OBJECT (self), view_signals[CLOSED], 0); |
188 | } |
189 | @@ -561,6 +555,14 @@ |
190 | } |
191 | |
192 | static void |
193 | +bamf_view_on_icon_changed (BamfDBusItemView *proxy, GParamSpec *param, BamfView *self) |
194 | +{ |
195 | + const char *icon = _bamf_dbus_item_view_get_icon (proxy); |
196 | + g_signal_emit (self, view_signals[ICON_CHANGED], 0, icon); |
197 | + _bamf_view_set_cached_icon (self, icon); |
198 | +} |
199 | + |
200 | +static void |
201 | bamf_view_on_running_changed (BamfDBusItemView *proxy, GParamSpec *param, BamfView *self) |
202 | { |
203 | gboolean running = _bamf_dbus_item_view_get_running (proxy); |
204 | @@ -708,10 +710,10 @@ |
205 | priv->type = NULL; |
206 | } |
207 | |
208 | - if (priv->local_icon) |
209 | + if (priv->cached_icon) |
210 | { |
211 | - g_free (priv->local_icon); |
212 | - priv->local_icon = NULL; |
213 | + g_free (priv->cached_icon); |
214 | + priv->cached_icon = NULL; |
215 | } |
216 | |
217 | if (priv->cached_name) |
218 | @@ -808,6 +810,9 @@ |
219 | g_signal_connect (priv->proxy, "notify::name", |
220 | G_CALLBACK (bamf_view_on_name_changed), view); |
221 | |
222 | + g_signal_connect (priv->proxy, "notify::icon", |
223 | + G_CALLBACK (bamf_view_on_icon_changed), view); |
224 | + |
225 | g_signal_connect (priv->proxy, "child-added", |
226 | G_CALLBACK (bamf_view_on_child_added), view); |
227 | |
228 | @@ -929,6 +934,15 @@ |
229 | G_TYPE_NONE, 2, |
230 | G_TYPE_STRING, |
231 | G_TYPE_STRING); |
232 | + |
233 | + view_signals [ICON_CHANGED] = |
234 | + g_signal_new (BAMF_VIEW_SIGNAL_ICON_CHANGED, |
235 | + G_OBJECT_CLASS_TYPE (klass), |
236 | + 0, |
237 | + G_STRUCT_OFFSET (BamfViewClass, icon_changed), |
238 | + NULL, NULL, NULL, |
239 | + G_TYPE_NONE, 1, |
240 | + G_TYPE_STRING); |
241 | } |
242 | |
243 | static void |
244 | |
245 | === modified file 'lib/libbamf/bamf-view.h' |
246 | --- lib/libbamf/bamf-view.h 2013-06-08 13:54:06 +0000 |
247 | +++ lib/libbamf/bamf-view.h 2013-06-19 20:08:28 +0000 |
248 | @@ -54,6 +54,7 @@ |
249 | #define BAMF_VIEW_SIGNAL_URGENT_CHANGED "urgent-changed" |
250 | #define BAMF_VIEW_SIGNAL_USER_VISIBLE_CHANGED "user-visible-changed" |
251 | #define BAMF_VIEW_SIGNAL_NAME_CHANGED "name-changed" |
252 | +#define BAMF_VIEW_SIGNAL_ICON_CHANGED "icon-changed" |
253 | #define BAMF_VIEW_SIGNAL_CHILD_ADDED "child-added" |
254 | #define BAMF_VIEW_SIGNAL_CHILD_REMOVED "child-removed" |
255 | #define BAMF_VIEW_SIGNAL_CHILD_MOVED "child-moved" |
256 | @@ -107,13 +108,13 @@ |
257 | void (*urgent_changed) (BamfView *view, gboolean urgent); |
258 | void (*user_visible_changed) (BamfView *view, gboolean user_visible); |
259 | void (*name_changed) (BamfView *view, gchar* old_name, gchar* new_name); |
260 | + void (*icon_changed) (BamfView *view, gchar* icon); |
261 | void (*child_moved) (BamfView *view, BamfView *child); |
262 | |
263 | /*< private >*/ |
264 | void (*_view_padding1) (void); |
265 | void (*_view_padding2) (void); |
266 | void (*_view_padding3) (void); |
267 | - void (*_view_padding4) (void); |
268 | }; |
269 | |
270 | GType bamf_view_get_type (void) G_GNUC_CONST; |
271 | |
272 | === modified file 'src/bamf-application.c' |
273 | --- src/bamf-application.c 2013-06-18 17:55:15 +0000 |
274 | +++ src/bamf-application.c 2013-06-19 20:08:28 +0000 |
275 | @@ -41,7 +41,6 @@ |
276 | char * desktop_file; |
277 | GList * desktop_file_list; |
278 | char * app_type; |
279 | - char * icon; |
280 | char * wmclass; |
281 | char ** mimes; |
282 | gboolean is_tab_container; |
283 | @@ -58,14 +57,6 @@ |
284 | |
285 | #define STUB_KEY "X-Ayatana-Appmenu-Show-Stubs" |
286 | |
287 | -static const char * |
288 | -bamf_application_get_icon (BamfView *view) |
289 | -{ |
290 | - g_return_val_if_fail (BAMF_IS_APPLICATION (view), NULL); |
291 | - |
292 | - return BAMF_APPLICATION (view)->priv->icon; |
293 | -} |
294 | - |
295 | void |
296 | bamf_application_supported_mime_types_changed (BamfApplication *application, |
297 | const gchar **new_mimes) |
298 | @@ -213,16 +204,16 @@ |
299 | |
300 | g_return_if_fail (BAMF_IS_APPLICATION (self)); |
301 | |
302 | - if (self->priv->icon && bamf_view_get_name (BAMF_VIEW (self))) |
303 | + if (bamf_view_get_icon (BAMF_VIEW (self)) && bamf_view_get_name (BAMF_VIEW (self))) |
304 | return; |
305 | |
306 | if (self->priv->desktop_file) |
307 | { |
308 | - keyfile = g_key_file_new(); |
309 | + keyfile = g_key_file_new (); |
310 | |
311 | - if (!g_key_file_load_from_file(keyfile, self->priv->desktop_file, G_KEY_FILE_NONE, NULL)) |
312 | + if (!g_key_file_load_from_file (keyfile, self->priv->desktop_file, G_KEY_FILE_NONE, NULL)) |
313 | { |
314 | - g_key_file_free(keyfile); |
315 | + g_key_file_free (keyfile); |
316 | return; |
317 | } |
318 | |
319 | @@ -235,7 +226,6 @@ |
320 | } |
321 | |
322 | gicon = g_app_info_get_icon (G_APP_INFO (desktop)); |
323 | - |
324 | name = g_strdup (g_app_info_get_display_name (G_APP_INFO (desktop))); |
325 | |
326 | if (gicon) |
327 | @@ -244,7 +234,7 @@ |
328 | } |
329 | else |
330 | { |
331 | - icon = g_strdup ("application-default-icon"); |
332 | + icon = g_strdup (BAMF_APPLICATION_DEFAULT_ICON); |
333 | } |
334 | |
335 | if (g_key_file_has_key(keyfile, G_KEY_FILE_DESKTOP_GROUP, STUB_KEY, NULL)) |
336 | @@ -257,20 +247,19 @@ |
337 | STUB_KEY, NULL); |
338 | } |
339 | |
340 | - if (g_key_file_has_key (keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-GNOME-FullName", NULL)) |
341 | + if (g_key_file_has_key (keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_FULLNAME, NULL)) |
342 | { |
343 | /* Grab the better name if its available */ |
344 | gchar *fullname = NULL; |
345 | error = NULL; |
346 | fullname = g_key_file_get_locale_string (keyfile, |
347 | G_KEY_FILE_DESKTOP_GROUP, |
348 | - "X-GNOME-FullName", NULL, |
349 | - &error); |
350 | + G_KEY_FILE_DESKTOP_KEY_FULLNAME, |
351 | + NULL, &error); |
352 | if (error != NULL) |
353 | { |
354 | g_error_free (error); |
355 | - if (fullname) |
356 | - g_free (fullname); |
357 | + g_free (fullname); |
358 | } |
359 | else |
360 | { |
361 | @@ -327,7 +316,7 @@ |
362 | |
363 | if (!icon) |
364 | { |
365 | - icon = g_strdup ("application-default-icon"); |
366 | + icon = g_strdup (BAMF_APPLICATION_DEFAULT_ICON); |
367 | } |
368 | } |
369 | } |
370 | @@ -337,12 +326,7 @@ |
371 | } |
372 | |
373 | if (icon) |
374 | - { |
375 | - if (self->priv->icon) |
376 | - g_free (self->priv->icon); |
377 | - |
378 | - self->priv->icon = icon; |
379 | - } |
380 | + bamf_view_set_icon (BAMF_VIEW (self), icon); |
381 | |
382 | if (name) |
383 | bamf_view_set_name (BAMF_VIEW (self), name); |
384 | @@ -910,12 +894,6 @@ |
385 | priv->app_type = NULL; |
386 | } |
387 | |
388 | - if (priv->icon) |
389 | - { |
390 | - g_free (priv->icon); |
391 | - priv->icon = NULL; |
392 | - } |
393 | - |
394 | if (priv->wmclass) |
395 | { |
396 | g_free (priv->wmclass); |
397 | @@ -1008,7 +986,6 @@ |
398 | view_class->view_type = bamf_application_get_view_type; |
399 | view_class->child_added = bamf_application_child_added; |
400 | view_class->child_removed = bamf_application_child_removed; |
401 | - view_class->get_icon = bamf_application_get_icon; |
402 | view_class->stable_bus_name = bamf_application_get_stable_bus_name; |
403 | |
404 | klass->get_supported_mime_types = bamf_application_default_get_supported_mime_types; |
405 | @@ -1083,8 +1060,8 @@ |
406 | gboolean |
407 | bamf_application_get_show_stubs (BamfApplication *application) |
408 | { |
409 | - g_return_val_if_fail(BAMF_IS_APPLICATION(application), TRUE); |
410 | - return application->priv->show_stubs; |
411 | + g_return_val_if_fail (BAMF_IS_APPLICATION(application), TRUE); |
412 | + return application->priv->show_stubs; |
413 | } |
414 | |
415 | |
416 | |
417 | === modified file 'src/bamf-view.c' |
418 | --- src/bamf-view.c 2013-06-19 13:09:00 +0000 |
419 | +++ src/bamf-view.c 2013-06-19 20:08:28 +0000 |
420 | @@ -33,6 +33,7 @@ |
421 | PROP_0, |
422 | |
423 | PROP_NAME, |
424 | + PROP_ICON, |
425 | PROP_ACTIVE, |
426 | PROP_RUNNING, |
427 | PROP_URGENT, |
428 | @@ -62,6 +63,7 @@ |
429 | gboolean active; |
430 | |
431 | gchar *name; |
432 | + gchar *icon; |
433 | } BamfViewPropCache; |
434 | |
435 | struct _BamfViewPrivate |
436 | @@ -121,6 +123,12 @@ |
437 | } |
438 | |
439 | static void |
440 | +bamf_view_icon_changed (BamfView *view, const gchar *new_icon) |
441 | +{ |
442 | + g_object_notify (G_OBJECT (view), "icon"); |
443 | +} |
444 | + |
445 | +static void |
446 | bamf_view_user_visible_changed (BamfView *view, gboolean user_visible) |
447 | { |
448 | g_return_if_fail (BAMF_IS_VIEW (view)); |
449 | @@ -439,28 +447,23 @@ |
450 | const char * |
451 | bamf_view_get_icon (BamfView *view) |
452 | { |
453 | - g_return_val_if_fail (BAMF_IS_VIEW (view), NULL); |
454 | - |
455 | - if (BAMF_VIEW_GET_CLASS (view)->get_icon) |
456 | - return BAMF_VIEW_GET_CLASS (view)->get_icon (view); |
457 | - |
458 | - return NULL; |
459 | + BAMF_VIEW_GET_PROPERTY (view, icon, NULL); |
460 | +} |
461 | + |
462 | +void |
463 | +bamf_view_set_icon (BamfView *view, const char *icon) |
464 | +{ |
465 | + BAMF_VIEW_SET_STRING_PROPERTY (view, icon); |
466 | } |
467 | |
468 | const char * |
469 | bamf_view_get_name (BamfView *view) |
470 | { |
471 | - g_return_val_if_fail (BAMF_IS_VIEW (view), NULL); |
472 | - |
473 | - if (BAMF_VIEW_GET_CLASS (view)->get_name) |
474 | - return BAMF_VIEW_GET_CLASS (view)->get_name (view); |
475 | - |
476 | BAMF_VIEW_GET_PROPERTY (view, name, NULL); |
477 | } |
478 | |
479 | void |
480 | -bamf_view_set_name (BamfView *view, |
481 | - const char * name) |
482 | +bamf_view_set_name (BamfView *view, const char *name) |
483 | { |
484 | BAMF_VIEW_SET_STRING_PROPERTY (view, name); |
485 | } |
486 | @@ -494,6 +497,7 @@ |
487 | return; |
488 | |
489 | g_free (view->priv->props->name); |
490 | + g_free (view->priv->props->icon); |
491 | g_free (view->priv->props); |
492 | view->priv->props = NULL; |
493 | } |
494 | @@ -509,6 +513,7 @@ |
495 | view->priv->props = NULL; |
496 | |
497 | bamf_view_set_name (view, cache->name); |
498 | + bamf_view_set_icon (view, cache->icon); |
499 | bamf_view_set_active (view, cache->active); |
500 | bamf_view_set_running (view, cache->running); |
501 | bamf_view_set_user_visible (view, cache->user_visible); |
502 | @@ -811,6 +816,9 @@ |
503 | case PROP_NAME: |
504 | g_value_set_string (value, bamf_view_get_name (view)); |
505 | break; |
506 | + case PROP_ICON: |
507 | + g_value_set_string (value, bamf_view_get_icon (view)); |
508 | + break; |
509 | case PROP_ACTIVE: |
510 | g_value_set_boolean (value, bamf_view_is_active (view)); |
511 | break; |
512 | @@ -911,6 +919,7 @@ |
513 | /* Overriding the properties defined in the interface, this is needed |
514 | * but we actually don't use these properties, as we act like a proxy */ |
515 | g_object_class_override_property (object_class, PROP_NAME, "name"); |
516 | + g_object_class_override_property (object_class, PROP_ICON, "icon"); |
517 | g_object_class_override_property (object_class, PROP_ACTIVE, "active"); |
518 | g_object_class_override_property (object_class, PROP_URGENT, "urgent"); |
519 | g_object_class_override_property (object_class, PROP_RUNNING, "running"); |
520 | @@ -919,24 +928,32 @@ |
521 | view_signals [CLOSED_INTERNAL] = |
522 | g_signal_new ("closed-internal", |
523 | G_OBJECT_CLASS_TYPE (klass), |
524 | - 0, 0, NULL, NULL, NULL, |
525 | + G_SIGNAL_RUN_LAST, |
526 | + G_STRUCT_OFFSET (BamfViewClass, closed_internal), |
527 | + NULL, NULL, NULL, |
528 | G_TYPE_NONE, 0); |
529 | |
530 | view_signals [CHILD_ADDED_INTERNAL] = |
531 | g_signal_new ("child-added-internal", |
532 | G_OBJECT_CLASS_TYPE (klass), |
533 | - 0, 0, NULL, NULL, NULL, |
534 | + G_SIGNAL_RUN_FIRST, |
535 | + G_STRUCT_OFFSET (BamfViewClass, child_added_internal), |
536 | + NULL, NULL, NULL, |
537 | G_TYPE_NONE, 1, BAMF_TYPE_VIEW); |
538 | |
539 | view_signals [CHILD_REMOVED_INTERNAL] = |
540 | g_signal_new ("child-removed-internal", |
541 | G_OBJECT_CLASS_TYPE (klass), |
542 | - 0, 0, NULL, NULL, NULL, |
543 | + G_SIGNAL_RUN_FIRST, |
544 | + G_STRUCT_OFFSET (BamfViewClass, child_removed_internal), |
545 | + NULL, NULL, NULL, |
546 | G_TYPE_NONE, 1, BAMF_TYPE_VIEW); |
547 | |
548 | view_signals [EXPORTED] = |
549 | g_signal_new ("exported", |
550 | G_OBJECT_CLASS_TYPE (klass), |
551 | - 0, 0, NULL, NULL, NULL, |
552 | + G_SIGNAL_RUN_FIRST, |
553 | + G_STRUCT_OFFSET (BamfViewClass, exported), |
554 | + NULL, NULL, NULL, |
555 | G_TYPE_NONE, 0); |
556 | } |
557 | |
558 | === modified file 'src/bamf-view.h' |
559 | --- src/bamf-view.h 2013-06-18 17:55:15 +0000 |
560 | +++ src/bamf-view.h 2013-06-19 20:08:28 +0000 |
561 | @@ -42,10 +42,8 @@ |
562 | GList *names; |
563 | |
564 | /*< methods >*/ |
565 | - const char * (*view_type) (BamfView *view); |
566 | - char * (*stable_bus_name) (BamfView *view); |
567 | - const char * (*get_name) (BamfView *view); |
568 | - const char * (*get_icon) (BamfView *view); |
569 | + const char * (*view_type) (BamfView *view); |
570 | + char * (*stable_bus_name) (BamfView *view); |
571 | |
572 | /*< random stuff >*/ |
573 | gboolean (* urgent_changed) (BamfView *view, gboolean urgent); |
574 | @@ -53,12 +51,14 @@ |
575 | gboolean (* active_changed) (BamfView *view, gboolean active); |
576 | gboolean (* user_visible_changed) (BamfView *view, gboolean visible); |
577 | gboolean (* closed) (BamfView *view); |
578 | + void (* child_added) (BamfView *view, BamfView *child); |
579 | + void (* child_removed) (BamfView *view, BamfView *child); |
580 | |
581 | /*< signals >*/ |
582 | - void (*child_added) (BamfView *view, BamfView *child); |
583 | - void (*child_removed) (BamfView *view, BamfView *child); |
584 | - void (*exported) (BamfView *view); |
585 | - void (*name_changed) (BamfView *view, const gchar* old_name, const gchar* new_name); |
586 | + void (* closed_internal) (BamfView *view); |
587 | + void (* child_added_internal) (BamfView *view, BamfView *child); |
588 | + void (* child_removed_internal) (BamfView *view, BamfView *child); |
589 | + void (* exported) (BamfView *view); |
590 | }; |
591 | |
592 | struct _BamfView |
593 | @@ -98,10 +98,11 @@ |
594 | gboolean bamf_view_is_urgent (BamfView *view); |
595 | void bamf_view_set_urgent (BamfView *view, gboolean urgent); |
596 | |
597 | +void bamf_view_set_icon (BamfView *view, const char *icon); |
598 | const char * bamf_view_get_icon (BamfView *view); |
599 | |
600 | const char * bamf_view_get_name (BamfView *view); |
601 | -void bamf_view_set_name (BamfView *view, const char * name); |
602 | +void bamf_view_set_name (BamfView *view, const char *name); |
603 | |
604 | const char * bamf_view_get_parent_path (BamfView *view); |
605 | |
606 | |
607 | === modified file 'tests/bamfdaemon/test-view.c' |
608 | --- tests/bamfdaemon/test-view.c 2013-06-19 15:44:52 +0000 |
609 | +++ tests/bamfdaemon/test-view.c 2013-06-19 20:08:28 +0000 |
610 | @@ -35,43 +35,59 @@ |
611 | g_object_unref (G_OBJECT (view)); |
612 | } |
613 | |
614 | -static void |
615 | -test_name (void) |
616 | -{ |
617 | - BamfView *view; |
618 | - |
619 | - view = g_object_new (BAMF_TYPE_VIEW, NULL); |
620 | - |
621 | - g_assert (bamf_view_get_name (view) == NULL); |
622 | - |
623 | - bamf_view_set_name (view, "SomeName"); |
624 | - |
625 | - g_assert_cmpstr (bamf_view_get_name (view), ==, "SomeName"); |
626 | - |
627 | - g_object_unref (view); |
628 | -} |
629 | - |
630 | -static void |
631 | -test_name_exported (void) |
632 | -{ |
633 | - BamfView *view; |
634 | - |
635 | - view = g_object_new (BAMF_TYPE_VIEW, NULL); |
636 | - |
637 | - bamf_view_set_name (view, "SomeName"); |
638 | - bamf_view_export_on_bus (view, gdbus_connection); |
639 | - g_assert_cmpstr (bamf_view_get_name (view), ==, "SomeName"); |
640 | - |
641 | - bamf_view_set_name (view, "AnotherName"); |
642 | - g_assert_cmpstr (bamf_view_get_name (view), ==, "AnotherName"); |
643 | - |
644 | - g_object_unref (view); |
645 | -} |
646 | +#define test_string_property(prop) test_##prop |
647 | +#define declare_test_string_property(prop) \ |
648 | + static void \ |
649 | + test_string_property (prop) (void) \ |
650 | + { \ |
651 | + BamfView *view; \ |
652 | + \ |
653 | + view = g_object_new (BAMF_TYPE_VIEW, NULL); \ |
654 | + g_assert (!bamf_view_get_##prop (view)); \ |
655 | + \ |
656 | + const gchar *new_##prop = "Some" #prop; \ |
657 | + bamf_view_set_##prop (view, new_##prop); \ |
658 | + g_assert_cmpstr (bamf_view_get_##prop (view), ==, new_##prop); \ |
659 | + \ |
660 | + new_##prop = "Another" #prop; \ |
661 | + bamf_view_set_##prop (view, new_##prop); \ |
662 | + g_assert_cmpstr (bamf_view_get_##prop (view), ==, new_##prop); \ |
663 | + \ |
664 | + g_object_unref (view); \ |
665 | + } |
666 | + |
667 | +declare_test_string_property (name); |
668 | +declare_test_string_property (icon); |
669 | + |
670 | +#define test_string_property_exported(prop) test_##prop##_exported |
671 | +#define declare_test_string_property_exported(prop) \ |
672 | + static void \ |
673 | + test_string_property_exported (prop) (void) \ |
674 | + { \ |
675 | + BamfView *view; \ |
676 | + \ |
677 | + view = g_object_new (BAMF_TYPE_VIEW, NULL); \ |
678 | + g_assert (!bamf_view_get_##prop (view)); \ |
679 | + \ |
680 | + const gchar *new_##prop = "Some" #prop; \ |
681 | + bamf_view_set_##prop (view, new_##prop); \ |
682 | + bamf_view_export_on_bus (view, gdbus_connection); \ |
683 | + g_assert_cmpstr (bamf_view_get_##prop (view), ==, new_##prop); \ |
684 | + \ |
685 | + new_##prop = "Another" #prop; \ |
686 | + bamf_view_set_##prop (view, new_##prop); \ |
687 | + g_assert_cmpstr (bamf_view_get_##prop (view), ==, new_##prop); \ |
688 | + \ |
689 | + g_object_unref (view); \ |
690 | + } |
691 | + |
692 | +declare_test_string_property_exported (name); |
693 | +declare_test_string_property_exported (icon); |
694 | |
695 | #define test_boolean_property(prop) test_##prop |
696 | #define declare_test_boolean_property(prop) \ |
697 | static void \ |
698 | - test_##prop (void) \ |
699 | + test_boolean_property (prop) (void) \ |
700 | { \ |
701 | BamfView *view; \ |
702 | \ |
703 | @@ -95,7 +111,7 @@ |
704 | #define test_boolean_property_exported(prop) test_##prop##_exported |
705 | #define declare_test_boolean_property_exported(prop) \ |
706 | static void \ |
707 | - test_##prop##_exported (void) \ |
708 | + test_boolean_property_exported(prop) (void) \ |
709 | { \ |
710 | BamfView *view; \ |
711 | \ |
712 | @@ -295,7 +311,7 @@ |
713 | #define test_boolean_property_event(prop) test_##prop##_event |
714 | #define declare_test_boolean_property_event(prop) \ |
715 | static void \ |
716 | - test_##prop##_event (void) \ |
717 | + test_boolean_property_event (prop) (void) \ |
718 | { \ |
719 | BamfView *view; \ |
720 | \ |
721 | @@ -332,7 +348,7 @@ |
722 | declare_test_boolean_property_event (user_visible); |
723 | |
724 | static gboolean string_event_fired = FALSE; |
725 | -static char * string_event_result = FALSE; |
726 | +static char * string_event_result = NULL; |
727 | |
728 | static void |
729 | on_string_event (BamfView *view, const gchar *oval, const gchar *nval, gpointer pointer) |
730 | @@ -374,11 +390,53 @@ |
731 | g_object_unref (view); |
732 | } |
733 | |
734 | +static gboolean property_event_fired = FALSE; |
735 | +static char * property_event_name = NULL; |
736 | + |
737 | +static void |
738 | +on_property_changed (BamfView *view, GParamSpec *param, BamfView *self) |
739 | +{ |
740 | + g_free (property_event_name); |
741 | + property_event_fired = TRUE; |
742 | + property_event_name = g_strdup (param->name); |
743 | +} |
744 | + |
745 | +static void |
746 | +test_icon_event (void) |
747 | +{ |
748 | + BamfView *view; |
749 | + |
750 | + view = g_object_new (BAMF_TYPE_VIEW, NULL); |
751 | + g_assert (!bamf_view_get_icon (view)); |
752 | + |
753 | + g_signal_connect (G_OBJECT (view), "notify::icon", |
754 | + (GCallback) on_property_changed, NULL); |
755 | + |
756 | + property_event_fired = FALSE; |
757 | + property_event_name = NULL; |
758 | + |
759 | + bamf_view_set_icon (view, "NewIcon"); |
760 | + |
761 | + while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); |
762 | + g_assert (property_event_fired); |
763 | + g_assert_cmpstr (property_event_name, ==, "icon"); |
764 | + |
765 | + property_event_fired = FALSE; |
766 | + bamf_view_set_icon (view, "AnotherIcon"); |
767 | + g_assert_cmpstr (bamf_view_get_icon (view), ==, "AnotherIcon"); |
768 | + |
769 | + while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); |
770 | + g_assert (property_event_fired); |
771 | + g_assert_cmpstr (property_event_name, ==, "icon"); |
772 | + |
773 | + g_object_unref (view); |
774 | +} |
775 | + |
776 | |
777 | #define test_boolean_property_event_exported(prop) test_##prop##_event_exported |
778 | #define declare_test_boolean_property_event_exported(prop) \ |
779 | static void \ |
780 | - test_##prop##_event_exported (void) \ |
781 | + test_boolean_property_event_exported (prop) (void) \ |
782 | { \ |
783 | BamfView *view; \ |
784 | \ |
785 | @@ -460,6 +518,45 @@ |
786 | } |
787 | |
788 | static void |
789 | +test_icon_event_exported (void) |
790 | +{ |
791 | + BamfView *view; |
792 | + |
793 | + view = g_object_new (BAMF_TYPE_VIEW, NULL); |
794 | + g_assert (!bamf_view_get_icon (view)); |
795 | + |
796 | + |
797 | + g_signal_connect (G_OBJECT (view), "notify::icon", |
798 | + (GCallback) on_property_changed, NULL); |
799 | + |
800 | + property_event_fired = FALSE; |
801 | + property_event_name = NULL; |
802 | + |
803 | + bamf_view_set_icon (view, "NewIcon"); |
804 | + |
805 | + while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); |
806 | + g_assert (property_event_fired); |
807 | + g_assert_cmpstr (property_event_name, ==, "icon"); |
808 | + property_event_fired = FALSE; |
809 | + g_free (property_event_name); |
810 | + property_event_name = NULL; |
811 | + |
812 | + bamf_view_export_on_bus (view, gdbus_connection); |
813 | + while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); |
814 | + g_assert (property_event_fired); |
815 | + g_assert_cmpstr (property_event_name, ==, "icon"); |
816 | + |
817 | + property_event_fired = FALSE; |
818 | + bamf_view_set_icon (view, "AnotherIcon"); |
819 | + g_assert_cmpstr (bamf_view_get_icon (view), ==, "AnotherIcon"); |
820 | + |
821 | + while (g_main_context_pending (NULL)) g_main_context_iteration (NULL, TRUE); |
822 | + g_assert (property_event_fired); |
823 | + g_assert_cmpstr (property_event_name, ==, "icon"); |
824 | + g_object_unref (view); |
825 | +} |
826 | + |
827 | +static void |
828 | on_boolean_event_count (BamfView *view, gboolean event, gpointer pointer) |
829 | { |
830 | boolean_event_calls++; |
831 | @@ -625,8 +722,10 @@ |
832 | gdbus_connection = connection; |
833 | |
834 | g_test_add_func (DOMAIN"/Allocation", test_allocation); |
835 | - g_test_add_func (DOMAIN"/Name", test_name); |
836 | - g_test_add_func (DOMAIN"/Name/Exported", test_name_exported); |
837 | + g_test_add_func (DOMAIN"/Name", test_string_property (name)); |
838 | + g_test_add_func (DOMAIN"/Name/Exported", test_string_property_exported (name)); |
839 | + g_test_add_func (DOMAIN"/Icon", test_string_property (icon)); |
840 | + g_test_add_func (DOMAIN"/Icon/Exported", test_string_property_exported (icon)); |
841 | g_test_add_func (DOMAIN"/Active", test_boolean_property (active)); |
842 | g_test_add_func (DOMAIN"/Active/Exported", test_boolean_property_exported (active)); |
843 | g_test_add_func (DOMAIN"/Running", test_boolean_property (running)); |
844 | @@ -641,6 +740,8 @@ |
845 | g_test_add_func (DOMAIN"/Events/Active", test_boolean_property_event (active)); |
846 | g_test_add_func (DOMAIN"/Events/Name", test_name_event); |
847 | g_test_add_func (DOMAIN"/Events/Name/Exported", test_name_event_exported); |
848 | + g_test_add_func (DOMAIN"/Events/Icon", test_icon_event); |
849 | + g_test_add_func (DOMAIN"/Events/Icon/Exported", test_icon_event_exported); |
850 | g_test_add_func (DOMAIN"/Events/Active/Count", test_active_event_count); |
851 | g_test_add_func (DOMAIN"/Events/Active/Exported", test_boolean_property_event_exported (active)); |
852 | g_test_add_func (DOMAIN"/Events/Running", test_boolean_property_event (running)); |
853 | |
854 | === modified file 'tests/libbamf/test-application.c' |
855 | --- tests/libbamf/test-application.c 2013-06-08 13:54:06 +0000 |
856 | +++ tests/libbamf/test-application.c 2013-06-19 20:08:28 +0000 |
857 | @@ -20,6 +20,7 @@ |
858 | #include <stdlib.h> |
859 | #include <glib.h> |
860 | #include <glib-object.h> |
861 | +#include <libbamf-private/bamf-private.h> |
862 | #include "bamf-view-private.h" |
863 | |
864 | #define DATA_DIR TESTDIR "/data" |
865 | @@ -86,7 +87,7 @@ |
866 | BamfApplication *application; |
867 | |
868 | application = bamf_application_new_favorite (DATA_DIR"/no-icon.desktop"); |
869 | - g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "application-default-icon"); |
870 | + g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, BAMF_APPLICATION_DEFAULT_ICON); |
871 | |
872 | g_object_unref (application); |
873 | } |
PASSED: Continuous integration, rev:576 jenkins. qa.ubuntu. com/job/ bamf-ci/ 59/ jenkins. qa.ubuntu. com/job/ bamf-saucy- amd64-ci/ 40 jenkins. qa.ubuntu. com/job/ bamf-saucy- armhf-ci/ 40
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ bamf-ci/ 59/rebuild
http://