[gimp] plug-ins: in metadata-editor use /iptcExt instead of /Iptc4xmpExt when saving.



commit a95371c2b070c83b4807786ffd3ba12c7b808872
Author: Jacob Boerema <jgboerema gmail com>
Date:   Mon Mar 15 20:49:39 2021 -0400

    plug-ins: in metadata-editor use /iptcExt instead of /Iptc4xmpExt when saving.
    
    We need to work around an issue in Exiv2 that saving to /Iptc4xmpExt bag
    records fails which seems related to it registering /iptcExt. Unregistering
    that and registering the first one doesn't work.
    See: https://gitlab.gnome.org/GNOME/gexiv2/-/issues/24
    
    So let's use /iptcExt for saving even though it's the less common form
    for now. When loading metadata we try to load the most common
    form first and if that fails we will load /iptcExt.

 plug-ins/metadata/metadata-editor.c | 43 ++++++++++++++++++++++++++++++++++---
 plug-ins/metadata/metadata-tags.c   | 27 +++++++++++++++++++++++
 plug-ins/metadata/metadata-tags.h   |  3 +++
 3 files changed, 70 insertions(+), 3 deletions(-)
---
diff --git a/plug-ins/metadata/metadata-editor.c b/plug-ins/metadata/metadata-editor.c
index abb1836ba0..ea15fd9673 100644
--- a/plug-ins/metadata/metadata-editor.c
+++ b/plug-ins/metadata/metadata-editor.c
@@ -2313,6 +2313,7 @@ metadata_dialog_editor_set_metadata (GExiv2Metadata *metadata,
                                      GINT_TO_POINTER (COL_LOC_SHO_CNTRY_WRLD_REG));
                 }
 
+              /* Favor the most common form: /Iptc4xmpExt:* */
               counter = count_tags (metadata, LOCATIONSHOWN_HEADER,
                                     locationshown,
                                     n_locationshown);
@@ -2321,6 +2322,18 @@ metadata_dialog_editor_set_metadata (GExiv2Metadata *metadata,
                                   locationshown,
                                   n_locationshown, counter);
 
