aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-02-18 13:53:45 -0600
committerTed Gould <ted@gould.cx>2011-02-18 13:53:45 -0600
commita128fd2e85e2f442522c280a6d1d22663e8cdfea (patch)
treee86f4728cf4d1d895f8afa17a1b59f3abe77f00a /libdbusmenu-glib
parent87703b408d42ce97b5a64142b0c33951d366890a (diff)
downloadlibdbusmenu-a128fd2e85e2f442522c280a6d1d22663e8cdfea.tar.gz
libdbusmenu-a128fd2e85e2f442522c280a6d1d22663e8cdfea.tar.bz2
libdbusmenu-a128fd2e85e2f442522c280a6d1d22663e8cdfea.zip
Handle a request for selective properties and give less data back
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r--libdbusmenu-glib/menuitem.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c
index 54d2540..bc38e24 100644
--- a/libdbusmenu-glib/menuitem.c
+++ b/libdbusmenu-glib/menuitem.c
@@ -1274,7 +1274,7 @@ dbusmenu_menuitem_properties_variant (DbusmenuMenuitem * mi, const gchar ** prop
GVariant * final_variant = NULL;
- if (g_hash_table_size(priv->properties) > 0) {
+ if (properties == NULL && g_hash_table_size(priv->properties) > 0) {
GVariantBuilder builder;
g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY);
@@ -1283,6 +1283,33 @@ dbusmenu_menuitem_properties_variant (DbusmenuMenuitem * mi, const gchar ** prop
final_variant = g_variant_builder_end(&builder);
}
+ if (properties != NULL) {
+ GVariantBuilder builder;
+ gboolean builder_init = FALSE;
+ int i = 0; const gchar * prop;
+
+ for (prop = properties[i]; prop != NULL; prop = properties[++i]) {
+ GVariant * propvalue = dbusmenu_menuitem_property_get_variant(mi, prop);
+
+ if (propvalue == NULL) {
+ continue;
+ }
+
+ if (!builder_init) {
+ builder_init = TRUE;
+ g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY);
+ }
+
+ GVariant * dict = g_variant_new_dict_entry(g_variant_new_string((gchar *)prop),
+ g_variant_new_variant((GVariant *)propvalue));
+ g_variant_builder_add_value(&builder, dict);
+ }
+
+ if (builder_init) {
+ final_variant = g_variant_builder_end(&builder);
+ }
+ }
+
return final_variant;
}