Commit e933a216 authored by Paolo Bacchilega's avatar Paolo Bacchilega

gThumb destroys metadata by flattening XMP lists

save XmpBag and XmpSeq data types as string lists, and
recreate the lists before saving to file.

[bug #674908]
parent 2e7ec5bf
......@@ -293,6 +293,23 @@ create_metadata (const char *key,
}
static void
add_string_list_to_metadata (GthMetadata *metadata,
const Exiv2::Value &value)
{
GList *list = NULL;
GthStringList *string_list;
for (int i = 0; i < value.count(); i++)
list = g_list_prepend (list, g_strdup (value.toString(i).c_str()));
string_list = gth_string_list_new (g_list_reverse (list));
g_object_set (metadata, "string-list", string_list, NULL);
g_object_unref (string_list);
_g_string_list_free (list);
}
static void
set_file_info (GFileInfo *info,
const char *key,
......@@ -651,6 +668,13 @@ exiv2_read_metadata (Exiv2::Image::AutoPtr image,
raw_value.str().c_str(),
"Xmp::Embedded",
md->typeName());
if ((g_strcmp0 (md->typeName(), "XmpBag") == 0)
|| (g_strcmp0 (md->typeName(), "XmpSeq") == 0))
{
add_string_list_to_metadata (metadata, md->value());
}
add_metadata_to_hash (table, metadata);
_g_object_unref (metadata);
}
......@@ -1111,12 +1135,28 @@ exiv2_write_metadata_private (Exiv2::Image::AutoPtr image,
}
}
else if (GTH_IS_METADATA (metadatum)) {
const char *raw_value;
const char *raw_value;
GthStringList *string_list;
GList *scan;
raw_value = gth_metadata_get_raw (GTH_METADATA (metadatum));
if ((raw_value != NULL) && (strcmp (raw_value, "") != 0)) {
value->read (raw_value);
xd.add (xmp_key, value.get());
switch (gth_metadata_get_data_type (GTH_METADATA (metadatum))) {
case GTH_METADATA_TYPE_STRING:
raw_value = gth_metadata_get_raw (GTH_METADATA (metadatum));
if ((raw_value != NULL) && (strcmp (raw_value, "") != 0)) {
value->read (raw_value);
xd.add (xmp_key, value.get());
}
break;
case GTH_METADATA_TYPE_STRING_LIST:
string_list = gth_metadata_get_string_list (GTH_METADATA (metadatum));
for (scan = gth_string_list_get_list (string_list); scan; scan = scan->next) {
char *single_value = (char *) scan->data;
value->read (single_value);
xd.add (xmp_key, value.get());
}
break;
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment