aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-09-10 08:29:11 -0500
committerTed Gould <ted@canonical.com>2009-09-10 08:29:11 -0500
commit4360759bad53007488882164d7ca6586740e99f1 (patch)
tree5f69589e081c63bef9cd9754f5d42f75042a5404
parent8552d29bf3ead9866b1cc37da0945ea04fb5e5a5 (diff)
parentd40af5fcc3475404dcf4cc99d44be33e8d3c5e02 (diff)
downloadlibdbusmenu-4360759bad53007488882164d7ca6586740e99f1.tar.gz
libdbusmenu-4360759bad53007488882164d7ca6586740e99f1.tar.bz2
libdbusmenu-4360759bad53007488882164d7ca6586740e99f1.zip
Merging in a fix for reordering entries in the GTK menu object. And some comments.
-rw-r--r--libdbusmenu-gtk/client.c29
-rw-r--r--libdbusmenu-gtk/menu.c20
2 files changed, 45 insertions, 4 deletions
diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c
index 44d952d..901d739 100644
--- a/libdbusmenu-gtk/client.c
+++ b/libdbusmenu-gtk/client.c
@@ -55,6 +55,7 @@ static void process_sensitive (GtkMenuItem * gmi, const gchar * value);
/* 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 @@ dbusmenu_gtkclient_class_init (DbusmenuGtkClientClass *klass)
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 @@ dbusmenu_gtkclient_init (DbusmenuGtkClient *self)
return;
}
+/* Just calling the super class. Future use. */
static void
dbusmenu_gtkclient_dispose (GObject *object)
{
@@ -86,6 +90,7 @@ dbusmenu_gtkclient_dispose (GObject *object)
return;
}
+/* Just calling the super class. Future use. */
static void
dbusmenu_gtkclient_finalize (GObject *object)
{
@@ -159,9 +164,9 @@ destoryed_dbusmenuitem_cb (gpointer udata, GObject * dbusmenuitem)
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 @@ new_menuitem (DbusmenuClient * client, DbusmenuMenuitem * mi, gpointer userdata)
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 @@ new_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint position, Dbus
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 @@ delete_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, DbusmenuGtkClient
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);
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) {