diff options
author | Ted Gould <ted@canonical.com> | 2009-09-09 17:09:10 -0500 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-09-09 17:09:10 -0500 |
commit | d40af5fcc3475404dcf4cc99d44be33e8d3c5e02 (patch) | |
tree | 5f69589e081c63bef9cd9754f5d42f75042a5404 /libdbusmenu-gtk | |
parent | dae396b4945bb73eb5a42833dc0b7293709fe17b (diff) | |
download | libdbusmenu-d40af5fcc3475404dcf4cc99d44be33e8d3c5e02.tar.gz libdbusmenu-d40af5fcc3475404dcf4cc99d44be33e8d3c5e02.tar.bz2 libdbusmenu-d40af5fcc3475404dcf4cc99d44be33e8d3c5e02.zip |
Some comments and when a root item is realized we're reordering it right away. This makes a lot more sense.
Diffstat (limited to 'libdbusmenu-gtk')
-rw-r--r-- | libdbusmenu-gtk/menu.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index 74e1bec..5bcf0a1 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -185,6 +185,9 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) /* Internal Functions */ +/* Called when a new child of the root item is + added. Sets up a signal for when it's actually + realized. */ static void root_child_added (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint position, DbusmenuGtkMenu * menu) { @@ -193,6 +196,8 @@ root_child_added (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint posit return; } +/* When one of the children move we need to react to that and + move it on the GTK side as well. */ static void root_child_moved (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint newposition, guint oldposition, DbusmenuGtkMenu * menu) { @@ -202,6 +207,7 @@ root_child_moved (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint newpo return; } +/* When a root child item disappears. */ static void root_child_delete (DbusmenuMenuitem * root, DbusmenuMenuitem * child, DbusmenuGtkMenu * menu) { @@ -212,6 +218,8 @@ root_child_delete (DbusmenuMenuitem * root, DbusmenuMenuitem * child, DbusmenuGt return; } +/* Called when the child is realized, and thus has all of it's + properties and GTK-isms. We can put it in our menu here. */ static void child_realized (DbusmenuMenuitem * child, gpointer userdata) { @@ -220,10 +228,20 @@ child_realized (DbusmenuMenuitem * child, gpointer userdata) DbusmenuGtkMenu * menu = DBUSMENU_GTKMENU(userdata); DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(menu); - gtk_menu_append(menu, GTK_WIDGET(dbusmenu_gtkclient_menuitem_get(priv->client, child))); + GtkWidget * child_widget = GTK_WIDGET(dbusmenu_gtkclient_menuitem_get(priv->client, child)); + + if (child_widget != NULL) { + gtk_menu_append(menu, child_widget); + gtk_menu_reorder_child(GTK_MENU(menu), child_widget, dbusmenu_menuitem_get_position(child, dbusmenu_client_get_root(DBUSMENU_CLIENT(priv->client)))); + } else { + g_warning("Child is realized, but doesn't have a GTK Widget!"); + } + return; } +/* When the root menuitem changes we need to resetup things so that + we're back in the game. */ static void root_changed (DbusmenuGtkClient * client, DbusmenuMenuitem * newroot, DbusmenuGtkMenu * menu) { if (newroot == NULL) { |