mirror of https://github.com/GNOME/gimp.git
plug-ins: improve loading of XMP BAG/SEQ tags in metadata-editor
XMP array tags of type BAG and SEQ can have multiple values, each of these values needs to be on a separate line to be correctly recognized as a different value in the tag array. We were incorrectly loading all values on one line separated by a comma. For those tags that have equivalent IPTC tags we were also comparing just the one XMP value with the whole, possibly multiple lines, of the same IPTC, which could cause a failure to recognize identical tags. We changed this to now have each value in a tag array on a separate line by adding \n between values. Each IPTC equivalent tag value is now compared to each value in the XMP tag array and only added when a different value is found.
This commit is contained in:
parent
baaa1380cf
commit
76dc649b3f
|
@ -2081,6 +2081,90 @@ metadata_dialog_editor_set_metadata (GExiv2Metadata *metadata,
|
|||
continue;
|
||||
}
|
||||
|
||||
index = default_metadata_tags[i].other_tag_index;
|
||||
|
||||
if (default_metadata_tags[i].xmp_type == GIMP_XMP_BAG ||
|
||||
default_metadata_tags[i].xmp_type == GIMP_XMP_SEQ)
|
||||
{
|
||||
gchar **values;
|
||||
|
||||
value = NULL;
|
||||
values = gexiv2_metadata_get_tag_multiple (metadata,
|
||||
default_metadata_tags[i].tag);
|
||||
|
||||
if (values)
|
||||
{
|
||||
gint vi;
|
||||
|
||||
for (vi = 0; values[vi] != NULL; vi++)
|
||||
{
|
||||
gchar *value_clean;
|
||||
|
||||
value_clean = clean_xmp_string (values[vi]);
|
||||
|
||||
if (value_clean != NULL && value_clean[0] != '\0')
|
||||
{
|
||||
if (! value)
|
||||
{
|
||||
value = g_strdup (value_clean);
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar *tmpvalue;
|
||||
|
||||
tmpvalue = value;
|
||||
value = g_strconcat (value, "\n", value_clean, NULL);
|
||||
g_free (tmpvalue);
|
||||
}
|
||||
}
|
||||
g_free (value_clean);
|
||||
}
|
||||
}
|
||||
|
||||
if (index > -1)
|
||||
{
|
||||
gchar **equiv_values;
|
||||
|
||||
/* These are all IPTC tags some of which can appear multiple times so
|
||||
* we will use get_tag_multiple. Also IPTC most commonly uses UTF-8
|
||||
* not current locale so get_tag_interpreted was wrong anyway.
|
||||
* FIXME For now lets interpret as UTF-8 and in the future read
|
||||
* and interpret based on the CharacterSet tag.
|
||||
*/
|
||||
equiv_values = gexiv2_metadata_get_tag_multiple (metadata,
|
||||
equivalent_metadata_tags[index].tag);
|
||||
|
||||
if (equiv_values)
|
||||
{
|
||||
gint evi;
|
||||
|
||||
for (evi = 0; equiv_values[evi] != NULL; evi++)
|
||||
{
|
||||
if (equiv_values[evi][0] != '\0')
|
||||
{
|
||||
if (! value)
|
||||
{
|
||||
value = g_strdup (equiv_values[evi]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! g_strv_contains (values, equiv_values[evi]))
|
||||
{
|
||||
gchar *tmpvalue;
|
||||
|
||||
tmpvalue = value;
|
||||
value = g_strconcat (value, "\n", equiv_values[evi], NULL);
|
||||
g_free (tmpvalue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
g_strfreev (values);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = gexiv2_metadata_get_tag_interpreted_string (metadata,
|
||||
default_metadata_tags[i].tag);
|
||||
|
||||
|
@ -2102,14 +2186,14 @@ metadata_dialog_editor_set_metadata (GExiv2Metadata *metadata,
|
|||
g_free (value_utf8);
|
||||
}
|
||||
|
||||
index = default_metadata_tags[i].other_tag_index;
|
||||
if (index > -1)
|
||||
{
|
||||
gchar **values;
|
||||
|
||||
/* These are all IPTC tags some of which can appear multiple times so
|
||||
* we will use get_tag_multiple. Also IPTC most commonly uses UTF-8
|
||||
* not current locale so get_tag_interpreted was wrong anyway.
|
||||
/* It's not very likely we will have an XMP tag that can only
|
||||
* have a single value instead of an array, which corresponds to
|
||||
* an IPTC tag that can have multiple values, but since we
|
||||
* already have this code it can't hurt to keep testing for it.
|
||||
* FIXME For now lets interpret as UTF-8 and in the future read
|
||||
* and interpret based on the CharacterSet tag.
|
||||
*/
|
||||
|
@ -2167,6 +2251,7 @@ metadata_dialog_editor_set_metadata (GExiv2Metadata *metadata,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp ("list", default_metadata_tags[i].mode))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue