[gimp/metadata-browser] Merge changes back into raw values during serialisation
- From: Roman Joost <romanofski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/metadata-browser] Merge changes back into raw values during serialisation
- Date: Wed, 28 Sep 2011 10:53:53 +0000 (UTC)
commit b29d83eaa3ab8da7c79c0289d1796db915300e6a
Author: Roman Joost <roman bromeco de>
Date: Mon Sep 26 21:01:51 2011 +1000
Merge changes back into raw values during serialisation
In case widgets changed the string representation of the raw values,
merge them back when serializing.
plug-ins/metadata/xmp-encode.c | 30 +++++++++++++++++++++++-------
1 files changed, 23 insertions(+), 7 deletions(-)
---
diff --git a/plug-ins/metadata/xmp-encode.c b/plug-ins/metadata/xmp-encode.c
index 29cb644..f24a58f 100644
--- a/plug-ins/metadata/xmp-encode.c
+++ b/plug-ins/metadata/xmp-encode.c
@@ -99,6 +99,7 @@ static void
gen_property (GString *buffer,
const XMPSchema *schema,
const XMPProperty *property,
+ const gchar *value,
const gchar **value_array)
{
gint i;
@@ -153,18 +154,31 @@ gen_property (GString *buffer,
case XMP_TYPE_LANG_ALT:
g_string_append_printf (buffer, " <%s:%s>\n <rdf:Alt>\n",
schema->prefix, property->name);
- for (i = 0; value_array[i] != NULL; i += 2)
- {
- if (value_array[i+1] == NULL)
- {
+ if (value_array == NULL && value != NULL)
+ {
+ gen_element (buffer, 4,
+ "rdf", "li", value,
+ "xml:lang", "x-default",
+ NULL);
+ }
+ else
+ {
+ for (i = 0; value_array[i] != NULL; i += 2)
+ {
+ if (value_array[i+1] == NULL)
+ {
g_printerr("Bailing out:%s:%s", schema->prefix, property->name);
break;
- }
+ }
+ if (i == 0 && value_array[i+1] != value)
+ value_array[i+1] = g_strdup (value);
+
gen_element (buffer, 4,
"rdf", "li", value_array[i + 1],
"xml:lang", value_array[i],
NULL);
- }
+ }
+ }
g_string_append_printf (buffer, " </rdf:Alt>\n </%s:%s>\n",
schema->prefix, property->name);
break;
@@ -269,9 +283,11 @@ xmp_generate_packet (XMPModel *xmp_model,
{
const XMPProperty *property;
const gchar **value_array;
+ const gchar *value;
gtk_tree_model_get (model, &child,
COL_XMP_TYPE_XREF, &property,
+ COL_XMP_VALUE, &value,
COL_XMP_VALUE_RAW, &value_array,
-1);
/* do not process structured types multiple times */
@@ -279,7 +295,7 @@ xmp_generate_packet (XMPModel *xmp_model,
{
saved_ref = value_array;
g_return_if_fail (property->name != NULL);
- gen_property (buffer, schema, property, value_array);
+ gen_property (buffer, schema, property, value, value_array);
}
}
while (gtk_tree_model_iter_next (model, &child));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]