[gimp/wip/wormnest/add-thumbnail-pref] WIP: Add metadata preference for saving thumbnail by default




commit 7a68457039c782928f972ecb566fadc66790d535
Author: Jacob Boerema <jgboerema gmail com>
Date:   Wed Aug 25 15:00:45 2021 -0400

    WIP: Add metadata preference for saving thumbnail by default

 app/config/gimpcoreconfig.c              | 14 ++++++++++++++
 app/config/gimpcoreconfig.h              |  1 +
 app/config/gimprc-blurbs.h               |  3 +++
 app/dialogs/preferences-dialog.c         |  3 +++
 devel-docs/libgimp/libgimp3-sections.txt |  1 +
 libgimp/gimp.c                           | 17 +++++++++++++++++
 libgimp/gimp.def                         |  1 +
 libgimp/gimp.h                           |  1 +
 libgimp/gimpimagemetadata-save.c         |  2 +-
 libgimp/gimpsaveprocedure.c              |  5 +++--
 10 files changed, 45 insertions(+), 3 deletions(-)
---
diff --git a/app/config/gimpcoreconfig.c b/app/config/gimpcoreconfig.c
index e7ac85e050..c5b651fa28 100644
--- a/app/config/gimpcoreconfig.c
+++ b/app/config/gimpcoreconfig.c
@@ -124,6 +124,7 @@ enum
   PROP_EXPORT_FILE_TYPE,
   PROP_EXPORT_COLOR_PROFILE,
   PROP_EXPORT_COMMENT,
+  PROP_EXPORT_THUMBNAIL,
   PROP_EXPORT_METADATA_EXIF,
   PROP_EXPORT_METADATA_XMP,
   PROP_EXPORT_METADATA_IPTC,
@@ -790,6 +791,13 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
                             TRUE,
                             GIMP_PARAM_STATIC_STRINGS);
 
+  GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_EXPORT_THUMBNAIL,
+                            "export-thumbnail",
+                            "Export Thumbnail",
+                            EXPORT_THUMBNAIL_BLURB,
+                            TRUE,
+                            GIMP_PARAM_STATIC_STRINGS);
+
   GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_EXPORT_METADATA_EXIF,
                             "export-metadata-exif",
                             "Export Exif metadata",
