[gimp] plug-ins: port file-heif and file-webp to the new export stuff



commit b5f10b6edaacb39e2d7f92fbc1b459f5b926b83a
Author: Michael Natterer <mitch gimp org>
Date:   Wed Oct 9 23:50:14 2019 +0200

    plug-ins: port file-heif and file-webp to the new export stuff

 plug-ins/common/file-heif.c    | 38 ++++++-----------------
 plug-ins/file-webp/file-webp.c | 69 +++++++++---------------------------------
 2 files changed, 23 insertions(+), 84 deletions(-)
---
diff --git a/plug-ins/common/file-heif.c b/plug-ins/common/file-heif.c
index 0ba3c609a1..85f75d44af 100644
--- a/plug-ins/common/file-heif.c
+++ b/plug-ins/common/file-heif.c
@@ -250,19 +250,17 @@ heif_save (GimpProcedure        *procedure,
           const GimpValueArray *args,
           gpointer              run_data)
 {
-  GimpProcedureConfig  *config;
-  GimpPDBStatusType     status = GIMP_PDB_SUCCESS;
-  GimpExportReturn      export = GIMP_EXPORT_CANCEL;
-  GimpImage            *orig_image;
-  GError               *error  = NULL;
+  GimpProcedureConfig *config;
+  GimpPDBStatusType    status = GIMP_PDB_SUCCESS;
+  GimpExportReturn     export = GIMP_EXPORT_CANCEL;
+  GError              *error  = NULL;
 
   INIT_I18N ();
   gegl_init (NULL, NULL);
 
   config = gimp_procedure_create_config (procedure);
-  gimp_procedure_config_begin_run (config, image, run_mode, args);
-
-  orig_image = image;
+  gimp_procedure_config_begin_export (config, image, run_mode,
+                                      args, "image/heif");
 
   switch (run_mode)
     {
@@ -292,32 +290,14 @@ heif_save (GimpProcedure        *procedure,
 
   if (status == GIMP_PDB_SUCCESS)
     {
-      if (save_image (file, image, drawable, G_OBJECT (config),
-                      &error))
-        {
-          GimpMetadata          *metadata;
-          GimpMetadataSaveFlags  metadata_flags;
-
-          metadata = gimp_image_metadata_save_prepare (orig_image,
-                                                       "image/heif",
-                                                       &metadata_flags);
-
-          if (metadata)
-            {
-              gimp_image_metadata_save_finish (image,
-                                               "image/heif",
-                                               metadata, metadata_flags,
-                                               file, NULL);
-              g_object_unref (metadata);
-            }
-        }
-      else
+      if (! save_image (file, image, drawable, G_OBJECT (config),
+                        &error))
         {
           status = GIMP_PDB_EXECUTION_ERROR;
         }
     }
 
-  gimp_procedure_config_end_run (config, status);
+  gimp_procedure_config_end_export (config, image, file, status);
   g_object_unref (config);
 
   if (export == GIMP_EXPORT_EXPORT)
diff --git a/plug-ins/file-webp/file-webp.c b/plug-ins/file-webp/file-webp.c
index 0ba5b7b9f7..e6d5cb05f1 100644
--- a/plug-ins/file-webp/file-webp.c
+++ b/plug-ins/file-webp/file-webp.c
@@ -288,35 +288,24 @@ webp_save (GimpProcedure        *procedure,
           const GimpValueArray *args,
           gpointer              run_data)
 {
-  GimpProcedureConfig   *config;
-  GimpPDBStatusType      status   = GIMP_PDB_SUCCESS;
-  GimpExportReturn       export   = GIMP_EXPORT_CANCEL;
-  GimpMetadata          *metadata = NULL;
-  GimpMetadataSaveFlags  metadata_flags;
-  gboolean               animation;
-  GError                *error    = NULL;
+  GimpProcedureConfig *config;
+  GimpPDBStatusType    status = GIMP_PDB_SUCCESS;
+  GimpExportReturn     export = GIMP_EXPORT_CANCEL;
+  GimpMetadata        *metadata;
+  gboolean             animation;
+  GError              *error  = NULL;
 
   INIT_I18N ();
   gegl_init (NULL, NULL);
 
   config = gimp_procedure_create_config (procedure);
-  gimp_procedure_config_begin_run (config, image, run_mode, args);
+  metadata = gimp_procedure_config_begin_export (config, image, run_mode,
+                                                 args, "image/webp");
 
   if (run_mode == GIMP_RUN_INTERACTIVE ||
       run_mode == GIMP_RUN_WITH_LAST_VALS)
     gimp_ui_init (PLUG_IN_BINARY);
 
-  /* Override the defaults with preferences. */
-  metadata = gimp_image_metadata_save_prepare (image,
-                                               "image/webp",
-                                               &metadata_flags);
-#if 0
-  params.save_exif    = (metadata_flags & GIMP_METADATA_SAVE_EXIF) != 0;
-  params.save_xmp     = (metadata_flags & GIMP_METADATA_SAVE_XMP) != 0;
-  params.save_iptc    = (metadata_flags & GIMP_METADATA_SAVE_IPTC) != 0;
-  params.save_profile = (metadata_flags & GIMP_METADATA_SAVE_COLOR_PROFILE) != 0;
-#endif
-
   if (run_mode == GIMP_RUN_INTERACTIVE)
     {
       if (! save_dialog (image, procedure, G_OBJECT (config)))
@@ -368,50 +357,20 @@ webp_save (GimpProcedure        *procedure,
 
   if (status == GIMP_PDB_SUCCESS && metadata)
     {
-      gboolean save_exif;
       gboolean save_xmp;
-      gboolean save_iptc;
-      gboolean save_profile;
 
+      /* WebP doesn't support iptc natively and sets it via xmp */
       g_object_get (config,
-                    "save-exif",    &save_exif,
-                    "save-xmp",     &save_xmp,
-                    "save-iptc",    &save_iptc,
-                    "save-profile", &save_profile,
+                    "save-xmp", &save_xmp,
+                    NULL);
+      g_object_set (config,
+                    "save-iptc", save_xmp,
                     NULL);
-
-      /* WebP doesn't support iptc natively and sets it via xmp */
-      save_iptc = save_xmp;
 
       gimp_metadata_set_bits_per_sample (metadata, 8);
-
-      if (save_exif)
-        metadata_flags |= GIMP_METADATA_SAVE_EXIF;
-      else
-        metadata_flags &= ~GIMP_METADATA_SAVE_EXIF;
-
-      if (save_xmp)
-        metadata_flags |= GIMP_METADATA_SAVE_XMP;
-      else
-        metadata_flags &= ~GIMP_METADATA_SAVE_XMP;
-
-      if (save_iptc)
-        metadata_flags |= GIMP_METADATA_SAVE_IPTC;
-      else
-        metadata_flags &= ~GIMP_METADATA_SAVE_IPTC;
-
-      if (save_profile)
-        metadata_flags |= GIMP_METADATA_SAVE_COLOR_PROFILE;
-      else
-        metadata_flags &= ~GIMP_METADATA_SAVE_COLOR_PROFILE;
-
-      gimp_image_metadata_save_finish (image,
-                                       "image/webp",
-                                       metadata, metadata_flags,
-                                       file, NULL);
     }
 
-  gimp_procedure_config_end_run (config, status);
+  gimp_procedure_config_end_export (config, image, file, status);
   g_object_unref (config);
 
   if (export == GIMP_EXPORT_EXPORT)


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