← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~ted/dbusmenu/reorder into lp:dbusmenu

 

Ted Gould has proposed merging lp:~ted/dbusmenu/reorder into lp:dbusmenu.

Requested reviews:
    DBus Menu Team (dbusmenu-team)

Fixing the reordering for the messaging menu.
-- 
https://code.launchpad.net/~ted/dbusmenu/reorder/+merge/11492
Your team ayatana-commits is subscribed to branch lp:dbusmenu.
=== modified file 'libdbusmenu-gtk/client.c'
--- libdbusmenu-gtk/client.c	2009-09-03 19:16:01 +0000
+++ libdbusmenu-gtk/client.c	2009-09-09 21:50:48 +0000
@@ -55,6 +55,7 @@
 /* GObject Stuff */
 G_DEFINE_TYPE (DbusmenuGtkClient, dbusmenu_gtkclient, DBUSMENU_TYPE_CLIENT);
 
+/* Basic build for the class.  Only a finalize and dispose handler. */
 static void
 dbusmenu_gtkclient_class_init (DbusmenuGtkClientClass *klass)
 {
@@ -66,6 +67,8 @@
 	return;
 }
 
+/* Registers the three times of menuitems that we're going to handle
+   for the gtk world.  And tracks when a new item gets added. */
 static void
 dbusmenu_gtkclient_init (DbusmenuGtkClient *self)
 {
@@ -78,6 +81,7 @@
 	return;
 }
 
+/* Just calling the super class.  Future use. */
 static void
 dbusmenu_gtkclient_dispose (GObject *object)
 {
@@ -86,6 +90,7 @@
 	return;
 }
 
+/* Just calling the super class.  Future use. */
 static void
 dbusmenu_gtkclient_finalize (GObject *object)
 {
@@ -159,9 +164,9 @@
 	return;
 }
 
-/* This takes a new DbusmenuMenuitem and attaches the
-   various things that we need to make it work in a 
-   GTK World.  */
+/* The new menuitem signal only happens if we don't have a type handler
+   for the type of the item.  This should be an error condition and we're
+   printing out a message. */
 static void
 new_menuitem (DbusmenuClient * client, DbusmenuMenuitem * mi, gpointer userdata)
 {
@@ -171,6 +176,22 @@
 	return;
 }
 
+/**
+	dbusmenu_gtkclient_newitem_base:
+	@client: The client handling everything on this connection
+	@item: The #DbusmenuMenuitem to attach the GTK-isms to
+	@gmi: A #GtkMenuItem representing the GTK world's view of this menuitem
+	@parent: The parent #DbusmenuMenuitem
+
+	This function provides some of the basic connectivity for being in
+	the GTK world.  Things like visibility and sensitivity of the item are
+	handled here so that the subclasses don't have to.  If you're building
+	your on GTK menu item you can use this function to apply those basic
+	attributes so that you don't have to deal with them either.
+
+	This also handles passing the "activate" signal back to the
+	#DbusmenuMenuitem side of thing.
+*/
 void
 dbusmenu_gtkclient_newitem_base (DbusmenuGtkClient * client, DbusmenuMenuitem * item, GtkMenuItem * gmi, DbusmenuMenuitem * parent)
 {
@@ -224,6 +245,7 @@
 static void
 delete_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, DbusmenuGtkClient * gtkclient)
 {
+	/* If it's a root item, we shouldn't be dealing with it here. */
 	if (dbusmenu_menuitem_get_root(mi)) { return; }
 
 	if (g_list_length(dbusmenu_menuitem_get_children(mi)) == 0) {
@@ -242,6 +264,7 @@
 static void
 move_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint new, guint old, DbusmenuGtkClient * gtkclient)
 {
+	/* If it's a root item, we shouldn't be dealing with it here. */
 	if (dbusmenu_menuitem_get_root(mi)) { return; }
 
 	gpointer ann_menu = g_object_get_data(G_OBJECT(mi), data_menu);

=== modified file 'libdbusmenu-gtk/menu.c'
--- libdbusmenu-gtk/menu.c	2009-08-27 13:49:11 +0000
+++ libdbusmenu-gtk/menu.c	2009-09-09 22:09:10 +0000
@@ -185,6 +185,9 @@
 
 /* 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 @@
 	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 @@
 	return;
 }
 
+/* When a root child item disappears. */
 static void
 root_child_delete (DbusmenuMenuitem * root, DbusmenuMenuitem * child, DbusmenuGtkMenu * menu)
 {
@@ -212,6 +218,8 @@
 	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 @@
 	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) {


Follow ups