Merge lp:~3v1n0/indicator-appmenu/lim-mode-trusty into lp:indicator-appmenu/14.04
- lim-mode-trusty
- Merge into trunk.14.04
Status: | Approved |
---|---|
Approved by: | Christopher Townsend |
Approved revision: | 267 |
Proposed branch: | lp:~3v1n0/indicator-appmenu/lim-mode-trusty |
Merge into: | lp:indicator-appmenu/14.04 |
Diff against target: |
1281 lines (+328/-278) 9 files modified
configure.ac (+1/-2) debian/changelog (+6/-0) debian/control (+1/-2) m4/gcov.m4 (+1/-1) src/indicator-appmenu.c (+294/-215) src/window-menu-dbusmenu.c (+9/-14) src/window-menu-model.c (+13/-37) src/window-menu.c (+2/-2) tools/current-menu-dump.in (+1/-5) |
To merge this branch: | bzr merge lp:~3v1n0/indicator-appmenu/lim-mode-trusty |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Christopher Townsend | Approve | ||
Review via email: mp+264843@code.launchpad.net |
Commit message
IndicatorAppmenu: add modes support and implement unity-all-menus mode
When this mode is enabled, we export all the menus to the indicator, it will be up
to unity to filter them out based on their parent xid.
Description of the change
Backported relevant branches for LIM
- 267. By Marco Trevisan (Treviño)
-
debian/changelog: fix version
Unmerged revisions
- 267. By Marco Trevisan (Treviño)
-
debian/changelog: fix version
- 266. By Marco Trevisan (Treviño)
-
IndicatorAppmenu: make sure we call window_
menu_entry_ activate also in AllMenus mode - 265. By Marco Trevisan (Treviño)
-
IndicatorAppmenu: ensure we emit entry-added/removed signals after/before creating/destroying WindowMenu
- 264. By Marco Trevisan (Treviño)
-
IndicatorAppmenu: add modes support and implement unity-all-menus mode
When this mode is enabled, we export all the menus to the indicator, it will be up
to unity to filter them out based on their parent xid. Fixes: #1309778 - 263. By Dmitry Shachnev
-
Look for dbusmenu-dumper in correct location
Preview Diff
1 | === modified file 'configure.ac' |
2 | --- configure.ac 2013-10-24 14:43:59 +0000 |
3 | +++ configure.ac 2015-07-15 14:58:39 +0000 |
4 | @@ -1,5 +1,5 @@ |
5 | AC_INIT([indicator-appmenu], |
6 | - [13.01.0], |
7 | + [15.02.0], |
8 | [http://bugs.launchpad.net/indicator-appmenu], |
9 | [indicator-appmenu], |
10 | [http://launchpad.net/indicator-appmenu]) |
11 | @@ -45,7 +45,6 @@ |
12 | ########################### |
13 | |
14 | GTK_DOC_CHECK([1.9], [--flavour=no-tmpl]) |
15 | -AC_CONFIG_MACRO_DIR(m4) |
16 | |
17 | ########################### |
18 | # GLib GSettings |
19 | |
20 | === modified file 'debian/changelog' |
21 | --- debian/changelog 2014-04-04 14:54:48 +0000 |
22 | +++ debian/changelog 2015-07-15 14:58:39 +0000 |
23 | @@ -1,3 +1,9 @@ |
24 | +indicator-appmenu (15.02.0-0ubuntu1) UNRELEASED; urgency=medium |
25 | + |
26 | + * Bump indicator-appmenu version to 15.02 |
27 | + |
28 | + -- Marco Trevisan (Treviño) <marco@ubuntu.com> Tue, 03 Feb 2015 11:05:53 +0100 |
29 | + |
30 | indicator-appmenu (13.01.0+14.04.20140404-0ubuntu1) trusty; urgency=low |
31 | |
32 | [ Ted Gould ] |
33 | |
34 | === modified file 'debian/control' |
35 | --- debian/control 2014-03-21 10:23:09 +0000 |
36 | +++ debian/control 2015-07-15 14:58:39 +0000 |
37 | @@ -44,8 +44,7 @@ |
38 | Depends: ${shlibs:Depends}, |
39 | ${misc:Depends}, |
40 | indicator-appmenu (= ${binary:Version}), |
41 | - libdbusmenu-tools, |
42 | + libdbusmenu-tools (>= 12.10.3daily13.02.01), |
43 | Description: Tools for debuging application menus. |
44 | . |
45 | This package provides tools for supporting application menus. |
46 | - |
47 | |
48 | === modified file 'm4/gcov.m4' |
49 | --- m4/gcov.m4 2014-02-06 19:57:18 +0000 |
50 | +++ m4/gcov.m4 2015-07-15 14:58:39 +0000 |
51 | @@ -30,7 +30,7 @@ |
52 | AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.]) |
53 | fi |
54 | |
55 | - lcov_version_list="1.6 1.7 1.8 1.9 1.10" |
56 | + lcov_version_list="1.6 1.7 1.8 1.9 1.10 1.11 1.12" |
57 | AC_CHECK_PROG(LCOV, lcov, lcov) |
58 | AC_CHECK_PROG(GENHTML, genhtml, genhtml) |
59 | |
60 | |
61 | === modified file 'src/indicator-appmenu.c' |
62 | --- src/indicator-appmenu.c 2014-03-19 14:23:20 +0000 |
63 | +++ src/indicator-appmenu.c 2015-07-15 14:58:39 +0000 |
64 | @@ -5,6 +5,7 @@ |
65 | |
66 | Authors: |
67 | Ted Gould <ted@canonical.com> |
68 | + Marco Trevisan <marco@canonical.com> |
69 | |
70 | This program is free software: you can redistribute it and/or modify it |
71 | under the terms of the GNU General Public License version 3, as published |
72 | @@ -73,16 +74,22 @@ |
73 | STUBS_HIDE |
74 | }; |
75 | |
76 | +typedef enum _AppmenuMode AppmenuMode; |
77 | +enum _AppmenuMode { |
78 | + MODE_STANDARD, |
79 | + MODE_UNITY, |
80 | + MODE_UNITY_ALL_MENUS |
81 | +}; |
82 | + |
83 | struct _IndicatorAppmenuClass { |
84 | IndicatorObjectClass parent_class; |
85 | - |
86 | - void (*window_registered) (IndicatorAppmenu * iapp, guint wid, gchar * address, gpointer path, gpointer user_data); |
87 | - void (*window_unregistered) (IndicatorAppmenu * iapp, guint wid, gpointer user_data); |
88 | }; |
89 | |
90 | struct _IndicatorAppmenu { |
91 | IndicatorObject parent; |
92 | |
93 | + AppmenuMode mode; |
94 | + |
95 | WindowMenu * default_app; |
96 | GHashTable * apps; |
97 | |
98 | @@ -90,14 +97,7 @@ |
99 | BamfWindow * active_window; |
100 | ActiveStubsState active_stubs; |
101 | |
102 | - gulong sig_entry_added; |
103 | - gulong sig_entry_removed; |
104 | - gulong sig_status_changed; |
105 | - gulong sig_show_menu; |
106 | - gulong sig_a11y_update; |
107 | - |
108 | GtkMenuItem * close_item; |
109 | - |
110 | GArray * window_menus; |
111 | |
112 | GHashTable * desktop_windows; |
113 | @@ -137,6 +137,7 @@ |
114 | /********************** |
115 | Prototypes |
116 | **********************/ |
117 | +static gboolean indicator_appmenu_delayed_init (IndicatorAppmenu * iapp); |
118 | static void indicator_appmenu_dispose (GObject *object); |
119 | static void indicator_appmenu_finalize (GObject *object); |
120 | static void build_window_menus (IndicatorAppmenu * iapp); |
121 | @@ -153,7 +154,7 @@ |
122 | static void switch_default_app (IndicatorAppmenu * iapp, |
123 | WindowMenu * newdef, |
124 | BamfWindow * active_window); |
125 | -static void find_desktop_windows (IndicatorAppmenu * iapp); |
126 | +static void find_relevant_windows (IndicatorAppmenu * iapp); |
127 | static void new_window (BamfMatcher * matcher, |
128 | BamfView * view, |
129 | gpointer user_data); |
130 | @@ -162,10 +163,10 @@ |
131 | gpointer user_data); |
132 | static void window_entry_added (WindowMenu * mw, |
133 | IndicatorObjectEntry * entry, |
134 | - gpointer user_data); |
135 | + IndicatorAppmenu * iapp); |
136 | static void window_entry_removed (WindowMenu * mw, |
137 | IndicatorObjectEntry * entry, |
138 | - gpointer user_data); |
139 | + IndicatorAppmenu * iapp); |
140 | static void window_status_changed (WindowMenu * mw, |
141 | DbusmenuStatus status, |
142 | IndicatorAppmenu * iapp); |
143 | @@ -180,6 +181,8 @@ |
144 | BamfView * oldview, |
145 | BamfView * newview, |
146 | gpointer user_data); |
147 | +static WindowMenu * update_active_window (IndicatorAppmenu * appmenu, |
148 | + BamfWindow *window); |
149 | static GQuark error_quark (void); |
150 | static void bus_method_call (GDBusConnection * connection, |
151 | const gchar * sender, |
152 | @@ -195,8 +198,12 @@ |
153 | static void on_name_lost (GDBusConnection * connection, |
154 | const gchar * name, |
155 | gpointer user_data); |
156 | +static WindowMenu * ensure_menus (IndicatorAppmenu * iapp, |
157 | + BamfWindow * window); |
158 | static GVariant * unregister_window (IndicatorAppmenu * iapp, |
159 | guint windowid); |
160 | +static void connect_to_menu_signals (IndicatorAppmenu * iapp, |
161 | + WindowMenu * menus); |
162 | |
163 | /* Unique error codes for debug interface */ |
164 | enum { |
165 | @@ -260,24 +267,31 @@ |
166 | static void |
167 | indicator_appmenu_init (IndicatorAppmenu *self) |
168 | { |
169 | - self->default_app = NULL; |
170 | self->apps = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_object_unref); |
171 | - self->matcher = NULL; |
172 | - self->active_window = NULL; |
173 | + self->mode = MODE_STANDARD; |
174 | self->active_stubs = STUBS_UNKNOWN; |
175 | - self->close_item = NULL; |
176 | - self->bus = NULL; |
177 | - self->owner_id = 0; |
178 | - self->dbus_registration = 0; |
179 | - |
180 | - /* Setup the entries for the fallbacks */ |
181 | - self->window_menus = g_array_sized_new(FALSE, FALSE, sizeof(IndicatorObjectEntry), 2); |
182 | |
183 | /* Setup the cache of windows with possible desktop entries */ |
184 | self->desktop_windows = g_hash_table_new(g_direct_hash, g_direct_equal); |
185 | - self->desktop_menu = NULL; /* Starts NULL until found */ |
186 | - |
187 | - build_window_menus(self); |
188 | + |
189 | + g_idle_add((GSourceFunc) indicator_appmenu_delayed_init, self); |
190 | +} |
191 | + |
192 | +/* Delayed Init, this is done so it can happen after that the mode has been set */ |
193 | +static gboolean |
194 | +indicator_appmenu_delayed_init (IndicatorAppmenu *self) |
195 | +{ |
196 | + if (indicator_object_check_environment(INDICATOR_OBJECT(self), "unity-all-menus")) { |
197 | + self->mode = MODE_UNITY_ALL_MENUS; |
198 | + } else if (indicator_object_check_environment(INDICATOR_OBJECT(self), "unity")) { |
199 | + self->mode = MODE_UNITY; |
200 | + } |
201 | + |
202 | + if (self->mode != MODE_STANDARD) |
203 | + self->active_stubs = STUBS_HIDE; |
204 | + |
205 | + if (self->active_stubs != STUBS_HIDE) |
206 | + build_window_menus(self); |
207 | |
208 | /* Get the default BAMF matcher */ |
209 | self->matcher = bamf_matcher_get_default(); |
210 | @@ -293,7 +307,7 @@ |
211 | g_signal_connect(G_OBJECT(self->matcher), "view-closed", G_CALLBACK(old_window), self); |
212 | } |
213 | |
214 | - find_desktop_windows(self); |
215 | + find_relevant_windows(self); |
216 | |
217 | /* Request a name so others can find us */ |
218 | self->owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, |
219 | @@ -304,6 +318,8 @@ |
220 | on_name_lost, |
221 | self, |
222 | NULL); |
223 | + |
224 | + return G_SOURCE_REMOVE; |
225 | } |
226 | |
227 | static void |
228 | @@ -365,10 +381,7 @@ |
229 | iapp->dbus_registration = 0; |
230 | } |
231 | |
232 | - if (iapp->bus != NULL) { |
233 | - g_object_unref(iapp->bus); |
234 | - iapp->bus = NULL; |
235 | - } |
236 | + g_clear_object(&iapp->bus); |
237 | |
238 | if (iapp->owner_id != 0) { |
239 | g_bus_unown_name(iapp->owner_id); |
240 | @@ -377,23 +390,13 @@ |
241 | |
242 | /* bring down the matcher before resetting to no menu so we don't |
243 | get match signals */ |
244 | - if (iapp->matcher != NULL) { |
245 | - g_object_unref(iapp->matcher); |
246 | - iapp->matcher = NULL; |
247 | - } |
248 | + g_clear_object(&iapp->matcher); |
249 | |
250 | /* No specific ref */ |
251 | - switch_default_app (iapp, NULL, NULL); |
252 | - |
253 | - if (iapp->apps != NULL) { |
254 | - g_hash_table_destroy(iapp->apps); |
255 | - iapp->apps = NULL; |
256 | - } |
257 | - |
258 | - if (iapp->desktop_windows != NULL) { |
259 | - g_hash_table_destroy(iapp->desktop_windows); |
260 | - iapp->desktop_windows = NULL; |
261 | - } |
262 | + switch_default_app(iapp, NULL, NULL); |
263 | + |
264 | + g_clear_pointer(&iapp->apps, g_hash_table_destroy); |
265 | + g_clear_pointer(&iapp->desktop_windows, g_hash_table_destroy); |
266 | |
267 | if (iapp->desktop_menu != NULL) { |
268 | /* Wait, nothing here? Yup. We're not referencing the |
269 | @@ -413,13 +416,19 @@ |
270 | IndicatorAppmenu * iapp = INDICATOR_APPMENU(object); |
271 | |
272 | if (iapp->window_menus != NULL) { |
273 | - if (iapp->window_menus->len != 0) { |
274 | - g_warning("Window menus weren't free'd in dispose!"); |
275 | + g_signal_handlers_disconnect_by_data(iapp->close_item, iapp); |
276 | + |
277 | + gint i; |
278 | + for (i = 0; i < iapp->window_menus->len; ++i) { |
279 | + IndicatorObjectEntry *entry = &g_array_index(iapp->window_menus, IndicatorObjectEntry, i); |
280 | + g_clear_object(&(entry->label)); |
281 | + g_clear_object(&(entry->menu)); |
282 | } |
283 | g_array_free(iapp->window_menus, TRUE); |
284 | - iapp->window_menus = NULL; |
285 | } |
286 | |
287 | + g_signal_handlers_disconnect_by_data(iapp->matcher, iapp); |
288 | + |
289 | G_OBJECT_CLASS (indicator_appmenu_parent_class)->finalize (object); |
290 | return; |
291 | } |
292 | @@ -496,11 +505,17 @@ |
293 | GtkMenuItem * mi = NULL; |
294 | GtkStockItem stockitem; |
295 | |
296 | + /* Setup the entries for the fallbacks */ |
297 | + iapp->window_menus = g_array_sized_new(FALSE, FALSE, sizeof(IndicatorObjectEntry), 2); |
298 | + |
299 | +G_GNUC_BEGIN_IGNORE_DEPRECATIONS |
300 | /* File Menu */ |
301 | if (!gtk_stock_lookup(GTK_STOCK_FILE, &stockitem)) { |
302 | g_warning("Unable to find the file menu stock item"); |
303 | stockitem.label = "_File"; |
304 | } |
305 | +G_GNUC_END_IGNORE_DEPRECATIONS |
306 | + |
307 | entries[0].label = GTK_LABEL(gtk_label_new_with_mnemonic(stockitem.label)); |
308 | g_object_ref(G_OBJECT(entries[0].label)); |
309 | gtk_widget_show(GTK_WIDGET(entries[0].label)); |
310 | @@ -508,7 +523,10 @@ |
311 | entries[0].menu = GTK_MENU(gtk_menu_new()); |
312 | g_object_ref(G_OBJECT(entries[0].menu)); |
313 | |
314 | +G_GNUC_BEGIN_IGNORE_DEPRECATIONS |
315 | mi = GTK_MENU_ITEM(gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, agroup)); |
316 | +G_GNUC_END_IGNORE_DEPRECATIONS |
317 | + |
318 | gtk_widget_set_sensitive(GTK_WIDGET(mi), FALSE); |
319 | g_signal_connect(G_OBJECT(mi), "activate", G_CALLBACK(close_current), iapp); |
320 | gtk_widget_show(GTK_WIDGET(mi)); |
321 | @@ -519,8 +537,6 @@ |
322 | |
323 | /* Copy the entries on the stack into the array */ |
324 | g_array_insert_vals(iapp->window_menus, 0, entries, 1); |
325 | - |
326 | - return; |
327 | } |
328 | |
329 | /* Determine which windows should be used as the desktop |
330 | @@ -537,6 +553,7 @@ |
331 | if (pwm != NULL) { |
332 | g_debug("Setting Desktop Menus to: %X", xid); |
333 | iapp->desktop_menu = WINDOW_MENU(pwm); |
334 | + break; |
335 | } |
336 | } |
337 | |
338 | @@ -545,10 +562,10 @@ |
339 | return; |
340 | } |
341 | |
342 | -/* Puts all the desktop windows into the hash table so that we |
343 | +/* Puts all the windows we care about into the hash table so that we |
344 | can have a nice list of them. */ |
345 | static void |
346 | -find_desktop_windows (IndicatorAppmenu * iapp) |
347 | +find_relevant_windows (IndicatorAppmenu * iapp) |
348 | { |
349 | GList * windows = bamf_matcher_get_windows(iapp->matcher); |
350 | GList * lwindow; |
351 | @@ -568,7 +585,7 @@ |
352 | static void |
353 | new_window (BamfMatcher * matcher, BamfView * view, gpointer user_data) |
354 | { |
355 | - if (view == NULL || !BAMF_IS_WINDOW(view)) { |
356 | + if (!BAMF_IS_WINDOW(view)) { |
357 | return; |
358 | } |
359 | |
360 | @@ -576,6 +593,11 @@ |
361 | IndicatorAppmenu * iapp = INDICATOR_APPMENU(user_data); |
362 | guint32 xid = bamf_window_get_xid(window); |
363 | |
364 | + if (iapp->mode == MODE_UNITY_ALL_MENUS) { |
365 | + ensure_menus(iapp, window); |
366 | + return; |
367 | + } |
368 | + |
369 | if (bamf_window_get_window_type(window) != BAMF_WINDOW_DESKTOP) { |
370 | return; |
371 | } |
372 | @@ -593,15 +615,13 @@ |
373 | switch_default_app(iapp, NULL, NULL); |
374 | } |
375 | } |
376 | - |
377 | - return; |
378 | } |
379 | |
380 | /* When windows leave us, this function gets called */ |
381 | static void |
382 | old_window (BamfMatcher * matcher, BamfView * view, gpointer user_data) |
383 | { |
384 | - if (view == NULL || !BAMF_IS_WINDOW(view)) { |
385 | + if (!BAMF_IS_WINDOW(view)) { |
386 | return; |
387 | } |
388 | |
389 | @@ -617,21 +637,21 @@ |
390 | /* List of desktop files that shouldn't have menu stubs. */ |
391 | const static gchar * stubs_blacklist[] = { |
392 | /* Firefox */ |
393 | - "/usr/share/applications/firefox.desktop", |
394 | + "/firefox.desktop", |
395 | /* Thunderbird */ |
396 | - "/usr/share/applications/thunderbird.desktop", |
397 | + "/thunderbird.desktop", |
398 | /* Open Office */ |
399 | - "/usr/share/applications/openoffice.org-base.desktop", |
400 | - "/usr/share/applications/openoffice.org-impress.desktop", |
401 | - "/usr/share/applications/openoffice.org-calc.desktop", |
402 | - "/usr/share/applications/openoffice.org-math.desktop", |
403 | - "/usr/share/applications/openoffice.org-draw.desktop", |
404 | - "/usr/share/applications/openoffice.org-writer.desktop", |
405 | + "/openoffice.org-base.desktop", |
406 | + "/openoffice.org-impress.desktop", |
407 | + "/openoffice.org-calc.desktop", |
408 | + "/openoffice.org-math.desktop", |
409 | + "/openoffice.org-draw.desktop", |
410 | + "/openoffice.org-writer.desktop", |
411 | /* Blender */ |
412 | - "/usr/share/applications/blender-fullscreen.desktop", |
413 | - "/usr/share/applications/blender-windowed.desktop", |
414 | + "/blender-fullscreen.desktop", |
415 | + "/blender-windowed.desktop", |
416 | /* Eclipse */ |
417 | - "/usr/share/applications/eclipse.desktop", |
418 | + "/eclipse.desktop", |
419 | |
420 | NULL |
421 | }; |
422 | @@ -652,7 +672,7 @@ |
423 | |
424 | int i; |
425 | for (i = 0; stubs_blacklist[i] != NULL; i++) { |
426 | - if (g_strcmp0(stubs_blacklist[i], desktop_file) == 0) { |
427 | + if (g_str_has_suffix(desktop_file, stubs_blacklist[i]) == 0) { |
428 | return FALSE; |
429 | } |
430 | } |
431 | @@ -666,6 +686,19 @@ |
432 | { |
433 | g_return_val_if_fail(IS_INDICATOR_APPMENU(io), NULL); |
434 | IndicatorAppmenu * iapp = INDICATOR_APPMENU(io); |
435 | + GHashTableIter iter; |
436 | + gpointer value; |
437 | + GList* entries = NULL; |
438 | + |
439 | + if (iapp->mode == MODE_UNITY_ALL_MENUS) { |
440 | + g_hash_table_iter_init(&iter, iapp->apps); |
441 | + while (g_hash_table_iter_next(&iter, NULL, &value)) { |
442 | + GList *app_entries = window_menu_get_entries(WINDOW_MENU (value)); |
443 | + entries = g_list_concat(app_entries, entries); |
444 | + } |
445 | + |
446 | + return entries; |
447 | + } |
448 | |
449 | /* If we have a focused app with menus, use it's windows */ |
450 | if (iapp->default_app != NULL) { |
451 | @@ -702,21 +735,15 @@ |
452 | return NULL; |
453 | } |
454 | |
455 | - if (indicator_object_check_environment(INDICATOR_OBJECT(iapp), "unity")) { |
456 | - return NULL; |
457 | - } |
458 | - |
459 | - GList * output = NULL; |
460 | - int i; |
461 | - |
462 | /* There is only one item in window_menus now, but there |
463 | was more, and there is likely to be more in the future |
464 | so we're leaving this here to avoid a possible bug. */ |
465 | + int i; |
466 | for (i = 0; i < iapp->window_menus->len; i++) { |
467 | - output = g_list_append(output, &g_array_index(iapp->window_menus, IndicatorObjectEntry, i)); |
468 | + entries = g_list_append(entries, &g_array_index(iapp->window_menus, IndicatorObjectEntry, i)); |
469 | } |
470 | |
471 | - return output; |
472 | + return entries; |
473 | } |
474 | |
475 | /* Grabs the location of the entry */ |
476 | @@ -725,10 +752,26 @@ |
477 | { |
478 | guint count = 0; |
479 | IndicatorAppmenu * iapp = INDICATOR_APPMENU(io); |
480 | + |
481 | + if (iapp->mode == MODE_UNITY_ALL_MENUS) { |
482 | + GHashTableIter iter; |
483 | + gpointer value; |
484 | + |
485 | + g_hash_table_iter_init(&iter, iapp->apps); |
486 | + while (g_hash_table_iter_next(&iter, NULL, &value)) { |
487 | + count = window_menu_get_location(WINDOW_MENU (value), entry); |
488 | + |
489 | + if (count != G_MAXUINT) |
490 | + return count; |
491 | + } |
492 | + |
493 | + return 0; |
494 | + } |
495 | + |
496 | if (iapp->default_app != NULL) { |
497 | /* Find the location in the app */ |
498 | count = window_menu_get_location(iapp->default_app, entry); |
499 | - } else if (iapp->active_window != NULL) { |
500 | + } else if (iapp->active_window != NULL && iapp->window_menus) { |
501 | /* Find the location in the window menus */ |
502 | for (count = 0; count < iapp->window_menus->len; count++) { |
503 | if (entry == &g_array_index(iapp->window_menus, IndicatorObjectEntry, count)) { |
504 | @@ -737,7 +780,7 @@ |
505 | } |
506 | if (count == iapp->window_menus->len) { |
507 | g_warning("Unable to find entry in default window menus"); |
508 | - count = 0; |
509 | + count = G_MAXUINT; |
510 | } |
511 | } else { |
512 | /* Find the location in the desktop menu */ |
513 | @@ -745,7 +788,8 @@ |
514 | count = window_menu_get_location(iapp->desktop_menu, entry); |
515 | } |
516 | } |
517 | - return count; |
518 | + |
519 | + return (count == G_MAXUINT) ? 0 : count; |
520 | } |
521 | |
522 | /* Responds to a menuitem being activated on the panel. */ |
523 | @@ -760,23 +804,24 @@ |
524 | static BamfWindow * |
525 | xid_to_bamf_window (IndicatorAppmenu * iapp, guint xid) |
526 | { |
527 | - GList * windows = bamf_matcher_get_windows(iapp->matcher); |
528 | - GList * window; |
529 | + BamfApplication *application = bamf_matcher_get_application_for_xid(iapp->matcher, xid); |
530 | + GList * children = bamf_view_get_children (BAMF_VIEW (application)); |
531 | + GList * l; |
532 | BamfWindow * newwindow = NULL; |
533 | |
534 | - for (window = windows; window != NULL; window = g_list_next(window)) { |
535 | - if (!BAMF_IS_WINDOW(window->data)) { |
536 | + for (l = children; l; l = l->next) { |
537 | + if (!BAMF_IS_WINDOW(l->data)) { |
538 | continue; |
539 | } |
540 | |
541 | - BamfWindow * testwindow = BAMF_WINDOW(window->data); |
542 | + BamfWindow * testwindow = BAMF_WINDOW(l->data); |
543 | |
544 | if (xid == bamf_window_get_xid(testwindow)) { |
545 | newwindow = testwindow; |
546 | break; |
547 | } |
548 | } |
549 | - g_list_free(windows); |
550 | + g_list_free(children); |
551 | |
552 | return newwindow; |
553 | } |
554 | @@ -785,33 +830,30 @@ |
555 | static void |
556 | entry_activate_window (IndicatorObject * io, IndicatorObjectEntry * entry, guint windowid, guint timestamp) |
557 | { |
558 | + WindowMenu * menus = NULL; |
559 | IndicatorAppmenu * iapp = INDICATOR_APPMENU(io); |
560 | |
561 | /* We need to force a focus change in this case as we probably |
562 | just haven't gotten the signal from BAMF yet */ |
563 | if (windowid != 0) { |
564 | - BamfView * newwindow = BAMF_VIEW(xid_to_bamf_window(iapp, windowid)); |
565 | + BamfWindow * newwindow = xid_to_bamf_window(iapp, windowid); |
566 | |
567 | if (newwindow != NULL) { |
568 | - active_window_changed(iapp->matcher, BAMF_VIEW(iapp->active_window), newwindow, iapp); |
569 | - } |
570 | - } |
571 | - |
572 | - if (iapp->default_app != NULL) { |
573 | - window_menu_entry_activate(iapp->default_app, entry, timestamp); |
574 | - return; |
575 | - } |
576 | - |
577 | - if (iapp->active_window == NULL) { |
578 | - if (iapp->desktop_menu != NULL) { |
579 | - window_menu_entry_activate(iapp->desktop_menu, entry, timestamp); |
580 | - } |
581 | - return; |
582 | - } |
583 | - |
584 | - /* Else we've got stubs, and the stubs don't care. */ |
585 | - |
586 | - return; |
587 | + menus = update_active_window(iapp, newwindow); |
588 | + } |
589 | + } |
590 | + |
591 | + if (iapp->mode != MODE_UNITY_ALL_MENUS && iapp->default_app != NULL) { |
592 | + menus = iapp->default_app; |
593 | + |
594 | + if (!menus && iapp->active_window == NULL) { |
595 | + menus = iapp->desktop_menu; |
596 | + } |
597 | + } |
598 | + |
599 | + if (menus) { |
600 | + window_menu_entry_activate(menus, entry, timestamp); |
601 | + } |
602 | } |
603 | |
604 | /* Checks to see we cared about a window that's going |
605 | @@ -832,7 +874,7 @@ |
606 | |
607 | /* We're going to a state where we don't know what the active |
608 | window is, hopefully BAMF will save us */ |
609 | - active_window_changed (iapp->matcher, NULL, NULL, iapp); |
610 | + active_window_changed(iapp->matcher, NULL, NULL, iapp); |
611 | |
612 | return; |
613 | } |
614 | @@ -842,7 +884,7 @@ |
615 | static void |
616 | switch_active_window (IndicatorAppmenu * iapp, BamfWindow * active_window) |
617 | { |
618 | - if (iapp->active_window == active_window) { |
619 | + if (iapp->active_window == active_window || iapp->mode == MODE_UNITY_ALL_MENUS) { |
620 | return; |
621 | } |
622 | |
623 | @@ -851,7 +893,9 @@ |
624 | } |
625 | |
626 | iapp->active_window = active_window; |
627 | - iapp->active_stubs = STUBS_UNKNOWN; |
628 | + |
629 | + if (iapp->mode == MODE_STANDARD) |
630 | + iapp->active_stubs = STUBS_UNKNOWN; |
631 | |
632 | /* Close any existing open menu by showing a null entry */ |
633 | window_show_menu(iapp->default_app, NULL, gtk_get_current_event_time(), iapp); |
634 | @@ -875,7 +919,7 @@ |
635 | if (xid == 0 || bamf_view_is_closed (BAMF_VIEW (iapp->active_window))) { |
636 | return; |
637 | } |
638 | - |
639 | + |
640 | GdkWMFunction functions; |
641 | if (!egg_xid_get_functions(xid, &functions)) { |
642 | g_debug("Unable to get MWM functions for: %d", xid); |
643 | @@ -889,11 +933,43 @@ |
644 | return; |
645 | } |
646 | |
647 | +static void |
648 | +connect_to_menu_signals (IndicatorAppmenu * iapp, WindowMenu * menus) |
649 | +{ |
650 | + g_return_if_fail(G_IS_OBJECT(menus)); |
651 | + |
652 | + /* Connect signals */ |
653 | + g_signal_connect(menus, |
654 | + WINDOW_MENU_SIGNAL_ENTRY_ADDED, |
655 | + G_CALLBACK(window_entry_added), |
656 | + iapp); |
657 | + g_signal_connect(menus, |
658 | + WINDOW_MENU_SIGNAL_ENTRY_REMOVED, |
659 | + G_CALLBACK(window_entry_removed), |
660 | + iapp); |
661 | + g_signal_connect(menus, |
662 | + WINDOW_MENU_SIGNAL_STATUS_CHANGED, |
663 | + G_CALLBACK(window_status_changed), |
664 | + iapp); |
665 | + g_signal_connect(menus, |
666 | + WINDOW_MENU_SIGNAL_SHOW_MENU, |
667 | + G_CALLBACK(window_show_menu), |
668 | + iapp); |
669 | + g_signal_connect(menus, |
670 | + WINDOW_MENU_SIGNAL_A11Y_UPDATE, |
671 | + G_CALLBACK(window_a11y_update), |
672 | + iapp); |
673 | +} |
674 | + |
675 | /* Switch applications, remove all the entires for the previous |
676 | one and add them for the new application */ |
677 | static void |
678 | switch_default_app (IndicatorAppmenu * iapp, WindowMenu * newdef, BamfWindow * active_window) |
679 | { |
680 | + if (iapp->mode == MODE_UNITY_ALL_MENUS) { |
681 | + return; |
682 | + } |
683 | + |
684 | if (iapp->default_app == newdef && iapp->default_app != NULL) { |
685 | /* We've got an app with menus and it hasn't changed. */ |
686 | |
687 | @@ -911,31 +987,15 @@ |
688 | |
689 | /* hide the entries that we're swapping out */ |
690 | indicator_object_set_visible (INDICATOR_OBJECT(iapp), FALSE); |
691 | - |
692 | - /* Disconnect signals */ |
693 | - if (iapp->sig_entry_added != 0) { |
694 | - g_signal_handler_disconnect(G_OBJECT(iapp->default_app), iapp->sig_entry_added); |
695 | - iapp->sig_entry_added = 0; |
696 | - } |
697 | - if (iapp->sig_entry_removed != 0) { |
698 | - g_signal_handler_disconnect(G_OBJECT(iapp->default_app), iapp->sig_entry_removed); |
699 | - iapp->sig_entry_removed = 0; |
700 | - } |
701 | - if (iapp->sig_status_changed != 0) { |
702 | - g_signal_handler_disconnect(G_OBJECT(iapp->default_app), iapp->sig_status_changed); |
703 | - iapp->sig_status_changed = 0; |
704 | - } |
705 | - if (iapp->sig_show_menu != 0) { |
706 | - g_signal_handler_disconnect(G_OBJECT(iapp->default_app), iapp->sig_show_menu); |
707 | - iapp->sig_show_menu = 0; |
708 | - } |
709 | - if (iapp->sig_a11y_update != 0) { |
710 | - g_signal_handler_disconnect(G_OBJECT(iapp->default_app), iapp->sig_a11y_update); |
711 | - iapp->sig_a11y_update = 0; |
712 | - } |
713 | - |
714 | - /* Default App is NULL, let's see if it needs replacement */ |
715 | - iapp->default_app = NULL; |
716 | + |
717 | + if (iapp->default_app) |
718 | + { |
719 | + /* Disconnect signals */ |
720 | + g_signal_handlers_disconnect_by_data(iapp->default_app, iapp); |
721 | + |
722 | + /* Default App is NULL, let's see if it needs replacement */ |
723 | + iapp->default_app = NULL; |
724 | + } |
725 | |
726 | /* Update the active window pointer -- may be NULL */ |
727 | switch_active_window(iapp, active_window); |
728 | @@ -944,28 +1004,7 @@ |
729 | if (newdef != NULL) { |
730 | /* Switch */ |
731 | iapp->default_app = newdef; |
732 | - |
733 | - /* Connect signals */ |
734 | - iapp->sig_entry_added = g_signal_connect(G_OBJECT(iapp->default_app), |
735 | - WINDOW_MENU_SIGNAL_ENTRY_ADDED, |
736 | - G_CALLBACK(window_entry_added), |
737 | - iapp); |
738 | - iapp->sig_entry_removed = g_signal_connect(G_OBJECT(iapp->default_app), |
739 | - WINDOW_MENU_SIGNAL_ENTRY_REMOVED, |
740 | - G_CALLBACK(window_entry_removed), |
741 | - iapp); |
742 | - iapp->sig_status_changed = g_signal_connect(G_OBJECT(iapp->default_app), |
743 | - WINDOW_MENU_SIGNAL_STATUS_CHANGED, |
744 | - G_CALLBACK(window_status_changed), |
745 | - iapp); |
746 | - iapp->sig_show_menu = g_signal_connect(G_OBJECT(iapp->default_app), |
747 | - WINDOW_MENU_SIGNAL_SHOW_MENU, |
748 | - G_CALLBACK(window_show_menu), |
749 | - iapp); |
750 | - iapp->sig_a11y_update = g_signal_connect(G_OBJECT(iapp->default_app), |
751 | - WINDOW_MENU_SIGNAL_A11Y_UPDATE, |
752 | - G_CALLBACK(window_a11y_update), |
753 | - iapp); |
754 | + connect_to_menu_signals(iapp, iapp->default_app); |
755 | } |
756 | |
757 | /* show the entries that we're swapping in */ |
758 | @@ -974,45 +1013,51 @@ |
759 | /* Set up initial state for new entries if needed */ |
760 | if (iapp->default_app != NULL && |
761 | window_menu_get_status (iapp->default_app) != WINDOW_MENU_STATUS_NORMAL) { |
762 | - window_status_changed (iapp->default_app, |
763 | - window_menu_get_status (iapp->default_app), |
764 | - iapp); |
765 | + window_status_changed(iapp->default_app, |
766 | + window_menu_get_status (iapp->default_app), |
767 | + iapp); |
768 | } |
769 | |
770 | return; |
771 | } |
772 | |
773 | -/* Recieve the signal that the window being shown |
774 | - has now changed. */ |
775 | static void |
776 | -active_window_changed (BamfMatcher * matcher, BamfView * oldview, BamfView * newview, gpointer user_data) |
777 | -{ |
778 | - BamfWindow * window = NULL; |
779 | - |
780 | - if (newview != NULL) { |
781 | - window = BAMF_WINDOW(newview); |
782 | - if (window == NULL) { |
783 | - g_warning("Active window changed to View thats not a window."); |
784 | - } |
785 | - } else { |
786 | - g_debug("Active window is: NULL"); |
787 | - } |
788 | - |
789 | - IndicatorAppmenu * appmenu = INDICATOR_APPMENU(user_data); |
790 | - |
791 | - if (window != NULL && bamf_window_get_window_type(window) == BAMF_WINDOW_DESKTOP) { |
792 | - g_debug("Switching to menus from desktop"); |
793 | - switch_default_app(appmenu, NULL, NULL); |
794 | - return; |
795 | - } |
796 | - |
797 | +track_menus (IndicatorAppmenu * iapp, guint xid, WindowMenu * menus) |
798 | +{ |
799 | + g_return_if_fail(IS_WINDOW_MENU(menus)); |
800 | + |
801 | + g_hash_table_insert(iapp->apps, GUINT_TO_POINTER(xid), menus); |
802 | + |
803 | + if (iapp->mode == MODE_UNITY_ALL_MENUS) { |
804 | + GList *entries, *l; |
805 | + WindowMenuStatus status; |
806 | + |
807 | + connect_to_menu_signals(iapp, menus); |
808 | + entries = window_menu_get_entries(menus); |
809 | + status = window_menu_get_status(menus); |
810 | + |
811 | + for (l = entries; l; l = l->next) { |
812 | + window_entry_added(menus, l->data, iapp); |
813 | + } |
814 | + |
815 | + if (status != WINDOW_MENU_STATUS_ACTIVE) { |
816 | + window_status_changed(menus, status, iapp); |
817 | + } |
818 | + |
819 | + g_list_free(entries); |
820 | + } |
821 | +} |
822 | + |
823 | +static WindowMenu * |
824 | +ensure_menus (IndicatorAppmenu * iapp, BamfWindow * window) |
825 | +{ |
826 | WindowMenu * menus = NULL; |
827 | guint32 xid = 0; |
828 | |
829 | while (window != NULL && menus == NULL) { |
830 | xid = bamf_window_get_xid(window); |
831 | - |
832 | - menus = g_hash_table_lookup(appmenu->apps, GUINT_TO_POINTER(xid)); |
833 | + |
834 | + menus = g_hash_table_lookup(iapp->apps, GUINT_TO_POINTER(xid)); |
835 | |
836 | /* First look to see if we can get these from the |
837 | GMenuModel access */ |
838 | @@ -1020,11 +1065,10 @@ |
839 | gchar * uniquename = bamf_window_get_utf8_prop (window, "_GTK_UNIQUE_BUS_NAME"); |
840 | |
841 | if (uniquename != NULL) { |
842 | - BamfApplication * app = bamf_matcher_get_application_for_window(matcher, window); |
843 | + BamfApplication * app = bamf_matcher_get_application_for_window(iapp->matcher, window); |
844 | |
845 | menus = WINDOW_MENU(window_menu_model_new(app, window)); |
846 | - |
847 | - g_hash_table_insert(appmenu->apps, GUINT_TO_POINTER(xid), menus); |
848 | + track_menus(iapp, xid, menus); |
849 | } |
850 | |
851 | g_free(uniquename); |
852 | @@ -1036,17 +1080,49 @@ |
853 | } |
854 | } |
855 | |
856 | - /* Note: We're not using window here, but re-casting the |
857 | - newwindow variable. Which means we stay where we were |
858 | - but get the menus from parents. */ |
859 | - g_debug("Switching to menus from XID %d", xid); |
860 | - if (newview != NULL) { |
861 | - switch_default_app(appmenu, menus, BAMF_WINDOW(newview)); |
862 | + return menus; |
863 | +} |
864 | + |
865 | +/* Recieve the signal that the window being shown |
866 | + has now changed. */ |
867 | +static void |
868 | +active_window_changed (BamfMatcher * matcher, BamfView * oldview, BamfView * newview, gpointer user_data) |
869 | +{ |
870 | + update_active_window(INDICATOR_APPMENU(user_data), (BamfWindow *) newview); |
871 | +} |
872 | + |
873 | +static WindowMenu * |
874 | +update_active_window (IndicatorAppmenu * appmenu, BamfWindow *window) |
875 | +{ |
876 | + WindowMenu * menus = NULL; |
877 | + |
878 | + if (window != NULL) { |
879 | + if (!BAMF_IS_WINDOW(window)) { |
880 | + window = NULL; |
881 | + g_warning("Active window changed to View thats not a window."); |
882 | + } |
883 | } else { |
884 | - switch_default_app(appmenu, menus, NULL); |
885 | - } |
886 | - |
887 | - return; |
888 | + g_debug("Active window is: NULL"); |
889 | + } |
890 | + |
891 | + if (appmenu->mode == MODE_UNITY_ALL_MENUS) { |
892 | + if (window != NULL) { |
893 | + menus = ensure_menus(appmenu, window); |
894 | + } |
895 | + return menus; |
896 | + } |
897 | + |
898 | + if (window != NULL && bamf_window_get_window_type(window) == BAMF_WINDOW_DESKTOP) { |
899 | + g_debug("Switching to menus from desktop"); |
900 | + switch_default_app(appmenu, NULL, NULL); |
901 | + return menus; |
902 | + } |
903 | + |
904 | + g_debug("Switching to menus from XID %d", window ? bamf_window_get_xid(window) : 0); |
905 | + menus = ensure_menus(appmenu, window); |
906 | + switch_default_app(appmenu, menus, window); |
907 | + |
908 | + return menus; |
909 | } |
910 | |
911 | /* Respond to the menus being destroyed. We need to deregister |
912 | @@ -1056,9 +1132,10 @@ |
913 | { |
914 | gboolean reload_menus = FALSE; |
915 | WindowMenu * wm = g_hash_table_lookup(iapp->apps, GUINT_TO_POINTER(windowid)); |
916 | - g_return_if_fail (wm != NULL); |
917 | + g_return_if_fail (IS_WINDOW_MENU(wm)); |
918 | |
919 | g_hash_table_steal(iapp->apps, GUINT_TO_POINTER(windowid)); |
920 | + g_signal_handlers_disconnect_by_data(wm, iapp); |
921 | |
922 | g_debug("Removing menus for %d", windowid); |
923 | |
924 | @@ -1080,6 +1157,15 @@ |
925 | switch_default_app(iapp, NULL, NULL); |
926 | } |
927 | |
928 | + if (iapp->mode == MODE_UNITY_ALL_MENUS) { |
929 | + GList * entries, * l; |
930 | + entries = window_menu_get_entries(wm); |
931 | + for (l = entries; l; l = l->next) { |
932 | + window_entry_removed(wm, l->data, iapp); |
933 | + } |
934 | + g_list_free(entries); |
935 | + } |
936 | + |
937 | g_object_unref(wm); |
938 | } |
939 | |
940 | @@ -1094,7 +1180,7 @@ |
941 | WindowMenu * wm = WINDOW_MENU(window_menu_dbusmenu_new(windowid, sender, objectpath)); |
942 | g_return_val_if_fail(wm != NULL, FALSE); |
943 | |
944 | - g_hash_table_insert(iapp->apps, GUINT_TO_POINTER(windowid), wm); |
945 | + track_menus(iapp, windowid, wm); |
946 | |
947 | emit_signal(iapp, "WindowRegistered", |
948 | g_variant_new("(uso)", windowid, sender, objectpath)); |
949 | @@ -1106,8 +1192,7 @@ |
950 | |
951 | /* Note: Does not cause ref */ |
952 | BamfWindow * win = bamf_matcher_get_active_window(iapp->matcher); |
953 | - |
954 | - active_window_changed(iapp->matcher, NULL, BAMF_VIEW(win), iapp); |
955 | + update_active_window(iapp, win); |
956 | } else { |
957 | if (windowid == 0) { |
958 | g_warning("Can't build windows for a NULL window ID %d with path %s from %s", windowid, objectpath, sender); |
959 | @@ -1267,20 +1352,18 @@ |
960 | |
961 | /* Pass up the entry added event */ |
962 | static void |
963 | -window_entry_added (WindowMenu * mw, IndicatorObjectEntry * entry, gpointer user_data) |
964 | +window_entry_added (WindowMenu * mw, IndicatorObjectEntry * entry, IndicatorAppmenu * iapp) |
965 | { |
966 | - entry->parent_object = user_data; |
967 | - g_signal_emit_by_name(G_OBJECT(user_data), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, entry); |
968 | - return; |
969 | + entry->parent_object = INDICATOR_OBJECT(iapp); |
970 | + g_signal_emit_by_name(G_OBJECT(iapp), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, entry); |
971 | } |
972 | |
973 | /* Pass up the entry removed event */ |
974 | static void |
975 | -window_entry_removed (WindowMenu * mw, IndicatorObjectEntry * entry, gpointer user_data) |
976 | +window_entry_removed (WindowMenu * mw, IndicatorObjectEntry * entry, IndicatorAppmenu * iapp) |
977 | { |
978 | - entry->parent_object = user_data; |
979 | - g_signal_emit_by_name(G_OBJECT(user_data), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, entry); |
980 | - return; |
981 | + entry->parent_object = INDICATOR_OBJECT(iapp); |
982 | + g_signal_emit_by_name(G_OBJECT(iapp), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, entry); |
983 | } |
984 | |
985 | /* Pass up the status changed event */ |
986 | @@ -1296,8 +1379,6 @@ |
987 | IndicatorObjectEntry * entry = (IndicatorObjectEntry *)entries->data; |
988 | g_signal_emit(G_OBJECT(iapp), INDICATOR_OBJECT_SIGNAL_SHOW_NOW_CHANGED_ID, 0, entry, show_now); |
989 | } |
990 | - |
991 | - return; |
992 | } |
993 | |
994 | /* Pass up the show menu event */ |
995 | @@ -1305,7 +1386,6 @@ |
996 | window_show_menu (WindowMenu * mw, IndicatorObjectEntry * entry, guint timestamp, gpointer user_data) |
997 | { |
998 | g_signal_emit_by_name(G_OBJECT(user_data), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, entry, timestamp); |
999 | - return; |
1000 | } |
1001 | |
1002 | /* Pass up the accessible string update */ |
1003 | @@ -1313,7 +1393,6 @@ |
1004 | window_a11y_update (WindowMenu * mw, IndicatorObjectEntry * entry, gpointer user_data) |
1005 | { |
1006 | g_signal_emit_by_name(G_OBJECT(user_data), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, entry); |
1007 | - return; |
1008 | } |
1009 | |
1010 | /********************** |
1011 | |
1012 | === modified file 'src/window-menu-dbusmenu.c' |
1013 | --- src/window-menu-dbusmenu.c 2014-02-06 16:20:23 +0000 |
1014 | +++ src/window-menu-dbusmenu.c 2015-07-15 14:58:39 +0000 |
1015 | @@ -169,7 +169,7 @@ |
1016 | IndicatorObjectEntry * entry; |
1017 | entry = g_array_index(priv->entries, IndicatorObjectEntry *, 0); |
1018 | g_array_remove_index(priv->entries, 0); |
1019 | - if (should_signal) { |
1020 | + if (should_signal) { |
1021 | g_signal_emit_by_name(object, WINDOW_MENU_SIGNAL_ENTRY_REMOVED, entry, TRUE); |
1022 | } |
1023 | entry_free(entry); |
1024 | @@ -196,15 +196,11 @@ |
1025 | } |
1026 | |
1027 | if (priv->client != NULL) { |
1028 | - g_signal_handlers_disconnect_by_func(G_OBJECT(priv->client), G_CALLBACK(root_changed), object); |
1029 | - g_signal_handlers_disconnect_by_func(G_OBJECT(priv->client), G_CALLBACK(event_status), object); |
1030 | - g_signal_handlers_disconnect_by_func(G_OBJECT(priv->client), G_CALLBACK(item_activate), object); |
1031 | - g_signal_handlers_disconnect_by_func(G_OBJECT(priv->client), G_CALLBACK(status_changed), object); |
1032 | - |
1033 | + g_signal_handlers_disconnect_by_data(priv->client, object); |
1034 | g_object_unref(G_OBJECT(priv->client)); |
1035 | priv->client = NULL; |
1036 | } |
1037 | - |
1038 | + |
1039 | if (priv->props != NULL) { |
1040 | g_object_unref(G_OBJECT(priv->props)); |
1041 | priv->props = NULL; |
1042 | @@ -459,7 +455,7 @@ |
1043 | g_return_val_if_fail(IS_WINDOW_MENU_DBUSMENU(wm), 0); |
1044 | |
1045 | if (entry == NULL) { |
1046 | - return 0; |
1047 | + return G_MAXUINT; |
1048 | } |
1049 | |
1050 | guint i; |
1051 | @@ -471,7 +467,7 @@ |
1052 | } |
1053 | |
1054 | if (i == priv->entries->len) { |
1055 | - return 0; |
1056 | + return G_MAXUINT; |
1057 | } |
1058 | |
1059 | return i; |
1060 | @@ -513,8 +509,8 @@ |
1061 | { |
1062 | g_signal_handlers_disconnect_by_func(G_OBJECT(mi), G_CALLBACK(menu_entry_realized), user_data); |
1063 | g_signal_handlers_disconnect_by_func(G_OBJECT(mi), G_CALLBACK(menu_entry_realized_child_added), user_data); |
1064 | - g_signal_handlers_disconnect_matched (mi, G_SIGNAL_MATCH_FUNC, 0, 0, 0, menu_child_realized, NULL); |
1065 | - g_signal_handlers_disconnect_matched (mi, G_SIGNAL_MATCH_FUNC, 0, 0, 0, menu_prop_changed, NULL); |
1066 | + g_signal_handlers_disconnect_matched(mi, G_SIGNAL_MATCH_FUNC, 0, 0, 0, menu_child_realized, NULL); |
1067 | + g_signal_handlers_disconnect_matched(mi, G_SIGNAL_MATCH_FUNC, 0, 0, 0, menu_prop_changed, NULL); |
1068 | |
1069 | return; |
1070 | } |
1071 | @@ -531,9 +527,7 @@ |
1072 | |
1073 | if (priv->root != NULL) { |
1074 | dbusmenu_menuitem_foreach(priv->root, remove_menuitem_signals, user_data); |
1075 | - |
1076 | - g_signal_handlers_disconnect_by_func(G_OBJECT(priv->root), G_CALLBACK(menu_entry_added), user_data); |
1077 | - g_signal_handlers_disconnect_by_func(G_OBJECT(priv->root), G_CALLBACK(menu_entry_removed), user_data); |
1078 | + g_signal_handlers_disconnect_by_data(priv->root, user_data); |
1079 | g_object_unref(priv->root); |
1080 | } |
1081 | |
1082 | @@ -711,6 +705,7 @@ |
1083 | WMEntry * wmentry = g_new0(WMEntry, 1); |
1084 | wmentry->wm = wm; |
1085 | IndicatorObjectEntry * entry = &wmentry->ioentry; |
1086 | + entry->parent_window = priv->windowid; |
1087 | |
1088 | wmentry->mi = newentry; |
1089 | g_object_ref(G_OBJECT(wmentry->mi)); |
1090 | |
1091 | === modified file 'src/window-menu-model.c' |
1092 | --- src/window-menu-model.c 2013-11-19 10:20:17 +0000 |
1093 | +++ src/window-menu-model.c 2015-07-15 14:58:39 +0000 |
1094 | @@ -45,8 +45,6 @@ |
1095 | /* Window Menus */ |
1096 | GDBusMenuModel * win_menu_model; |
1097 | GtkMenuBar * win_menu; |
1098 | - gulong win_menu_insert; |
1099 | - gulong win_menu_remove; |
1100 | }; |
1101 | |
1102 | #define WINDOW_MENU_MODEL_GET_PRIVATE(o) \ |
1103 | @@ -56,7 +54,6 @@ |
1104 | static void window_menu_model_class_init (WindowMenuModelClass *klass); |
1105 | static void window_menu_model_init (WindowMenuModel *self); |
1106 | static void window_menu_model_dispose (GObject *object); |
1107 | -static void window_menu_model_finalize (GObject *object); |
1108 | |
1109 | /* Window Menu subclassin' */ |
1110 | static GList * get_entries (WindowMenu * wm); |
1111 | @@ -85,7 +82,6 @@ |
1112 | g_type_class_add_private (klass, sizeof (WindowMenuModelPrivate)); |
1113 | |
1114 | object_class->dispose = window_menu_model_dispose; |
1115 | - object_class->finalize = window_menu_model_finalize; |
1116 | |
1117 | WindowMenuClass * wm_class = WINDOW_MENU_CLASS(klass); |
1118 | |
1119 | @@ -113,6 +109,11 @@ |
1120 | { |
1121 | WindowMenuModel * menu = WINDOW_MENU_MODEL(object); |
1122 | |
1123 | + if (menu->priv->has_application_menu) { |
1124 | + g_signal_emit_by_name(menu, WINDOW_MENU_SIGNAL_ENTRY_REMOVED, &menu->priv->application_menu); |
1125 | + menu->priv->has_application_menu = FALSE; |
1126 | + } |
1127 | + |
1128 | g_clear_object(&menu->priv->accel_group); |
1129 | |
1130 | /* Application Menu */ |
1131 | @@ -121,19 +122,10 @@ |
1132 | g_clear_object(&menu->priv->application_menu.menu); |
1133 | |
1134 | /* Window Menus */ |
1135 | - if (menu->priv->win_menu_insert != 0) { |
1136 | - g_signal_handler_disconnect(menu->priv->win_menu, menu->priv->win_menu_insert); |
1137 | - menu->priv->win_menu_insert = 0; |
1138 | - } |
1139 | - |
1140 | - if (menu->priv->win_menu_remove != 0) { |
1141 | - g_signal_handler_disconnect(menu->priv->win_menu, menu->priv->win_menu_remove); |
1142 | - menu->priv->win_menu_remove = 0; |
1143 | - } |
1144 | - |
1145 | g_clear_object(&menu->priv->win_menu_model); |
1146 | |
1147 | if (menu->priv->win_menu) { |
1148 | + g_signal_handlers_disconnect_by_data(menu->priv->win_menu, menu); |
1149 | gtk_widget_destroy (GTK_WIDGET (menu->priv->win_menu)); |
1150 | g_object_unref (menu->priv->win_menu); |
1151 | menu->priv->win_menu = NULL; |
1152 | @@ -147,14 +139,6 @@ |
1153 | return; |
1154 | } |
1155 | |
1156 | -static void |
1157 | -window_menu_model_finalize (GObject *object) |
1158 | -{ |
1159 | - |
1160 | - G_OBJECT_CLASS (window_menu_model_parent_class)->finalize (object); |
1161 | - return; |
1162 | -} |
1163 | - |
1164 | /* Adds the application menu and turns the whole thing into an object |
1165 | entry that can be used elsewhere */ |
1166 | static void |
1167 | @@ -163,6 +147,7 @@ |
1168 | g_return_if_fail(G_IS_MENU_MODEL(model)); |
1169 | |
1170 | menu->priv->app_menu_model = g_object_ref(model); |
1171 | + menu->priv->application_menu.parent_window = menu->priv->xid; |
1172 | |
1173 | if (appname != NULL) { |
1174 | menu->priv->application_menu.label = GTK_LABEL(gtk_label_new(appname)); |
1175 | @@ -187,8 +172,7 @@ |
1176 | g_object_ref_sink(menu->priv->application_menu.menu); |
1177 | |
1178 | menu->priv->has_application_menu = TRUE; |
1179 | - |
1180 | - return; |
1181 | + g_signal_emit_by_name(menu, WINDOW_MENU_SIGNAL_ENTRY_ADDED, &menu->priv->application_menu); |
1182 | } |
1183 | |
1184 | /* Find the label in a GTK MenuItem */ |
1185 | @@ -330,9 +314,7 @@ |
1186 | { |
1187 | WindowMenuEntry * entry = (WindowMenuEntry *)inentry; |
1188 | |
1189 | - g_signal_handlers_disconnect_by_func (entry->gmi, entry_label_notify, entry); |
1190 | - g_signal_handlers_disconnect_by_func (entry->gmi, entry_sensitive_notify, entry); |
1191 | - g_signal_handlers_disconnect_by_func (entry->gmi, entry_visible_notify, entry); |
1192 | + g_signal_handlers_disconnect_by_data(entry->gmi, entry); |
1193 | |
1194 | g_clear_object(&entry->entry.label); |
1195 | g_clear_object(&entry->entry.image); |
1196 | @@ -350,6 +332,7 @@ |
1197 | |
1198 | entry->gmi = gmi; |
1199 | |
1200 | + entry->entry.parent_window = menu->priv->xid; |
1201 | entry->entry.label = mi_find_label(GTK_WIDGET(gmi)); |
1202 | entry->entry.image = mi_find_icon(GTK_WIDGET(gmi)); |
1203 | entry->entry.menu = mi_find_menu(gmi); |
1204 | @@ -365,7 +348,6 @@ |
1205 | gtk_widget_show(GTK_WIDGET(entry->entry.label)); |
1206 | g_signal_connect(G_OBJECT(gmi), "notify::label", G_CALLBACK(entry_label_notify), entry); |
1207 | } |
1208 | - |
1209 | if (entry->entry.label != NULL) { |
1210 | g_object_ref_sink(entry->entry.label); |
1211 | } |
1212 | @@ -409,7 +391,6 @@ |
1213 | item_removed_cb (GtkContainer *menu, GtkWidget *widget, gpointer data) |
1214 | { |
1215 | g_signal_emit_by_name(data, WINDOW_MENU_SIGNAL_ENTRY_REMOVED, g_object_get_data(G_OBJECT(widget), ENTRY_DATA)); |
1216 | - return; |
1217 | } |
1218 | |
1219 | /* Adds the window menu and turns it into a set of IndicatorObjectEntries |
1220 | @@ -430,14 +411,8 @@ |
1221 | if (menu->priv->unity_actions) |
1222 | gtk_widget_insert_action_group(GTK_WIDGET(menu->priv->win_menu), ACTION_MUX_PREFIX_UNITY, menu->priv->unity_actions); |
1223 | |
1224 | - menu->priv->win_menu_insert = g_signal_connect(G_OBJECT (menu->priv->win_menu), |
1225 | - "insert", |
1226 | - G_CALLBACK (item_inserted_cb), |
1227 | - menu); |
1228 | - menu->priv->win_menu_remove = g_signal_connect (G_OBJECT (menu->priv->win_menu), |
1229 | - "remove", |
1230 | - G_CALLBACK (item_removed_cb), |
1231 | - menu); |
1232 | + g_signal_connect(G_OBJECT(menu->priv->win_menu), "insert", G_CALLBACK (item_inserted_cb), menu); |
1233 | + g_signal_connect(G_OBJECT(menu->priv->win_menu), "remove", G_CALLBACK (item_removed_cb), menu); |
1234 | |
1235 | GList * children = gtk_container_get_children(GTK_CONTAINER(menu->priv->win_menu)); |
1236 | GList * child; |
1237 | @@ -627,6 +602,7 @@ |
1238 | /* NOTE: Not printing any of the values here because there's |
1239 | a pretty good chance that they're not valid. Let's not crash |
1240 | things here. */ |
1241 | + pos = G_MAXUINT; |
1242 | g_warning("Unable to find entry: %p", entry); |
1243 | } |
1244 | |
1245 | |
1246 | === modified file 'src/window-menu.c' |
1247 | --- src/window-menu.c 2014-03-19 13:07:30 +0000 |
1248 | +++ src/window-menu.c 2015-07-15 14:58:39 +0000 |
1249 | @@ -150,14 +150,14 @@ |
1250 | guint |
1251 | window_menu_get_location (WindowMenu * wm, IndicatorObjectEntry * entry) |
1252 | { |
1253 | - g_return_val_if_fail (IS_WINDOW_MENU(wm), 0); |
1254 | + g_return_val_if_fail (IS_WINDOW_MENU(wm), G_MAXUINT); |
1255 | |
1256 | WindowMenuClass * class = WINDOW_MENU_GET_CLASS(wm); |
1257 | |
1258 | if (class->get_location != NULL) { |
1259 | return class->get_location(wm, entry); |
1260 | } else { |
1261 | - return 0; |
1262 | + return G_MAXUINT; |
1263 | } |
1264 | } |
1265 | |
1266 | |
1267 | === modified file 'tools/current-menu-dump.in' |
1268 | --- tools/current-menu-dump.in 2012-02-03 05:51:58 +0000 |
1269 | +++ tools/current-menu-dump.in 2015-07-15 14:58:39 +0000 |
1270 | @@ -2,11 +2,7 @@ |
1271 | |
1272 | TMPFILE=`mktemp` |
1273 | CURMENU="@LIBEXECDIR@/current-menu" |
1274 | -if [ -x /usr/lib/libdbusmenu/dbusmenu-dumper ]; then |
1275 | - DBUSDUMP="/usr/lib/libdbusmenu/dbusmenu-dumper" |
1276 | -else |
1277 | - DBUSDUMP="/usr/lib/dbusmenu-dumper" |
1278 | -fi |
1279 | +DBUSDUMP="@LIBEXECDIR@/dbusmenu-dumper" |
1280 | |
1281 | $CURMENU > $TMPFILE |
1282 |
Good as far as I can tell.