mirror of https://github.com/GNOME/gimp.git
Issue #1299 - Add selection of default export file type
Patch cleaned up by Alexandre Prokoudine and Michael Natterer.
This commit is contained in:
parent
d90b0024f0
commit
bfbad0a5ca
|
@ -101,6 +101,47 @@ gimp_cursor_mode_get_type (void)
|
|||
return type;
|
||||
}
|
||||
|
||||
GType
|
||||
gimp_export_file_type_get_type (void)
|
||||
{
|
||||
static const GEnumValue values[] =
|
||||
{
|
||||
{ GIMP_EXPORT_FILE_PNG, "GIMP_EXPORT_FILE_PNG", "png" },
|
||||
{ GIMP_EXPORT_FILE_JPG, "GIMP_EXPORT_FILE_JPG", "jpg" },
|
||||
{ GIMP_EXPORT_FILE_ORA, "GIMP_EXPORT_FILE_ORA", "ora" },
|
||||
{ GIMP_EXPORT_FILE_PSD, "GIMP_EXPORT_FILE_PSD", "psd" },
|
||||
{ GIMP_EXPORT_FILE_PDF, "GIMP_EXPORT_FILE_PDF", "pdf" },
|
||||
{ GIMP_EXPORT_FILE_TIF, "GIMP_EXPORT_FILE_TIF", "tif" },
|
||||
{ GIMP_EXPORT_FILE_BMP, "GIMP_EXPORT_FILE_BMP", "bmp" },
|
||||
{ GIMP_EXPORT_FILE_WEBP, "GIMP_EXPORT_FILE_WEBP", "webp" },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static const GimpEnumDesc descs[] =
|
||||
{
|
||||
{ GIMP_EXPORT_FILE_PNG, NC_("export-file-type", "PNG Image"), NULL },
|
||||
{ GIMP_EXPORT_FILE_JPG, NC_("export-file-type", "JPEG Image"), NULL },
|
||||
{ GIMP_EXPORT_FILE_ORA, NC_("export-file-type", "OpenRaster Image"), NULL },
|
||||
{ GIMP_EXPORT_FILE_PSD, NC_("export-file-type", "Photoshop Image"), NULL },
|
||||
{ GIMP_EXPORT_FILE_PDF, NC_("export-file-type", "Portable Document Format"), NULL },
|
||||
{ GIMP_EXPORT_FILE_TIF, NC_("export-file-type", "TIFF Image"), NULL },
|
||||
{ GIMP_EXPORT_FILE_BMP, NC_("export-file-type", "Windows BMP Image"), NULL },
|
||||
{ GIMP_EXPORT_FILE_WEBP, NC_("export-file-type", "WebP Image"), NULL },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static GType type = 0;
|
||||
|
||||
if (G_UNLIKELY (! type))
|
||||
{
|
||||
type = g_enum_register_static ("GimpExportFileType", values);
|
||||
gimp_type_set_translation_context (type, "export-file-type");
|
||||
gimp_enum_set_value_descriptions (type, descs);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
GType
|
||||
gimp_handedness_get_type (void)
|
||||
{
|
||||
|
|
|
@ -56,6 +56,23 @@ typedef enum
|
|||
} GimpCursorMode;
|
||||
|
||||
|
||||
#define GIMP_TYPE_EXPORT_FILE_TYPE (gimp_export_file_type_get_type ())
|
||||
|
||||
GType gimp_export_file_type_get_type (void) G_GNUC_CONST;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GIMP_EXPORT_FILE_PNG, /*< desc="PNG Image" >*/
|
||||
GIMP_EXPORT_FILE_JPG, /*< desc="JPEG Image" >*/
|
||||
GIMP_EXPORT_FILE_ORA, /*< desc="OpenRaster Image" >*/
|
||||
GIMP_EXPORT_FILE_PSD, /*< desc="Photoshop Image" >*/
|
||||
GIMP_EXPORT_FILE_PDF, /*< desc="Portable Document Format" >*/
|
||||
GIMP_EXPORT_FILE_TIF, /*< desc="TIFF Image" >*/
|
||||
GIMP_EXPORT_FILE_BMP, /*< desc="Windows BMP Image" >*/
|
||||
GIMP_EXPORT_FILE_WEBP, /*< desc="WebP Image" >*/
|
||||
} GimpExportFileType;
|
||||
|
||||
|
||||
#define GIMP_TYPE_HANDEDNESS (gimp_handedness_get_type ())
|
||||
|
||||
GType gimp_handedness_get_type (void) G_GNUC_CONST;
|
||||
|
|
|
@ -111,6 +111,7 @@ enum
|
|||
PROP_IMPORT_PROMOTE_DITHER,
|
||||
PROP_IMPORT_ADD_ALPHA,
|
||||
PROP_IMPORT_RAW_PLUG_IN,
|
||||
PROP_EXPORT_FILE_TYPE,
|
||||
PROP_EXPORT_COLOR_PROFILE,
|
||||
PROP_EXPORT_METADATA_EXIF,
|
||||
PROP_EXPORT_METADATA_XMP,
|
||||
|
@ -650,6 +651,14 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
|
|||
GIMP_PARAM_STATIC_STRINGS |
|
||||
GIMP_CONFIG_PARAM_RESTART);
|
||||
|
||||
GIMP_CONFIG_PROP_ENUM (object_class, PROP_EXPORT_FILE_TYPE,
|
||||
"export-file-type",
|
||||
"Default export file type",
|
||||
EXPORT_FILE_TYPE_BLURB,
|
||||
GIMP_TYPE_EXPORT_FILE_TYPE,
|
||||
GIMP_EXPORT_FILE_PNG,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_EXPORT_COLOR_PROFILE,
|
||||
"export-color-profile",
|
||||
"Export Color Profile",
|
||||
|
@ -986,6 +995,9 @@ gimp_core_config_set_property (GObject *object,
|
|||
g_free (core_config->import_raw_plug_in);
|
||||
core_config->import_raw_plug_in = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_EXPORT_FILE_TYPE:
|
||||
core_config->export_file_type = g_value_get_enum (value);
|
||||
break;
|
||||
case PROP_EXPORT_COLOR_PROFILE:
|
||||
core_config->export_color_profile = g_value_get_boolean (value);
|
||||
break;
|
||||
|
@ -1191,6 +1203,9 @@ gimp_core_config_get_property (GObject *object,
|
|||
case PROP_IMPORT_RAW_PLUG_IN:
|
||||
g_value_set_string (value, core_config->import_raw_plug_in);
|
||||
break;
|
||||
case PROP_EXPORT_FILE_TYPE:
|
||||
g_value_set_enum (value, core_config->export_file_type);
|
||||
break;
|
||||
case PROP_EXPORT_COLOR_PROFILE:
|
||||
g_value_set_boolean (value, core_config->export_color_profile);
|
||||
break;
|
||||
|
|
|
@ -96,6 +96,7 @@ struct _GimpCoreConfig
|
|||
gboolean import_promote_dither;
|
||||
gboolean import_add_alpha;
|
||||
gchar *import_raw_plug_in;
|
||||
GimpExportFileType export_file_type;
|
||||
gboolean export_color_profile;
|
||||
gboolean export_metadata_exif;
|
||||
gboolean export_metadata_xmp;
|
||||
|
|
|
@ -204,6 +204,9 @@ _("Add an alpha channel to all layers of imported images.")
|
|||
#define IMPORT_RAW_PLUG_IN_BLURB \
|
||||
_("Which plug-in to use for importing raw digital camera files.")
|
||||
|
||||
#define EXPORT_FILE_TYPE_BLURB \
|
||||
_("Export file type used by default.")
|
||||
|
||||
#define EXPORT_COLOR_PROFILE_BLURB \
|
||||
_("Export the image's color profile by default.")
|
||||
|
||||
|
|
|
@ -1476,6 +1476,10 @@ prefs_dialog_new (Gimp *gimp,
|
|||
NULL,
|
||||
&top_iter);
|
||||
|
||||
gimp_prefs_box_set_page_scrollable (GIMP_PREFS_BOX (prefs_box), vbox, TRUE);
|
||||
|
||||
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||
|
||||
/* Import Policies */
|
||||
vbox2 = prefs_frame_new (_("Import Policies"),
|
||||
GTK_CONTAINER (vbox), FALSE);
|
||||
|
@ -1501,7 +1505,7 @@ prefs_dialog_new (Gimp *gimp,
|
|||
grid = prefs_grid_new (GTK_CONTAINER (vbox2));
|
||||
button = prefs_enum_combo_box_add (object, "color-profile-policy", 0, 0,
|
||||
_("Color profile policy:"),
|
||||
GTK_GRID (grid), 0, NULL);
|
||||
GTK_GRID (grid), 0, size_group);
|
||||
|
||||
/* Export Policies */
|
||||
vbox2 = prefs_frame_new (_("Export Policies"),
|
||||
|
@ -1511,20 +1515,26 @@ prefs_dialog_new (Gimp *gimp,
|
|||
_("Export the image's color profile by default"),
|
||||
GTK_BOX (vbox2));
|
||||
button = prefs_check_button_add (object, "export-metadata-exif",
|
||||
/* Translators: label for configuration option (checkbox).
|
||||
* It determines how file export plug-ins handle Exif by default.
|
||||
/* Translators: label for
|
||||
* configuration option (checkbox).
|
||||
* It determines how file export
|
||||
* plug-ins handle Exif by default.
|
||||
*/
|
||||
_("Export Exif metadata by default when available"),
|
||||
GTK_BOX (vbox2));
|
||||
button = prefs_check_button_add (object, "export-metadata-xmp",
|
||||
/* Translators: label for configuration option (checkbox).
|
||||
* It determines how file export plug-ins handle XMP by default.
|
||||
/* Translators: label for
|
||||
* configuration option (checkbox).
|
||||
* It determines how file export
|
||||
* plug-ins handle XMP by default.
|
||||
*/
|
||||
_("Export XMP metadata by default when available"),
|
||||
GTK_BOX (vbox2));
|
||||
button = prefs_check_button_add (object, "export-metadata-iptc",
|
||||
/* Translators: label for configuration option (checkbox).
|
||||
* It determines how file export plug-ins handle IPTC by default.
|
||||
/* Translators: label for
|
||||
* configuration option (checkbox).
|
||||
* It determines how file export
|
||||
* plug-ins handle IPTC by default.
|
||||
*/
|
||||
_("Export IPTC metadata by default when available"),
|
||||
GTK_BOX (vbox2));
|
||||
|
@ -1532,6 +1542,13 @@ prefs_dialog_new (Gimp *gimp,
|
|||
_("Metadata can contain sensitive information."));
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
|
||||
|
||||
/* Export File Type */
|
||||
vbox2 = prefs_frame_new (_("Export File Type"), GTK_CONTAINER (vbox), FALSE);
|
||||
grid = prefs_grid_new (GTK_CONTAINER (vbox2));
|
||||
|
||||
prefs_enum_combo_box_add (object, "export-file-type", 0, 0,
|
||||
_("Default export file type:"),
|
||||
GTK_GRID (grid), 0, size_group);
|
||||
|
||||
/* Raw Image Importer */
|
||||
vbox2 = prefs_frame_new (_("Raw Image Importer"),
|
||||
|
@ -1560,6 +1577,8 @@ prefs_dialog_new (Gimp *gimp,
|
|||
config);
|
||||
}
|
||||
|
||||
g_object_unref (size_group);
|
||||
|
||||
/****************/
|
||||
/* Playground */
|
||||
/****************/
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include "core/gimp-utils.h"
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "config/gimpcoreconfig.h"
|
||||
|
||||
#include "file/gimp-file.h"
|
||||
|
||||
#include "gimpexportdialog.h"
|
||||
|
@ -158,7 +160,7 @@ gimp_export_dialog_set_image (GimpExportDialog *dialog,
|
|||
* 1. Type of last Export
|
||||
* 2. Type of the image Import
|
||||
* 3. Type of latest Export of any document
|
||||
* 4. .png
|
||||
* 4. Default file type set in Preferences
|
||||
*/
|
||||
|
||||
ext_file = gimp_image_get_exported_file (image);
|
||||
|
@ -171,9 +173,23 @@ gimp_export_dialog_set_image (GimpExportDialog *dialog,
|
|||
GIMP_FILE_EXPORT_LAST_FILE_KEY);
|
||||
|
||||
if (ext_file)
|
||||
g_object_ref (ext_file);
|
||||
{
|
||||
g_object_ref (ext_file);
|
||||
}
|
||||
else
|
||||
ext_file = g_file_new_for_uri ("file:///we/only/care/about/extension.png");
|
||||
{
|
||||
const gchar *extension;
|
||||
gchar *uri;
|
||||
|
||||
gimp_enum_get_value (GIMP_TYPE_EXPORT_FILE_TYPE,
|
||||
image->gimp->config->export_file_type,
|
||||
NULL, &extension, NULL, NULL);
|
||||
|
||||
uri = g_strconcat ("file:///we/only/care/about/extension.",
|
||||
extension, NULL);
|
||||
ext_file = g_file_new_for_uri (uri);
|
||||
g_free (uri);
|
||||
}
|
||||
|
||||
if (ext_file)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue