From 9ce6eb561b1a9e188330fe73952bbc1a3d2e256f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 23:09:19 +0200 Subject: Playing with debug stuff --- libdbusmenu-glib/client.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index c6833cc..f21f721 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -387,6 +387,7 @@ parse_layout_xml(xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * pa dbusmenu_menuitem_child_delete(parent, item); } g_object_unref(G_OBJECT(item)); + item = NULL; } if (id == 0) { @@ -403,6 +404,7 @@ parse_layout_xml(xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * pa xmlNodePtr children; guint position; GList * oldchildren = dbusmenu_menuitem_take_children(item); + /* g_debug("Starting old children: %d", g_list_length(oldchildren)); */ for (children = node->children, position = 0; children != NULL; children = children->next, position++) { /* g_debug("Looking at child: %d", position); */ @@ -423,9 +425,11 @@ parse_layout_xml(xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * pa dbusmenu_menuitem_child_add_position(item, childmi, position); } + /* g_debug("Stopping old children: %d", g_list_length(oldchildren)); */ GList * oldchildleft = NULL; for (oldchildleft = oldchildren; oldchildleft != NULL; oldchildleft = g_list_next(oldchildleft)) { DbusmenuMenuitem * oldmi = DBUSMENU_MENUITEM(oldchildleft->data); + g_debug("Unref'ing menu item with layout update. ID: %d", dbusmenu_menuitem_get_id(oldmi)); g_object_unref(G_OBJECT(oldmi)); } g_list_free(oldchildren); -- cgit v1.2.3 From 59e8bba4ca5c9164fcbc886af94e6e2c627d523e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 23:15:16 +0200 Subject: Unref'ing root when we dispose --- libdbusmenu-glib/client.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index f21f721..61f8c34 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -169,6 +169,11 @@ dbusmenu_client_dispose (GObject *object) } priv->session_bus = NULL; + if (priv->root != NULL) { + g_object_unref(G_OBJECT(priv->root)); + priv->root = NULL; + } + G_OBJECT_CLASS (dbusmenu_client_parent_class)->dispose (object); return; } -- cgit v1.2.3 From a0ba99c7840a0db2eb957138854050060221a8df Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Jun 2009 15:28:54 -0500 Subject: Handling the concept of not having a property proxy. --- libdbusmenu-glib/client.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 61f8c34..ea77cc3 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -499,6 +499,10 @@ update_layout (DbusmenuClient * client) { DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); + if (priv->propproxy == NULL) { + return; + } + if (priv->layoutcall != NULL) { return; } @@ -554,7 +558,8 @@ dbusmenu_client_new (const gchar * name, const gchar * object) it could block longer. Return value: A #DbusmenuMenuitem representing the root of - menu on the server. + menu on the server. If there is no server or there is + an error receiving its layout it'll return #NULL. */ DbusmenuMenuitem * dbusmenu_client_get_root (DbusmenuClient * client) @@ -563,6 +568,10 @@ dbusmenu_client_get_root (DbusmenuClient * client) DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); + if (priv->propproxy == NULL) { + return NULL; + } + if (priv->layoutcall != NULL) { /* Will end the current call and block on it's completion */ update_layout_cb(priv->propproxy, priv->layoutcall, client); -- cgit v1.2.3 From 6b29e7e5a258644cc0c82963aab5d167748f8af2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Jun 2009 16:30:13 -0500 Subject: If we can't get a proxy on the stuff that we want, we're going to set up a DBus one and just wait for it to show up. When it showes up, then we'll pounce --- libdbusmenu-glib/client.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index ea77cc3..fec495d 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -64,6 +64,8 @@ struct _DbusmenuClientPrivate DBusGProxy * menuproxy; DBusGProxy * propproxy; DBusGProxyCall * layoutcall; + + DBusGProxy * dbusproxy; }; #define DBUSMENU_CLIENT_GET_PRIVATE(o) \ @@ -147,6 +149,8 @@ dbusmenu_client_init (DbusmenuClient *self) priv->propproxy = NULL; priv->layoutcall = NULL; + priv->dbusproxy = NULL; + return; } @@ -167,6 +171,10 @@ dbusmenu_client_dispose (GObject *object) g_object_unref(G_OBJECT(priv->propproxy)); priv->propproxy = NULL; } + if (priv->dbusproxy != NULL) { + g_object_unref(G_OBJECT(priv->dbusproxy)); + priv->dbusproxy = NULL; + } priv->session_bus = NULL; if (priv->root != NULL) { @@ -276,6 +284,62 @@ id_update (DBusGProxy * proxy, guint id, DbusmenuClient * client) return; } +/* Watches to see if our DBus savior comes onto the bus */ +static void +dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, DbusmenuClient * client) +{ + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); + + if (!(new != NULL && prev == NULL)) { + /* If it's not someone new getting on the bus, sorry we + simply just don't care. It's not that your service isn't + important to someone, just not us. You'll find the right + process someday, there's lots of processes out there. */ + return; + } + + if (g_strcmp0(new, priv->dbus_name)) { + /* Again, someone else's service. */ + return; + } + + /* Woot! A service for us to love and to hold for ever + and ever and ever! */ + return build_proxies(client); +} + +/* This function builds the DBus proxy which will look out for + the service coming up. */ +static void +build_dbus_proxy (DbusmenuClient * client) +{ + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); + GError * error = NULL; + + if (priv->dbusproxy != NULL) { + return; + } + + priv->dbusproxy = dbus_g_proxy_new_for_name_owner (priv->session_bus, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS, + &error); + if (error != NULL) { + g_debug("Oh, that's bad. That's really bad. We can't get a proxy to DBus itself? Seriously? Here's all I know: %s", error->message); + g_error_free(error); + return; + } + + dbus_g_proxy_add_signal(priv->dbusproxy, "NameOwnerChanged", + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal(priv->dbusproxy, "NameOwnerChanged", + G_CALLBACK(dbus_owner_change), client, NULL); + + return; +} + /* When we have a name and an object, build the two proxies and get the first version of the layout */ static void @@ -291,6 +355,7 @@ build_proxies (DbusmenuClient * client) if (error != NULL) { g_error("Unable to get session bus: %s", error->message); g_error_free(error); + build_dbus_proxy(client); return; } @@ -304,6 +369,7 @@ build_proxies (DbusmenuClient * client) g_error_free(error); return; } + // g_signal_connect(G_OBJECT(priv->propproxy), "destroy", proxy_destroyed, client); priv->menuproxy = dbus_g_proxy_new_for_name_owner(priv->session_bus, priv->dbus_name, @@ -315,6 +381,13 @@ build_proxies (DbusmenuClient * client) g_error_free(error); return; } + // g_signal_connect(G_OBJECT(priv->menuproxy), "destroy", proxy_destroyed, client); + + /* If we get here, we don't need the DBus proxy */ + if (priv->dbusproxy != NULL) { + g_object_unref(G_OBJECT(priv->dbusproxy)); + priv->dbusproxy = NULL; + } dbus_g_proxy_add_signal(priv->menuproxy, "LayoutUpdate", G_TYPE_INVALID); dbus_g_proxy_connect_signal(priv->menuproxy, "LayoutUpdate", G_CALLBACK(layout_update), client, NULL); -- cgit v1.2.3 From f56565b09f6747442f94f0218466f1a3d6b8869d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Jun 2009 16:54:25 -0500 Subject: Handle the server removing itself from the bus and putting us into a dark world waiting for it to rejoin the world. --- libdbusmenu-glib/client.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index fec495d..043bf43 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -340,6 +340,27 @@ build_dbus_proxy (DbusmenuClient * client) return; } +/* A signal handler that gets called when a proxy is destoryed a + so it needs to clean up a little. Make sure we don't think we + have a layout and setup the dbus watcher. */ +static void +proxy_destroyed (GObject * gobj_proxy, gpointer userdata) +{ + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(userdata); + + if (priv->root != NULL) { + g_object_unref(G_OBJECT(priv->root)); + priv->root = NULL; + } + + if ((gpointer)priv->menuproxy == (gpointer)gobj_proxy) { + priv->layoutcall = NULL; + } + + build_dbus_proxy(DBUSMENU_CLIENT(userdata)); + return; +} + /* When we have a name and an object, build the two proxies and get the first version of the layout */ static void @@ -369,7 +390,8 @@ build_proxies (DbusmenuClient * client) g_error_free(error); return; } - // g_signal_connect(G_OBJECT(priv->propproxy), "destroy", proxy_destroyed, client); + g_object_add_weak_pointer(G_OBJECT(priv->propproxy), (gpointer *)&priv->propproxy); + g_signal_connect(G_OBJECT(priv->propproxy), "destroy", G_CALLBACK(proxy_destroyed), client); priv->menuproxy = dbus_g_proxy_new_for_name_owner(priv->session_bus, priv->dbus_name, @@ -381,7 +403,8 @@ build_proxies (DbusmenuClient * client) g_error_free(error); return; } - // g_signal_connect(G_OBJECT(priv->menuproxy), "destroy", proxy_destroyed, client); + g_object_add_weak_pointer(G_OBJECT(priv->menuproxy), (gpointer *)&priv->menuproxy); + g_signal_connect(G_OBJECT(priv->menuproxy), "destroy", G_CALLBACK(proxy_destroyed), client); /* If we get here, we don't need the DBus proxy */ if (priv->dbusproxy != NULL) { -- cgit v1.2.3 From 369442ddbe17b5886f0dfb3d3cfc54b3d0518186 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Jun 2009 16:56:11 -0500 Subject: Making it so that if we clear the menu structure by destroying the proxies we also signal that to the callers. --- libdbusmenu-glib/client.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 043bf43..97265db 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -351,6 +351,7 @@ proxy_destroyed (GObject * gobj_proxy, gpointer userdata) if (priv->root != NULL) { g_object_unref(G_OBJECT(priv->root)); priv->root = NULL; + g_signal_emit(G_OBJECT(userdata), signals[LAYOUT_UPDATED], 0, TRUE); } if ((gpointer)priv->menuproxy == (gpointer)gobj_proxy) { -- cgit v1.2.3 From 6d57a21249c6089514bdaca9b6fe041296adeec3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 23 Jun 2009 15:44:29 -0500 Subject: Adding two new signals to the client. 'root-changed' and 'new-menuitem' to make it so that this can go up the stack easier. --- libdbusmenu-glib/client.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index d5e4334..f7de67f 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -47,6 +47,8 @@ enum { /* Signals */ enum { LAYOUT_UPDATED, + ROOT_CHANGED, + NEW_MENUITEM, LAST_SIGNAL }; @@ -120,6 +122,39 @@ dbusmenu_client_class_init (DbusmenuClientClass *klass) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, G_TYPE_NONE); + /** + DbusmenuClient::root-changed: + @arg0: The #DbusmenuClient object + @arg1: The new root #DbusmenuMenuitem + + The layout has changed in a way that can not be + represented by the individual items changing as the + root of this client has changed. + */ + signals[ROOT_CHANGED] = g_signal_new(DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED, + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (DbusmenuClientClass, root_changed), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, G_TYPE_OBJECT); + /** + DbusmenuClient::new-menuitem: + @arg0: The #DbusmenuClient object + @arg1: The new #DbusmenuMenuitem created + + Signaled when the client creates a new menuitem. This + doesn't mean that it's placed anywhere. The parent that + it's applied to will signal #DbusmenuMenuitem::child-added + when it gets parented. + */ + signals[NEW_MENUITEM] = g_signal_new(DBUSMENU_CLIENT_SIGNAL_NEW_MENUITEM, + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (DbusmenuClientClass, new_menuitem), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, G_TYPE_OBJECT); g_object_class_install_property (object_class, PROP_DBUSOBJECT, g_param_spec_string(DBUSMENU_CLIENT_PROP_DBUS_OBJECT, "DBus Object we represent", -- cgit v1.2.3 From 8c3a3f8a0b0418e4cd93413fade9a43bb549f546 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 23 Jun 2009 15:48:23 -0500 Subject: Signaling the new menuitem. --- libdbusmenu-glib/client.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index f7de67f..5bf7087 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -86,7 +86,7 @@ static void id_prop_update (DBusGProxy * proxy, guint id, gchar * property, gcha static void id_update (DBusGProxy * proxy, guint id, DbusmenuClient * client); static void build_proxies (DbusmenuClient * client); static guint parse_node_get_id (xmlNodePtr node); -static DbusmenuMenuitem * parse_layout_xml(xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * parent, DBusGProxy * proxy); +static DbusmenuMenuitem * parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * parent, DBusGProxy * proxy); static void parse_layout (DbusmenuClient * client, const gchar * layout); static void update_layout_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data); static void update_layout (DbusmenuClient * client); @@ -515,7 +515,7 @@ menuitem_get_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError /* Parse recursively through the XML and make it into objects as need be */ static DbusmenuMenuitem * -parse_layout_xml(xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * parent, DBusGProxy * proxy) +parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * parent, DBusGProxy * proxy) { guint id = parse_node_get_id(node); /* g_debug("Looking at node with id: %d", id); */ @@ -535,6 +535,7 @@ parse_layout_xml(xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * pa /* Build a new item */ item = dbusmenu_menuitem_new_with_id(id); + g_signal_emit(G_OBJECT(client), signals[NEW_MENUITEM], 0, item, TRUE); /* Get the properties queued up for this item */ org_freedesktop_dbusmenu_get_properties_async(proxy, id, menuitem_get_properties_cb, item); } @@ -559,7 +560,7 @@ parse_layout_xml(xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * pa } } - childmi = parse_layout_xml(children, childmi, item, proxy); + childmi = parse_layout_xml(client, children, childmi, item, proxy); dbusmenu_menuitem_child_add_position(item, childmi, position); } @@ -588,7 +589,7 @@ parse_layout (DbusmenuClient * client, const gchar * layout) xmlNodePtr root = xmlDocGetRootElement(xmldoc); - priv->root = parse_layout_xml(root, priv->root, NULL, priv->menuproxy); + priv->root = parse_layout_xml(client, root, priv->root, NULL, priv->menuproxy); if (priv->root == NULL) { g_warning("Unable to parse layout on client %s object %s: %s", priv->dbus_name, priv->dbus_object, layout); } -- cgit v1.2.3 From df10a41905899f303eb8d63267e6bd385ba538d4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 23 Jun 2009 15:54:49 -0500 Subject: Signaling on root changes. --- libdbusmenu-glib/client.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 5bf7087..5c429c8 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -387,6 +387,7 @@ proxy_destroyed (GObject * gobj_proxy, gpointer userdata) if (priv->root != NULL) { g_object_unref(G_OBJECT(priv->root)); priv->root = NULL; + g_signal_emit(G_OBJECT(userdata), signals[ROOT_CHANGED], 0, NULL, TRUE); g_signal_emit(G_OBJECT(userdata), signals[LAYOUT_UPDATED], 0, TRUE); } @@ -589,12 +590,18 @@ parse_layout (DbusmenuClient * client, const gchar * layout) xmlNodePtr root = xmlDocGetRootElement(xmldoc); + DbusmenuMenuitem * oldroot = priv->root; priv->root = parse_layout_xml(client, root, priv->root, NULL, priv->menuproxy); + xmlFreeDoc(xmldoc); + if (priv->root == NULL) { g_warning("Unable to parse layout on client %s object %s: %s", priv->dbus_name, priv->dbus_object, layout); } - xmlFreeDoc(xmldoc); + if (priv->root != oldroot) { + g_signal_emit(G_OBJECT(client), signals[ROOT_CHANGED], 0, priv->root, TRUE); + } + return; } -- cgit v1.2.3 From ceacc52b9ce52feb4e3b12cbfd802f38c65a8b4a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 26 Jun 2009 11:08:06 -0500 Subject: Flipping arround the original update of the layout to be after building the proxies, not something driven by new. Also ensuring that the callback pointer is reset when we're in it so that it doesn't get called recursively. --- libdbusmenu-glib/client.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 5c429c8..4308d58 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -460,6 +460,8 @@ build_proxies (DbusmenuClient * client) dbus_g_proxy_add_signal(priv->menuproxy, "IdUpdate", G_TYPE_UINT, G_TYPE_INVALID); dbus_g_proxy_connect_signal(priv->menuproxy, "IdUpdate", G_CALLBACK(id_update), client, NULL); + update_layout(client); + return; } @@ -615,9 +617,9 @@ update_layout_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) GError * error = NULL; GValue value = {0}; + priv->layoutcall = NULL; if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { g_warning("Getting layout failed on client %s object %s: %s", priv->dbus_name, priv->dbus_object, error->message); - priv->layoutcall = NULL; g_error_free(error); return; } @@ -626,7 +628,6 @@ update_layout_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) /* g_debug("Got layout string: %s", xml); */ parse_layout(client, xml); - priv->layoutcall = NULL; /* g_debug("Root is now: 0x%X", (unsigned int)priv->root); */ g_signal_emit(G_OBJECT(client), signals[LAYOUT_UPDATED], 0, TRUE); @@ -681,7 +682,6 @@ dbusmenu_client_new (const gchar * name, const gchar * object) DBUSMENU_CLIENT_PROP_DBUS_NAME, name, DBUSMENU_CLIENT_PROP_DBUS_OBJECT, object, NULL); - update_layout(self); return self; } -- cgit v1.2.3 From 290c64793a50ef7b996a558068b2275ced2cceda Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 26 Jun 2009 11:08:58 -0500 Subject: Switching the loss of the proxies to be warnings instead of errors as we can recover from it and handle it gracefully if we need to. --- libdbusmenu-glib/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 4308d58..b9a5b90 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -424,7 +424,7 @@ build_proxies (DbusmenuClient * client) DBUS_INTERFACE_PROPERTIES, &error); if (error != NULL) { - g_error("Unable to get property proxy for %s on %s: %s", priv->dbus_name, priv->dbus_object, error->message); + g_warning("Unable to get property proxy for %s on %s: %s", priv->dbus_name, priv->dbus_object, error->message); g_error_free(error); return; } @@ -437,7 +437,7 @@ build_proxies (DbusmenuClient * client) "org.freedesktop.dbusmenu", &error); if (error != NULL) { - g_error("Unable to get dbusmenu proxy for %s on %s: %s", priv->dbus_name, priv->dbus_object, error->message); + g_warning("Unable to get dbusmenu proxy for %s on %s: %s", priv->dbus_name, priv->dbus_object, error->message); g_error_free(error); return; } -- cgit v1.2.3 From fc6e61d8d731b4cfb7f8e3598893b4805807ffe4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 26 Jun 2009 12:49:52 -0500 Subject: Add the property of the menuitems to check to see if they're the root node or not. Also set that when the layout is being parsed. --- libdbusmenu-glib/client.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index b9a5b90..7319a7f 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -538,6 +538,9 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it /* Build a new item */ item = dbusmenu_menuitem_new_with_id(id); + if (parent == NULL) { + dbusmenu_menuitem_set_root(item, TRUE); + } g_signal_emit(G_OBJECT(client), signals[NEW_MENUITEM], 0, item, TRUE); /* Get the properties queued up for this item */ org_freedesktop_dbusmenu_get_properties_async(proxy, id, menuitem_get_properties_cb, item); -- cgit v1.2.3 From 92f690257a45e81b86b39fc77ce1fe10c7b4908a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 20 Jul 2009 16:34:39 -0500 Subject: Heh, turns out we need to actually signal people across DBus or nothing works. Who'd a thought. --- libdbusmenu-glib/client.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 7319a7f..212071b 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -515,6 +515,26 @@ menuitem_get_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError return; } +static void +menuitem_call_cb (DBusGProxy * proxy, GError * error, gpointer userdata) +{ + DbusmenuMenuitem * mi = (DbusmenuMenuitem *)userdata; + + if (error != NULL) { + g_warning("Unable to call menu item %d: %s", dbusmenu_menuitem_get_id(mi), error->message); + } + + return; +} + +static void +menuitem_activate (DbusmenuMenuitem * mi, DbusmenuClient * client) +{ + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); + org_freedesktop_dbusmenu_call_async (priv->menuproxy, dbusmenu_menuitem_get_id(mi), menuitem_call_cb, mi); + return; +} + /* Parse recursively through the XML and make it into objects as need be */ static DbusmenuMenuitem * @@ -541,6 +561,7 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it if (parent == NULL) { dbusmenu_menuitem_set_root(item, TRUE); } + g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(menuitem_activate), client); g_signal_emit(G_OBJECT(client), signals[NEW_MENUITEM], 0, item, TRUE); /* Get the properties queued up for this item */ org_freedesktop_dbusmenu_get_properties_async(proxy, id, menuitem_get_properties_cb, item); -- cgit v1.2.3