Merge lp:~3v1n0/indicator-appmenu/all-menus-signals-fixes into lp:indicator-appmenu/15.04

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Christopher Townsend
Approved revision: 270
Merged at revision: 269
Proposed branch: lp:~3v1n0/indicator-appmenu/all-menus-signals-fixes
Merge into: lp:indicator-appmenu/15.04
Diff against target: 166 lines (+41/-25)
2 files modified
src/indicator-appmenu.c (+35/-11)
src/window-menu-model.c (+6/-14)
To merge this branch: bzr merge lp:~3v1n0/indicator-appmenu/all-menus-signals-fixes
Reviewer Review Type Date Requested Status
Christopher Townsend Approve
Review via email: mp+251459@code.launchpad.net

Commit message

IndicatorAppmenu: ensure we emit "entry-added/removed" signals after/before creating/destroying WindowMenu

Description of the change

When in ALL-menus mode, we need to make sure that we inform our loader (ups) also about menus that have been created on WindowMenu construction and about those that are going to be removed during WindowMenu destruction.

To post a comment you must log in.
Revision history for this message
Christopher Townsend (townsend) wrote :

LGTM +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/indicator-appmenu.c'
2--- src/indicator-appmenu.c 2015-01-29 15:09:16 +0000
3+++ src/indicator-appmenu.c 2015-03-02 14:52:44 +0000
4@@ -163,10 +163,10 @@
5 gpointer user_data);
6 static void window_entry_added (WindowMenu * mw,
7 IndicatorObjectEntry * entry,
8- gpointer user_data);
9+ IndicatorAppmenu * iapp);
10 static void window_entry_removed (WindowMenu * mw,
11 IndicatorObjectEntry * entry,
12- gpointer user_data);
13+ IndicatorAppmenu * iapp);
14 static void window_status_changed (WindowMenu * mw,
15 DbusmenuStatus status,
16 IndicatorAppmenu * iapp);
17@@ -997,9 +997,9 @@
18 /* Set up initial state for new entries if needed */
19 if (iapp->default_app != NULL &&
20 window_menu_get_status (iapp->default_app) != WINDOW_MENU_STATUS_NORMAL) {
21- window_status_changed (iapp->default_app,
22- window_menu_get_status (iapp->default_app),
23- iapp);
24+ window_status_changed(iapp->default_app,
25+ window_menu_get_status (iapp->default_app),
26+ iapp);
27 }
28
29 return;
30@@ -1013,7 +1013,22 @@
31 g_hash_table_insert(iapp->apps, GUINT_TO_POINTER(xid), menus);
32
33 if (iapp->mode == MODE_UNITY_ALL_MENUS) {
34+ GList *entries, *l;
35+ WindowMenuStatus status;
36+
37 connect_to_menu_signals(iapp, menus);
38+ entries = window_menu_get_entries(menus);
39+ status = window_menu_get_status(menus);
40+
41+ for (l = entries; l; l = l->next) {
42+ window_entry_added(menus, l->data, iapp);
43+ }
44+
45+ if (status != WINDOW_MENU_STATUS_ACTIVE) {
46+ window_status_changed(menus, status, iapp);
47+ }
48+
49+ g_list_free(entries);
50 }
51 }
52
53@@ -1126,6 +1141,15 @@
54 switch_default_app(iapp, NULL, NULL);
55 }
56
57+ if (iapp->mode == MODE_UNITY_ALL_MENUS) {
58+ GList * entries, * l;
59+ entries = window_menu_get_entries(wm);
60+ for (l = entries; l; l = l->next) {
61+ window_entry_removed(wm, l->data, iapp);
62+ }
63+ g_list_free(entries);
64+ }
65+
66 g_object_unref(wm);
67 }
68
69@@ -1313,18 +1337,18 @@
70
71 /* Pass up the entry added event */
72 static void
73-window_entry_added (WindowMenu * mw, IndicatorObjectEntry * entry, gpointer user_data)
74+window_entry_added (WindowMenu * mw, IndicatorObjectEntry * entry, IndicatorAppmenu * iapp)
75 {
76- entry->parent_object = user_data;
77- g_signal_emit_by_name(G_OBJECT(user_data), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, entry);
78+ entry->parent_object = INDICATOR_OBJECT(iapp);
79+ g_signal_emit_by_name(G_OBJECT(iapp), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, entry);
80 }
81
82 /* Pass up the entry removed event */
83 static void
84-window_entry_removed (WindowMenu * mw, IndicatorObjectEntry * entry, gpointer user_data)
85+window_entry_removed (WindowMenu * mw, IndicatorObjectEntry * entry, IndicatorAppmenu * iapp)
86 {
87- entry->parent_object = user_data;
88- g_signal_emit_by_name(G_OBJECT(user_data), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, entry);
89+ entry->parent_object = INDICATOR_OBJECT(iapp);
90+ g_signal_emit_by_name(G_OBJECT(iapp), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, entry);
91 }
92
93 /* Pass up the status changed event */
94
95=== modified file 'src/window-menu-model.c'
96--- src/window-menu-model.c 2014-12-15 16:13:58 +0000
97+++ src/window-menu-model.c 2015-03-02 14:52:44 +0000
98@@ -54,7 +54,6 @@
99 static void window_menu_model_class_init (WindowMenuModelClass *klass);
100 static void window_menu_model_init (WindowMenuModel *self);
101 static void window_menu_model_dispose (GObject *object);
102-static void window_menu_model_finalize (GObject *object);
103
104 /* Window Menu subclassin' */
105 static GList * get_entries (WindowMenu * wm);
106@@ -83,7 +82,6 @@
107 g_type_class_add_private (klass, sizeof (WindowMenuModelPrivate));
108
109 object_class->dispose = window_menu_model_dispose;
110- object_class->finalize = window_menu_model_finalize;
111
112 WindowMenuClass * wm_class = WINDOW_MENU_CLASS(klass);
113
114@@ -111,6 +109,11 @@
115 {
116 WindowMenuModel * menu = WINDOW_MENU_MODEL(object);
117
118+ if (menu->priv->has_application_menu) {
119+ g_signal_emit_by_name(menu, WINDOW_MENU_SIGNAL_ENTRY_REMOVED, &menu->priv->application_menu);
120+ menu->priv->has_application_menu = FALSE;
121+ }
122+
123 g_clear_object(&menu->priv->accel_group);
124
125 /* Application Menu */
126@@ -136,14 +139,6 @@
127 return;
128 }
129
130-static void
131-window_menu_model_finalize (GObject *object)
132-{
133-
134- G_OBJECT_CLASS (window_menu_model_parent_class)->finalize (object);
135- return;
136-}
137-
138 /* Adds the application menu and turns the whole thing into an object
139 entry that can be used elsewhere */
140 static void
141@@ -177,8 +172,7 @@
142 g_object_ref_sink(menu->priv->application_menu.menu);
143
144 menu->priv->has_application_menu = TRUE;
145-
146- return;
147+ g_signal_emit_by_name(menu, WINDOW_MENU_SIGNAL_ENTRY_ADDED, &menu->priv->application_menu);
148 }
149
150 /* Find the label in a GTK MenuItem */
151@@ -342,7 +336,6 @@
152 entry->entry.label = mi_find_label(GTK_WIDGET(gmi));
153 entry->entry.image = mi_find_icon(GTK_WIDGET(gmi));
154 entry->entry.menu = mi_find_menu(gmi);
155- g_print("%s Setting entry %p paret as %u\n",G_STRFUNC, &entry->entry, entry->entry.parent_window);
156
157 if (entry->entry.label == NULL && entry->entry.image == NULL) {
158 const gchar * label = gtk_menu_item_get_label(gmi);
159@@ -398,7 +391,6 @@
160 item_removed_cb (GtkContainer *menu, GtkWidget *widget, gpointer data)
161 {
162 g_signal_emit_by_name(data, WINDOW_MENU_SIGNAL_ENTRY_REMOVED, g_object_get_data(G_OBJECT(widget), ENTRY_DATA));
163- return;
164 }
165
166 /* Adds the window menu and turns it into a set of IndicatorObjectEntries

Subscribers

People subscribed via source and target branches