+              if (counter == 0 || ! tagdata)
+                {
+                  /* Alternatively try: /iptcExt:* */
+                  counter = count_tags (metadata, LOCATIONSHOWN_HEADER,
+                                        locationshown_alternative,
+                                        n_locationshown);
+
+                  tagdata = get_tags (metadata, LOCATIONSHOWN_HEADER,
+                                      locationshown_alternative,
+                                      n_locationshown, counter);
+                }
+
               if (counter > 0 && tagdata)
                 {
                   gint item;
@@ -2599,6 +2612,18 @@ metadata_dialog_editor_set_metadata (GExiv2Metadata *metadata,
                                   artworkorobject,
                                   n_artworkorobject, counter);
 
+              if (counter == 0 || ! tagdata)
+                {
+                  /* Alternatively try: /iptcExt:* */
+                  counter = count_tags (metadata, ARTWORKOROBJECT_HEADER,
+                                        artworkorobject_alternative,
+                                        n_artworkorobject);
+
+                  tagdata = get_tags (metadata, ARTWORKOROBJECT_HEADER,
+                                      artworkorobject_alternative,
+                                      n_artworkorobject, counter);
+                }
+
 
               if (counter > 0 && tagdata)
                 {
@@ -2759,6 +2784,18 @@ metadata_dialog_editor_set_metadata (GExiv2Metadata *metadata,
                                   registryid,
                                   n_registryid, counter);
 
+              if (counter == 0 || ! tagdata)
+                {
+                  /* Alternatively try: /iptcExt:* */
+                  counter = count_tags (metadata, REGISTRYID_HEADER,
+                                        registryid_alternative,
+                                        n_registryid);
+
+                  tagdata = get_tags (metadata, REGISTRYID_HEADER,
+                                      registryid_alternative,
+                                      n_registryid, counter);
+                }
+
               if (counter > 0 && tagdata)
                 {
                   gint item;
@@ -3950,15 +3987,15 @@ metadata_editor_write_callback (GtkWidget  *dialog,
 
   write_metadata_tag_multiple (builder, g_metadata, GEXIV2_STRUCTURE_XA_BAG,
                                "Xmp.iptcExt.LocationShown",
-                               n_locationshown, locationshown, NULL);
+                               n_locationshown, locationshown_alternative, NULL);
 
   write_metadata_tag_multiple (builder, g_metadata, GEXIV2_STRUCTURE_XA_BAG,
                                "Xmp.iptcExt.ArtworkOrObject",
-                               n_artworkorobject, artworkorobject, NULL);
+                               n_artworkorobject, artworkorobject_alternative, NULL);
 
   write_metadata_tag_multiple (builder, g_metadata, GEXIV2_STRUCTURE_XA_BAG,
                                "Xmp.iptcExt.RegistryId",
-                               n_registryid, registryid, NULL);
+                               n_registryid, registryid_alternative, NULL);
 
   write_metadata_tag_multiple (builder, g_metadata, GEXIV2_STRUCTURE_XA_SEQ,
                                "Xmp.plus.ImageCreator",
diff --git a/plug-ins/metadata/metadata-tags.c b/plug-ins/metadata/metadata-tags.c
index dc723790af..9fae102041 100644
--- a/plug-ins/metadata/metadata-tags.c
+++ b/plug-ins/metadata/metadata-tags.c
@@ -390,6 +390,12 @@ const gchar *registryid[] =
 };
 const gint n_registryid = G_N_ELEMENTS (registryid);
 
+const gchar *registryid_alternative[] =
+{
+  "/iptcExt:RegOrgId",
+  "/iptcExt:RegItemId"
+};
+
 const gchar *artworkorobject[] =
 {
   "/Iptc4xmpExt:AOTitle",
@@ -401,6 +407,16 @@ const gchar *artworkorobject[] =
 };
 const gint n_artworkorobject = G_N_ELEMENTS (artworkorobject);
 
+const gchar *artworkorobject_alternative[] =
+{
+  "/iptcExt:AOTitle",
+  "/iptcExt:AODateCreated",
+  "/iptcExt:AOCreator",
+  "/iptcExt:AOSource",
+  "/iptcExt:AOSourceInvNo",
+  "/iptcExt:AOCopyrightNotice",
+};
+
 const gchar *locationshown[] =
 {
   "/Iptc4xmpExt:Sublocation",
@@ -412,6 +428,17 @@ const gchar *locationshown[] =
 };
 const gint n_locationshown = G_N_ELEMENTS (locationshown);
 
+const gchar *locationshown_alternative[] =
+{
+  "/iptcExt:Sublocation",
+  "/iptcExt:City",
+  "/iptcExt:ProvinceState",
+  "/iptcExt:CountryName",
+  "/iptcExt:CountryCode",
+  "/iptcExt:WorldRegion"
+};
+
+
 #ifdef USE_TAGS
 const gchar *locationcreated[] =
 {
diff --git a/plug-ins/metadata/metadata-tags.h b/plug-ins/metadata/metadata-tags.h
index e3df58f827..81209d5be1 100644
--- a/plug-ins/metadata/metadata-tags.h
+++ b/plug-ins/metadata/metadata-tags.h
@@ -225,14 +225,17 @@ extern const gint   n_copyrightowner;
 
 #define REGISTRYID_HEADER "Xmp.iptcExt.RegistryId"
 extern const gchar *registryid[];
+extern const gchar *registryid_alternative[];
 extern const gint   n_registryid;
 
 #define ARTWORKOROBJECT_HEADER "Xmp.iptcExt.ArtworkOrObject"
 extern const gchar *artworkorobject[];
+extern const gchar *artworkorobject_alternative[];
 extern const gint   n_artworkorobject;
 
 #define LOCATIONSHOWN_HEADER "Xmp.iptcExt.LocationShown"
 extern const gchar *locationshown[];
+extern const gchar *locationshown_alternative[];
 extern const gint   n_locationshown;
 
 #ifdef USE_TAGS


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