From 4d8cbce87fe21a2d098543052017d29c589c2466 Mon Sep 17 00:00:00 2001 From: programmer_ceds Date: Tue, 14 Nov 2023 14:48:21 +0000 Subject: [PATCH] Optionally always offer default file type when exporting (take 2) --- app/config/gimpcoreconfig.c | 14 ++++++++++++++ app/config/gimpcoreconfig.h | 1 + app/config/gimprc-blurbs.h | 3 +++ app/dialogs/preferences-dialog.c | 9 +++++++++ app/widgets/gimpexportdialog.c | 19 +++++++++++-------- etc/gimprc.in | 5 +++++ 6 files changed, 43 insertions(+), 8 deletions(-) diff --git a/app/config/gimpcoreconfig.c b/app/config/gimpcoreconfig.c index 3d3ab88c87..09990ec408 100644 --- a/app/config/gimpcoreconfig.c +++ b/app/config/gimpcoreconfig.c @@ -114,6 +114,7 @@ enum PROP_IMPORT_ADD_ALPHA, PROP_IMPORT_RAW_PLUG_IN, PROP_EXPORT_FILE_TYPE, + PROP_EXPORT_FILE_TYPE_ALWAYS, PROP_EXPORT_COLOR_PROFILE, PROP_EXPORT_COMMENT, PROP_EXPORT_THUMBNAIL, @@ -741,6 +742,13 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass) GIMP_EXPORT_FILE_PNG, GIMP_PARAM_STATIC_STRINGS); + GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_EXPORT_FILE_TYPE_ALWAYS, + "export-file-type-always", + "Always offer default export file type", + EXPORT_FILE_TYPE_ALWAYS_BLURB, + FALSE, + GIMP_PARAM_STATIC_STRINGS); + GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_EXPORT_COLOR_PROFILE, "export-color-profile", "Export Color Profile", @@ -1149,6 +1157,9 @@ gimp_core_config_set_property (GObject *object, case PROP_EXPORT_FILE_TYPE: core_config->export_file_type = g_value_get_enum (value); break; + case PROP_EXPORT_FILE_TYPE_ALWAYS: + core_config->export_file_type_always = g_value_get_boolean (value); + break; case PROP_EXPORT_COLOR_PROFILE: core_config->export_color_profile = g_value_get_boolean (value); break; @@ -1414,6 +1425,9 @@ gimp_core_config_get_property (GObject *object, case PROP_EXPORT_FILE_TYPE: g_value_set_enum (value, core_config->export_file_type); break; + case PROP_EXPORT_FILE_TYPE_ALWAYS: + g_value_set_boolean (value, core_config->export_file_type_always); + break; case PROP_EXPORT_COLOR_PROFILE: g_value_set_boolean (value, core_config->export_color_profile); break; diff --git a/app/config/gimpcoreconfig.h b/app/config/gimpcoreconfig.h index 3ebc62bea9..abccf39d23 100644 --- a/app/config/gimpcoreconfig.h +++ b/app/config/gimpcoreconfig.h @@ -98,6 +98,7 @@ struct _GimpCoreConfig gboolean import_add_alpha; gchar *import_raw_plug_in; GimpExportFileType export_file_type; + gboolean export_file_type_always; gboolean export_color_profile; gboolean export_comment; gboolean export_thumbnail; diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h index dc7445c888..e8cdaea633 100644 --- a/app/config/gimprc-blurbs.h +++ b/app/config/gimprc-blurbs.h @@ -229,6 +229,9 @@ _("Which plug-in to use for importing raw digital camera files.") #define EXPORT_FILE_TYPE_BLURB \ _("Export file type used by default.") +#define EXPORT_FILE_TYPE_ALWAYS_BLURB \ +_("Always offer the default export file type when exporting.") + #define EXPORT_COLOR_PROFILE_BLURB \ _("Export the image's color profile by default.") diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c index 0ac7eabed2..13a77f0ae3 100644 --- a/app/dialogs/preferences-dialog.c +++ b/app/dialogs/preferences-dialog.c @@ -1685,6 +1685,15 @@ prefs_dialog_new (Gimp *gimp, _("Default export file t_ype:"), GTK_GRID (grid), 0, size_group); + button = prefs_check_button_add (object, "export-file-type-always", + /* Translators: label for + * configuration option (checkbox). + * If selected the default export file type is always + * offered when exporting even if the file type is known.. + */ + _("Always offer the default file type when exporting"), + GTK_BOX (vbox2)); + /* Raw Image Importer */ vbox2 = prefs_frame_new (_("Raw Image Importer"), GTK_CONTAINER (vbox), TRUE); diff --git a/app/widgets/gimpexportdialog.c b/app/widgets/gimpexportdialog.c index 02ccad0c30..2806b606db 100644 --- a/app/widgets/gimpexportdialog.c +++ b/app/widgets/gimpexportdialog.c @@ -165,16 +165,19 @@ gimp_export_dialog_set_image (GimpExportDialog *dialog, * 4. Default file type set in Preferences */ - ext_file = gimp_image_get_exported_file (image); + if (! image->gimp->config->export_file_type_always) + { + ext_file = gimp_image_get_exported_file (image); - if (! ext_file) - ext_file = gimp_image_get_imported_file (image); + if (ext_file == NULL) + ext_file = gimp_image_get_imported_file (image); - if (! ext_file) - ext_file = g_object_get_data (G_OBJECT (file_dialog->gimp), - GIMP_FILE_EXPORT_LAST_FILE_KEY); + if (ext_file == NULL) + ext_file = g_object_get_data (G_OBJECT (file_dialog->gimp), + GIMP_FILE_EXPORT_LAST_FILE_KEY); + } - if (ext_file) + if (ext_file != NULL) { g_object_ref (ext_file); } @@ -193,7 +196,7 @@ gimp_export_dialog_set_image (GimpExportDialog *dialog, g_free (uri); } - if (ext_file) + if (ext_file != NULL) { GFile *tmp_file = gimp_file_with_new_extension (name_file, ext_file); basename = g_path_get_basename (gimp_file_get_utf8_name (tmp_file)); diff --git a/etc/gimprc.in b/etc/gimprc.in index 9f8afa102a..69ffcba8e1 100644 --- a/etc/gimprc.in +++ b/etc/gimprc.in @@ -365,6 +365,11 @@ # # (export-file-type png) +# Always offer the default file type when exporting an image file. Possible +# values are yes and no +# +# (export-file-type-always no) + # Export the image's color profile by default. Possible values are yes and # no. #