From b19de3c3c90df6420200c6ba45ba45060382cca2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Feb 2011 14:07:18 -0600 Subject: Set a fixed set of properties that we ask for when requesting the layout --- libdbusmenu-glib/client.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index ba4ae7e..ca32d48 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -79,6 +79,7 @@ struct _DbusmenuClientPrivate GCancellable * menuproxy_cancel; GCancellable * layoutcall; + GVariant * layout_props; gint current_revision; gint my_revision; @@ -316,6 +317,13 @@ dbusmenu_client_init (DbusmenuClient *self) priv->layoutcall = NULL; + gchar * layout_props[3]; + layout_props[0] = DBUSMENU_MENUITEM_PROP_TYPE; + layout_props[1] = DBUSMENU_MENUITEM_PROP_LABEL; + layout_props[2] = NULL; + priv->layout_props = g_variant_new_strv((const gchar * const *)layout_props, 2); + g_variant_ref_sink(priv->layout_props); + priv->current_revision = 0; priv->my_revision = 0; @@ -380,6 +388,11 @@ dbusmenu_client_dispose (GObject *object) priv->layoutcall = NULL; } + if (priv->layout_props != NULL) { + g_variant_unref(priv->layout_props); + priv->layout_props = NULL; + } + /* Bring down the menu proxy, ensure we're not looking for one at the same time. */ if (priv->menuproxy_cancel != NULL) { @@ -1662,7 +1675,7 @@ update_layout (DbusmenuClient * client) g_variant_builder_add_value(&tupleb, g_variant_new_int32(0)); // root g_variant_builder_add_value(&tupleb, g_variant_new_int32(-1)); // recurse - g_variant_builder_add_value(&tupleb, g_variant_new_array(G_VARIANT_TYPE_STRING, NULL, 0)); // props + g_variant_builder_add_value(&tupleb, priv->layout_props); // props GVariant * args = g_variant_builder_end(&tupleb); // g_debug("Args (type: %s): %s", g_variant_get_type_string(args), g_variant_print(args, TRUE)); -- cgit v1.2.3 From 895343f4aa0c8c0a58e26a7de8c74e49fd9da292 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Feb 2011 14:40:04 -0600 Subject: Use the property structures that are from the GetLayout properties --- libdbusmenu-glib/client.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index ca32d48..d990b93 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1486,6 +1486,21 @@ parse_layout_xml(DbusmenuClient * client, GVariant * layout, DbusmenuMenuitem * parse_layout_update(childmi, client); } + /* Apply known properties sent in the structure to the + menu item. Sometimes they may just be copies */ + if (childmi != NULL) { + GVariantIter iter; + g_variant_iter_init(&iter, g_variant_get_child_value(child, 1)); + gchar * prop; + GVariant * value; + + while (g_variant_iter_next(&iter, "{sv}", &prop, &value)) { + dbusmenu_menuitem_property_set_variant(childmi, prop, value); + g_free(prop); + g_variant_unref(value); + } + } + position++; } -- cgit v1.2.3 From c780c27de91ff7b36c25e50f11ccb051c6e8ac1d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 12:55:10 -0600 Subject: Fixup documentation and move the private functions to a private header file --- 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 0848294..ee1186b 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -33,6 +33,7 @@ License version 3 and version 2.1 along with this program. If not, see #include #include "client.h" +#include "client-private.h" #include "menuitem.h" #include "menuitem-private.h" #include "client-menuitem.h" -- cgit v1.2.3 From 749be25d3f7736e518b3d33d3d64349118bfdf84 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 23 Feb 2011 11:28:12 -0600 Subject: Adding visible and enabled to the initial grab. --- libdbusmenu-glib/client.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index d990b93..b6a00fc 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -317,11 +317,13 @@ dbusmenu_client_init (DbusmenuClient *self) priv->layoutcall = NULL; - gchar * layout_props[3]; + gchar * layout_props[5]; layout_props[0] = DBUSMENU_MENUITEM_PROP_TYPE; layout_props[1] = DBUSMENU_MENUITEM_PROP_LABEL; - layout_props[2] = NULL; - priv->layout_props = g_variant_new_strv((const gchar * const *)layout_props, 2); + layout_props[2] = DBUSMENU_MENUITEM_PROP_VISIBLE; + layout_props[3] = DBUSMENU_MENUITEM_PROP_ENABLED; + layout_props[4] = NULL; + priv->layout_props = g_variant_new_strv((const gchar * const *)layout_props, 4); g_variant_ref_sink(priv->layout_props); priv->current_revision = 0; -- cgit v1.2.3 From 10859b3dd0cf399aa02a5adf7f848bb2e61121e5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 23 Feb 2011 12:58:52 -0600 Subject: Search for and process type first --- libdbusmenu-glib/client.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index b6a00fc..6e25ba1 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1492,10 +1492,22 @@ parse_layout_xml(DbusmenuClient * client, GVariant * layout, DbusmenuMenuitem * menu item. Sometimes they may just be copies */ if (childmi != NULL) { GVariantIter iter; - g_variant_iter_init(&iter, g_variant_get_child_value(child, 1)); gchar * prop; GVariant * value; + /* Set the type first as it can manage the behavior of + all other properties. */ + g_variant_iter_init(&iter, g_variant_get_child_value(child, 1)); + while (g_variant_iter_next(&iter, "{sv}", &prop, &value)) { + if (g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_TYPE) == 0) { + dbusmenu_menuitem_property_set_variant(childmi, prop, value); + } + g_free(prop); + g_variant_unref(value); + } + + /* Now go through and do all the properties. */ + g_variant_iter_init(&iter, g_variant_get_child_value(child, 1)); while (g_variant_iter_next(&iter, "{sv}", &prop, &value)) { dbusmenu_menuitem_property_set_variant(childmi, prop, value); g_free(prop); -- cgit v1.2.3 From 0e6db378e81e24f2ee2ff4498ff40dc60d1915bc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 1 Mar 2011 21:19:43 -0600 Subject: Don't tell us everytime, we know you're good, you don't have to brag. --- libdbusmenu-glib/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib/client.c') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index d368a0e..e1f20d1 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1168,7 +1168,7 @@ menuproxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVarian gchar * property; while (g_variant_iter_next(&properties, "s", &property)) { - g_debug("Removing property '%s' on %d", property, id); + /* g_debug("Removing property '%s' on %d", property, id); */ dbusmenu_menuitem_property_remove(menuitem, property); } } -- cgit v1.2.3 From 33b4e34124c38f8159ea4af25f2b3622b3cc392e Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Wed, 2 Mar 2011 12:07:07 +0100 Subject: Rename dbus properties to follow dbus naming conventions - version => Version - text-direction => TextDirection - status => Status --- 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 d368a0e..8424d6f 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1026,7 +1026,7 @@ menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data) } /* Check the text direction if available */ - GVariant * textdir = g_dbus_proxy_get_cached_property(priv->menuproxy, "text-direction"); + GVariant * textdir = g_dbus_proxy_get_cached_property(priv->menuproxy, "TextDirection"); if (textdir != NULL) { GVariant * str = textdir; if (g_variant_is_of_type(str, G_VARIANT_TYPE_VARIANT)) { @@ -1069,10 +1069,10 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva gchar * invalid; gint i = 0; for (invalid = invalidated[i]; invalid != NULL; invalid = invalidated[++i]) { - if (g_strcmp0(invalid, "text-direction") == 0) { + if (g_strcmp0(invalid, "TextDirection") == 0) { priv->text_direction = DBUSMENU_TEXT_DIRECTION_NONE; } - if (g_strcmp0(invalid, "status") == 0) { + if (g_strcmp0(invalid, "Status") == 0) { priv->status = DBUSMENU_STATUS_NORMAL; } } @@ -1082,7 +1082,7 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva gchar * key; GVariant * value; g_variant_iter_init(&iters, properties); while (g_variant_iter_next(&iters, "{sv}", &key, &value)) { - if (g_strcmp0(key, "text-direction") == 0) { + if (g_strcmp0(key, "TextDirection") == 0) { GVariant * str = value; if (g_variant_is_of_type(str, G_VARIANT_TYPE_VARIANT)) { str = g_variant_get_variant(str); @@ -1090,7 +1090,7 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva priv->text_direction = dbusmenu_text_direction_get_value_from_nick(g_variant_get_string(str, NULL)); } - if (g_strcmp0(key, "status") == 0) { + if (g_strcmp0(key, "Status") == 0) { GVariant * str = value; if (g_variant_is_of_type(str, G_VARIANT_TYPE_VARIANT)) { str = g_variant_get_variant(str); -- cgit v1.2.3