[gimp/wip/wormnest/add-thumbnail-pref: 160/160] app, libgimp: Add metadata preference for saving thumbnail by default




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

    app, libgimp: Add metadata preference for saving thumbnail by default
    
    Saving a thumbnail is closely related to the other metadata preferences,
    but so far this was the only one that didn't have a preference for a
    default user value.
    This commit adds a preference in the metadata section where a user can
    select whether thumbnail saving is enabled by default or not.

 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 72a116dcef..428c996943 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,
@@ -793,6 +794,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",
@@ -1168,6 +1176,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;
@@ -1421,6 +1432,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 3b9bd49226..acac7e8675 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 df04e20af4..5522014142 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 1d77e072c9..ad07a7252c 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -1551,6 +1551,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..154f44f094 100644
--- a/libgimp/gimp.def
+++ b/libgimp/gimp.def
@@ -259,6 +259,7 @@ EXPORTS
        gimp_export_comment
        gimp_export_exif
        gimp_export_iptc
+       gimp_export_thumbnail
        gimp_export_xmp
        gimp_file_load
        gimp_file_load_layer
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 ff2ae4e57a..31563614db 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]