[gimp/metadata-browser] metadata: Set a default for XMP_TYPE_LANG_ALT



commit d085efe7567b8b9dd839c7f9f2292ba8db101f7e
Author: Roman Joost <roman bromeco de>
Date:   Mon Mar 4 14:41:30 2013 +1000

    metadata: Set a default for XMP_TYPE_LANG_ALT

 plug-ins/metadata/tests/test-xmp-model.c |   18 +++++++-----------
 plug-ins/metadata/xmp-model.c            |   12 ++++++++++--
 2 files changed, 17 insertions(+), 13 deletions(-)
---
diff --git a/plug-ins/metadata/tests/test-xmp-model.c b/plug-ins/metadata/tests/test-xmp-model.c
index 8cc21a4..244050d 100644
--- a/plug-ins/metadata/tests/test-xmp-model.c
+++ b/plug-ins/metadata/tests/test-xmp-model.c
@@ -147,23 +147,19 @@ test_xmp_model_set_get_scalar_property (GimpTestFixture *fixture,
                                                 "title");
   g_assert_cmpstr (scalar_value, ==, "title_lang_alt");
 
-  /* The raw data for this type looks different tho. Because we only
-   * changed the string represenation we expect it to return FALSE as
-   * there is currently no RAW value set.
-   **/
-  value = xmp_model_get_raw_property_value (fixture->xmp_model,
-                                            "dc", "title");
-  g_assert (value == NULL);
-
+  /* Setting an XMP_TYPE_LANG_ALT value without a language identifier,
+   * we'll assume it is 'x-default' and the accessor returns the same
+   * value.
+   */
   result = xmp_model_set_scalar_property (fixture->xmp_model,
                                            "dc",
                                            "title",
                                            "me too");
   g_assert (result == TRUE);
 
-  value = xmp_model_get_raw_property_value (fixture->xmp_model,
-                                             "dc", "title");
-  g_assert (value == NULL);
+  scalar_value = xmp_model_get_scalar_property (fixture->xmp_model,
+                                         "dc", "title");
+  g_assert_cmpstr (scalar_value, ==, "me too");
 }
 
 
diff --git a/plug-ins/metadata/xmp-model.c b/plug-ins/metadata/xmp-model.c
index 6c8ef54..5b5baaf 100644
--- a/plug-ins/metadata/xmp-model.c
+++ b/plug-ins/metadata/xmp-model.c
@@ -220,7 +220,7 @@ tree_model_row_changed (GtkTreeModel    *model,
 
 /* utility function in order to translate XMP_TYPE_LANG_ALT values to an
  * array of strings. This is needed to set the value in
- * xmp_model_set_property.
+ * xmp_model_set_property when extracted by libgexiv2.
  * TODO: Possibly this function can be ignored after the full
  * integration of gexiv2
  */
@@ -246,9 +246,17 @@ convert_xmp_value (const gchar *in)
          list = g_slist_append (list, g_strdup (value));
    }
 
+  /* in case we only extracted one element, the language identifier is
+   * missing. We'll simply append one */
+  i = g_slist_length (list);
+  if (i == 1)
+   {
+    list = g_slist_prepend (list, "x-default");
+    i++;
+   }
+
   /* put it back into an array and return it
    */
-  i = g_slist_length (list);
   result = g_new (gchar*, i + 1);
   result[i--] = NULL;
   list = g_slist_reverse(list);


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