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: 842 lines
11 files modified
.bzrignore (+6/-0)
configure.ac (+14/-3)
debian/changelog (+45/-0)
libdbusmenu-glib/client.c (+45/-1)
libdbusmenu-glib/menuitem.c (+38/-0)
libdbusmenu-gtk/Makefile.am (+1/-1)
libdbusmenu-gtk/client.c (+28/-6)
libdbusmenu-gtk/menu.c (+46/-0)
tests/Makefile.am (+61/-10)
tests/test-glib-simple-items.c (+9/-0)
tests/test-gtk-reorder-server.c (+119/-0)
To merge this branch: bzr merge lp:~dbusmenu-team/libdbusmenu/ubuntu
Reviewer Review Type Date Requested Status
Ken VanDine Approve
Review via email: mp+12808@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

0.1.6

Revision history for this message
Ken VanDine (ken-vandine) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2009-09-03 19:26:18 +0000
3+++ .bzrignore 2009-10-02 22:05:19 +0000
4@@ -43,3 +43,9 @@
5 mago.results
6 test-glib-simple-items
7 libdbusmenu-gtk/libdbusmenu_gtk_la-menuitem.lo
8+tests/test-glib-layout
9+tests/test-glib-properties
10+tests/test-gtk-label
11+tests/test-gtk-reorder-server.c
12+tests/test-gtk-reorder-server
13+tests/test-gtk-reorder
14
15=== modified file 'configure.ac'
16--- configure.ac 2009-09-24 21:07:24 +0000
17+++ configure.ac 2009-10-02 22:05:19 +0000
18@@ -1,11 +1,11 @@
19
20-AC_INIT(libdbusmenu, 0.1.5, ted@canonical.com)
21+AC_INIT(libdbusmenu, 0.1.6, ted@canonical.com)
22 AC_COPYRIGHT([Copyright 2009 Canonical])
23
24 AC_PREREQ(2.53)
25
26 AM_CONFIG_HEADER(config.h)
27-AM_INIT_AUTOMAKE(libdbusmenu, 0.1.5)
28+AM_INIT_AUTOMAKE(libdbusmenu, 0.1.6)
29
30 AM_MAINTAINER_MODE
31
32@@ -66,7 +66,7 @@
33 ###########################
34
35 LIBDBUSMENU_CURRENT=0
36-LIBDBUSMENU_REVISION=5
37+LIBDBUSMENU_REVISION=6
38 LIBDBUSMENU_AGE=0
39
40 AC_SUBST(LIBDBUSMENU_CURRENT)
41@@ -84,6 +84,16 @@
42 AM_GLIB_GNU_GETTEXT
43
44 ###########################
45+# Massive Debugging
46+###########################
47+
48+with_massivedebugging="no"
49+AC_ARG_ENABLE(massivedebugging, AS_HELP_STRING([--enable-massivedebugging], [Print out so much information your brain will hurt]), with_massivedebugging=$enableval, with_massivedebugging=no)
50+if test "x$with_massivedebugging" = "xyes"; then
51+ AC_DEFINE([MASSIVEDEBUGGING], [1], [Print everyting])
52+fi
53+
54+###########################
55 # Files
56 ###########################
57
58@@ -109,5 +119,6 @@
59 libdbusmenu Configuration:
60
61 Prefix: $prefix
62+ Massive Debugging: $with_massivedebugging
63 ])
64
65
66=== modified file 'debian/changelog'
67--- debian/changelog 2009-09-24 22:22:47 +0000
68+++ debian/changelog 2009-10-02 22:05:19 +0000
69@@ -1,3 +1,4 @@
70+<<<<<<< TREE
71 libdbusmenu (0.1.5-0ubuntu1) karmic; urgency=low
72
73 * New upstream release (LP: #436185)
74@@ -5,6 +6,50 @@
75 -- Ken VanDine <ken.vandine@canonical.com> Thu, 24 Sep 2009 17:12:25 -0400
76
77 libdbusmenu (0.1.4-0ubuntu1) karmic; urgency=low
78+=======
79+libdbusmenu (0.1.6-0ubuntu1~ppa1) karmic; urgency=low
80+
81+ * Upstream release 0.1.6
82+ * Managing the life-cycle of the GTK Menu item better to
83+ ensure that it is positioned correctly and dies
84+ appropriately. (LP: #430904 and LP: #419953)
85+ * Checking returned properties to ensure that there wasn't
86+ DBus errors. (LP: #433719)
87+
88+ -- Ted Gould <ted@ubuntu.com> Fri, 02 Oct 2009 17:00:45 -0500
89+
90+libdbusmenu (0.1.5-0ubuntu1~ppa1) karmic; urgency=low
91+
92+ * Upstream release 0.1.5
93+
94+ -- Ted Gould <ted@ubuntu.com> Thu, 24 Sep 2009 16:11:42 -0500
95+
96+libdbusmenu (0.1.4-0ubuntu2~ppa4) karmic; urgency=low
97+
98+ * Hooking up with trunk.
99+
100+ -- Ted Gould <ted@ubuntu.com> Thu, 24 Sep 2009 15:57:34 -0500
101+
102+libdbusmenu (0.1.4-0ubuntu2~ppa3) karmic; urgency=low
103+
104+ * Trying a revision ID
105+
106+ -- Ted Gould <ted@ubuntu.com> Mon, 21 Sep 2009 15:40:48 -0500
107+
108+libdbusmenu (0.1.4-0ubuntu2~ppa2) karmic; urgency=low
109+
110+ * Trying to double check the layout
111+
112+ -- Ted Gould <ted@ubuntu.com> Thu, 17 Sep 2009 16:14:16 -0500
113+
114+libdbusmenu (0.1.4-0ubuntu2~ppa1) karmic; urgency=low
115+
116+ * Signaling layout update on child moved
117+
118+ -- Ted Gould <ted@ubuntu.com> Thu, 17 Sep 2009 13:52:13 -0500
119+
120+libdbusmenu (0.1.4-0ubuntu1) UNRELEASED; urgency=low
121+>>>>>>> MERGE-SOURCE
122
123 * Upstream release (LP: #432003)
124 - Applying a fix by not blocking if we're calling for the root. Everyone
125
126=== modified file 'libdbusmenu-glib/client.c'
127--- libdbusmenu-glib/client.c 2009-09-21 20:38:02 +0000
128+++ libdbusmenu-glib/client.c 2009-10-02 22:05:19 +0000
129@@ -322,6 +322,10 @@
130 static void
131 id_prop_update (DBusGProxy * proxy, guint id, gchar * property, gchar * value, DbusmenuClient * client)
132 {
133+ #ifdef MASSIVEDEBUGGING
134+ g_debug("Property change sent to client for item %d property %s value %s", id, property, g_utf8_strlen(value, 50) < 25 ? value : "<too long>");
135+ #endif
136+
137 DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client);
138 g_return_if_fail(priv->root != NULL);
139
140@@ -337,6 +341,10 @@
141 static void
142 id_update (DBusGProxy * proxy, guint id, DbusmenuClient * client)
143 {
144+ #ifdef MASSIVEDEBUGGING
145+ g_debug("Client side ID update: %d", id);
146+ #endif
147+
148 DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client);
149 g_return_if_fail(priv->root != NULL);
150
151@@ -414,6 +422,9 @@
152 if (priv->root != NULL) {
153 g_object_unref(G_OBJECT(priv->root));
154 priv->root = NULL;
155+ #ifdef MASSIVEDEBUGGING
156+ g_debug("Proxies destroyed, signaling a root change and a layout update.");
157+ #endif
158 g_signal_emit(G_OBJECT(userdata), signals[ROOT_CHANGED], 0, NULL, TRUE);
159 g_signal_emit(G_OBJECT(userdata), signals[LAYOUT_UPDATED], 0, TRUE);
160 }
161@@ -565,6 +576,10 @@
162 static void
163 menuitem_get_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data)
164 {
165+ if (error != NULL) {
166+ g_warning("Error getting properties on a menuitem: %s", error->message);
167+ return;
168+ }
169 g_hash_table_foreach(properties, get_properties_helper, data);
170 g_hash_table_destroy(properties);
171 return;
172@@ -575,6 +590,10 @@
173 static void
174 menuitem_get_properties_new_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data)
175 {
176+ if (error != NULL) {
177+ g_warning("Error getting properties on a new menuitem: %s", error->message);
178+ return;
179+ }
180 g_return_if_fail(data != NULL);
181
182 newItemPropData * propdata = (newItemPropData *)data;
183@@ -598,6 +617,9 @@
184 handled = newfunc(propdata->item, propdata->parent, propdata->client);
185 }
186
187+ #ifdef MASSIVEDEBUGGING
188+ g_debug("Client has realized a menuitem: %d", dbusmenu_menuitem_get_id(propdata->item));
189+ #endif
190 g_signal_emit(G_OBJECT(propdata->item), DBUSMENU_MENUITEM_SIGNAL_REALIZED_ID, 0, TRUE);
191
192 if (!handled) {
193@@ -635,7 +657,9 @@
194 parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * parent, DBusGProxy * proxy)
195 {
196 guint id = parse_node_get_id(node);
197- /* g_debug("Looking at node with id: %d", id); */
198+ #ifdef MASSIVEDEBUGGING
199+ g_debug("Client looking at node with id: %d", id);
200+ #endif
201 if (item == NULL || dbusmenu_menuitem_get_id(item) != id || id == 0) {
202 if (item != NULL) {
203 if (parent != NULL) {
204@@ -699,7 +723,9 @@
205 GList * oldchildleft = NULL;
206 for (oldchildleft = oldchildren; oldchildleft != NULL; oldchildleft = g_list_next(oldchildleft)) {
207 DbusmenuMenuitem * oldmi = DBUSMENU_MENUITEM(oldchildleft->data);
208+ #ifdef MASSIVEDEBUGGING
209 g_debug("Unref'ing menu item with layout update. ID: %d", dbusmenu_menuitem_get_id(oldmi));
210+ #endif
211 g_object_unref(G_OBJECT(oldmi));
212 }
213 g_list_free(oldchildren);
214@@ -712,6 +738,10 @@
215 static gint
216 parse_layout (DbusmenuClient * client, const gchar * layout)
217 {
218+ #ifdef MASSIVEDEBUGGING
219+ g_debug("Client Parsing a new layout");
220+ #endif
221+
222 DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client);
223
224 xmlDocPtr xmldoc;
225@@ -730,6 +760,9 @@
226 }
227
228 if (priv->root != oldroot) {
229+ #ifdef MASSIVEDEBUGGING
230+ g_debug("Client signaling root changed.");
231+ #endif
232 g_signal_emit(G_OBJECT(client), signals[ROOT_CHANGED], 0, priv->root, TRUE);
233 }
234
235@@ -764,6 +797,9 @@
236
237 priv->my_revision = rev;
238 /* g_debug("Root is now: 0x%X", (unsigned int)priv->root); */
239+ #ifdef MASSIVEDEBUGGING
240+ g_debug("Client signaling layout has changed.");
241+ #endif
242 g_signal_emit(G_OBJECT(client), signals[LAYOUT_UPDATED], 0, TRUE);
243
244 if (priv->my_revision < priv->current_revision) {
245@@ -852,6 +888,10 @@
246 return NULL;
247 }
248
249+ #ifdef MASSIVEDEBUGGING
250+ g_debug("Client get root: %X", (guint)priv->root);
251+ #endif
252+
253 return priv->root;
254 }
255
256@@ -884,6 +924,10 @@
257
258 DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client);
259
260+ #ifdef MASSIVEDEBUGGING
261+ g_debug("Adding a type handler for '%s'", type);
262+ #endif
263+
264 if (priv->type_handlers == NULL) {
265 g_warning("Type handlers hashtable not built");
266 return FALSE;
267
268=== modified file 'libdbusmenu-glib/menuitem.c'
269--- libdbusmenu-glib/menuitem.c 2009-09-21 20:01:40 +0000
270+++ libdbusmenu-glib/menuitem.c 2009-10-02 22:05:19 +0000
271@@ -32,6 +32,11 @@
272 #include "menuitem.h"
273 #include "menuitem-marshal.h"
274
275+#ifdef MASSIVEDEBUGGING
276+#define LABEL(x) dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(x), DBUSMENU_MENUITEM_PROP_LABEL)
277+#define ID(x) dbusmenu_menuitem_get_id(DBUSMENU_MENUITEM(x))
278+#endif
279+
280 /* Private */
281 /**
282 DbusmenuMenuitemPrivate:
283@@ -362,6 +367,9 @@
284 static void
285 take_children_signal (gpointer data, gpointer user_data)
286 {
287+ #ifdef MASSIVEDEBUGGING
288+ g_debug("Menuitem %d (%s) signalling child removed %d (%s)", ID(user_data), LABEL(user_data), ID(data), LABEL(data));
289+ #endif
290 g_signal_emit(G_OBJECT(user_data), signals[CHILD_REMOVED], 0, DBUSMENU_MENUITEM(data), TRUE);
291 return;
292 }
293@@ -404,6 +412,11 @@
294 guint
295 dbusmenu_menuitem_get_position (DbusmenuMenuitem * mi, DbusmenuMenuitem * parent)
296 {
297+ #ifdef MASSIVEDEBUGGING
298+ if (!DBUSMENU_IS_MENUITEM(mi)) g_warning("Getting position of %d (%s), it's at: %d (mi fail)", ID(mi), LABEL(mi), 0);
299+ if (!DBUSMENU_IS_MENUITEM(parent)) g_warning("Getting position of %d (%s), it's at: %d (parent fail)", ID(mi), LABEL(mi), 0);
300+ #endif
301+
302 /* TODO: I'm not too happy returning zeros here. But that's all I've got */
303 g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), 0);
304 g_return_val_if_fail(DBUSMENU_IS_MENUITEM(parent), 0);
305@@ -417,6 +430,10 @@
306
307 if (childs == NULL) return 0;
308
309+ #ifdef MASSIVEDEBUGGING
310+ g_debug("Getting position of %d (%s), it's at: %d", ID(mi), LABEL(mi), count);
311+ #endif
312+
313 return count;
314 }
315
316@@ -438,6 +455,9 @@
317
318 DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi);
319 priv->children = g_list_append(priv->children, child);
320+ #ifdef MASSIVEDEBUGGING
321+ 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);
322+ #endif
323 g_signal_emit(G_OBJECT(mi), signals[CHILD_ADDED], 0, child, g_list_length(priv->children) - 1, TRUE);
324 return TRUE;
325 }
326@@ -460,6 +480,9 @@
327
328 DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi);
329 priv->children = g_list_prepend(priv->children, child);
330+ #ifdef MASSIVEDEBUGGING
331+ g_debug("Menuitem %d (%s) signalling child added %d (%s) at %d", ID(mi), LABEL(mi), ID(child), LABEL(child), 0);
332+ #endif
333 g_signal_emit(G_OBJECT(mi), signals[CHILD_ADDED], 0, child, 0, TRUE);
334 return TRUE;
335 }
336@@ -483,6 +506,9 @@
337
338 DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi);
339 priv->children = g_list_remove(priv->children, child);
340+ #ifdef MASSIVEDEBUGGING
341+ g_debug("Menuitem %d (%s) signalling child removed %d (%s)", ID(mi), LABEL(mi), ID(child), LABEL(child));
342+ #endif
343 g_signal_emit(G_OBJECT(mi), signals[CHILD_REMOVED], 0, child, TRUE);
344 return TRUE;
345 }
346@@ -507,6 +533,9 @@
347
348 DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi);
349 priv->children = g_list_insert(priv->children, child, position);
350+ #ifdef MASSIVEDEBUGGING
351+ g_debug("Menuitem %d (%s) signalling child added %d (%s) at %d", ID(mi), LABEL(mi), ID(child), LABEL(child), position);
352+ #endif
353 g_signal_emit(G_OBJECT(mi), signals[CHILD_ADDED], 0, child, position, TRUE);
354 return TRUE;
355 }
356@@ -543,6 +572,9 @@
357 priv->children = g_list_remove(priv->children, child);
358 priv->children = g_list_insert(priv->children, child, position);
359
360+ #ifdef MASSIVEDEBUGGING
361+ g_debug("Menuitem %d (%s) signalling child %d (%s) moved from %d to %d", ID(mi), LABEL(mi), ID(child), LABEL(child), oldpos, position);
362+ #endif
363 g_signal_emit(G_OBJECT(mi), signals[CHILD_MOVED], 0, child, position, oldpos, TRUE);
364
365 return TRUE;
366@@ -658,6 +690,9 @@
367 gchar * lval = g_strdup(value);
368
369 g_hash_table_insert(priv->properties, lprop, lval);
370+ #ifdef MASSIVEDEBUGGING
371+ g_debug("Menuitem %d (%s) signalling property '%s' changed to '%s'", ID(mi), LABEL(mi), property, g_utf8_strlen(value, 50) < 25 ? value : "<too long>");
372+ #endif
373 g_signal_emit(G_OBJECT(mi), signals[PROPERTY_CHANGED], 0, property, value, TRUE);
374
375 return TRUE;
376@@ -882,6 +917,9 @@
377 dbusmenu_menuitem_activate (DbusmenuMenuitem * mi)
378 {
379 g_return_if_fail(DBUSMENU_IS_MENUITEM(mi));
380+ #ifdef MASSIVEDEBUGGING
381+ g_debug("Menuitem %d (%s) activated", ID(mi), LABEL(mi));
382+ #endif
383 g_signal_emit(G_OBJECT(mi), signals[ITEM_ACTIVATED], 0, TRUE);
384 return;
385 }
386
387=== modified file 'libdbusmenu-gtk/Makefile.am'
388--- libdbusmenu-gtk/Makefile.am 2009-09-02 18:29:01 +0000
389+++ libdbusmenu-gtk/Makefile.am 2009-10-02 22:05:19 +0000
390@@ -26,7 +26,7 @@
391 -export-symbols-regex "^[^_].*"
392
393 libdbusmenu_gtk_la_CFLAGS = \
394- $(DBUSMENUGTK_CFLAGS) -I$(srcdir)/.. -Wall -Werror
395+ $(DBUSMENUGTK_CFLAGS) -I$(srcdir)/.. -Wall -Werror -DG_DISABLE_DEPRECATED -DG_LOG_DOMAIN="\"LIBDBUSMENU-GTK\""
396
397 libdbusmenu_gtk_la_LIBADD = \
398 ../libdbusmenu-glib/libdbusmenu-glib.la \
399
400=== modified file 'libdbusmenu-gtk/client.c'
401--- libdbusmenu-gtk/client.c 2009-09-09 21:50:48 +0000
402+++ libdbusmenu-gtk/client.c 2009-10-02 22:05:19 +0000
403@@ -159,7 +159,9 @@
404 static void
405 destoryed_dbusmenuitem_cb (gpointer udata, GObject * dbusmenuitem)
406 {
407- /* g_debug("DbusmenuMenuitem was destroyed"); */
408+ #ifdef MASSIVEDEBUGGING
409+ g_debug("DbusmenuMenuitem was destroyed");
410+ #endif
411 gtk_widget_destroy(GTK_WIDGET(udata));
412 return;
413 }
414@@ -176,6 +178,15 @@
415 return;
416 }
417
418+#ifdef MASSIVEDEBUGGING
419+static void
420+destroy_gmi (GtkMenuItem * gmi, DbusmenuMenuitem * mi)
421+{
422+ g_debug("Destorying GTK Menuitem for %d", dbusmenu_menuitem_get_id(mi));
423+ return;
424+}
425+#endif
426+
427 /**
428 dbusmenu_gtkclient_newitem_base:
429 @client: The client handling everything on this connection
430@@ -195,8 +206,16 @@
431 void
432 dbusmenu_gtkclient_newitem_base (DbusmenuGtkClient * client, DbusmenuMenuitem * item, GtkMenuItem * gmi, DbusmenuMenuitem * parent)
433 {
434+ #ifdef MASSIVEDEBUGGING
435+ g_debug("GTK Client new item base for %d", dbusmenu_menuitem_get_id(item));
436+ #endif
437+
438 /* Attach these two */
439 g_object_set_data(G_OBJECT(item), data_menuitem, gmi);
440+ g_object_ref(G_OBJECT(gmi));
441+ #ifdef MASSIVEDEBUGGING
442+ g_signal_connect(G_OBJECT(gmi), "destroy", G_CALLBACK(destroy_gmi), item);
443+ #endif
444
445 /* DbusmenuMenuitem signals */
446 g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(menu_prop_change_cb), gmi);
447@@ -222,6 +241,10 @@
448 static void
449 new_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint position, DbusmenuGtkClient * gtkclient)
450 {
451+ #ifdef MASSIVEDEBUGGING
452+ g_debug("GTK Client new child for %d on %d at %d", dbusmenu_menuitem_get_id(mi), dbusmenu_menuitem_get_id(child), position);
453+ #endif
454+
455 if (dbusmenu_menuitem_get_root(mi)) { return; }
456
457 gpointer ann_menu = g_object_get_data(G_OBJECT(mi), data_menu);
458@@ -316,14 +339,13 @@
459 g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), NULL);
460 g_return_val_if_fail(DBUSMENU_IS_MENUITEM(item), NULL);
461
462- GtkMenuItem * mi = GTK_MENU_ITEM(g_object_get_data(G_OBJECT(item), data_menuitem));
463- if (mi == NULL) {
464- // new_menuitem(DBUSMENU_CLIENT(client), item, NULL);
465+ gpointer data = g_object_get_data(G_OBJECT(item), data_menuitem);
466+ if (data == NULL) {
467 g_warning("GTK not updated");
468- mi = GTK_MENU_ITEM(g_object_get_data(G_OBJECT(item), data_menuitem));
469+ return NULL;
470 }
471
472- return mi;
473+ return GTK_MENU_ITEM(data);
474 }
475
476 /* The base type handler that builds a plain ol'
477
478=== modified file 'libdbusmenu-gtk/menu.c'
479--- libdbusmenu-gtk/menu.c 2009-09-09 22:09:10 +0000
480+++ libdbusmenu-gtk/menu.c 2009-10-02 22:05:19 +0000
481@@ -185,6 +185,28 @@
482
483 /* Internal Functions */
484
485+#ifdef MASSIVEDEBUGGING
486+typedef struct {
487+ GtkMenuItem * mi;
488+ gint finalpos;
489+ gboolean found;
490+} menu_pos_t;
491+
492+static void
493+find_pos (GtkWidget * widget, gpointer data)
494+{
495+ menu_pos_t * menu_pos = (menu_pos_t *)data;
496+ if (menu_pos->found) return;
497+ if ((gpointer)(menu_pos->mi) == (gpointer)widget) {
498+ menu_pos->found = TRUE;
499+ } else {
500+ menu_pos->finalpos++;
501+ }
502+ return;
503+}
504+#endif
505+
506+
507 /* Called when a new child of the root item is
508 added. Sets up a signal for when it's actually
509 realized. */
510@@ -192,7 +214,24 @@
511 root_child_added (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint position, DbusmenuGtkMenu * menu)
512 {
513 g_debug("Root new child");
514+ DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(menu);
515+
516 g_signal_connect(G_OBJECT(child), DBUSMENU_MENUITEM_SIGNAL_REALIZED, G_CALLBACK(child_realized), menu);
517+
518+ GtkMenuItem * mi = dbusmenu_gtkclient_menuitem_get(priv->client, child);
519+ if (mi != NULL) {
520+ GtkWidget * item = GTK_WIDGET(mi);
521+ gtk_menu_insert(GTK_MENU(menu), item, position);
522+ #ifdef MASSIVEDEBUGGING
523+ menu_pos_t menu_pos;
524+ menu_pos.mi = mi;
525+ menu_pos.finalpos = 0;
526+ menu_pos.found = FALSE;
527+
528+ gtk_container_foreach(GTK_CONTAINER(menu), find_pos, &menu_pos);
529+ g_debug("Menu position requested was %d but got %d", position, menu_pos.finalpos);
530+ #endif
531+ }
532 return;
533 }
534
535@@ -212,6 +251,12 @@
536 root_child_delete (DbusmenuMenuitem * root, DbusmenuMenuitem * child, DbusmenuGtkMenu * menu)
537 {
538 g_debug("Root child deleted");
539+ DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(menu);
540+ GtkWidget * item = GTK_WIDGET(dbusmenu_gtkclient_menuitem_get(priv->client, child));
541+ if (item != NULL) {
542+ gtk_container_remove(GTK_CONTAINER(menu), item);
543+ }
544+
545 if (g_list_length(dbusmenu_menuitem_get_children(root)) == 0) {
546 gtk_widget_hide(GTK_WIDGET(menu));
547 }
548@@ -223,6 +268,7 @@
549 static void
550 child_realized (DbusmenuMenuitem * child, gpointer userdata)
551 {
552+ g_debug("Root child realized");
553 g_return_if_fail(DBUSMENU_IS_GTKMENU(userdata));
554
555 DbusmenuGtkMenu * menu = DBUSMENU_GTKMENU(userdata);
556
557=== modified file 'tests/Makefile.am'
558--- tests/Makefile.am 2009-07-01 05:34:05 +0000
559+++ tests/Makefile.am 2009-10-02 22:05:19 +0000
560@@ -1,12 +1,15 @@
561 SUBDIRS = dbusmenu-gtk
562
563-check: tests
564-
565 DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf
566
567-tests: test-glib-layout test-glib-properties test-gtk-label test-glib-simple-items
568+TESTS = \
569+ test-glib-layout \
570+ test-glib-properties \
571+ test-gtk-label \
572+ test-glib-simple-items \
573+ test-gtk-reorder
574
575-libexec_PROGRAMS = \
576+check_PROGRAMS = \
577 glib-server-nomenu \
578 test-glib-layout-client \
579 test-glib-layout-server \
580@@ -14,7 +17,8 @@
581 test-glib-properties-server \
582 test-gtk-label-client \
583 test-gtk-label-server \
584- test-glib-simple-items
585+ test-glib-simple-items \
586+ test-gtk-reorder-server
587
588 glib_server_nomenu_SOURCES = \
589 glib-server-nomenu.c
590@@ -27,10 +31,14 @@
591 ../libdbusmenu-glib/libdbusmenu-glib.la \
592 $(DBUSMENUGLIB_LIBS)
593
594-
595+######################
596+# Test Glib Layout
597+######################
598
599 test-glib-layout: test-glib-layout-client test-glib-layout-server
600- $(DBUS_RUNNER) --task ./test-glib-layout-client --task-name Client --task ./test-glib-layout-server --task-name Server --ignore-return
601+ @echo "#!/bin/sh" > test-glib-layout
602+ @echo $(DBUS_RUNNER) --task ./test-glib-layout-client --task-name Client --task ./test-glib-layout-server --task-name Server --ignore-return >> test-glib-layout
603+ @chmod +x test-glib-layout
604
605 test_glib_layout_server_SOURCES = \
606 test-glib-layout.h \
607@@ -57,9 +65,14 @@
608 $(DBUSMENUGLIB_LIBS)
609
610
611+######################
612+# Test Glib Properties
613+######################
614
615 test-glib-properties: test-glib-properties-client test-glib-properties-server
616- $(DBUS_RUNNER) --task ./test-glib-properties-client --task-name Client --task ./test-glib-properties-server --task-name Server --ignore-return
617+ @echo "#!/bin/sh" > test-glib-properties
618+ @echo $(DBUS_RUNNER) --task ./test-glib-properties-client --task-name Client --task ./test-glib-properties-server --task-name Server --ignore-return >> test-glib-properties
619+ @chmod +x test-glib-properties
620
621 test_glib_properties_server_SOURCES = \
622 test-glib-properties.h \
623@@ -85,6 +98,9 @@
624 ../libdbusmenu-glib/libdbusmenu-glib.la \
625 $(DBUSMENUGLIB_LIBS)
626
627+#########################
628+# Test Glib Simple Items
629+#########################
630
631 test_glib_simple_items_SOURCES = \
632 test-glib-simple-items.c
633@@ -97,9 +113,14 @@
634 ../libdbusmenu-glib/libdbusmenu-glib.la \
635 $(DBUSMENUGLIB_LIBS)
636
637+#########################
638+# Test GTK Label
639+#########################
640
641 test-gtk-label: test-gtk-label-client test-gtk-label-server test-gtk-label.json
642- $(DBUS_RUNNER) --task ./test-gtk-label-client --task-name Client --task ./test-gtk-label-server --parameter $(srcdir)/test-gtk-label.json --task-name Server --ignore-return
643+ @echo "#!/bin/sh" > test-gtk-label
644+ @echo $(DBUS_RUNNER) --task ./test-gtk-label-client --task-name Client --task ./test-gtk-label-server --parameter $(srcdir)/test-gtk-label.json --task-name Server --ignore-return >> test-gtk-label
645+ @chmod +x test-gtk-label
646
647 test_gtk_label_server_SOURCES = \
648 test-gtk-label-server.c
649@@ -131,7 +152,34 @@
650 $(DBUSMENUGTK_LIBS) \
651 $(DBUSMENUTESTS_LIBS)
652
653-
654+#########################
655+# Test GTK Reorder
656+#########################
657+
658+test-gtk-reorder: test-gtk-label-client test-gtk-reorder-server
659+ @echo "#!/bin/sh" > test-gtk-reorder
660+ @echo $(DBUS_RUNNER) --task ./test-gtk-label-client --task-name Client --task ./test-gtk-reorder-server --parameter $(srcdir)/test-gtk-label.json --task-name Server --ignore-return >> test-gtk-reorder
661+ @chmod +x test-gtk-reorder
662+
663+test_gtk_reorder_server_SOURCES = \
664+ test-gtk-reorder-server.c
665+
666+test_gtk_reorder_server_CFLAGS = \
667+ -I $(srcdir)/.. \
668+ $(DBUSMENUGTK_CFLAGS) \
669+ $(DBUSMENUTESTS_CFLAGS) \
670+ $(DBUSMENUGLIB_CFLAGS) -Wall -Werror
671+
672+test_gtk_reorder_server_LDADD = \
673+ ../libdbusmenu-glib/libdbusmenu-glib.la \
674+ ../libdbusmenu-gtk/libdbusmenu-gtk.la \
675+ $(DBUSMENUGTK_LIBS) \
676+ $(DBUSMENUTESTS_LIBS)
677+
678+
679+#########################
680+# Other
681+#########################
682
683 examplesdir = $(docdir)/examples/
684
685@@ -141,3 +189,6 @@
686 EXTRA_DIST = \
687 $(examples_DATA) \
688 test-gtk-label.json
689+
690+DISTCLEANFILES = \
691+ $(TESTS)
692
693=== modified file 'tests/test-glib-simple-items.c'
694--- tests/test-glib-simple-items.c 2009-07-01 05:34:05 +0000
695+++ tests/test-glib-simple-items.c 2009-10-02 22:05:19 +0000
696@@ -25,6 +25,13 @@
697 return;
698 }
699
700+static gboolean
701+quititall (gpointer data)
702+{
703+ g_main_quit(mainloop);
704+ return FALSE;
705+}
706+
707 int
708 main (int argc, char ** argv)
709 {
710@@ -37,6 +44,8 @@
711
712 dummy_users(root_menuitem);
713
714+ g_timeout_add_seconds(1, quititall, NULL);
715+
716 mainloop = g_main_loop_new(NULL, FALSE);
717 g_main_loop_run(mainloop);
718
719
720=== added file 'tests/test-gtk-reorder-server.c'
721--- tests/test-gtk-reorder-server.c 1970-01-01 00:00:00 +0000
722+++ tests/test-gtk-reorder-server.c 2009-10-02 22:05:19 +0000
723@@ -0,0 +1,119 @@
724+/*
725+A test for libdbusmenu to ensure its quality.
726+
727+Copyright 2009 Canonical Ltd.
728+
729+Authors:
730+ Ted Gould <ted@canonical.com>
731+
732+This program is free software: you can redistribute it and/or modify it
733+under the terms of the GNU General Public License version 3, as published
734+by the Free Software Foundation.
735+
736+This program is distributed in the hope that it will be useful, but
737+WITHOUT ANY WARRANTY; without even the implied warranties of
738+MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
739+PURPOSE. See the GNU General Public License for more details.
740+
741+You should have received a copy of the GNU General Public License along
742+with this program. If not, see <http://www.gnu.org/licenses/>.
743+*/
744+
745+#include <glib.h>
746+
747+#include <dbus/dbus.h>
748+#include <dbus/dbus-glib.h>
749+#include <dbus/dbus-glib-lowlevel.h>
750+#include <dbus/dbus-glib-bindings.h>
751+
752+#include <libdbusmenu-glib/menuitem.h>
753+#include <libdbusmenu-glib/server.h>
754+
755+#define NUMBER_TESTS 5
756+#define NUMBER_ENTRIES 5
757+
758+guint ordering [NUMBER_TESTS][NUMBER_ENTRIES] = {
759+ {0, 1, 2, 3, 4},
760+ {1, 2, 3, 4, 0},
761+ {3, 1, 4, 2, 0},
762+ {4, 3, 2, 1, 0},
763+ {0, 1, 2, 3, 4}
764+};
765+
766+gchar * names [NUMBER_ENTRIES] = {
767+ "One", "Two", "Three", "Four", "Five"
768+};
769+
770+DbusmenuMenuitem * entries[NUMBER_ENTRIES] = {0};
771+DbusmenuMenuitem * root = NULL;
772+
773+gint test = 0;
774+
775+static DbusmenuServer * server = NULL;
776+static GMainLoop * mainloop = NULL;
777+
778+static gboolean
779+timer_func (gpointer data)
780+{
781+ if (test == NUMBER_TESTS) {
782+ g_main_quit(mainloop);
783+ return FALSE;
784+ }
785+
786+ g_debug("Testing pattern %d", test);
787+
788+ int i;
789+ for (i = 0; i < NUMBER_ENTRIES; i++) {
790+ g_debug("Putting entry '%d' at position '%d'", i, ordering[test][i]);
791+ dbusmenu_menuitem_child_reorder(root, entries[i], ordering[test][i]);
792+ dbusmenu_menuitem_property_set(entries[i], "label", names[i]);
793+ }
794+
795+ test++;
796+ return TRUE;
797+}
798+
799+int
800+main (int argc, char ** argv)
801+{
802+ GError * error = NULL;
803+
804+ g_type_init();
805+
806+ DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
807+ g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL))));
808+
809+ DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
810+ guint nameret = 0;
811+
812+ if (!org_freedesktop_DBus_request_name(bus_proxy, "glib.label.test", 0, &nameret, &error)) {
813+ g_error("Unable to call to request name");
814+ return 1;
815+ }
816+
817+ if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
818+ g_error("Unable to get name");
819+ return 1;
820+ }
821+
822+ server = dbusmenu_server_new("/org/test");
823+ root = dbusmenu_menuitem_new();
824+ dbusmenu_server_set_root(server, root);
825+
826+ int i;
827+ for (i = 0; i < NUMBER_ENTRIES; i++) {
828+ entries[i] = dbusmenu_menuitem_new();
829+ dbusmenu_menuitem_child_append(root, entries[i]);
830+ }
831+
832+ timer_func(NULL);
833+ g_timeout_add_seconds(5, timer_func, NULL);
834+
835+ mainloop = g_main_loop_new(NULL, FALSE);
836+ g_main_loop_run(mainloop);
837+
838+ g_debug("Quiting");
839+
840+ return 0;
841+}
842+

Subscribers

People subscribed via source and target branches

to all changes: