[gimp/wip/wormnest/iptc-multiple-keys: 7/7] plug-ins: fix not showing all values of iptc tags that appear more than once.




commit 0ce704ce14cde70c6c506d1476099b7a5e699652
Author: Jacob Boerema <jgboerema gmail com>
Date:   Mon Nov 16 19:09:07 2020 -0500

    plug-ins: fix not showing all values of iptc tags that appear more than once.
    
    This is one of the problems mentioned in issue #5863. This commit fixes
    this problem in the metadata-editor by using gexiv2_metadata_get_tag_multiple.
    Empty string values will be skipped.

 plug-ins/metadata/metadata-editor.c | 46 +++++++++++++++++++++++++++++++++++--
 1 file changed, 44 insertions(+), 2 deletions(-)
---
diff --git a/plug-ins/metadata/metadata-editor.c b/plug-ins/metadata/metadata-editor.c
index 8350adb6a0..a05bf7b483 100644
--- a/plug-ins/metadata/metadata-editor.c
+++ b/plug-ins/metadata/metadata-editor.c
@@ -1910,8 +1910,50 @@ metadata_dialog_editor_set_metadata (GExiv2Metadata *metadata,
           index = default_metadata_tags[i].other_tag_index;
           if (index > -1)
             {
-              value = gexiv2_metadata_get_tag_interpreted_string (metadata,
-                                                                  equivalent_metadata_tags[index].tag);
+              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.
+               * FIXME For now lets interpret as UTF-8 and in the future read
+               * and interpret based on the CharacterSet tag.
+               */
+              values = gexiv2_metadata_get_tag_multiple (metadata,
+                                                         equivalent_metadata_tags[index].tag);
+
+              if (values)
+                {
+                  gint     i;
+                  GString *str = NULL;
+
+                  for (i = 0; values[i] != NULL; i++)
+                    {
+                      if (values[i][0] != '\0')
+                        {
+                          if (! str)
+                            {
+                              str = g_string_new (values[i]);
+                            }
+                          else
+                            {
+                              if (! strcmp ("multi", equivalent_metadata_tags[index].mode))
+                                {
+                                  g_string_append (str, "\n");
+                                }
+                              else
+                                {
+                                  g_string_append (str, ", ");
+                                }
+                              g_string_append (str, values[i]);
+                            }
+                        }
+                    }
+
+                  if (str)
+                    {
+                      value = g_string_free (str, FALSE);
+                    }
+                }
             }
         }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]