@@ -1154,6 +1162,9 @@ gimp_core_config_set_property (GObject      *object,
     case PROP_EXPORT_COMMENT:
       core_config->export_comment = g_value_get_boolean (value);
       break;
+    case PROP_EXPORT_THUMBNAIL:
+      core_config->export_thumbnail = g_value_get_boolean (value);
+      break;
     case PROP_EXPORT_METADATA_EXIF:
       core_config->export_metadata_exif = g_value_get_boolean (value);
       break;
@@ -1383,6 +1394,9 @@ gimp_core_config_get_property (GObject    *object,
     case PROP_EXPORT_COMMENT:
       g_value_set_boolean (value, core_config->export_comment);
       break;
+    case PROP_EXPORT_THUMBNAIL:
+      g_value_set_boolean (value, core_config->export_thumbnail);
+      break;
     case PROP_EXPORT_METADATA_EXIF:
       g_value_set_boolean (value, core_config->export_metadata_exif);
       break;
diff --git a/app/config/gimpcoreconfig.h b/app/config/gimpcoreconfig.h
index 06d79770db..bb9acc4f45 100644
--- a/app/config/gimpcoreconfig.h
+++ b/app/config/gimpcoreconfig.h
@@ -99,6 +99,7 @@ struct _GimpCoreConfig
   GimpExportFileType      export_file_type;
   gboolean                export_color_profile;
   gboolean                export_comment;
+  gboolean                export_thumbnail;
   gboolean                export_metadata_exif;
   gboolean                export_metadata_xmp;
   gboolean                export_metadata_iptc;
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index daa5b0fe9f..df522508fc 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -226,6 +226,9 @@ _("Export the image's color profile by default.")
 #define EXPORT_COMMENT_BLURB \
 _("Export the image's comment by default.")
 
+#define EXPORT_THUMBNAIL_BLURB \
+_("Export the image's thumbnail by default")
+
 /* Translators: tooltip for configuration option (checkbox).
  * It determines how file export plug-ins handle Exif by default.
  */
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index d93c7102a5..cf4df03556 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -1519,6 +1519,9 @@ prefs_dialog_new (Gimp       *gimp,
   button = prefs_check_button_add (object, "export-comment",
                                    _("Export the image's comment by default"),
                                    GTK_BOX (vbox2));
+  button = prefs_check_button_add (object, "export-thumbnail",
+                                   _("Export the image's thumbnail by default"),
+                                   GTK_BOX (vbox2));
   button = prefs_check_button_add (object, "export-metadata-exif",
                                    /* Translators: label for
                                     * configuration option (checkbox).
diff --git a/devel-docs/libgimp/libgimp3-sections.txt b/devel-docs/libgimp/libgimp3-sections.txt
index 504af5eed3..3a1ce66258 100644
--- a/devel-docs/libgimp/libgimp3-sections.txt
+++ b/devel-docs/libgimp/libgimp3-sections.txt
@@ -14,6 +14,7 @@ gimp_export_comment
 gimp_export_exif
 gimp_export_xmp
 gimp_export_iptc
+gimp_export_thumbnail
 gimp_check_size
 gimp_check_type
 gimp_default_display
diff --git a/libgimp/gimp.c b/libgimp/gimp.c
index 2ccc9b3499..69c298e1a8 100644
--- a/libgimp/gimp.c
+++ b/libgimp/gimp.c
@@ -137,6 +137,7 @@ static gboolean            _export_comment       = FALSE;
 static gboolean            _export_exif          = FALSE;
 static gboolean            _export_xmp           = FALSE;
 static gboolean            _export_iptc          = FALSE;
+static gboolean            _export_thumbnail     = TRUE;
 static gint32              _num_processors       = 1;
 static GimpCheckSize       _check_size           = GIMP_CHECK_SIZE_MEDIUM_CHECKS;
 static GimpCheckType       _check_type           = GIMP_CHECK_TYPE_GRAY_CHECKS;
@@ -727,6 +728,22 @@ gimp_export_iptc (void)
   return _export_iptc;
 }
 
+/**
+ * gimp_export_thumbnail:
+ *
+ * Returns whether file plug-ins should default to exporting the
+ * image's comment.
+ *
+ * Returns: TRUE if preferences are set to export the thumbnail.
+ *
+ * Since: 3.0
+ **/
+gboolean
+gimp_export_thumbnail (void)
+{
+  return _export_thumbnail;
+}
+
 /**
  * gimp_get_num_processors:
  *
diff --git a/libgimp/gimp.def b/libgimp/gimp.def
index 8e5c2cced8..f26e1325d5 100644
--- a/libgimp/gimp.def
+++ b/libgimp/gimp.def
@@ -260,6 +260,7 @@ EXPORTS
        gimp_export_exif
        gimp_export_iptc
        gimp_export_xmp
+       gimp_export_thumbnail
        gimp_file_load
        gimp_file_load_layer
        gimp_file_load_layers
diff --git a/libgimp/gimp.h b/libgimp/gimp.h
index 9686719875..ae1a91138f 100644
--- a/libgimp/gimp.h
+++ b/libgimp/gimp.h
@@ -178,6 +178,7 @@ gboolean            gimp_export_comment       (void) G_GNUC_CONST;
 gboolean            gimp_export_exif          (void) G_GNUC_CONST;
 gboolean            gimp_export_xmp           (void) G_GNUC_CONST;
 gboolean            gimp_export_iptc          (void) G_GNUC_CONST;
+gboolean            gimp_export_thumbnail     (void) G_GNUC_CONST;
 gint                gimp_get_num_processors   (void) G_GNUC_CONST;
 GimpCheckSize       gimp_check_size           (void) G_GNUC_CONST;
 GimpCheckType       gimp_check_type           (void) G_GNUC_CONST;
diff --git a/libgimp/gimpimagemetadata-save.c b/libgimp/gimpimagemetadata-save.c
index ff9ba52fab..2174ae887c 100644
--- a/libgimp/gimpimagemetadata-save.c
+++ b/libgimp/gimpimagemetadata-save.c
@@ -223,7 +223,7 @@ gimp_image_metadata_save_prepare (GimpImage             *image,
 
   /* Thumbnail */
 
-  if (FALSE /* FIXME if (original image had a thumbnail) */)
+  if (! gimp_export_thumbnail () /* FIXME if (original image had a thumbnail) */)
     *suggested_flags &= ~GIMP_METADATA_SAVE_THUMBNAIL;
 
   /* Color profile */
diff --git a/libgimp/gimpsaveprocedure.c b/libgimp/gimpsaveprocedure.c
index 69346bec00..e18fafaca2 100644
--- a/libgimp/gimpsaveprocedure.c
+++ b/libgimp/gimpsaveprocedure.c
@@ -430,7 +430,7 @@ gimp_save_procedure_add_metadata (GimpSaveProcedure *save_procedure)
     GIMP_PROC_AUX_ARG_BOOLEAN (procedure, "save-thumbnail",
                                "Save _thumbnail",
                                "Save a smaller representation of the image as metadata",
-                               TRUE,
+                               gimp_export_thumbnail (),
                                G_PARAM_READWRITE);
   if (save_procedure->priv->supports_comment)
     {
@@ -684,7 +684,8 @@ gimp_save_procedure_set_support_profile (GimpSaveProcedure *procedure,
  *   properties to decide whether to save a given metadata or not.
  *
  * Note that since this is an auxiliary argument, it won't be part of
- * the PDB arguments. By default, the value will be %TRUE.
+ * the PDB arguments. By default, the value will be
+ * gimp_export_thumbnail().
  * Since: 3.0
  **/
 void


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