[PATCH 6/7] 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 95cef71..f661b95 100644
--- a/tools/grilo-test-ui/main.c
+++ b/tools/grilo-test-ui/main.c
@@ -511,6 +511,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, "%FT%H:%M:%S.%NZ");
+  }
+
+  return g_strdup_value_contents (value);
+}
+
 static void
 metadata_cb (GrlMediaSource *source,
              guint operation_id,
@@ -558,7 +573,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]