From 5040095814d0bf27a6aa2e8b3f3f9a5c1c02f38a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 1 Oct 2009 20:44:05 -0500 Subject: Reporting on the request pos vs. the actual. --- libdbusmenu-gtk/menu.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-gtk/menu.c') diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index 8f97294..2dd7a6e 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -185,6 +185,28 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) /* Internal Functions */ +#ifdef MASSIVEDEBUGGING +typedef struct { + GtkMenuItem * mi; + gint finalpos; + gboolean found; +} menu_pos_t; + +static void +find_pos (GtkWidget * widget, gpointer data) +{ + menu_pos_t * menu_pos = (menu_pos_t *)data; + if (menu_pos->found) return; + if ((gpointer)(menu_pos->mi) == (gpointer)widget) { + menu_pos->found = TRUE; + } else { + menu_pos->finalpos++; + } + return; +} +#endif + + /* Called when a new child of the root item is added. Sets up a signal for when it's actually realized. */ @@ -199,8 +221,16 @@ root_child_added (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint posit GtkMenuItem * mi = dbusmenu_gtkclient_menuitem_get(priv->client, child); if (mi != NULL) { GtkWidget * item = GTK_WIDGET(mi); - gtk_menu_append(GTK_MENU(menu), item); - gtk_menu_reorder_child(GTK_MENU(menu), item, dbusmenu_menuitem_get_position(root, child)); + gtk_menu_insert(GTK_MENU(menu), item, position); + #ifdef MASSIVEDEBUGGING + menu_pos_t menu_pos; + menu_pos.mi = mi; + menu_pos.finalpos = 0; + menu_pos.found = FALSE; + + gtk_container_foreach(GTK_CONTAINER(menu), find_pos, &menu_pos); + g_debug("Menu position requested was %d but got %d", position, menu_pos.finalpos); + #endif } return; } -- cgit v1.2.3