Merge lp:~dbusmenu-team/libdbusmenu/ubuntu into lp:~ubuntu-desktop/libdbusmenu/ubuntu

Proposed by Ted Gould
Status: Merged
Merged at revision: not available
Proposed branch: lp:~dbusmenu-team/libdbusmenu/ubuntu
Merge into: lp:~ubuntu-desktop/libdbusmenu/ubuntu
Diff against target: 358 lines (+139/-7)
9 files modified
debian/changelog (+13/-0)
libdbusmenu-glib/client.c (+4/-1)
libdbusmenu-glib/dbus-menu.xml (+6/-0)
libdbusmenu-glib/menuitem-private.h (+2/-0)
libdbusmenu-glib/menuitem.c (+97/-0)
libdbusmenu-glib/menuitem.h (+1/-0)
libdbusmenu-glib/server.c (+10/-0)
libdbusmenu-gtk/client.c (+3/-3)
libdbusmenu-gtk/menu.c (+3/-3)
To merge this branch: bzr merge lp:~dbusmenu-team/libdbusmenu/ubuntu
Reviewer Review Type Date Requested Status
Sebastien Bacher Pending
Review via email: mp+23455@code.launchpad.net

Description of the change

Bug fix for reordering issues.

To post a comment you must log in.
lp:~dbusmenu-team/libdbusmenu/ubuntu updated
73. By Sebastien Bacher

