[gimp/wip/wormnest/iptc-multiple-keys: 5/14] plug-ins: fix incorrect reading of iptc tags that appear more than once.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/wormnest/iptc-multiple-keys: 5/14] plug-ins: fix incorrect reading of iptc tags that appear more than once.
- Date: Thu, 19 Nov 2020 23:25:28 +0000 (UTC)
commit 26db975a849bf5e7b72bd8c1c7a7e8188ac1e2e7
Author: Jacob Boerema <jgboerema gmail com>
Date: Mon Nov 16 14:27:54 2020 -0500
plug-ins: fix incorrect reading of iptc tags that appear more than once.
This is one of the problems mentioned in issue #5863. This commit only fixes
this problem in the metadata-viewer.
plug-ins/metadata/metadata-viewer.c | 74 ++++++++++++++++++++++++++++++-------
1 file changed, 60 insertions(+), 14 deletions(-)
---
diff --git a/plug-ins/metadata/metadata-viewer.c b/plug-ins/metadata/metadata-viewer.c
index e62e938c1e..9f2c849e43 100644
--- a/plug-ins/metadata/metadata-viewer.c
+++ b/plug-ins/metadata/metadata-viewer.c
@@ -105,7 +105,8 @@ static void metadata_dialog_append_tags (GExiv2Metadata *metadata,
gchar **tags,
GtkListStore *store,
gint tag_column,
- gint value_column);
+ gint value_column,
+ gboolean load_iptc);
static gchar * metadata_dialog_format_tag_value (GExiv2Metadata *metadata,
const gchar *tag,
gboolean truncate);
@@ -299,7 +300,7 @@ metadata_dialog_set_metadata (GExiv2Metadata *metadata,
tags = gexiv2_metadata_get_exif_tags (metadata);
store = GTK_LIST_STORE (gtk_builder_get_object (builder, "exif-liststore"));
- metadata_dialog_append_tags (metadata, tags, store, C_EXIF_TAG, C_EXIF_VALUE);
+ metadata_dialog_append_tags (metadata, tags, store, C_EXIF_TAG, C_EXIF_VALUE, FALSE);
g_strfreev (tags);
@@ -307,7 +308,7 @@ metadata_dialog_set_metadata (GExiv2Metadata *metadata,
tags = gexiv2_metadata_get_xmp_tags (metadata);
store = GTK_LIST_STORE (gtk_builder_get_object (builder, "xmp-liststore"));
- metadata_dialog_append_tags (metadata, tags, store, C_XMP_TAG, C_XMP_VALUE);
+ metadata_dialog_append_tags (metadata, tags, store, C_XMP_TAG, C_XMP_VALUE, FALSE);
g_strfreev (tags);
@@ -315,7 +316,7 @@ metadata_dialog_set_metadata (GExiv2Metadata *metadata,
tags = gexiv2_metadata_get_iptc_tags (metadata);
store = GTK_LIST_STORE (gtk_builder_get_object (builder, "iptc-liststore"));
- metadata_dialog_append_tags (metadata, tags, store, C_IPTC_TAG, C_IPTC_VALUE);
+ metadata_dialog_append_tags (metadata, tags, store, C_IPTC_TAG, C_IPTC_VALUE, TRUE);
g_strfreev (tags);
}
@@ -370,26 +371,71 @@ metadata_dialog_append_tags (GExiv2Metadata *metadata,
gchar **tags,
GtkListStore *store,
gint tag_column,
- gint value_column)
+ gint value_column,
+ gboolean load_iptc)
{
GtkTreeIter iter;
const gchar *tag;
+ const gchar *last_tag = NULL;
while ((tag = *tags++))
{
- gchar *value;
+ gchar *value;
+ gchar **values;
+
+ /* We need special handling for iptc tags like "Keywords" which
+ * can appear multiple times. For now assuming that this can
+ * only happen for iptc tags of String and related types.
+ * See also: https://exiv2.org/iptc.html which only lists
+ * one Date type as repeatable (Iptc.Application2.ReferenceDate),
+ * and Date is handled here as string.
+ */
+ if (load_iptc && metadata_tag_is_string (tag))
+ {
+ if (last_tag && ! strcmp (tag, last_tag))
+ {
+ continue;
+ }
+ last_tag = tag;
- gtk_list_store_append (store, &iter);
+ values = gexiv2_metadata_get_tag_multiple (GEXIV2_METADATA (metadata),
+ tag);
- value = metadata_dialog_format_tag_value (metadata, tag,
- /* truncate = */ TRUE);
+ if (values)
+ {
+ gint i;
- gtk_list_store_set (store, &iter,
- tag_column, tag,
- value_column, value,
- -1);
+ for (i = 0; values[i] != NULL; i++)
+ {
+ gtk_list_store_append (store, &iter);
- g_free (value);
+ value = metadata_format_string_value (values[i], /* truncate = */ TRUE);
+
+ gtk_list_store_set (store, &iter,
+ tag_column, tag,
+ value_column, value,
+ -1);
+
+ g_free (value);
+ }
+
+ g_strfreev (values);
+ }
+
+ }
+ else
+ {
+ value = metadata_dialog_format_tag_value (metadata, tag,
+ /* truncate = */ TRUE);
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ tag_column, tag,
+ value_column, value,
+ -1);
+
+ g_free (value);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]