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
=== modified file 'src/indicator-appmenu.c'
--- src/indicator-appmenu.c 2015-01-29 15:09:16 +0000
+++ src/indicator-appmenu.c 2015-03-02 14:52:44 +0000
@@ -163,10 +163,10 @@
163 gpointer user_data);163 gpointer user_data);
164static void window_entry_added (WindowMenu * mw,164static void window_entry_added (WindowMenu * mw,
165 IndicatorObjectEntry * entry,165 IndicatorObjectEntry * entry,
166 gpointer user_data);166 IndicatorAppmenu * iapp);
167static void window_entry_removed (WindowMenu * mw,167static void window_entry_removed (WindowMenu * mw,
168 IndicatorObjectEntry * entry,168 IndicatorObjectEntry * entry,
169 gpointer user_data);169 IndicatorAppmenu * iapp);
170static void window_status_changed (WindowMenu * mw,170static void window_status_changed (WindowMenu * mw,
171 DbusmenuStatus status,171 DbusmenuStatus status,
172 IndicatorAppmenu * iapp);172 IndicatorAppmenu * iapp);
@@ -997,9 +997,9 @@
997 /* Set up initial state for new entries if needed */997 /* Set up initial state for new entries if needed */
998 if (iapp->default_app != NULL &&998 if (iapp->default_app != NULL &&
999 window_menu_get_status (iapp->default_app) != WINDOW_MENU_STATUS_NORMAL) {999 window_menu_get_status (iapp->default_app) != WINDOW_MENU_STATUS_NORMAL) {
1000 window_status_changed (iapp->default_app,1000 window_status_changed(iapp->default_app,
1001 window_menu_get_status (iapp->default_app),1001 window_menu_get_status (iapp->default_app),
1002 iapp);1002 iapp);
1003 }1003 }
10041004
1005 return;1005 return;
@@ -1013,7 +1013,22 @@
1013 g_hash_table_insert(iapp->apps, GUINT_TO_POINTER(xid), menus);1013 g_hash_table_insert(iapp->apps, GUINT_TO_POINTER(xid), menus);
10141014
1015 if (iapp->mode == MODE_UNITY_ALL_MENUS) {1015 if (iapp->mode == MODE_UNITY_ALL_MENUS) {
1016 GList *entries, *l;
1017 WindowMenuStatus status;
1018
1016 connect_to_menu_signals(iapp, menus);1019 connect_to_menu_signals(iapp, menus);
1020 entries = window_menu_get_entries(menus);
1021 status = window_menu_get_status(menus);
1022
1023 for (l = entries; l; l = l->next) {
1024 window_entry_added(menus, l->data, iapp);
1025 }
1026
1027 if (status != WINDOW_MENU_STATUS_ACTIVE) {
1028 window_status_changed(menus, status, iapp);
1029 }
1030
1031 g_list_free(entries);
1017 }1032 }
1018}1033}
10191034
@@ -1126,6 +1141,15 @@
1126 switch_default_app(iapp, NULL, NULL);1141 switch_default_app(iapp, NULL, NULL);
1127 }1142 }
11281143
1144 if (iapp->mode == MODE_UNITY_ALL_MENUS) {
1145 GList * entries, * l;
1146 entries = window_menu_get_entries(wm);
1147 for (l = entries; l; l = l->next) {
1148 window_entry_removed(wm, l->data, iapp);
1149 }
1150 g_list_free(entries);
1151 }
1152
1129 g_object_unref(wm);1153 g_object_unref(wm);
1130}1154}
11311155
@@ -1313,18 +1337,18 @@
13131337
1314/* Pass up the entry added event */1338/* Pass up the entry added event */
1315static void1339static void
1316window_entry_added (WindowMenu * mw, IndicatorObjectEntry * entry, gpointer user_data)1340window_entry_added (WindowMenu * mw, IndicatorObjectEntry * entry, IndicatorAppmenu * iapp)
1317{1341{
1318 entry->parent_object = user_data;1342 entry->parent_object = INDICATOR_OBJECT(iapp);
1319 g_signal_emit_by_name(G_OBJECT(user_data), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, entry);1343 g_signal_emit_by_name(G_OBJECT(iapp), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, entry);
1320}1344}
13211345
1322/* Pass up the entry removed event */1346/* Pass up the entry removed event */
1323static void1347static void
1324window_entry_removed (WindowMenu * mw, IndicatorObjectEntry * entry, gpointer user_data)1348window_entry_removed (WindowMenu * mw, IndicatorObjectEntry * entry, IndicatorAppmenu * iapp)
1325{1349{
1326 entry->parent_object = user_data;1350 entry->parent_object = INDICATOR_OBJECT(iapp);
1327 g_signal_emit_by_name(G_OBJECT(user_data), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, entry);1351 g_signal_emit_by_name(G_OBJECT(iapp), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, entry);
1328}1352}
13291353
1330/* Pass up the status changed event */1354/* Pass up the status changed event */
13311355
=== modified file 'src/window-menu-model.c'
--- src/window-menu-model.c 2014-12-15 16:13:58 +0000
+++ src/window-menu-model.c 2015-03-02 14:52:44 +0000
@@ -54,7 +54,6 @@
54static void window_menu_model_class_init (WindowMenuModelClass *klass);54static void window_menu_model_class_init (WindowMenuModelClass *klass);
55static void window_menu_model_init (WindowMenuModel *self);55static void window_menu_model_init (WindowMenuModel *self);
56static void window_menu_model_dispose (GObject *object);56static void window_menu_model_dispose (GObject *object);
57static void window_menu_model_finalize (GObject *object);
5857
59/* Window Menu subclassin' */58/* Window Menu subclassin' */
60static GList * get_entries (WindowMenu * wm);59static GList * get_entries (WindowMenu * wm);
@@ -83,7 +82,6 @@
83 g_type_class_add_private (klass, sizeof (WindowMenuModelPrivate));82 g_type_class_add_private (klass, sizeof (WindowMenuModelPrivate));
8483
85 object_class->dispose = window_menu_model_dispose;84 object_class->dispose = window_menu_model_dispose;
86 object_class->finalize = window_menu_model_finalize;
8785
88 WindowMenuClass * wm_class = WINDOW_MENU_CLASS(klass);86 WindowMenuClass * wm_class = WINDOW_MENU_CLASS(klass);
8987
@@ -111,6 +109,11 @@
111{109{
112 WindowMenuModel * menu = WINDOW_MENU_MODEL(object);110 WindowMenuModel * menu = WINDOW_MENU_MODEL(object);
113111
112 if (menu->priv->has_application_menu) {
113 g_signal_emit_by_name(menu, WINDOW_MENU_SIGNAL_ENTRY_REMOVED, &menu->priv->application_menu);
114 menu->priv->has_application_menu = FALSE;
115 }
116
114 g_clear_object(&menu->priv->accel_group);117 g_clear_object(&menu->priv->accel_group);
115118
116 /* Application Menu */119 /* Application Menu */
@@ -136,14 +139,6 @@
136 return;139 return;
137}140}
138141
139static void
140window_menu_model_finalize (GObject *object)
141{
142
143 G_OBJECT_CLASS (window_menu_model_parent_class)->finalize (object);
144 return;
145}
146
147/* Adds the application menu and turns the whole thing into an object142/* Adds the application menu and turns the whole thing into an object
148 entry that can be used elsewhere */143 entry that can be used elsewhere */
149static void144static void
@@ -177,8 +172,7 @@
177 g_object_ref_sink(menu->priv->application_menu.menu);172 g_object_ref_sink(menu->priv->application_menu.menu);
178173
179 menu->priv->has_application_menu = TRUE;174 menu->priv->has_application_menu = TRUE;
180175 g_signal_emit_by_name(menu, WINDOW_MENU_SIGNAL_ENTRY_ADDED, &menu->priv->application_menu);
181 return;
182}176}
183177
184/* Find the label in a GTK MenuItem */178/* Find the label in a GTK MenuItem */
@@ -342,7 +336,6 @@
342 entry->entry.label = mi_find_label(GTK_WIDGET(gmi));336 entry->entry.label = mi_find_label(GTK_WIDGET(gmi));
343 entry->entry.image = mi_find_icon(GTK_WIDGET(gmi));337 entry->entry.image = mi_find_icon(GTK_WIDGET(gmi));
344 entry->entry.menu = mi_find_menu(gmi);338 entry->entry.menu = mi_find_menu(gmi);
345 g_print("%s Setting entry %p paret as %u\n",G_STRFUNC, &entry->entry, entry->entry.parent_window);
346339
347 if (entry->entry.label == NULL && entry->entry.image == NULL) {340 if (entry->entry.label == NULL && entry->entry.image == NULL) {
348 const gchar * label = gtk_menu_item_get_label(gmi);341 const gchar * label = gtk_menu_item_get_label(gmi);
@@ -398,7 +391,6 @@
398item_removed_cb (GtkContainer *menu, GtkWidget *widget, gpointer data)391item_removed_cb (GtkContainer *menu, GtkWidget *widget, gpointer data)
399{392{
400 g_signal_emit_by_name(data, WINDOW_MENU_SIGNAL_ENTRY_REMOVED, g_object_get_data(G_OBJECT(widget), ENTRY_DATA));393 g_signal_emit_by_name(data, WINDOW_MENU_SIGNAL_ENTRY_REMOVED, g_object_get_data(G_OBJECT(widget), ENTRY_DATA));
401 return;
402}394}
403395
404/* Adds the window menu and turns it into a set of IndicatorObjectEntries396/* Adds the window menu and turns it into a set of IndicatorObjectEntries

Subscribers

People subscribed via source and target branches