[gimp/metadata-browser] metadata: Helper function.
- From: Roman Joost <romanofski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/metadata-browser] metadata: Helper function.
- Date: Mon, 4 Mar 2013 10:25:32 +0000 (UTC)
commit 9e2ec9cf5596af14dce49883badf29c25e5be55a
Author: Roman Joost <roman bromeco de>
Date: Wed Feb 27 12:31:44 2013 +1000
metadata: Helper function.
Becase we'll use libgexiv2 to retrieve scalar string values, we'll most
likely have to preprocess some of them in order to correctly
store/edit/export them again. This patch is based on a hunch with the
integration and might not work out as expected.
plug-ins/metadata/xmp-model.c | 48 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/plug-ins/metadata/xmp-model.c b/plug-ins/metadata/xmp-model.c
index 1154c4c..b21e5d8 100644
--- a/plug-ins/metadata/xmp-model.c
+++ b/plug-ins/metadata/xmp-model.c
@@ -47,6 +47,8 @@ static void tree_model_row_changed (GtkTreeModel *model,
static XMPSchema * find_xmp_schema_by_iter (XMPModel *xmp_model,
GtkTreeIter *iter);
+gchar** convert_xmp_value (const gchar *in);
+
enum
{
PROPERTY_CHANGED,
@@ -215,6 +217,52 @@ 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.
+ * TODO: Possibly this function can be ignored after the full
+ * integration of gexiv2
+ */
+gchar**
+convert_xmp_value (const gchar *in)
+{
+ gchar **splitted = NULL;
+ gchar **result;
+ gchar *value = NULL;
+ GSList *list = NULL;
+ GSList *list_iter;
+ int i;
+
+ /* extract the language and corresponding value
+ */
+ splitted = g_strsplit_set (in, "\",", -1);
+ for (i=0; splitted[i] != NULL; i++)
+ {
+ value = g_strchug (splitted[i]);
+ if (g_str_has_prefix (value, "lang"))
+ continue;
+ else
+ list = g_slist_append (list, g_strdup (value));
+ }
+
+ /* 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);
+ for (list_iter = list; list_iter != NULL; list_iter = list_iter->next)
+ {
+ result[i--] = list_iter->data;
+ }
+
+ g_slist_free (list);
+ g_strfreev (splitted);
+ return g_strdupv(result);
+}
+
+
static XMPSchema *
find_xmp_schema_by_iter (XMPModel *xmp_model,
GtkTreeIter *child)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]