From 84e7a884a2f3c6bd480060235478beb50a38841e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 28 Jun 2010 11:22:07 -0500 Subject: Printing more like we'd want a collection to print. --- tools/dbusmenu-dumper.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'tools') 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(""); + 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\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); } -- cgit v1.2.3