From 96546d127bd6669d7dffddb9192be8af837f93a7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 13 May 2009 21:17:17 -0500 Subject: Connecting to the other signals coming from the server --- libdbusmenu-glib/client.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index b0b1157..b7ac9e0 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -77,6 +77,8 @@ static void set_property (GObject * obj, guint id, const GValue * value, GParamS static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec); /* Private Funcs */ static void layout_update (DBusGProxy * proxy, DbusmenuClient * client); +static void id_prop_update (DBusGProxy * proxy, guint id, gchar * property, gchar * value, DbusmenuClient * client); +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); @@ -238,6 +240,20 @@ layout_update (DBusGProxy * proxy, DbusmenuClient * client) return; } +static void +id_prop_update (DBusGProxy * proxy, guint id, gchar * property, gchar * value, DbusmenuClient * client) +{ + + return; +} + +static void +id_update (DBusGProxy * proxy, guint id, DbusmenuClient * client) +{ + + return; +} + /* When we have a name and an object, build the two proxies and get the first version of the layout */ static void @@ -281,6 +297,12 @@ build_proxies (DbusmenuClient * client) 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); + dbus_g_proxy_add_signal(priv->menuproxy, "IdPropUpdate", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_connect_signal(priv->menuproxy, "IdPropUpdate", G_CALLBACK(id_prop_update), client, NULL); + + 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); + return; } -- cgit v1.2.3 From 80b6f8bba04f51b1f0b55f5d604723e5c9aad91e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 13 May 2009 21:29:52 -0500 Subject: Okay, throwing the signals down to the menuitems --- libdbusmenu-glib/client.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index b7ac9e0..9a73d6e 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -240,17 +240,33 @@ layout_update (DBusGProxy * proxy, DbusmenuClient * client) return; } +/* Signal from the server that a property has changed + on one of our menuitems */ static void id_prop_update (DBusGProxy * proxy, guint id, gchar * property, gchar * value, DbusmenuClient * client) { + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); + g_return_if_fail(priv->root != NULL); + + DbusmenuMenuitem * menuitem = dbusmenu_menuitem_find_id(priv->root, id); + g_return_if_fail(menuitem != NULL); + dbusmenu_menuitem_property_set(menuitem, property, value); return; } +/* Oh, lots of updates now. That silly server, they want + to change all kinds of stuff! */ static void id_update (DBusGProxy * proxy, guint id, DbusmenuClient * client) { + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); + g_return_if_fail(priv->root != NULL); + + DbusmenuMenuitem * menuitem = dbusmenu_menuitem_find_id(priv->root, id); + g_return_if_fail(menuitem != NULL); + /* dbusmenu_menuitem_property_set(menuitem, property, value); */ return; } -- cgit v1.2.3 From 7c4cecd7765939a9f12c77a6a5117d55c1d329c0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 19 May 2009 00:45:22 +0200 Subject: Now we're calling the get_properties function on every menuitem that we build. Fun. --- libdbusmenu-glib/client.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 9a73d6e..eb54c12 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -81,7 +81,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); +static DbusmenuMenuitem * parse_layout_xml(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); @@ -350,10 +350,32 @@ parse_node_get_id (xmlNodePtr node) return 0; } +/* A small helper that calls _property_set on each hash table + entry in the properties hash. */ +static void +get_properties_helper (gpointer key, gpointer value, gpointer data) +{ + dbusmenu_menuitem_property_set((DbusmenuMenuitem *)data, (gchar *)key, (gchar *)value); + return; +} + +/* This is the callback for the properties on a menu item. There + should be all of them in the Hash, and they we use foreach to + copy them into the menuitem. + This isn't the most efficient way. We can optimize this by + somehow removing the foreach. But that is for later. */ +static void +menuitem_get_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data) +{ + g_hash_table_foreach(properties, get_properties_helper, data); + g_hash_table_destroy(properties); + return; +} + /* Parse recursively through the XML and make it into objects as need be */ static DbusmenuMenuitem * -parse_layout_xml(xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * parent) +parse_layout_xml(xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * parent, DBusGProxy * proxy) { guint id = parse_node_get_id(node); g_debug("Looking at node with id: %d", id); @@ -372,6 +394,8 @@ parse_layout_xml(xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * pa /* Build a new item */ item = dbusmenu_menuitem_new_with_id(id); + /* Get the properties queued up for this item */ + org_freedesktop_dbusmenu_get_properties_async(proxy, id, menuitem_get_properties_cb, item); } xmlNodePtr children; @@ -393,7 +417,7 @@ parse_layout_xml(xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * pa } } - childmi = parse_layout_xml(children, childmi, item); + childmi = parse_layout_xml(children, childmi, item, proxy); dbusmenu_menuitem_child_add_position(item, childmi, position); } @@ -420,7 +444,7 @@ parse_layout (DbusmenuClient * client, const gchar * layout) xmlNodePtr root = xmlDocGetRootElement(xmldoc); - priv->root = parse_layout_xml(root, priv->root, NULL); + priv->root = parse_layout_xml(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 89b87f5b44e9abed7dc71a7cf81c9846a4d3bd1f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 19 May 2009 00:58:31 +0200 Subject: Recycle the server's marshaller and register it with DBus as we don't have one for IdPropUpdate. The server and the client can use the same one. --- libdbusmenu-glib/client.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index eb54c12..8960393 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -35,6 +35,7 @@ License version 3 and version 2.1 along with this program. If not, see #include "client.h" #include "dbusmenu-client.h" +#include "server-marshal.h" /* Properties */ enum { @@ -313,6 +314,7 @@ build_proxies (DbusmenuClient * client) 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); + dbus_g_object_register_marshaller(_dbusmenu_server_marshal_VOID__UINT_STRING_STRING, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); dbus_g_proxy_add_signal(priv->menuproxy, "IdPropUpdate", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); dbus_g_proxy_connect_signal(priv->menuproxy, "IdPropUpdate", G_CALLBACK(id_prop_update), client, NULL); -- cgit v1.2.3 From 9ce161afed2050ca706912f0308e9f9e842c04c0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 19 May 2009 04:08:59 +0200 Subject: Disabling a large number of debug messages. Most aren't needed anymore. --- libdbusmenu-glib/client.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 8960393..c6833cc 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -341,7 +341,7 @@ parse_node_get_id (xmlNodePtr node) if (g_strcmp0((gchar *)attrib->name, "id") == 0) { if (attrib->children != NULL) { guint id = (guint)g_ascii_strtoull((gchar *)attrib->children->content, NULL, 10); - g_debug ("Found ID: %d", id); + /* g_debug ("Found ID: %d", id); */ return id; } break; @@ -380,7 +380,7 @@ static DbusmenuMenuitem * parse_layout_xml(xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * parent, DBusGProxy * proxy) { guint id = parse_node_get_id(node); - g_debug("Looking at node with id: %d", id); + /* g_debug("Looking at node with id: %d", id); */ if (item == NULL || dbusmenu_menuitem_get_id(item) != id || id == 0) { if (item != NULL) { if (parent != NULL) { @@ -405,7 +405,7 @@ parse_layout_xml(xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * pa GList * oldchildren = dbusmenu_menuitem_take_children(item); for (children = node->children, position = 0; children != NULL; children = children->next, position++) { - g_debug("Looking at child: %d", position); + /* g_debug("Looking at child: %d", position); */ guint childid = parse_node_get_id(children); DbusmenuMenuitem * childmi = NULL; @@ -473,11 +473,11 @@ update_layout_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) } const gchar * xml = g_value_get_string(&value); - g_debug("Got layout string: %s", xml); + /* 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_debug("Root is now: 0x%X", (unsigned int)priv->root); */ g_signal_emit(G_OBJECT(client), signals[LAYOUT_UPDATED], 0, TRUE); return; -- cgit v1.2.3 From 3c9734543b84ecd412ffd214ac0560b11858a00a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 5 Jun 2009 15:05:12 -0500 Subject: Making the ID update function rebuild all of the properties. Result of a code review comment by Cody Russell. --- libdbusmenu-glib/client.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index c6833cc..6094eca 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -86,6 +86,7 @@ static DbusmenuMenuitem * parse_layout_xml(xmlNodePtr node, DbusmenuMenuitem * i 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); +static void menuitem_get_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data); /* Build a type */ G_DEFINE_TYPE (DbusmenuClient, dbusmenu_client, G_TYPE_OBJECT); @@ -267,7 +268,7 @@ id_update (DBusGProxy * proxy, guint id, DbusmenuClient * client) DbusmenuMenuitem * menuitem = dbusmenu_menuitem_find_id(priv->root, id); g_return_if_fail(menuitem != NULL); - /* dbusmenu_menuitem_property_set(menuitem, property, value); */ + org_freedesktop_dbusmenu_get_properties_async(proxy, id, menuitem_get_properties_cb, menuitem); return; } -- cgit v1.2.3