releasing version 0.2.9-0ubuntu2

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2010-04-01 17:13:27 +0000
3+++ debian/changelog 2010-04-15 06:35:40 +0000
4@@ -1,3 +1,16 @@
5+libdbusmenu (0.2.9-0ubuntu2~ppa1) lucid; urgency=low
6+
7+ * Upstream Merge
8+ * Changing GTK layer to look at position in realized
9+ children to avoid realization races. (LP: #555816)
10+ * Don't allow setting children twice
11+ * Ref children of a menuitem
12+ * Return error when parent ID of getlayout can't be found
13+ * Adding in visible property to docs
14+ * Helpful comments in the code
15+
16+ -- Ted Gould <ted@ubuntu.com> Thu, 15 Apr 2010 01:25:42 -0500
17+
18 libdbusmenu (0.2.9-0ubuntu1) lucid; urgency=low
19
20 * New upstream release.
21
22=== modified file 'libdbusmenu-glib/client.c'
23--- libdbusmenu-glib/client.c 2010-03-31 19:48:26 +0000
24+++ libdbusmenu-glib/client.c 2010-04-15 06:35:40 +0000
25@@ -35,6 +35,7 @@
26
27 #include "client.h"
28 #include "menuitem.h"
29+#include "menuitem-private.h"
30 #include "client-menuitem.h"
31 #include "dbusmenu-client.h"
32 #include "server-marshal.h"
33@@ -645,7 +646,7 @@
34 #ifdef MASSIVEDEBUGGING
35 g_debug("Client has realized a menuitem: %d", dbusmenu_menuitem_get_id(propdata->item));
36 #endif
37- g_signal_emit(G_OBJECT(propdata->item), DBUSMENU_MENUITEM_SIGNAL_REALIZED_ID, 0, TRUE);
38+ dbusmenu_menuitem_set_realized(propdata->item);
39
40 if (!handled) {
41 g_signal_emit(G_OBJECT(propdata->client), signals[NEW_MENUITEM], 0, propdata->item, TRUE);
42@@ -748,6 +749,7 @@
43 if (parent != NULL) {
44 dbusmenu_menuitem_child_delete(parent, item);
45 }
46+ /* XXX: Should this be an unref? Who's reffing this that it exists without a parent? */
47 g_object_unref(G_OBJECT(item));
48 item = NULL;
49 }
50@@ -773,6 +775,7 @@
51 }
52 } else {
53 /* Refresh the properties */
54+ /* XXX: We shouldn't need to get the properties everytime we reuse an entry */
55 gchar * properties[1] = {NULL}; /* This gets them all */
56 org_ayatana_dbusmenu_get_properties_async(proxy, id, (const gchar **)properties, menuitem_get_properties_replace_cb, item);
57 }
58
59=== modified file 'libdbusmenu-glib/dbus-menu.xml'
60--- libdbusmenu-glib/dbus-menu.xml 2010-04-01 13:43:22 +0000
61+++ libdbusmenu-glib/dbus-menu.xml 2010-04-15 06:35:40 +0000
62@@ -82,6 +82,12 @@
63 <td>true</td>
64 </tr>
65 <tr>
66+ <td>visible</td>
67+ <td>boolean</td>
68+ <td>True if the item is visible in the menu.</td>
69+ <td>true</td>
70+ </tr>
71+ <tr>
72 <td>icon-name</td>
73 <td>string</td>
74 <td>Icon name of the item, following the freedesktop.org icon spec.</td>
75
76=== modified file 'libdbusmenu-glib/menuitem-private.h'
77--- libdbusmenu-glib/menuitem-private.h 2010-01-21 23:13:52 +0000
78+++ libdbusmenu-glib/menuitem-private.h 2010-04-15 06:35:40 +0000
79@@ -34,6 +34,8 @@
80 G_BEGIN_DECLS
81
82 void dbusmenu_menuitem_buildxml (DbusmenuMenuitem * mi, GPtrArray * array);
83+gboolean dbusmenu_menuitem_realized (DbusmenuMenuitem * mi);
84+void dbusmenu_menuitem_set_realized (DbusmenuMenuitem * mi);
85
86 G_END_DECLS
87
88
89=== modified file 'libdbusmenu-glib/menuitem.c'
90--- libdbusmenu-glib/menuitem.c 2010-03-31 18:51:48 +0000
91+++ libdbusmenu-glib/menuitem.c 2010-04-15 06:35:40 +0000
92@@ -59,6 +59,7 @@
93 GList * children;
94 GHashTable * properties;
95 gboolean root;
96+ gboolean realized;
97 };
98
99 /* Signals */
100@@ -278,6 +279,7 @@
101 priv->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, _g_value_free);
102
103 priv->root = FALSE;
104+ priv->realized = FALSE;
105
106 return;
107 }
108@@ -423,6 +425,46 @@
109 }
110
111 /**
112+ dbusmenu_menuitem_realized:
113+ @mi: #DbusmenuMenuitem to check on
114+
115+ This function returns whether the menuitem has been realized or
116+ not. This is significant mostly in client implementations that
117+ can use this additional state to see if the second layers of
118+ the implementation have been built yet.
119+
120+ Return value: Returns whether or not the menu item has been realized
121+ yet or not.
122+*/
123+gboolean
124+dbusmenu_menuitem_realized (DbusmenuMenuitem * mi)
125+{
126+ g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), FALSE);
127+ DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi);
128+ return priv->realized;
129+}
130+
131+/**
132+ dbusmenu_menuitem_set_realized:
133+ @mi: #DbusmenuMenuitem to realize
134+
135+ Sets the internal variable tracking whether it's been realized and
136+ signals the DbusmenuMenuitem::realized event.
137+*/
138+void
139+dbusmenu_menuitem_set_realized (DbusmenuMenuitem * mi)
140+{
141+ g_return_if_fail(DBUSMENU_IS_MENUITEM(mi));
142+ DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi);
143+ if (priv->realized) {
144+ g_warning("Realized entry realized again? ID: %d", dbusmenu_menuitem_get_id(mi));
145+ }
146+ priv->realized = TRUE;
147+ g_signal_emit(G_OBJECT(mi), signals[REALIZED], 0, TRUE);
148+ return;
149+}
150+
151+/**
152 dbusmenu_menuitem_get_children:
153 @mi: The #DbusmenuMenuitem to query.
154
155@@ -449,6 +491,7 @@
156 #ifdef MASSIVEDEBUGGING
157 g_debug("Menuitem %d (%s) signalling child removed %d (%s)", ID(user_data), LABEL(user_data), ID(data), LABEL(data));
158 #endif
159+ g_object_unref(G_OBJECT(data));
160 g_signal_emit(G_OBJECT(user_data), signals[CHILD_REMOVED], 0, DBUSMENU_MENUITEM(data), TRUE);
161 return;
162 }
163@@ -517,6 +560,50 @@
164 }
165
166 /**
167+ dbusmenu_menuitem_get_position_realized:
168+ @mi: The #DbusmenuMenuitem to find the position of
169+ @parent: The #DbusmenuMenuitem who's children contain @mi
170+
171+ This function is very similar to #dbusmenu_menuitem_get_position
172+ except that it only counts in the children that have been realized.
173+
174+ Return value: The position of @mi in the realized children of @parent.
175+*/
176+guint
177+dbusmenu_menuitem_get_position_realized (DbusmenuMenuitem * mi, DbusmenuMenuitem * parent)
178+{
179+ #ifdef MASSIVEDEBUGGING
180+ if (!DBUSMENU_IS_MENUITEM(mi)) g_warning("Getting position of %d (%s), it's at: %d (mi fail)", ID(mi), LABEL(mi), 0);
181+ if (!DBUSMENU_IS_MENUITEM(parent)) g_warning("Getting position of %d (%s), it's at: %d (parent fail)", ID(mi), LABEL(mi), 0);
182+ #endif
183+
184+ /* TODO: I'm not too happy returning zeros here. But that's all I've got */
185+ g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), 0);
186+ g_return_val_if_fail(DBUSMENU_IS_MENUITEM(parent), 0);
187+
188+ GList * childs = dbusmenu_menuitem_get_children(parent);
189+ if (childs == NULL) return 0;
190+ guint count = 0;
191+ for ( ; childs != NULL; childs = childs->next, count++) {
192+ if (!dbusmenu_menuitem_realized(DBUSMENU_MENUITEM(childs->data))) {
193+ count--;
194+ continue;
195+ }
196+ if (childs->data == mi) {
197+ break;
198+ }
199+ }
200+
201+ if (childs == NULL) return 0;
202+
203+ #ifdef MASSIVEDEBUGGING
204+ g_debug("Getting position of %d (%s), it's at: %d", ID(mi), LABEL(mi), count);
205+ #endif
206+
207+ return count;
208+}
209+
210+/**
211 dbusmenu_menuitem_child_append:
212 @mi: The #DbusmenuMenuitem which will become a new parent
213 @child: The #DbusmenMenuitem that will be a child
214@@ -533,10 +620,13 @@
215 g_return_val_if_fail(DBUSMENU_IS_MENUITEM(child), FALSE);
216
217 DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi);
218+ g_return_val_if_fail(g_list_find(priv->children, child) == NULL, FALSE);
219+
220 priv->children = g_list_append(priv->children, child);
221 #ifdef MASSIVEDEBUGGING
222 g_debug("Menuitem %d (%s) signalling child added %d (%s) at %d", ID(mi), LABEL(mi), ID(child), LABEL(child), g_list_length(priv->children) - 1);
223 #endif
224+ g_object_ref(G_OBJECT(child));
225 g_signal_emit(G_OBJECT(mi), signals[CHILD_ADDED], 0, child, g_list_length(priv->children) - 1, TRUE);
226 return TRUE;
227 }
228@@ -558,10 +648,13 @@
229 g_return_val_if_fail(DBUSMENU_IS_MENUITEM(child), FALSE);
230
231 DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi);
232+ g_return_val_if_fail(g_list_find(priv->children, child) == NULL, FALSE);
233+
234 priv->children = g_list_prepend(priv->children, child);
235 #ifdef MASSIVEDEBUGGING
236 g_debug("Menuitem %d (%s) signalling child added %d (%s) at %d", ID(mi), LABEL(mi), ID(child), LABEL(child), 0);
237 #endif
238+ g_object_ref(G_OBJECT(child));
239 g_signal_emit(G_OBJECT(mi), signals[CHILD_ADDED], 0, child, 0, TRUE);
240 return TRUE;
241 }
242@@ -588,6 +681,7 @@
243 #ifdef MASSIVEDEBUGGING
244 g_debug("Menuitem %d (%s) signalling child removed %d (%s)", ID(mi), LABEL(mi), ID(child), LABEL(child));
245 #endif
246+ g_object_unref(G_OBJECT(child));
247 g_signal_emit(G_OBJECT(mi), signals[CHILD_REMOVED], 0, child, TRUE);
248 return TRUE;
249 }
250@@ -611,10 +705,13 @@
251 g_return_val_if_fail(DBUSMENU_IS_MENUITEM(child), FALSE);
252
253 DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi);
254+ g_return_val_if_fail(g_list_find(priv->children, child) == NULL, FALSE);
255+
256 priv->children = g_list_insert(priv->children, child, position);
257 #ifdef MASSIVEDEBUGGING
258 g_debug("Menuitem %d (%s) signalling child added %d (%s) at %d", ID(mi), LABEL(mi), ID(child), LABEL(child), position);
259 #endif
260+ g_object_ref(G_OBJECT(child));
261 g_signal_emit(G_OBJECT(mi), signals[CHILD_ADDED], 0, child, position, TRUE);
262 return TRUE;
263 }
264
265=== modified file 'libdbusmenu-glib/menuitem.h'
266--- libdbusmenu-glib/menuitem.h 2010-03-31 18:51:48 +0000
267+++ libdbusmenu-glib/menuitem.h 2010-04-15 06:35:40 +0000
268@@ -148,6 +148,7 @@
269 GList * dbusmenu_menuitem_get_children (DbusmenuMenuitem * mi);
270 GList * dbusmenu_menuitem_take_children (DbusmenuMenuitem * mi) G_GNUC_WARN_UNUSED_RESULT;
271 guint dbusmenu_menuitem_get_position (DbusmenuMenuitem * mi, DbusmenuMenuitem * parent);
272+guint dbusmenu_menuitem_get_position_realized (DbusmenuMenuitem * mi, DbusmenuMenuitem * parent);
273
274 gboolean dbusmenu_menuitem_child_append (DbusmenuMenuitem * mi, DbusmenuMenuitem * child);
275 gboolean dbusmenu_menuitem_child_prepend (DbusmenuMenuitem * mi, DbusmenuMenuitem * child);
276
277=== modified file 'libdbusmenu-glib/server.c'
278--- libdbusmenu-glib/server.c 2010-03-31 19:15:36 +0000
279+++ libdbusmenu-glib/server.c 2010-04-15 06:35:40 +0000
280@@ -404,6 +404,16 @@
281 }
282 } else {
283 DbusmenuMenuitem * item = dbusmenu_menuitem_find_id(priv->root, parent);
284+ if (item == NULL) {
285+ if (error != NULL) {
286+ g_set_error(error,
287+ error_quark(),
288+ INVALID_MENUITEM_ID,
289+ "The ID supplied %d does not refer to a menu item we have",
290+ parent);
291+ }
292+ return FALSE;
293+ }
294 dbusmenu_menuitem_buildxml(item, xmlarray);
295 }
296 g_ptr_array_add(xmlarray, NULL);
297
298=== modified file 'libdbusmenu-gtk/client.c'
299--- libdbusmenu-gtk/client.c 2010-03-31 18:51:48 +0000
300+++ libdbusmenu-gtk/client.c 2010-04-15 06:35:40 +0000
301@@ -308,7 +308,7 @@
302
303 /* Oh, we're a child, let's deal with that */
304 if (parent != NULL) {
305- new_child(parent, item, dbusmenu_menuitem_get_position(item, parent), DBUSMENU_GTKCLIENT(client));
306+ new_child(parent, item, dbusmenu_menuitem_get_position_realized(item, parent), DBUSMENU_GTKCLIENT(client));
307 }
308
309 return;
310@@ -335,7 +335,7 @@
311 }
312
313 GtkMenuItem * childmi = dbusmenu_gtkclient_menuitem_get(gtkclient, child);
314- gtk_menu_shell_insert(GTK_MENU_SHELL(menu), GTK_WIDGET(childmi), position);
315+ gtk_menu_shell_insert(GTK_MENU_SHELL(menu), GTK_WIDGET(childmi), dbusmenu_menuitem_get_position_realized(child, mi));
316 gtk_widget_show(GTK_WIDGET(menu));
317
318 return;
319@@ -373,7 +373,7 @@
320 }
321
322 GtkMenuItem * childmi = dbusmenu_gtkclient_menuitem_get(gtkclient, child);
323- gtk_menu_reorder_child(GTK_MENU(ann_menu), GTK_WIDGET(childmi), new);
324+ gtk_menu_reorder_child(GTK_MENU(ann_menu), GTK_WIDGET(childmi), dbusmenu_menuitem_get_position_realized(child, mi));
325
326 return;
327 }
328
329=== modified file 'libdbusmenu-gtk/menu.c'
330--- libdbusmenu-gtk/menu.c 2010-03-31 18:49:32 +0000
331+++ libdbusmenu-gtk/menu.c 2010-04-15 06:35:40 +0000
332@@ -237,7 +237,7 @@
333 GtkMenuItem * mi = dbusmenu_gtkclient_menuitem_get(priv->client, child);
334 if (mi != NULL) {
335 GtkWidget * item = GTK_WIDGET(mi);
336- gtk_menu_insert(GTK_MENU(menu), item, position);
337+ gtk_menu_insert(GTK_MENU(menu), item, dbusmenu_menuitem_get_position_realized(child, root));
338 #ifdef MASSIVEDEBUGGING
339 menu_pos_t menu_pos;
340 menu_pos.mi = mi;
341@@ -260,7 +260,7 @@
342 g_debug("Root child moved");
343 #endif
344 DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(menu);
345- gtk_menu_reorder_child(GTK_MENU(menu), GTK_WIDGET(dbusmenu_gtkclient_menuitem_get(priv->client, child)), newposition);
346+ gtk_menu_reorder_child(GTK_MENU(menu), GTK_WIDGET(dbusmenu_gtkclient_menuitem_get(priv->client, child)), dbusmenu_menuitem_get_position_realized(child, root));
347 return;
348 }
349
350@@ -300,7 +300,7 @@
351
352 if (child_widget != NULL) {
353 gtk_menu_append(menu, child_widget);
354- gtk_menu_reorder_child(GTK_MENU(menu), child_widget, dbusmenu_menuitem_get_position(child, dbusmenu_client_get_root(DBUSMENU_CLIENT(priv->client))));
355+ gtk_menu_reorder_child(GTK_MENU(menu), child_widget, dbusmenu_menuitem_get_position_realized(child, dbusmenu_client_get_root(DBUSMENU_CLIENT(priv->client))));
356 } else {
357 g_warning("Child is realized, but doesn't have a GTK Widget!");
358 }

Subscribers

People subscribed via source and target branches

to all changes: