aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-06-28 11:22:07 -0500
committerTed Gould <ted@gould.cx>2010-06-28 11:22:07 -0500
commit84e7a884a2f3c6bd480060235478beb50a38841e (patch)
tree8a076b9a0c1ab614ee4798e9386f6971e043da48 /tools
parentb13fe82d9d489e0c77cd4e8a9e09fce934d40865 (diff)
downloadlibdbusmenu-84e7a884a2f3c6bd480060235478beb50a38841e.tar.gz
libdbusmenu-84e7a884a2f3c6bd480060235478beb50a38841e.tar.bz2
libdbusmenu-84e7a884a2f3c6bd480060235478beb50a38841e.zip
Printing more like we'd want a collection to print.
Diffstat (limited to 'tools')
-rw-r--r--tools/dbusmenu-dumper.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c
index 5790828..1bf6e43 100644
--- a/tools/dbusmenu-dumper.c
+++ b/tools/dbusmenu-dumper.c
@@ -32,7 +32,19 @@ static GMainLoop * mainloop = NULL;
static gchar *
collection_dumper (const GValue * value, int depth)
{
- return g_strdup("<collection>");
+ gchar * space = g_strnfill(depth, ' ');
+ GPtrArray * array = g_ptr_array_new_with_free_func(g_free);
+
+ g_ptr_array_add(array, g_strdup("[\n"));
+ g_ptr_array_add(array, g_strdup_printf("%s<collection>\n", space));
+ g_ptr_array_add(array, g_strdup_printf("%s]", space));
+
+ g_free(space);
+
+ gchar * retstr = g_strjoinv(NULL, (gchar **)array->pdata);
+ g_ptr_array_free(array, TRUE);
+
+ return retstr;
}
static void
@@ -47,7 +59,7 @@ print_menuitem (DbusmenuMenuitem * item, int depth)
const GValue * value = dbusmenu_menuitem_property_get_value(item, (gchar *)property->data);
gchar * str = NULL;
if (dbus_g_type_is_collection(G_VALUE_TYPE(value))) {
- str = collection_dumper(value, depth + g_utf8_strlen((gchar *)property->data, -1) + 2);
+ str = collection_dumper(value, depth + g_utf8_strlen((gchar *)property->data, -1) + 2 /*quotes*/ + 2 /*: */);
} else {
str = g_strdup_value_contents(value);
}