Merge lp:~3v1n0/bamf/use-libwnck-matching-signals into lp:bamf/0.4
- use-libwnck-matching-signals
- Merge into 0.4
Proposed by
Marco Trevisan (Treviño)
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Andrea Azzarone | ||||
Approved revision: | 542 | ||||
Merged at revision: | 532 | ||||
Proposed branch: | lp:~3v1n0/bamf/use-libwnck-matching-signals | ||||
Merge into: | lp:bamf/0.4 | ||||
Diff against target: |
843 lines (+190/-217) 10 files modified
configure.ac (+1/-1) debian/changelog (+7/-0) debian/control (+1/-1) src/bamf-legacy-window-test.c (+33/-0) src/bamf-legacy-window-test.h (+4/-0) src/bamf-legacy-window.c (+69/-28) src/bamf-legacy-window.h (+7/-0) src/bamf-matcher.c (+58/-176) src/bamf-matcher.h (+0/-1) tests/bamfdaemon/test-matcher.c (+10/-10) |
||||
To merge this branch: | bzr merge lp:~3v1n0/bamf/use-libwnck-matching-signals | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andrea Azzarone (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email:
|
Commit message
BamfMatcher: use role and class changes signal to match LibreOffice and g-c-c
Description of the change
Using libwnck 3.4.5 signals to properly match Gnome-Control-
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Approve
(continuous-integration)
- 542. By Marco Trevisan (Treviño)
-
BamfLegacyWindo
wTest: free previous values when setting strings
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'configure.ac' |
2 | --- configure.ac 2013-01-09 23:48:57 +0000 |
3 | +++ configure.ac 2013-04-18 13:59:29 +0000 |
4 | @@ -67,7 +67,7 @@ |
5 | # |
6 | # libwnck |
7 | # |
8 | -PKG_CHECK_MODULES(WNCK, libwnck-3.0) |
9 | +PKG_CHECK_MODULES(WNCK, libwnck-3.0 >= 3.4.5) |
10 | |
11 | # |
12 | # libgtop |
13 | |
14 | === modified file 'debian/changelog' |
15 | --- debian/changelog 2013-04-03 02:01:52 +0000 |
16 | +++ debian/changelog 2013-04-18 13:59:29 +0000 |
17 | @@ -1,3 +1,10 @@ |
18 | +bamf (0.4.0daily13.04.03-0ubuntu2) UNRELEASED; urgency=low |
19 | + |
20 | + * debian/control: |
21 | + - Update the libwnck-3-dev dependency to 3.4.5 |
22 | + |
23 | + -- Marco Trevisan (Treviño) <marco@ubuntu.com> Wed, 17 Apr 2013 03:37:31 +0200 |
24 | + |
25 | bamf (0.4.0daily13.04.03-0ubuntu1) raring; urgency=low |
26 | |
27 | [ Marco Trevisan (Treviño) ] |
28 | |
29 | === modified file 'debian/control' |
30 | --- debian/control 2013-01-09 23:51:33 +0000 |
31 | +++ debian/control 2013-04-18 13:59:29 +0000 |
32 | @@ -14,7 +14,7 @@ |
33 | libgtop2-dev, |
34 | libgtk-3-dev (>= 3.0.0), |
35 | libunity-webapps-dev (>= 2.3.3), |
36 | - libwnck-3-dev, |
37 | + libwnck-3-dev (>= 3.4.5), |
38 | libgirepository1.0-dev, |
39 | valac, |
40 | xvfb, |
41 | |
42 | === modified file 'src/bamf-legacy-window-test.c' |
43 | --- src/bamf-legacy-window-test.c 2013-01-29 15:56:49 +0000 |
44 | +++ src/bamf-legacy-window-test.c 2013-04-18 13:59:29 +0000 |
45 | @@ -132,25 +132,45 @@ |
46 | if (g_strcmp0 (self->name, val) == 0) |
47 | return; |
48 | |
49 | + g_free (self->name); |
50 | self->name = g_strdup (val); |
51 | |
52 | g_signal_emit_by_name (self, "name-changed"); |
53 | } |
54 | |
55 | void |
56 | +bamf_legacy_window_test_set_role (BamfLegacyWindowTest *self, const char *val) |
57 | +{ |
58 | + if (g_strcmp0 (self->role, val) == 0) |
59 | + return; |
60 | + |
61 | + g_free (self->role); |
62 | + self->role = g_strdup (val); |
63 | + |
64 | + g_signal_emit_by_name (self, "role-changed"); |
65 | +} |
66 | + |
67 | +void |
68 | bamf_legacy_window_test_set_wmclass (BamfLegacyWindowTest *self, const char *class_name, const char *instance_name) |
69 | { |
70 | + gboolean changed = FALSE; |
71 | + |
72 | if (g_strcmp0 (self->wm_class_name, class_name) != 0) |
73 | { |
74 | g_free (self->wm_class_name); |
75 | self->wm_class_name = g_strdup (class_name); |
76 | + changed = TRUE; |
77 | } |
78 | |
79 | if (g_strcmp0 (self->wm_class_instance, instance_name) != 0) |
80 | { |
81 | g_free (self->wm_class_instance); |
82 | self->wm_class_instance = g_strdup (instance_name); |
83 | + changed = TRUE; |
84 | } |
85 | + |
86 | + if (changed) |
87 | + g_signal_emit_by_name (self, "class-changed"); |
88 | } |
89 | |
90 | static const char * |
91 | @@ -163,6 +183,16 @@ |
92 | return self->name; |
93 | } |
94 | |
95 | +static const char * |
96 | +bamf_legacy_window_test_get_role (BamfLegacyWindow *legacy_window) |
97 | +{ |
98 | + BamfLegacyWindowTest *self; |
99 | + |
100 | + self = BAMF_LEGACY_WINDOW_TEST (legacy_window); |
101 | + |
102 | + return self->role; |
103 | +} |
104 | + |
105 | static BamfLegacyWindow * |
106 | bamf_legacy_window_test_get_transient (BamfLegacyWindow *legacy_window) |
107 | { |
108 | @@ -386,6 +416,7 @@ |
109 | BamfLegacyWindowTest *self = BAMF_LEGACY_WINDOW_TEST (object); |
110 | |
111 | g_free (self->name); |
112 | + g_free (self->role); |
113 | g_free (self->wm_class_name); |
114 | g_free (self->wm_class_instance); |
115 | g_free (self->exec); |
116 | @@ -407,6 +438,7 @@ |
117 | obj_class->finalize = bamf_legacy_window_test_finalize; |
118 | win_class->get_transient = bamf_legacy_window_test_get_transient; |
119 | win_class->get_name = bamf_legacy_window_test_get_name; |
120 | + win_class->get_role = bamf_legacy_window_test_get_role; |
121 | win_class->get_class_name = bamf_legacy_window_test_get_class_name; |
122 | win_class->get_class_instance_name = bamf_legacy_window_test_get_class_instance_name; |
123 | win_class->get_exec_string = bamf_legacy_window_test_get_exec_string; |
124 | @@ -449,6 +481,7 @@ |
125 | copy->xid = self->xid; |
126 | copy->pid = self->pid; |
127 | copy->name = g_strdup (self->name); |
128 | + copy->role = g_strdup (self->role); |
129 | copy->wm_class_name = g_strdup (self->wm_class_name); |
130 | copy->wm_class_instance = g_strdup (self->wm_class_instance); |
131 | copy->exec = g_strdup (self->exec); |
132 | |
133 | === modified file 'src/bamf-legacy-window-test.h' |
134 | --- src/bamf-legacy-window-test.h 2013-01-29 15:56:49 +0000 |
135 | +++ src/bamf-legacy-window-test.h 2013-04-18 13:59:29 +0000 |
136 | @@ -54,6 +54,7 @@ |
137 | guint32 xid; |
138 | guint pid; |
139 | char * name; |
140 | + char * role; |
141 | char * wm_class_name; |
142 | char * wm_class_instance; |
143 | char * exec; |
144 | @@ -122,6 +123,9 @@ |
145 | bamf_legacy_window_test_set_name (BamfLegacyWindowTest *self, const char *val); |
146 | |
147 | void |
148 | +bamf_legacy_window_test_set_role (BamfLegacyWindowTest *self, const char *val); |
149 | + |
150 | +void |
151 | bamf_legacy_window_test_set_geometry (BamfLegacyWindowTest *self, int x, int y, |
152 | int width, int height); |
153 | |
154 | |
155 | === modified file 'src/bamf-legacy-window.c' |
156 | --- src/bamf-legacy-window.c 2013-04-17 04:23:30 +0000 |
157 | +++ src/bamf-legacy-window.c 2013-04-18 13:59:29 +0000 |
158 | @@ -32,9 +32,13 @@ |
159 | #define BAMF_LEGACY_WINDOW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \ |
160 | BAMF_TYPE_LEGACY_WINDOW, BamfLegacyWindowPrivate)) |
161 | |
162 | +#define WNCK_WINDOW_BAMF_DATA "bamf-legacy-window" |
163 | + |
164 | enum |
165 | { |
166 | NAME_CHANGED, |
167 | + ROLE_CHANGED, |
168 | + CLASS_CHANGED, |
169 | STATE_CHANGED, |
170 | GEOMETRY_CHANGED, |
171 | CLOSED, |
172 | @@ -146,15 +150,29 @@ |
173 | { |
174 | g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), NULL); |
175 | |
176 | - |
177 | if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_name) |
178 | return BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_name (self); |
179 | |
180 | if (!self->priv->legacy_window) |
181 | return NULL; |
182 | + |
183 | return wnck_window_get_name (self->priv->legacy_window); |
184 | } |
185 | |
186 | +const char * |
187 | +bamf_legacy_window_get_role (BamfLegacyWindow *self) |
188 | +{ |
189 | + g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), NULL); |
190 | + |
191 | + if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_role) |
192 | + return BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_role (self); |
193 | + |
194 | + if (!self->priv->legacy_window) |
195 | + return NULL; |
196 | + |
197 | + return wnck_window_get_role (self->priv->legacy_window); |
198 | +} |
199 | + |
200 | char * |
201 | bamf_legacy_window_get_process_name (BamfLegacyWindow *self) |
202 | { |
203 | @@ -366,11 +384,12 @@ |
204 | } |
205 | |
206 | static void |
207 | -handle_name_changed (WnckWindow *window, BamfLegacyWindow *self) |
208 | +handle_window_signal (WnckWindow *window, gpointer data) |
209 | { |
210 | + BamfLegacyWindow *self = g_object_get_data (G_OBJECT (window), WNCK_WINDOW_BAMF_DATA); |
211 | g_return_if_fail (BAMF_IS_LEGACY_WINDOW (self)); |
212 | |
213 | - g_signal_emit (self, legacy_window_signals[NAME_CHANGED], 0); |
214 | + g_signal_emit (self, legacy_window_signals[GPOINTER_TO_UINT (data)], 0); |
215 | } |
216 | |
217 | static void |
218 | @@ -384,14 +403,6 @@ |
219 | g_signal_emit (self, legacy_window_signals[STATE_CHANGED], 0); |
220 | } |
221 | |
222 | -static void |
223 | -handle_geometry_changed (WnckWindow *window, BamfLegacyWindow *self) |
224 | -{ |
225 | - g_return_if_fail (BAMF_IS_LEGACY_WINDOW (self)); |
226 | - |
227 | - g_signal_emit (self, legacy_window_signals[GEOMETRY_CHANGED], 0); |
228 | -} |
229 | - |
230 | gboolean |
231 | bamf_legacy_window_is_closed (BamfLegacyWindow *self) |
232 | { |
233 | @@ -546,6 +557,7 @@ |
234 | { |
235 | BamfLegacyWindow *self; |
236 | GFile *file; |
237 | + guint i; |
238 | |
239 | self = BAMF_LEGACY_WINDOW (object); |
240 | |
241 | @@ -564,7 +576,15 @@ |
242 | |
243 | if (self->priv->legacy_window) |
244 | { |
245 | + g_object_set_data (G_OBJECT (self->priv->legacy_window), WNCK_WINDOW_BAMF_DATA, NULL); |
246 | g_signal_handlers_disconnect_by_data (self->priv->legacy_window, self); |
247 | + |
248 | + for (i = 0; i < LAST_SIGNAL; ++i) |
249 | + { |
250 | + g_signal_handlers_disconnect_by_func (self->priv->legacy_window, |
251 | + handle_window_signal, |
252 | + GUINT_TO_POINTER (NAME_CHANGED)); |
253 | + } |
254 | } |
255 | |
256 | G_OBJECT_CLASS (bamf_legacy_window_parent_class)->dispose (object); |
257 | @@ -593,36 +613,42 @@ |
258 | G_OBJECT_CLASS_TYPE (klass), |
259 | G_SIGNAL_RUN_FIRST, |
260 | G_STRUCT_OFFSET (BamfLegacyWindowClass, name_changed), |
261 | - NULL, NULL, |
262 | - g_cclosure_marshal_VOID__VOID, |
263 | - G_TYPE_NONE, 0); |
264 | + NULL, NULL, NULL, G_TYPE_NONE, 0); |
265 | + |
266 | + legacy_window_signals [ROLE_CHANGED] = |
267 | + g_signal_new (BAMF_LEGACY_WINDOW_SIGNAL_ROLE_CHANGED, |
268 | + G_OBJECT_CLASS_TYPE (klass), |
269 | + G_SIGNAL_RUN_FIRST, |
270 | + G_STRUCT_OFFSET (BamfLegacyWindowClass, role_changed), |
271 | + NULL, NULL, NULL, G_TYPE_NONE, 0); |
272 | + |
273 | + legacy_window_signals [CLASS_CHANGED] = |
274 | + g_signal_new (BAMF_LEGACY_WINDOW_SIGNAL_CLASS_CHANGED, |
275 | + G_OBJECT_CLASS_TYPE (klass), |
276 | + G_SIGNAL_RUN_FIRST, |
277 | + G_STRUCT_OFFSET (BamfLegacyWindowClass, class_changed), |
278 | + NULL, NULL, NULL, G_TYPE_NONE, 0); |
279 | |
280 | legacy_window_signals [STATE_CHANGED] = |
281 | g_signal_new (BAMF_LEGACY_WINDOW_SIGNAL_STATE_CHANGED, |
282 | G_OBJECT_CLASS_TYPE (klass), |
283 | G_SIGNAL_RUN_FIRST, |
284 | G_STRUCT_OFFSET (BamfLegacyWindowClass, state_changed), |
285 | - NULL, NULL, |
286 | - g_cclosure_marshal_VOID__VOID, |
287 | - G_TYPE_NONE, 0); |
288 | + NULL, NULL, NULL, G_TYPE_NONE, 0); |
289 | |
290 | legacy_window_signals [GEOMETRY_CHANGED] = |
291 | g_signal_new (BAMF_LEGACY_WINDOW_SIGNAL_GEOMETRY_CHANGED, |
292 | G_OBJECT_CLASS_TYPE (klass), |
293 | G_SIGNAL_RUN_FIRST, |
294 | G_STRUCT_OFFSET (BamfLegacyWindowClass, geometry_changed), |
295 | - NULL, NULL, |
296 | - g_cclosure_marshal_VOID__VOID, |
297 | - G_TYPE_NONE, 0); |
298 | + NULL, NULL, NULL, G_TYPE_NONE, 0); |
299 | |
300 | legacy_window_signals [CLOSED] = |
301 | g_signal_new (BAMF_LEGACY_WINDOW_SIGNAL_CLOSED, |
302 | G_OBJECT_CLASS_TYPE (klass), |
303 | G_SIGNAL_RUN_FIRST, |
304 | G_STRUCT_OFFSET (BamfLegacyWindowClass, closed), |
305 | - NULL, NULL, |
306 | - g_cclosure_marshal_VOID__VOID, |
307 | - G_TYPE_NONE, 0); |
308 | + NULL, NULL, NULL, G_TYPE_NONE, 0); |
309 | } |
310 | |
311 | BamfLegacyWindow * |
312 | @@ -633,14 +659,29 @@ |
313 | |
314 | self->priv->legacy_window = legacy_window; |
315 | |
316 | + g_return_val_if_fail (WNCK_IS_WINDOW (self->priv->legacy_window), self); |
317 | + g_warn_if_fail (!g_object_get_data (G_OBJECT (legacy_window), WNCK_WINDOW_BAMF_DATA)); |
318 | + |
319 | + g_object_set_data (G_OBJECT (legacy_window), WNCK_WINDOW_BAMF_DATA, self); |
320 | + |
321 | g_signal_connect (G_OBJECT (legacy_window), "name-changed", |
322 | - (GCallback) handle_name_changed, self); |
323 | + G_CALLBACK (handle_window_signal), |
324 | + GUINT_TO_POINTER (NAME_CHANGED)); |
325 | + |
326 | + g_signal_connect (G_OBJECT (legacy_window), "role-changed", |
327 | + G_CALLBACK (handle_window_signal), |
328 | + GUINT_TO_POINTER (ROLE_CHANGED)); |
329 | + |
330 | + g_signal_connect (G_OBJECT (legacy_window), "class-changed", |
331 | + G_CALLBACK (handle_window_signal), |
332 | + GUINT_TO_POINTER (CLASS_CHANGED)); |
333 | + |
334 | + g_signal_connect (G_OBJECT (legacy_window), "geometry-changed", |
335 | + G_CALLBACK (handle_window_signal), |
336 | + GUINT_TO_POINTER (GEOMETRY_CHANGED)); |
337 | |
338 | g_signal_connect (G_OBJECT (legacy_window), "state-changed", |
339 | - (GCallback) handle_state_changed, self); |
340 | - |
341 | - g_signal_connect (G_OBJECT (legacy_window), "geometry-changed", |
342 | - (GCallback) handle_geometry_changed, self); |
343 | + G_CALLBACK (handle_state_changed), self); |
344 | |
345 | return self; |
346 | } |
347 | |
348 | === modified file 'src/bamf-legacy-window.h' |
349 | --- src/bamf-legacy-window.h 2013-01-29 15:56:16 +0000 |
350 | +++ src/bamf-legacy-window.h 2013-04-18 13:59:29 +0000 |
351 | @@ -38,6 +38,8 @@ |
352 | #define BAMF_LEGACY_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_LEGACY_WINDOW, BamfLegacyWindowClass)) |
353 | |
354 | #define BAMF_LEGACY_WINDOW_SIGNAL_NAME_CHANGED "name-changed" |
355 | +#define BAMF_LEGACY_WINDOW_SIGNAL_ROLE_CHANGED "role-changed" |
356 | +#define BAMF_LEGACY_WINDOW_SIGNAL_CLASS_CHANGED "class-changed" |
357 | #define BAMF_LEGACY_WINDOW_SIGNAL_STATE_CHANGED "state-changed" |
358 | #define BAMF_LEGACY_WINDOW_SIGNAL_GEOMETRY_CHANGED "geometry-changed" |
359 | #define BAMF_LEGACY_WINDOW_SIGNAL_CLOSED "closed" |
360 | @@ -72,6 +74,7 @@ |
361 | |
362 | BamfLegacyWindow * (*get_transient) (BamfLegacyWindow *legacy_window); |
363 | const char * (*get_name) (BamfLegacyWindow *legacy_window); |
364 | + const char * (*get_role) (BamfLegacyWindow *legacy_window); |
365 | const char * (*get_class_name) (BamfLegacyWindow *legacy_window); |
366 | const char * (*get_class_instance_name) (BamfLegacyWindow *legacy_window); |
367 | char * (*get_exec_string) (BamfLegacyWindow *legacy_window); |
368 | @@ -99,6 +102,8 @@ |
369 | |
370 | /*< signals >*/ |
371 | void (*name_changed) (BamfLegacyWindow *legacy_window); |
372 | + void (*class_changed) (BamfLegacyWindow *legacy_window); |
373 | + void (*role_changed) (BamfLegacyWindow *legacy_window); |
374 | void (*state_changed) (BamfLegacyWindow *legacy_window); |
375 | void (*geometry_changed) (BamfLegacyWindow *legacy_window); |
376 | void (*closed) (BamfLegacyWindow *legacy_window); |
377 | @@ -140,6 +145,8 @@ |
378 | |
379 | const char * bamf_legacy_window_get_name (BamfLegacyWindow *self); |
380 | |
381 | +const char * bamf_legacy_window_get_role (BamfLegacyWindow *self); |
382 | + |
383 | const char * bamf_legacy_window_save_mini_icon (BamfLegacyWindow *self); |
384 | |
385 | char * bamf_legacy_window_get_exec_string (BamfLegacyWindow *self); |
386 | |
387 | === modified file 'src/bamf-matcher.c' |
388 | --- src/bamf-matcher.c 2013-04-17 14:25:48 +0000 |
389 | +++ src/bamf-matcher.c 2013-04-18 13:59:29 +0000 |
390 | @@ -337,177 +337,60 @@ |
391 | } |
392 | } |
393 | |
394 | -static char * |
395 | -get_open_office_window_hint (BamfMatcher * self, BamfLegacyWindow * window) |
396 | +static const char * |
397 | +get_libreoffice_window_hint (BamfMatcher * self, BamfLegacyWindow * window) |
398 | { |
399 | gchar *exec = NULL; |
400 | - const gchar *name; |
401 | const gchar *class; |
402 | const char *binary = NULL; |
403 | const char *parameter = NULL; |
404 | - BamfWindowType type; |
405 | + GList *l = NULL; |
406 | |
407 | g_return_val_if_fail (BAMF_IS_MATCHER (self), NULL); |
408 | g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (window), NULL); |
409 | |
410 | - name = bamf_legacy_window_get_name (window); |
411 | class = bamf_legacy_window_get_class_name (window); |
412 | - type = bamf_legacy_window_get_window_type (window); |
413 | - |
414 | - if (name == NULL && class == NULL) |
415 | - return NULL; |
416 | - |
417 | - if (g_str_has_suffix (name, "LibreOffice Writer")) |
418 | - { |
419 | - binary = "libreoffice"; |
420 | - parameter = "writer"; |
421 | - } |
422 | - else if (g_str_has_suffix (name, "LibreOffice Calc")) |
423 | - { |
424 | - binary = "libreoffice"; |
425 | - parameter = "calc"; |
426 | - } |
427 | - else if (g_str_has_suffix (name, "LibreOffice Impress")) |
428 | - { |
429 | - binary = "libreoffice"; |
430 | - parameter = "impress"; |
431 | - } |
432 | - else if (g_str_has_suffix (name, "LibreOffice Math")) |
433 | - { |
434 | - binary = "libreoffice"; |
435 | - parameter = "math"; |
436 | - } |
437 | - else if (g_str_has_suffix (name, "LibreOffice Draw")) |
438 | - { |
439 | - binary = "libreoffice"; |
440 | - parameter = "draw"; |
441 | - } |
442 | - else if (g_str_has_suffix (name, "LibreOffice Base")) |
443 | - { |
444 | - binary = "libreoffice"; |
445 | - parameter = "base"; |
446 | - } |
447 | - else if (g_strcmp0 (class, "libreoffice-startcenter") == 0) |
448 | - { |
449 | - binary = "libreoffice"; |
450 | - } |
451 | - else if (g_strcmp0 (name, "LibreOffice") == 0 && type == BAMF_WINDOW_NORMAL) |
452 | - { |
453 | - binary = "libreoffice"; |
454 | - } |
455 | - else if (g_str_has_suffix (name, "OpenOffice.org Writer")) |
456 | - { |
457 | - binary = "ooffice"; |
458 | - parameter = "writer"; |
459 | - } |
460 | - else if (g_str_has_suffix (name, "OpenOffice.org Calc")) |
461 | - { |
462 | - binary = "ooffice"; |
463 | - parameter = "calc"; |
464 | - } |
465 | - else if (g_str_has_suffix (name, "OpenOffice.org Impress")) |
466 | - { |
467 | - binary = "ooffice"; |
468 | - parameter = "impress"; |
469 | - } |
470 | - else if (g_str_has_suffix (name, "OpenOffice.org Math")) |
471 | - { |
472 | - binary = "ooffice"; |
473 | - parameter = "math"; |
474 | - } |
475 | - else if (g_str_has_suffix (name, "OpenOffice.org Draw")) |
476 | - { |
477 | - binary = "ooffice"; |
478 | - parameter = "draw"; |
479 | - } |
480 | - else if (g_str_has_suffix (name, "OpenOffice.org Base")) |
481 | - { |
482 | - binary = "ooffice"; |
483 | - parameter = "base"; |
484 | - } |
485 | - else if (g_strcmp0 (name, "OpenOffice.org") == 0 && type == BAMF_WINDOW_NORMAL) |
486 | - { |
487 | - binary = "ooffice"; |
488 | - } |
489 | - else |
490 | - { |
491 | - if (type != BAMF_WINDOW_NORMAL || bamf_legacy_window_get_transient (window)) |
492 | - { |
493 | - /* Child windows can generally easily be recognized by their class */ |
494 | - if (g_strcmp0 (class, "libreoffice-writer") == 0) |
495 | - { |
496 | - binary = "libreoffice"; |
497 | - parameter = "writer"; |
498 | - } |
499 | - else if (g_strcmp0 (class, "libreoffice-calc") == 0) |
500 | - { |
501 | - binary = "libreoffice"; |
502 | - parameter = "calc"; |
503 | - } |
504 | - else if (g_strcmp0 (class, "libreoffice-impress") == 0) |
505 | - { |
506 | - binary = "libreoffice"; |
507 | - parameter = "impress"; |
508 | - } |
509 | - else if (g_strcmp0 (class, "libreoffice-math") == 0) |
510 | - { |
511 | - binary = "libreoffice"; |
512 | - parameter = "math"; |
513 | - } |
514 | - else if (g_strcmp0 (class, "libreoffice-draw") == 0) |
515 | - { |
516 | - binary = "libreoffice"; |
517 | - parameter = "draw"; |
518 | - } |
519 | - else if (g_strcmp0 (class, "libreoffice-base") == 0) |
520 | - { |
521 | - binary = "libreoffice"; |
522 | - parameter = "base"; |
523 | - } |
524 | - } |
525 | - |
526 | - if (!binary) |
527 | - { |
528 | - /* By default fallback to the main launcher */ |
529 | - if (g_str_has_prefix (class, "OpenOffice")) |
530 | - { |
531 | - binary = "ooffice"; |
532 | - } |
533 | - else |
534 | - { |
535 | - binary = "libreoffice"; |
536 | - } |
537 | - } |
538 | - } |
539 | - |
540 | - if (!binary) |
541 | - return NULL; |
542 | - |
543 | - GList *l = NULL; |
544 | - |
545 | - if (parameter) |
546 | - { |
547 | - exec = g_strconcat (binary, " --", parameter, NULL); |
548 | - l = g_hash_table_lookup (self->priv->desktop_file_table, exec); |
549 | - g_free (exec); |
550 | - |
551 | - if (!l) |
552 | - { |
553 | - exec = g_strconcat (binary, " -", parameter, NULL); |
554 | - l = g_hash_table_lookup (self->priv->desktop_file_table, exec); |
555 | - g_free (exec); |
556 | - |
557 | - if (!l) |
558 | - { |
559 | - exec = g_strconcat (binary, "-", parameter, NULL); |
560 | - l = g_hash_table_lookup (self->priv->desktop_id_table, exec); |
561 | - g_free (exec); |
562 | - } |
563 | - } |
564 | - } |
565 | - else |
566 | - { |
567 | - l = g_hash_table_lookup (self->priv->desktop_file_table, binary); |
568 | + |
569 | + if (!class) |
570 | + return NULL; |
571 | + |
572 | + if (g_str_has_prefix (class, "libreoffice-")) |
573 | + { |
574 | + l = g_hash_table_lookup (self->priv->desktop_id_table, class); |
575 | + } |
576 | + |
577 | + if (!l) |
578 | + { |
579 | + binary = "libreoffice"; |
580 | + |
581 | + parameter = strchr(class, '-'); |
582 | + |
583 | + if (parameter) |
584 | + { |
585 | + parameter = parameter + 1; |
586 | + |
587 | + exec = g_strconcat (binary, " --", parameter, NULL); |
588 | + l = g_hash_table_lookup (self->priv->desktop_file_table, exec); |
589 | + g_free (exec); |
590 | + |
591 | + if (!l) |
592 | + { |
593 | + exec = g_strconcat (binary, " -", parameter, NULL); |
594 | + l = g_hash_table_lookup (self->priv->desktop_file_table, exec); |
595 | + g_free (exec); |
596 | + |
597 | + if (!l) |
598 | + { |
599 | + exec = g_strconcat (binary, "-", parameter, NULL); |
600 | + l = g_hash_table_lookup (self->priv->desktop_id_table, exec); |
601 | + g_free (exec); |
602 | + } |
603 | + } |
604 | + } |
605 | + else |
606 | + { |
607 | + l = g_hash_table_lookup (self->priv->desktop_file_table, binary); |
608 | + } |
609 | } |
610 | |
611 | return (l ? (char *) l->data : NULL); |
612 | @@ -1507,7 +1390,7 @@ |
613 | } |
614 | |
615 | static gboolean |
616 | -is_open_office_window (BamfMatcher * self, BamfLegacyWindow * window) |
617 | +is_libreoffice_window (BamfMatcher * self, BamfLegacyWindow * window) |
618 | { |
619 | const char *class_name = bamf_legacy_window_get_class_name (window); |
620 | |
621 | @@ -2131,7 +2014,7 @@ |
622 | } |
623 | |
624 | static void |
625 | -on_open_office_window_name_changed (BamfLegacyWindow *window, BamfMatcher* self) |
626 | +on_libreoffice_window_class_changed (BamfLegacyWindow *window, BamfMatcher* self) |
627 | { |
628 | g_return_if_fail (BAMF_IS_MATCHER (self)); |
629 | g_return_if_fail (BAMF_IS_LEGACY_WINDOW (window)); |
630 | @@ -2140,7 +2023,7 @@ |
631 | const char *new_hint; |
632 | |
633 | old_hint = bamf_legacy_window_get_hint (window, _NET_WM_DESKTOP_FILE); |
634 | - new_hint = get_open_office_window_hint (self, window); |
635 | + new_hint = get_libreoffice_window_hint (self, window); |
636 | |
637 | if (new_hint && g_strcmp0 (new_hint, old_hint) != 0) |
638 | { |
639 | @@ -2151,29 +2034,28 @@ |
640 | } |
641 | |
642 | static void |
643 | -on_open_office_window_closed (BamfLegacyWindow *window, BamfMatcher* self) |
644 | +on_libreoffice_window_closed (BamfLegacyWindow *window, BamfMatcher* self) |
645 | { |
646 | - g_signal_handlers_disconnect_by_func (window, on_open_office_window_name_changed, self); |
647 | + g_signal_handlers_disconnect_by_func (window, on_libreoffice_window_class_changed, self); |
648 | g_object_unref (window); |
649 | } |
650 | |
651 | static char * |
652 | get_gnome_control_center_window_hint (BamfMatcher * self, BamfLegacyWindow * window) |
653 | { |
654 | - gchar *role; |
655 | + const gchar *role; |
656 | GList *list; |
657 | |
658 | g_return_val_if_fail (BAMF_IS_MATCHER (self), NULL); |
659 | g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (window), NULL); |
660 | |
661 | - role = bamf_legacy_window_get_hint (window, WM_WINDOW_ROLE); |
662 | + role = bamf_legacy_window_get_role (window); |
663 | |
664 | if (role) |
665 | { |
666 | gchar *exec = g_strconcat ("gnome-control-center ", role, NULL); |
667 | list = g_hash_table_lookup (self->priv->desktop_file_table, exec); |
668 | g_free (exec); |
669 | - g_free (role); |
670 | } |
671 | |
672 | if (!role || !list) |
673 | @@ -2185,7 +2067,7 @@ |
674 | } |
675 | |
676 | static void |
677 | -on_gnome_control_center_window_name_changed (BamfLegacyWindow *window, BamfMatcher* self) |
678 | +on_gnome_control_center_window_role_changed (BamfLegacyWindow *window, BamfMatcher* self) |
679 | { |
680 | g_return_if_fail (BAMF_IS_MATCHER (self)); |
681 | g_return_if_fail (BAMF_IS_LEGACY_WINDOW (window)); |
682 | @@ -2207,7 +2089,7 @@ |
683 | static void |
684 | on_gnome_control_center_window_closed (BamfLegacyWindow *window, BamfMatcher* self) |
685 | { |
686 | - g_signal_handlers_disconnect_by_func (window, on_gnome_control_center_window_name_changed, self); |
687 | + g_signal_handlers_disconnect_by_func (window, on_gnome_control_center_window_role_changed, self); |
688 | g_object_unref (window); |
689 | } |
690 | |
691 | @@ -2226,7 +2108,7 @@ |
692 | return; |
693 | } |
694 | |
695 | - if (is_open_office_window (self, window)) |
696 | + if (is_libreoffice_window (self, window)) |
697 | { |
698 | if (win_type == BAMF_WINDOW_SPLASHSCREEN || win_type == BAMF_WINDOW_TOOLBAR) |
699 | { |
700 | @@ -2234,7 +2116,7 @@ |
701 | } |
702 | |
703 | char *old_hint = bamf_legacy_window_get_hint (window, _NET_WM_DESKTOP_FILE); |
704 | - const char *new_hint = get_open_office_window_hint (self, window); |
705 | + const char *new_hint = get_libreoffice_window_hint (self, window); |
706 | |
707 | if (new_hint && g_strcmp0 (old_hint, new_hint) != 0) |
708 | { |
709 | @@ -2242,8 +2124,8 @@ |
710 | } |
711 | |
712 | g_object_ref (window); |
713 | - g_signal_connect (window, "name-changed", (GCallback) on_open_office_window_name_changed, self); |
714 | - g_signal_connect (window, "closed", (GCallback) on_open_office_window_closed, self); |
715 | + g_signal_connect (window, "class-changed", (GCallback) on_libreoffice_window_class_changed, self); |
716 | + g_signal_connect (window, "closed", (GCallback) on_libreoffice_window_closed, self); |
717 | |
718 | g_free (old_hint); |
719 | } |
720 | @@ -2258,7 +2140,7 @@ |
721 | } |
722 | |
723 | g_object_ref (window); |
724 | - g_signal_connect (window, "name-changed", (GCallback) on_gnome_control_center_window_name_changed, self); |
725 | + g_signal_connect (window, "role-changed", (GCallback) on_gnome_control_center_window_role_changed, self); |
726 | g_signal_connect (window, "closed", (GCallback) on_gnome_control_center_window_closed, self); |
727 | |
728 | g_free (old_hint); |
729 | |
730 | === modified file 'src/bamf-matcher.h' |
731 | --- src/bamf-matcher.h 2012-10-16 17:59:37 +0000 |
732 | +++ src/bamf-matcher.h 2013-04-18 13:59:29 +0000 |
733 | @@ -47,7 +47,6 @@ |
734 | #define BAMF_MATCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_MATCHER, BamfMatcherClass)) |
735 | |
736 | #define _NET_WM_DESKTOP_FILE "_NET_WM_DESKTOP_FILE" |
737 | -#define WM_WINDOW_ROLE "WM_WINDOW_ROLE" |
738 | |
739 | typedef struct _BamfMatcher BamfMatcher; |
740 | typedef struct _BamfMatcherClass BamfMatcherClass; |
741 | |
742 | === modified file 'tests/bamfdaemon/test-matcher.c' |
743 | --- tests/bamfdaemon/test-matcher.c 2013-03-28 21:51:16 +0000 |
744 | +++ tests/bamfdaemon/test-matcher.c 2013-04-18 13:59:29 +0000 |
745 | @@ -461,8 +461,8 @@ |
746 | app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-startcenter.desktop"); |
747 | g_assert (find_window_in_app (app, BAMF_LEGACY_WINDOW (test_win))); |
748 | |
749 | + bamf_legacy_window_test_set_name (test_win, "FooDoc.odb - LibreOffice Base"); |
750 | bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-base", class_instance); |
751 | - bamf_legacy_window_test_set_name (test_win, "FooDoc.odb - LibreOffice Base"); |
752 | g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-startcenter.desktop")); |
753 | app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-base.desktop"); |
754 | g_assert (app); |
755 | @@ -472,8 +472,8 @@ |
756 | g_assert_cmpstr (hint, ==, DATA_DIR"/libreoffice-base.desktop"); |
757 | g_free (hint); |
758 | |
759 | - bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-calc", class_instance); |
760 | bamf_legacy_window_test_set_name (test_win, "FooDoc.ods - LibreOffice Calc"); |
761 | + bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-calc", class_instance); |
762 | g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-base.desktop")); |
763 | app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-calc.desktop"); |
764 | g_assert (app); |
765 | @@ -483,8 +483,8 @@ |
766 | g_assert_cmpstr (hint, ==, DATA_DIR"/libreoffice-calc.desktop"); |
767 | g_free (hint); |
768 | |
769 | + bamf_legacy_window_test_set_name (test_win, "FooDoc.odg - LibreOffice Draw"); |
770 | bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-draw", class_instance); |
771 | - bamf_legacy_window_test_set_name (test_win, "FooDoc.odg - LibreOffice Draw"); |
772 | g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-calc.desktop")); |
773 | app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-draw.desktop"); |
774 | g_assert (app); |
775 | @@ -494,8 +494,8 @@ |
776 | g_assert_cmpstr (hint, ==, DATA_DIR"/libreoffice-draw.desktop"); |
777 | g_free (hint); |
778 | |
779 | + bamf_legacy_window_test_set_name (test_win, "FooDoc.odp - LibreOffice Impress"); |
780 | bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-impress", class_instance); |
781 | - bamf_legacy_window_test_set_name (test_win, "FooDoc.odp - LibreOffice Impress"); |
782 | g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-draw.desktop")); |
783 | app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-impress.desktop"); |
784 | g_assert (app); |
785 | @@ -505,8 +505,8 @@ |
786 | g_assert_cmpstr (hint, ==, DATA_DIR"/libreoffice-impress.desktop"); |
787 | g_free (hint); |
788 | |
789 | + bamf_legacy_window_test_set_name (test_win, "FooDoc.odf - LibreOffice Math"); |
790 | bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-math", class_instance); |
791 | - bamf_legacy_window_test_set_name (test_win, "FooDoc.odf - LibreOffice Math"); |
792 | g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-impress.desktop")); |
793 | app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-math.desktop"); |
794 | g_assert (app); |
795 | @@ -516,8 +516,8 @@ |
796 | g_assert_cmpstr (hint, ==, DATA_DIR"/libreoffice-math.desktop"); |
797 | g_free (hint); |
798 | |
799 | - bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-writer", class_instance); |
800 | bamf_legacy_window_test_set_name (test_win, "FooDoc.odt - LibreOffice Writer"); |
801 | + bamf_legacy_window_test_set_wmclass (test_win, "libreoffice-writer", class_instance); |
802 | g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-math.desktop")); |
803 | app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/libreoffice-writer.desktop"); |
804 | g_assert (app); |
805 | @@ -570,7 +570,7 @@ |
806 | |
807 | test_win = bamf_legacy_window_test_new (xid, "System Settings", NULL, exec); |
808 | bamf_legacy_window_test_set_wmclass (test_win, class_name, class_instance); |
809 | - bamf_legacy_window_set_hint (BAMF_LEGACY_WINDOW (test_win), WM_WINDOW_ROLE, NULL); |
810 | + bamf_legacy_window_test_set_role (test_win, NULL); |
811 | _bamf_legacy_screen_open_test_window (screen, test_win); |
812 | |
813 | hint = bamf_legacy_window_get_hint (BAMF_LEGACY_WINDOW (test_win), _NET_WM_DESKTOP_FILE); |
814 | @@ -579,8 +579,8 @@ |
815 | app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/gnome-control-center.desktop"); |
816 | g_assert (find_window_in_app (app, BAMF_LEGACY_WINDOW (test_win))); |
817 | |
818 | - bamf_legacy_window_set_hint (BAMF_LEGACY_WINDOW (test_win), WM_WINDOW_ROLE, "display"); |
819 | bamf_legacy_window_test_set_name (test_win, "Displays"); |
820 | + bamf_legacy_window_test_set_role (test_win, "display"); |
821 | g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/gnome-control-center.desktop")); |
822 | app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/gnome-display-panel.desktop"); |
823 | g_assert (app); |
824 | @@ -590,8 +590,8 @@ |
825 | g_assert_cmpstr (hint, ==, DATA_DIR"/gnome-display-panel.desktop"); |
826 | g_free (hint); |
827 | |
828 | - bamf_legacy_window_set_hint (BAMF_LEGACY_WINDOW (test_win), WM_WINDOW_ROLE, "mouse"); |
829 | bamf_legacy_window_test_set_name (test_win, "Mouse and Touchpad"); |
830 | + bamf_legacy_window_test_set_role (test_win, "mouse"); |
831 | g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/gnome-display-panel.desktop")); |
832 | app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/gnome-mouse-panel.desktop"); |
833 | g_assert (app); |
834 | @@ -601,8 +601,8 @@ |
835 | g_assert_cmpstr (hint, ==, DATA_DIR"/gnome-mouse-panel.desktop"); |
836 | g_free (hint); |
837 | |
838 | - bamf_legacy_window_set_hint (BAMF_LEGACY_WINDOW (test_win), WM_WINDOW_ROLE, "invalid-role"); |
839 | bamf_legacy_window_test_set_name (test_win, "Invalid Panel"); |
840 | + bamf_legacy_window_test_set_role (test_win, "invalid-role"); |
841 | g_assert (!bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/gnome-mouse-panel.desktop")); |
842 | app = bamf_matcher_get_application_by_desktop_file (matcher, DATA_DIR"/gnome-control-center.desktop"); |
843 | g_assert (app); |
PASSED: Continuous integration, rev:541 jenkins. qa.ubuntu. com/job/ bamf-ci/ 19/ jenkins. qa.ubuntu. com/job/ bamf-raring- amd64-ci/ 19 jenkins. qa.ubuntu. com/job/ bamf-raring- armhf-ci/ 19
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ bamf-ci/ 19/rebuild
http://