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: 796 lines (+227/-61)
20 files modified
.bzrignore (+1/-0)
configure.ac (+3/-3)
debian/changelog (+11/-0)
debian/libdbusmenu-tools.install (+2/-0)
libdbusmenu-glib/client.c (+37/-1)
libdbusmenu-glib/dbus-menu.xml (+10/-7)
libdbusmenu-glib/menuitem.c (+57/-12)
libdbusmenu-glib/menuitem.h (+2/-1)
libdbusmenu-glib/server.c (+3/-1)
tests/Makefile.am (+6/-1)
tests/test-glib-layout-client.c (+7/-5)
tests/test-glib-layout-server.c (+2/-2)
tests/test-glib-layout.h (+11/-11)
tests/test-glib-objects.c (+25/-0)
tests/test-glib-properties-client.c (+7/-5)
tests/test-glib-properties-server.c (+3/-3)
tests/test-glib-properties.h (+6/-6)
tests/test-gtk-label.json (+2/-2)
tools/Makefile.am (+5/-1)
tools/README.dbusmenu-bench (+27/-0)
To merge this branch: bzr merge lp:~dbusmenu-team/libdbusmenu/ubuntu
Reviewer Review Type Date Requested Status
Sebastien Bacher Pending
Review via email: mp+18714@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

0.2.3

lp:~dbusmenu-team/libdbusmenu/ubuntu updated
63. By Sebastien Bacher

