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.
This commit is contained in:
Jacob Boerema 2021-08-25 15:00:45 -04:00
parent 54bd8c8763
commit 352ef68c46
10 changed files with 45 additions and 3 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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.
*/

View File

@ -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).

View File

@ -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

View File

@ -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:
*

View File

@ -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

View File

@ -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;

View File

@ -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 */

View File

@ -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