Merge lp:~mterry/indicator-appmenu/cleaner-remove into lp:indicator-appmenu/0.3

Proposed by Michael Terry
Status: Merged
Merged at revision: 96
Proposed branch: lp:~mterry/indicator-appmenu/cleaner-remove
Merge into: lp:indicator-appmenu/0.3
Diff against target: 84 lines (+31/-27)
1 file modified
src/window-menus.c (+31/-27)
To merge this branch: bzr merge lp:~mterry/indicator-appmenu/cleaner-remove
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+48364@code.launchpad.net

Description of the change

So when I was in the indicator-appmenu code, I noticed a TODO in the bit that removes entries from the window menu code. It currently just deleted the last entry in the list instead of the requested entry.

I haven't found code that hits this bug, so I'm not sure how important this is, but since I was there, I whipped up a little searcher function and used it there and elsewhere to grab an entry from the internal list.

Didn't seem to make things worse, though it also didn't make things noticeably better.

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

Ah, I couldn't figure out why I hadn't done the search before with the entries' menu item pointer. Forgot that I added that recently :) Good fix!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/window-menus.c'
2--- src/window-menus.c 2011-01-26 22:21:20 +0000
3+++ src/window-menus.c 2011-02-02 19:14:52 +0000
4@@ -338,6 +338,26 @@
5 return;
6 }
7
8+static IndicatorObjectEntry *
9+get_entry(WindowMenus *wm, DbusmenuMenuitem * item, guint *index)
10+{
11+ WindowMenusPrivate * priv = WINDOW_MENUS_GET_PRIVATE(wm);
12+
13+ guint position = 0;
14+ for (position = 0; position < priv->entries->len; ++position) {
15+ WMEntry * entry = g_array_index(priv->entries, WMEntry *, position);
16+ if (entry->mi == item) {
17+ if (index != NULL) {
18+ *index = position;
19+ }
20+ return &entry->ioentry;
21+ }
22+ }
23+
24+ /* Not found */
25+ return NULL;
26+}
27+
28 /* Called when a menu item wants to be displayed. We need to see if
29 it's one of our root items and pass it up if so. */
30 static void
31@@ -350,33 +370,12 @@
32 return;
33 }
34
35- GList * children = dbusmenu_menuitem_get_children(priv->root);
36- guint position = 0;
37- GList * child;
38-
39- for (child = children; child != NULL; position++, child = g_list_next(child)) {
40- DbusmenuMenuitem * childmi = DBUSMENU_MENUITEM(child->data);
41-
42- /* We're only putting items with children on the panel, so
43- they're the only one with entires. */
44- if (dbusmenu_menuitem_get_children(childmi) == NULL) {
45- position--;
46- continue;
47- }
48-
49- if (childmi == item) {
50- break;
51- }
52- }
53-
54- /* Not found */
55- if (child == NULL) {
56+ IndicatorObjectEntry * entry = get_entry(WINDOW_MENUS(user_data), item, NULL);
57+ if (entry == NULL) {
58+ /* Not found */
59 return;
60 }
61
62- g_return_if_fail(position < priv->entries->len);
63-
64- IndicatorObjectEntry * entry = g_array_index(priv->entries, IndicatorObjectEntry *, position);
65 g_signal_emit(G_OBJECT(user_data), signals[SHOW_MENU], 0, entry, timestamp, TRUE);
66
67 return;
68@@ -715,9 +714,14 @@
69 return;
70 }
71
72- /* TODO: find the menuitem */
73- IndicatorObjectEntry * entry = g_array_index(priv->entries, IndicatorObjectEntry *, priv->entries->len - 1);
74- g_array_remove_index(priv->entries, priv->entries->len - 1);
75+ guint position;
76+ IndicatorObjectEntry * entry = get_entry(WINDOW_MENUS(user_data), oldentry, &position);
77+ if (entry == NULL) {
78+ /* Not found */
79+ return;
80+ }
81+
82+ g_array_remove_index(priv->entries, position);
83
84 g_signal_emit(G_OBJECT(user_data), signals[ENTRY_REMOVED], 0, entry, TRUE);
85

Subscribers

People subscribed via source and target branches