releasing version 0.2.3-0ubuntu1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2010-02-04 20:15:43 +0000
3+++ .bzrignore 2010-02-05 19:30:27 +0000
4@@ -59,3 +59,4 @@
5 tests/test-glib-objects-test
6 tests/test-glib-objects.xml
7 tools/testapp/dbusmenu-testapp
8+libdbusmenu-glib/libdbusmenu_glib_la-client-menuitem.lo
9
10=== modified file 'configure.ac'
11--- configure.ac 2010-02-04 20:15:43 +0000
12+++ configure.ac 2010-02-05 19:30:27 +0000
13@@ -1,11 +1,11 @@
14
15-AC_INIT(libdbusmenu, 0.2.2, ted@canonical.com)
16+AC_INIT(libdbusmenu, 0.2.3, ted@canonical.com)
17 AC_COPYRIGHT([Copyright 2009,2010 Canonical])
18
19 AC_PREREQ(2.53)
20
21 AM_CONFIG_HEADER(config.h)
22-AM_INIT_AUTOMAKE(libdbusmenu, 0.2.2)
23+AM_INIT_AUTOMAKE(libdbusmenu, 0.2.3)
24
25 AM_MAINTAINER_MODE
26
27@@ -66,7 +66,7 @@
28 ###########################
29
30 LIBDBUSMENU_CURRENT=1
31-LIBDBUSMENU_REVISION=0
32+LIBDBUSMENU_REVISION=1
33 LIBDBUSMENU_AGE=0
34
35 AC_SUBST(LIBDBUSMENU_CURRENT)
36
37=== modified file 'debian/changelog'
38--- debian/changelog 2010-02-05 02:12:21 +0000
39+++ debian/changelog 2010-02-05 19:30:27 +0000
40@@ -1,3 +1,14 @@
41+libdbusmenu (0.2.3-0ubuntu1~ppa1) lucid; urgency=low
42+
43+ * Upstream release 0.2.3
44+ * Fixing handing of root IDs being zero
45+ * Handling syncing of properties when reusing items
46+ * Shipping new JSON files and READMEs for testing.
47+ * libdbusmenu-tools.install: Add in json file and README so
48+ that they're put in the right directories.
49+
50+ -- Ted Gould <ted@ubuntu.com> Fri, 05 Feb 2010 11:24:58 -0800
51+
52 libdbusmenu (0.2.2-0ubuntu3) lucid; urgency=low
53
54 * debian/control:
55
56=== modified file 'debian/libdbusmenu-tools.install'
57--- debian/libdbusmenu-tools.install 2010-02-04 20:17:02 +0000
58+++ debian/libdbusmenu-tools.install 2010-02-05 19:30:27 +0000
59@@ -1,1 +1,3 @@
60 debian/tmp/usr/lib/libdbusmenu/dbusmenu-*
61+debian/tmp/usr/share/libdbusmenu/* /usr/share/libdbusmenu-tools/
62+debian/tmp/usr/share/doc/libdbusmenu/README.dbusmenu-bench /usr/share/doc/libdbusmenu-tools/
63
64=== modified file 'libdbusmenu-glib/client.c'
65--- libdbusmenu-glib/client.c 2010-02-04 17:59:00 +0000
66+++ libdbusmenu-glib/client.c 2010-02-05 19:30:27 +0000
67@@ -339,6 +339,7 @@
68 g_return_if_fail(menuitem != NULL);
69
70 dbusmenu_menuitem_property_set_value(menuitem, property, value);
71+
72 return;
73 }
74
75@@ -569,6 +570,22 @@
76 return;
77 }
78
79+static void
80+menuitem_get_properties_replace_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data)
81+{
82+ GList * current_props = NULL;
83+
84+ for (current_props = dbusmenu_menuitem_properties_list(DBUSMENU_MENUITEM(data));
85+ current_props != NULL ; current_props = g_list_next(current_props)) {
86+ if (g_hash_table_lookup(properties, current_props->data) == NULL) {
87+ dbusmenu_menuitem_property_remove(DBUSMENU_MENUITEM(data), (const gchar *)current_props->data);
88+ }
89+ }
90+
91+ menuitem_get_properties_cb(proxy, properties, error, data);
92+ return;
93+}
94+
95 /* This is a different get properites call back that also sends
96 new signals. It basically is a small wrapper around the original. */
97 static void
98@@ -647,6 +664,7 @@
99 #ifdef MASSIVEDEBUGGING
100 g_debug("Client looking at node with id: %d", id);
101 #endif
102+ /* If we don't have any item, or the IDs don't match */
103 if (item == NULL || dbusmenu_menuitem_get_id(item) != id) {
104 if (item != NULL) {
105 if (parent != NULL) {
106@@ -675,7 +693,11 @@
107 } else {
108 g_warning("Unable to allocate memory to get properties for menuitem. This menuitem will never be realized.");
109 }
110- }
111+ } else {
112+ /* Refresh the properties */
113+ gchar * properties[1] = {NULL}; /* This gets them all */
114+ org_ayatana_dbusmenu_get_properties_async(proxy, id, (const gchar **)properties, menuitem_get_properties_replace_cb, item);
115+ }
116
117 xmlNodePtr children;
118 guint position;
119@@ -736,6 +758,10 @@
120 xmlNodePtr root = xmlDocGetRootElement(xmldoc);
121
122 DbusmenuMenuitem * oldroot = priv->root;
123+ if (oldroot != NULL) {
124+ g_object_ref(oldroot);
125+ }
126+
127 priv->root = parse_layout_xml(client, root, priv->root, NULL, priv->menuproxy);
128 xmlFreeDoc(xmldoc);
129
130@@ -747,6 +773,16 @@
131 #ifdef MASSIVEDEBUGGING
132 g_debug("Client signaling root changed.");
133 #endif
134+
135+ /* Switch the root around */
136+ g_object_ref(priv->root);
137+ dbusmenu_menuitem_set_root(priv->root, TRUE);
138+
139+ if (oldroot != NULL) {
140+ dbusmenu_menuitem_set_root(oldroot, FALSE);
141+ g_object_unref(oldroot);
142+ }
143+
144 g_signal_emit(G_OBJECT(client), signals[ROOT_CHANGED], 0, priv->root, TRUE);
145 }
146
147
148=== modified file 'libdbusmenu-glib/dbus-menu.xml'
149--- libdbusmenu-glib/dbus-menu.xml 2010-02-02 01:44:14 +0000
150+++ libdbusmenu-glib/dbus-menu.xml 2010-02-05 19:30:27 +0000
151@@ -1,6 +1,6 @@
152 <?xml version="1.0" encoding="UTF-8"?>
153 <!--
154-A library to allow applictions to provide simple indications of
155+A library to allow applications to provide simple indications of
156 information to be displayed to users of the application through the
157 interface shell.
158
159@@ -8,7 +8,7 @@
160
161 Authors:
162 Ted Gould <ted@canonical.com>
163- Aurelien Gateau <ted@canonical.com>
164+ Aurélien Gâteau <aurelien.gateau@canonical.com>
165
166 This program is free software: you can redistribute it and/or modify it
167 under the terms of either or both of the following licenses:
168@@ -37,6 +37,9 @@
169 Items are represented with a unique numeric id and a dictionary of
170 properties.
171
172+ To reduce the amount of DBus traffic, a property should only be returned
173+ if its value is not the default value.
174+
175 Available properties are:
176
177 <table>
178@@ -151,13 +154,13 @@
179 XML syntax:
180
181 @verbatim
182-<menu id="1" revision="2"> # Root container
183- <menu id="2" revision="2"> # First level menu, for example "File"
184- <menu id="3" revision="2"/> ~ Second level menu, for example "Open"
185- <menu id="4" revision="3"/>
186+<menu id="0"> # Root container
187+ <menu id="1"> # First level menu, for example "File"
188+ <menu id="2"/> ~ Second level menu, for example "Open"
189+ <menu id="3"/>
190 ...
191 </menu>
192- <menu id="5" revision="2"> # Another first level menu, say "Edit"
193+ <menu id="4"> # Another first level menu, say "Edit"
194 ...
195 </menu>
196 ...
197
198=== modified file 'libdbusmenu-glib/menuitem.c'
199--- libdbusmenu-glib/menuitem.c 2010-02-04 17:59:00 +0000
200+++ libdbusmenu-glib/menuitem.c 2010-02-05 19:30:27 +0000
201@@ -80,6 +80,8 @@
202 PROP_ID,
203 };
204
205+#define PROP_ID_S "id"
206+
207 #define DBUSMENU_MENUITEM_GET_PRIVATE(o) \
208 (G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_TYPE_MENUITEM, DbusmenuMenuitemPrivate))
209
210@@ -210,9 +212,9 @@
211 G_TYPE_NONE, 0, G_TYPE_NONE);
212
213 g_object_class_install_property (object_class, PROP_ID,
214- g_param_spec_int("id", "ID for the menu item",
215+ g_param_spec_int(PROP_ID_S, "ID for the menu item",
216 "This is a unique indentifier for the menu item.",
217- 0, 30000, 0,
218+ -1, 30000, -1,
219 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
220
221 /* Check transfer functions for GValue */
222@@ -249,7 +251,7 @@
223 return;
224 }
225
226-static gint menuitem_next_id = 0;
227+static gint menuitem_next_id = 1;
228
229 /* A small little function to both clear the insides of a
230 value as well as the memory it itself uses. */
231@@ -270,7 +272,7 @@
232 {
233 DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(self);
234
235- priv->id = 0;
236+ priv->id = -1;
237 priv->children = NULL;
238
239 priv->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, _g_value_free);
240@@ -323,6 +325,9 @@
241 menuitem_next_id = priv->id + 1;
242 }
243 break;
244+ default:
245+ G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, id, pspec);
246+ break;
247 }
248
249 return;
250@@ -335,7 +340,17 @@
251
252 switch (id) {
253 case PROP_ID:
254- g_value_set_int(value, priv->id);
255+ if (priv->id == -1) {
256+ priv->id = menuitem_next_id++;
257+ }
258+ if (dbusmenu_menuitem_get_root(DBUSMENU_MENUITEM(obj))) {
259+ g_value_set_int(value, 0);
260+ } else {
261+ g_value_set_int(value, priv->id);
262+ }
263+ break;
264+ default:
265+ G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, id, pspec);
266 break;
267 }
268
269@@ -365,7 +380,7 @@
270 DbusmenuMenuitem *
271 dbusmenu_menuitem_new (void)
272 {
273- return g_object_new(DBUSMENU_TYPE_MENUITEM, "id", menuitem_next_id++, NULL);
274+ return g_object_new(DBUSMENU_TYPE_MENUITEM, NULL);
275 }
276
277 /**
278@@ -379,7 +394,7 @@
279 DbusmenuMenuitem *
280 dbusmenu_menuitem_new_with_id (gint id)
281 {
282- DbusmenuMenuitem * mi = g_object_new(DBUSMENU_TYPE_MENUITEM, "id", id, NULL);
283+ DbusmenuMenuitem * mi = g_object_new(DBUSMENU_TYPE_MENUITEM, PROP_ID_S, id, NULL);
284 /* g_debug("New Menuitem id %d goal id %d", dbusmenu_menuitem_get_id(mi), id); */
285 return mi;
286 }
287@@ -392,15 +407,19 @@
288
289 Return value: The ID of the @mi.
290 */
291-guint
292+gint
293 dbusmenu_menuitem_get_id (DbusmenuMenuitem * mi)
294 {
295- g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), 0);
296+ g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), -1);
297
298 GValue retval = {0};
299- g_value_init(&retval, G_TYPE_UINT);
300- g_object_get_property(G_OBJECT(mi), "id", &retval);
301- return g_value_get_uint(&retval);
302+ g_value_init(&retval, G_TYPE_INT);
303+ g_object_get_property(G_OBJECT(mi), PROP_ID_S, &retval);
304+ gint ret = g_value_get_int(&retval);
305+ #ifdef MASSIVEDEBUGGING
306+ g_debug("Getting menuitem ID: %d", ret);
307+ #endif
308+ return ret;
309 }
310
311 /**
312@@ -710,6 +729,12 @@
313 dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, gint id)
314 {
315 g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), NULL);
316+ if (id == 0) {
317+ if (dbusmenu_menuitem_get_root(mi) == FALSE) {
318+ g_warning("Getting a menuitem with id zero, but it's not set as root.");
319+ }
320+ return mi;
321+ }
322 find_id_t find_id = {mi: NULL, id: id};
323 find_id_helper(mi, &find_id);
324 return find_id.mi;
325@@ -963,6 +988,26 @@
326 }
327
328 /**
329+ dbusmenu_menuitem_property_remove:
330+ @mi: The #DbusmenuMenuitem to remove the property on.
331+ @property: The property to look for.
332+
333+ Removes a property from the menuitem.
334+*/
335+void
336+dbusmenu_menuitem_property_remove (DbusmenuMenuitem * mi, const gchar * property)
337+{
338+ g_return_if_fail(DBUSMENU_IS_MENUITEM(mi));
339+ g_return_if_fail(property != NULL);
340+
341+ DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi);
342+
343+ g_hash_table_remove(priv->properties, property);
344+
345+ return;
346+}
347+
348+/**
349 dbusmenu_menuitem_properties_list:
350 @mi: #DbusmenuMenuitem to list the properties on
351
352
353=== modified file 'libdbusmenu-glib/menuitem.h'
354--- libdbusmenu-glib/menuitem.h 2010-02-04 17:59:00 +0000
355+++ libdbusmenu-glib/menuitem.h 2010-02-05 19:30:27 +0000
356@@ -127,7 +127,7 @@
357
358 DbusmenuMenuitem * dbusmenu_menuitem_new (void) G_GNUC_WARN_UNUSED_RESULT;
359 DbusmenuMenuitem * dbusmenu_menuitem_new_with_id (gint id) G_GNUC_WARN_UNUSED_RESULT;
360-guint dbusmenu_menuitem_get_id (DbusmenuMenuitem * mi);
361+gint dbusmenu_menuitem_get_id (DbusmenuMenuitem * mi);
362
363 GList * dbusmenu_menuitem_get_children (DbusmenuMenuitem * mi);
364 GList * dbusmenu_menuitem_take_children (DbusmenuMenuitem * mi) G_GNUC_WARN_UNUSED_RESULT;
365@@ -152,6 +152,7 @@
366 gboolean dbusmenu_menuitem_property_exist (DbusmenuMenuitem * mi, const gchar * property);
367 GList * dbusmenu_menuitem_properties_list (DbusmenuMenuitem * mi) G_GNUC_WARN_UNUSED_RESULT;
368 GHashTable * dbusmenu_menuitem_properties_copy (DbusmenuMenuitem * mi);
369+void dbusmenu_menuitem_property_remove (DbusmenuMenuitem * mi, const gchar * property);
370
371 void dbusmenu_menuitem_set_root (DbusmenuMenuitem * mi, gboolean root);
372 gboolean dbusmenu_menuitem_get_root (DbusmenuMenuitem * mi);
373
374=== modified file 'libdbusmenu-glib/server.c'
375--- libdbusmenu-glib/server.c 2010-02-04 20:12:17 +0000
376+++ libdbusmenu-glib/server.c 2010-02-05 19:30:27 +0000
377@@ -237,12 +237,14 @@
378 case PROP_ROOT_NODE:
379 if (priv->root != NULL) {
380 dbusmenu_menuitem_foreach(priv->root, menuitem_signals_remove, obj);
381+ dbusmenu_menuitem_set_root(priv->root, FALSE);
382 g_object_unref(G_OBJECT(priv->root));
383 priv->root = NULL;
384 }
385 priv->root = DBUSMENU_MENUITEM(g_value_get_object(value));
386 if (priv->root != NULL) {
387 g_object_ref(G_OBJECT(priv->root));
388+ dbusmenu_menuitem_set_root(priv->root, TRUE);
389 dbusmenu_menuitem_foreach(priv->root, menuitem_signals_create, obj);
390 } else {
391 g_debug("Setting root node to NULL");
392@@ -516,7 +518,7 @@
393 _dbusmenu_server_get_children (DbusmenuServer * server, gint id, GPtrArray * properties, GPtrArray ** output, GError ** error)
394 {
395 DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server);
396- DbusmenuMenuitem * mi = id == 0 ? priv->root : dbusmenu_menuitem_find_id(priv->root, id);
397+ DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id);
398
399 if (mi == NULL) {
400 if (error != NULL) {
401
402=== modified file 'tests/Makefile.am'
403--- tests/Makefile.am 2009-12-23 02:57:36 +0000
404+++ tests/Makefile.am 2010-02-05 19:30:27 +0000
405@@ -231,10 +231,15 @@
406 examples_DATA = \
407 $(glib_server_nomenu_SOURCES)
408
409+jsondir = $(datadir)/${PACKAGE}/json/
410+
411+json_DATA = \
412+ test-gtk-label.json
413+
414 EXTRA_DIST = \
415 $(examples_DATA) \
416 run-xvfb.sh \
417- test-gtk-label.json \
418+ $(json_DATA) \
419 dbusmenu-gtk/dbusMenuTest \
420 dbusmenu-gtk/mago_tests/dbusmenu.xml \
421 dbusmenu-gtk/mago_tests/dbusmenu.py \
422
423=== modified file 'tests/test-glib-layout-client.c'
424--- tests/test-glib-layout-client.c 2010-01-07 14:55:35 +0000
425+++ tests/test-glib-layout-client.c 2010-02-05 19:30:27 +0000
426@@ -36,8 +36,10 @@
427 g_debug("Verifying ID: %d", layout->id);
428
429 if (layout->id != dbusmenu_menuitem_get_id(mi)) {
430- g_debug("Failed as ID %d is not equal to %d", layout->id, dbusmenu_menuitem_get_id(mi));
431- return FALSE;
432+ if (!(dbusmenu_menuitem_get_root(mi) && dbusmenu_menuitem_get_id(mi) == 0)) {
433+ g_debug("Failed as ID %d is not equal to %d", layout->id, dbusmenu_menuitem_get_id(mi));
434+ return FALSE;
435+ }
436 }
437
438 GList * children = dbusmenu_menuitem_get_children(mi);
439@@ -55,13 +57,13 @@
440 }
441
442 guint i = 0;
443- for (i = 0; children != NULL && layout->submenu[i].id != 0; children = g_list_next(children), i++) {
444+ for (i = 0; children != NULL && layout->submenu[i].id != -1; children = g_list_next(children), i++) {
445 if (!verify_root_to_layout(DBUSMENU_MENUITEM(children->data), &layout->submenu[i])) {
446 return FALSE;
447 }
448 }
449
450- if (children == NULL && layout->submenu[i].id == 0) {
451+ if (children == NULL && layout->submenu[i].id == -1) {
452 return TRUE;
453 }
454
455@@ -88,7 +90,7 @@
456
457 layouton++;
458
459- if (layouts[layouton].id == 0) {
460+ if (layouts[layouton].id == -1) {
461 g_main_loop_quit(mainloop);
462 }
463
464
465=== modified file 'tests/test-glib-layout-server.c'
466--- tests/test-glib-layout-server.c 2010-01-07 14:55:35 +0000
467+++ tests/test-glib-layout-server.c 2010-02-05 19:30:27 +0000
468@@ -41,7 +41,7 @@
469
470 if (layout->submenu != NULL) {
471 guint count;
472- for (count = 0; layout->submenu[count].id != 0; count++) {
473+ for (count = 0; layout->submenu[count].id != -1; count++) {
474 DbusmenuMenuitem * child = layout2menuitem(&layout->submenu[count]);
475 if (child != NULL) {
476 dbusmenu_menuitem_child_append(local, child);
477@@ -60,7 +60,7 @@
478 static gboolean
479 timer_func (gpointer data)
480 {
481- if (layouts[layouton].id == 0) {
482+ if (layouts[layouton].id == -1) {
483 g_main_loop_quit(mainloop);
484 return FALSE;
485 }
486
487=== modified file 'tests/test-glib-layout.h'
488--- tests/test-glib-layout.h 2009-05-12 13:38:58 +0000
489+++ tests/test-glib-layout.h 2010-02-05 19:30:27 +0000
490@@ -21,51 +21,51 @@
491
492 typedef struct _layout_t layout_t;
493 struct _layout_t {
494- guint id;
495+ gint id;
496 layout_t * submenu;
497 };
498
499 layout_t submenu_2[] = {
500 {id: 2, submenu: NULL},
501 {id: 3, submenu: NULL},
502- {id: 0, submenu: NULL}
503+ {id: -1, submenu: NULL}
504 };
505 layout_t submenu_3_1[] = {
506 {id: 3, submenu: NULL},
507 {id: 4, submenu: NULL},
508 {id: 5, submenu: NULL},
509- {id: 0, submenu: NULL}
510+ {id: -1, submenu: NULL}
511 };
512 layout_t submenu_3_2[] = {
513 {id: 7, submenu: NULL},
514 {id: 8, submenu: NULL},
515 {id: 9, submenu: NULL},
516- {id: 0, submenu: NULL}
517+ {id: -1, submenu: NULL}
518 };
519 layout_t submenu_3[] = {
520 {id: 2, submenu: submenu_3_1},
521 {id: 6, submenu: submenu_3_2},
522- {id: 0, submenu: NULL}
523+ {id: -1, submenu: NULL}
524 };
525 layout_t submenu_4_1[] = {
526 {id: 6, submenu: NULL},
527- {id: 0, submenu: NULL}
528+ {id: -1, submenu: NULL}
529 };
530 layout_t submenu_4_2[] = {
531 {id: 5, submenu: submenu_4_1},
532- {id: 0, submenu: NULL}
533+ {id: -1, submenu: NULL}
534 };
535 layout_t submenu_4_3[] = {
536 {id: 4, submenu: submenu_4_2},
537- {id: 0, submenu: NULL}
538+ {id: -1, submenu: NULL}
539 };
540 layout_t submenu_4_4[] = {
541 {id: 3, submenu: submenu_4_3},
542- {id: 0, submenu: NULL}
543+ {id: -1, submenu: NULL}
544 };
545 layout_t submenu_4_5[] = {
546 {id: 2, submenu: submenu_4_4},
547- {id: 0, submenu: NULL}
548+ {id: -1, submenu: NULL}
549 };
550
551 layout_t layouts[] = {
552@@ -73,6 +73,6 @@
553 {id: 1, submenu: submenu_2},
554 {id: 1, submenu: submenu_3},
555 {id: 1, submenu: submenu_4_5},
556- {id: 0, submenu: NULL}
557+ {id: -1, submenu: NULL}
558 };
559
560
561=== modified file 'tests/test-glib-objects.c'
562--- tests/test-glib-objects.c 2009-12-23 02:51:37 +0000
563+++ tests/test-glib-objects.c 2010-02-05 19:30:27 +0000
564@@ -47,6 +47,30 @@
565 return;
566 }
567
568+/* Check to make sure a new ID is bigger than 0 */
569+static void
570+test_object_menuitem_id (void)
571+{
572+ /* Build a menu item */
573+ DbusmenuMenuitem * item = dbusmenu_menuitem_new();
574+
575+ /* Test to make sure it's a happy object */
576+ g_assert(item != NULL);
577+ g_assert(G_IS_OBJECT(item));
578+ g_assert(DBUSMENU_IS_MENUITEM(item));
579+
580+ g_assert(dbusmenu_menuitem_get_id(item) > 0);
581+
582+ /* Set up a check to make sure it gets destroyed on unref */
583+ g_object_add_weak_pointer(G_OBJECT(item), (gpointer *)&item);
584+ g_object_unref(item);
585+
586+ /* Did it go away? */
587+ g_assert(item == NULL);
588+
589+ return;
590+}
591+
592 /* Set a string prop, make sure it's stored as one */
593 static void
594 test_object_menuitem_props_string (void)
595@@ -255,6 +279,7 @@
596 test_glib_objects_suite (void)
597 {
598 g_test_add_func ("/dbusmenu/glib/objects/menuitem/base", test_object_menuitem);
599+ g_test_add_func ("/dbusmenu/glib/objects/menuitem/id", test_object_menuitem_id);
600 g_test_add_func ("/dbusmenu/glib/objects/menuitem/props_string", test_object_menuitem_props_string);
601 g_test_add_func ("/dbusmenu/glib/objects/menuitem/props_int", test_object_menuitem_props_int);
602 g_test_add_func ("/dbusmenu/glib/objects/menuitem/props_bool", test_object_menuitem_props_bool);
603
604=== modified file 'tests/test-glib-properties-client.c'
605--- tests/test-glib-properties-client.c 2009-12-23 02:51:37 +0000
606+++ tests/test-glib-properties-client.c 2010-02-05 19:30:27 +0000
607@@ -60,8 +60,10 @@
608 g_debug("Verifying ID: %d", layout->id);
609
610 if (layout->id != dbusmenu_menuitem_get_id(mi)) {
611- g_debug("\tFailed as ID %d is not equal to %d", layout->id, dbusmenu_menuitem_get_id(mi));
612- return FALSE;
613+ if (!dbusmenu_menuitem_get_root(mi)) {
614+ g_debug("\tFailed as ID %d is not equal to %d", layout->id, dbusmenu_menuitem_get_id(mi));
615+ return FALSE;
616+ }
617 }
618
619 if (!verify_props(mi, layout->properties)) {
620@@ -85,13 +87,13 @@
621 }
622
623 guint i = 0;
624- for (i = 0; children != NULL && layout->submenu[i].id != 0; children = g_list_next(children), i++) {
625+ for (i = 0; children != NULL && layout->submenu[i].id != -1; children = g_list_next(children), i++) {
626 if (!verify_root_to_layout(DBUSMENU_MENUITEM(children->data), &layout->submenu[i])) {
627 return FALSE;
628 }
629 }
630
631- if (children == NULL && layout->submenu[i].id == 0) {
632+ if (children == NULL && layout->submenu[i].id == -1) {
633 g_debug("\tPassed: %d", layout->id);
634 return TRUE;
635 }
636@@ -140,7 +142,7 @@
637
638 layouton++;
639
640- if (layouts[layouton].id == 0) {
641+ if (layouts[layouton].id == -1) {
642 g_main_loop_quit(mainloop);
643 }
644
645
646=== modified file 'tests/test-glib-properties-server.c'
647--- tests/test-glib-properties-server.c 2009-06-18 19:11:42 +0000
648+++ tests/test-glib-properties-server.c 2010-02-05 19:30:27 +0000
649@@ -46,14 +46,14 @@
650 static DbusmenuMenuitem *
651 layout2menuitem (proplayout_t * layout)
652 {
653- if (layout == NULL || layout->id == 0) return NULL;
654+ if (layout == NULL || layout->id == -1) return NULL;
655
656 DbusmenuMenuitem * local = dbusmenu_menuitem_new_with_id(layout->id);
657 set_props(local, layout->properties);
658
659 if (layout->submenu != NULL) {
660 guint count;
661- for (count = 0; layout->submenu[count].id != 0; count++) {
662+ for (count = 0; layout->submenu[count].id != -1; count++) {
663 DbusmenuMenuitem * child = layout2menuitem(&layout->submenu[count]);
664 if (child != NULL) {
665 dbusmenu_menuitem_child_append(local, child);
666@@ -72,7 +72,7 @@
667 static gboolean
668 timer_func (gpointer data)
669 {
670- if (layouts[layouton].id == 0) {
671+ if (layouts[layouton].id == -1) {
672 g_main_loop_quit(mainloop);
673 return FALSE;
674 }
675
676=== modified file 'tests/test-glib-properties.h'
677--- tests/test-glib-properties.h 2009-06-18 19:11:42 +0000
678+++ tests/test-glib-properties.h 2010-02-05 19:30:27 +0000
679@@ -24,7 +24,7 @@
680
681 typedef struct _proplayout_t proplayout_t;
682 struct _proplayout_t {
683- guint id;
684+ gint id;
685 gchar ** properties;
686 proplayout_t * submenu;
687 };
688@@ -68,7 +68,7 @@
689 {id: 17, properties: props2, submenu: NULL},
690 {id: 18, properties: props2, submenu: NULL},
691 {id: 19, properties: props2, submenu: NULL},
692- {id: 0, properties: NULL, submenu: NULL}
693+ {id: -1, properties: NULL, submenu: NULL}
694 };
695
696 proplayout_t submenu_4_2[] = {
697@@ -82,7 +82,7 @@
698 {id: 27, properties: props2, submenu: NULL},
699 {id: 28, properties: props2, submenu: NULL},
700 {id: 29, properties: props2, submenu: NULL},
701- {id: 0, properties: NULL, submenu: NULL}
702+ {id: -1, properties: NULL, submenu: NULL}
703 };
704
705 proplayout_t submenu_4_3[] = {
706@@ -96,14 +96,14 @@
707 {id: 37, properties: props2, submenu: NULL},
708 {id: 38, properties: props2, submenu: NULL},
709 {id: 39, properties: props2, submenu: NULL},
710- {id: 0, properties: NULL, submenu: NULL}
711+ {id: -1, properties: NULL, submenu: NULL}
712 };
713
714 proplayout_t submenu_4_0[] = {
715 {id: 1, properties: props2, submenu: submenu_4_1},
716 {id: 2, properties: props2, submenu: submenu_4_2},
717 {id: 3, properties: props2, submenu: submenu_4_3},
718- {id: 0, properties: NULL, submenu: NULL}
719+ {id: -1, properties: NULL, submenu: NULL}
720 };
721
722 proplayout_t layouts[] = {
723@@ -111,6 +111,6 @@
724 {id: 10, properties: props2, submenu: NULL},
725 {id: 20, properties: props3, submenu: NULL},
726 {id: 100, properties: props2, submenu: submenu_4_0},
727- {id: 0, properties: NULL, submenu: NULL}
728+ {id: -1, properties: NULL, submenu: NULL}
729 };
730
731
732=== modified file 'tests/test-gtk-label.json'
733--- tests/test-gtk-label.json 2010-02-03 18:33:47 +0000
734+++ tests/test-gtk-label.json 2010-02-05 19:30:27 +0000
735@@ -198,7 +198,7 @@
736 {"id": 39, "type": "standard",
737 "label": "value39"}
738 ]
739- },
740+ }
741 ]
742 },
743 {"id": 8, "type": "standard",
744@@ -367,5 +367,5 @@
745 "toggle-state": -1
746 }
747 ]
748- },
749+ }
750 ]
751
752=== modified file 'tools/Makefile.am'
753--- tools/Makefile.am 2010-02-04 19:34:58 +0000
754+++ tools/Makefile.am 2010-02-05 19:30:27 +0000
755@@ -16,4 +16,8 @@
756 ../libdbusmenu-glib/libdbusmenu-glib.la \
757 $(DBUSMENUGLIB_LIBS)
758
759-EXTRA_DIST = dbusmenu-bench
760+doc_DATA = README.dbusmenu-bench
761+
762+EXTRA_DIST = \
763+ $(doc_DATA) \
764+ dbusmenu-bench
765
766=== added file 'tools/README.dbusmenu-bench'
767--- tools/README.dbusmenu-bench 1970-01-01 00:00:00 +0000
768+++ tools/README.dbusmenu-bench 2010-02-05 19:30:27 +0000
769@@ -0,0 +1,27 @@
770+# Introduction
771+
772+dbusmenu-bench measures the time it takes to call various DBusMenu methods and
773+print the results on stdout. A test dbusmenu application must be started before
774+running dbusmenu-bench.
775+
776+A GLib test application is included in this archive. libdbusmenu-qt provides an
777+equivalent Qt test application. They both can load the same menu hierarchy from
778+a JSON file.
779+
780+# Using it
781+
782+1. Start dbusmenu-testapp:
783+
784+ dbusmenu-testapp /usr/share/libdbusmenu/json/test-gtk-label.json
785+
786+2. Run dbusmenu-bench
787+
788+ dbusmenu-bench --count 1000
789+
790+1000 is the number of times each DBusMenu method is called. Calling them 1000
791+times helps getting meaningful average values.
792+
793+3. Stop dbusmenu-testapp
794+
795+For debugging purpose, you can also run dbusmenu-bench with the "--dump"
796+parameter, which will dump the output of the called methods.

Subscribers

People subscribed via source and target branches

to all changes: