[PATCH 6/6] test-ui: improved display of GDateTime values



---
 tools/grilo-test-ui/main.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/tools/grilo-test-ui/main.c b/tools/grilo-test-ui/main.c
index 77ea9b6..2570366 100644
--- a/tools/grilo-test-ui/main.c
+++ b/tools/grilo-test-ui/main.c
@@ -516,6 +516,21 @@ cancel_current_operation (void)
   }
 }
 
+static gchar *
+value_description (const GValue *value)
+{
+  if (value == NULL)
+    return g_strdup ("");
+
+  if (G_VALUE_HOLDS_BOXED (value)
+      && G_VALUE_TYPE (value) == G_TYPE_DATE_TIME) {
+    GDateTime *date_time = g_value_get_boxed (value);
+    return g_date_time_format (date_time, "GDateTime: %FT%H:%M:%S.%NZ");
+  }
+
+  return g_strdup_value_contents (value);
+}
+
 static void
 metadata_cb (GrlMediaSource *source,
              guint operation_id,
@@ -563,7 +578,7 @@ metadata_cb (GrlMediaSource *source,
       key_name = grl_metadata_key_get_name (key);
       if (grl_data_has_key (GRL_DATA (media), key)) {
         const GValue *g_value = grl_data_get (GRL_DATA (media), key);
-        gchar *value = g_value ? g_strdup_value_contents (g_value) : "";
+        gchar *value = value_description (g_value);
         gtk_list_store_append (GTK_LIST_STORE (view->metadata_model), &iter);
         gtk_list_store_set (GTK_LIST_STORE (view->metadata_model),
                             &iter,
-- 
1.7.4.1



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]