Commit 82f6baf2 authored by Jehan's avatar Jehan

plug-ins: file export should follow preferences regarding metadata.

Various plug-ins exporting metadata should now follow preferences, which
would override any default. Of course these preferences can still be
overriden by saved settings (global parasite), previous run settings,
and finally through the GUI when interactive.
parent 3061268e
......@@ -184,8 +184,8 @@ static gboolean ia_has_transparent_pixels (GeglBuffer *buffer);
static gint find_unused_ia_color (GeglBuffer *buffer,
gint *colors);
static void load_defaults (void);
static void save_defaults (void);
static void load_parasite (void);
static void save_parasite (void);
static void load_gui_defaults (PngSaveGui *pg);
......@@ -540,21 +540,25 @@ run (const gchar *name,
break;
}
/* Initialize with hardcoded defaults */
pngvals = defaults;
/* Override the defaults with preferences. */
metadata = gimp_image_metadata_save_prepare (orig_image_ID,
"image/png",
&metadata_flags);
pngvals.save_exif = (metadata_flags & GIMP_METADATA_SAVE_EXIF) != 0;
pngvals.save_xmp = (metadata_flags & GIMP_METADATA_SAVE_XMP) != 0;
pngvals.save_iptc = (metadata_flags & GIMP_METADATA_SAVE_IPTC) != 0;
pngvals.save_thumbnail = (metadata_flags & GIMP_METADATA_SAVE_THUMBNAIL) != 0;
load_defaults ();
/* Override preferences from PNG export defaults (if saved). */
load_parasite ();
switch (run_mode)
{
case GIMP_RUN_INTERACTIVE:
/* possibly retrieve data */
/* Finally possibly retrieve data from previous run. */
gimp_get_data (SAVE_PROC, &pngvals);
alpha = gimp_drawable_has_alpha (drawable_ID);
......@@ -676,7 +680,8 @@ run (const gchar *name,
}
else if (strcmp (name, GET_DEFAULTS_PROC) == 0)
{
load_defaults ();
pngvals = defaults;
load_parasite ();
*nreturn_vals = 10;
......@@ -701,7 +706,8 @@ run (const gchar *name,
{
if (nparams == 9)
{
load_defaults ();
pngvals = defaults;
load_parasite ();
pngvals.interlaced = param[0].data.d_int32;
pngvals.compression_level = param[1].data.d_int32;
......@@ -713,7 +719,7 @@ run (const gchar *name,
pngvals.comment = param[7].data.d_int32;
pngvals.save_transp_pixels = param[8].data.d_int32;
save_defaults ();
save_parasite ();
}
else
{
......@@ -2430,7 +2436,7 @@ save_dialog (gint32 image_ID,
g_signal_connect_swapped (gtk_builder_get_object (builder, "save-defaults"),
"clicked",
G_CALLBACK (save_defaults),
G_CALLBACK (save_parasite),
&pg);
/* Show dialog and run */
......@@ -2462,13 +2468,10 @@ save_dialog_response (GtkWidget *widget,
}
static void
load_defaults (void)
load_parasite (void)
{
GimpParasite *parasite;
/* initialize with hardcoded defaults */
pngvals = defaults;
parasite = gimp_get_parasite (PNG_DEFAULTS_PARASITE);
if (parasite)
......@@ -2505,7 +2508,7 @@ load_defaults (void)
}
static void
save_defaults (void)
save_parasite (void)
{
GimpParasite *parasite;
gchar *def_str;
......@@ -2538,7 +2541,10 @@ save_defaults (void)
static void
load_gui_defaults (PngSaveGui *pg)
{
load_defaults ();
/* initialize with hardcoded defaults */
pngvals = defaults;
/* Override with parasite. */
load_parasite ();
#define SET_ACTIVE(field) \
if (gtk_widget_is_sensitive (pg->field)) \
......
......@@ -1231,12 +1231,6 @@ save_dialog_response (GtkWidget *widget,
void
load_defaults (void)
{
GimpParasite *parasite;
gchar *def_str;
JpegSaveVals tmpvals;
gint num_fields;
gint subsampling;
jsvals.quality = DEFAULT_QUALITY;
jsvals.smoothing = DEFAULT_SMOOTHING;
jsvals.optimize = DEFAULT_OPTIMIZE;
......@@ -1252,6 +1246,16 @@ load_defaults (void)
jsvals.save_xmp = DEFAULT_XMP;
jsvals.save_iptc = DEFAULT_IPTC;
jsvals.use_orig_quality = DEFAULT_USE_ORIG_QUALITY;
}
void
load_parasite (void)
{
GimpParasite *parasite;
gchar *def_str;
JpegSaveVals tmpvals;
gint num_fields;
gint subsampling;
parasite = gimp_get_parasite (JPEG_DEFAULTS_PARASITE);
......@@ -1333,6 +1337,7 @@ load_gui_defaults (JpegSaveGui *pg)
GtkAdjustment *restart_markers;
load_defaults ();
load_parasite ();
#define SET_ACTIVE_BTTN(field) \
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pg->field), jsvals.field)
......
......@@ -51,5 +51,6 @@ gboolean save_image (const gchar *filename,
GError **error);
gboolean save_dialog (void);
void load_defaults (void);
void load_parasite (void);
#endif /* __JPEG_SAVE_H__ */
......@@ -336,10 +336,13 @@ run (const gchar *name,
break;
}
/* Initialize with hardcoded defaults */
load_defaults ();
/* Override the defaults with preferences. */
metadata = gimp_image_metadata_save_prepare (orig_image_ID,
"image/jpeg",
&metadata_flags);
jsvals.save_exif = (metadata_flags & GIMP_METADATA_SAVE_EXIF) != 0;
jsvals.save_xmp = (metadata_flags & GIMP_METADATA_SAVE_XMP) != 0;
jsvals.save_iptc = (metadata_flags & GIMP_METADATA_SAVE_IPTC) != 0;
......@@ -353,8 +356,8 @@ run (const gchar *name,
gimp_parasite_free (parasite);
}
/* load defaults from gimp parasite */
load_defaults ();
/* Override preferences from JPG export defaults (if saved). */
load_parasite ();
switch (run_mode)
{
......
......@@ -358,9 +358,14 @@ run (const gchar *name,
break;
}
/* Override the defaults with preferences. */
metadata = gimp_image_metadata_save_prepare (orig_image,
"image/tiff",
&metadata_flags);
tsvals.save_exif = (metadata_flags & GIMP_METADATA_SAVE_EXIF) != 0;
tsvals.save_xmp = (metadata_flags & GIMP_METADATA_SAVE_XMP) != 0;
tsvals.save_iptc = (metadata_flags & GIMP_METADATA_SAVE_IPTC) != 0;
tsvals.save_thumbnail = (metadata_flags & GIMP_METADATA_SAVE_THUMBNAIL) != 0;
parasite = gimp_image_get_parasite (orig_image, "gimp-comment");
if (parasite)
......
......@@ -729,18 +729,18 @@ save_animation (const gchar *filename,
gboolean
save_image (const gchar *filename,
gint32 nLayers,
gint32 *allLayers,
gint32 image_ID,
gint32 drawable_ID,
WebPSaveParams *params,
GError **error)
save_image (const gchar *filename,
gint32 nLayers,
gint32 *allLayers,
gint32 image_ID,
gint32 drawable_ID,
GimpMetadata *metadata,
GimpMetadataSaveFlags metadata_flags,
WebPSaveParams *params,
GError **error)
{
GimpMetadata *metadata;
GimpMetadataSaveFlags metadata_flags;
gboolean status = FALSE;
GFile *file;
GFile *file;
gboolean status = FALSE;
if (nLayers == 0)
return FALSE;
......@@ -768,10 +768,6 @@ save_image (const gchar *filename,
}
}
metadata = gimp_image_metadata_save_prepare (image_ID,
"image/webp",
&metadata_flags);
if (metadata)
{
gimp_metadata_set_bits_per_sample (metadata, 8);
......
......@@ -41,13 +41,15 @@ typedef struct
} WebPSaveParams;
gboolean save_image (const gchar *filename,
gint32 nLayers,
gint32 *allLayers,
gint32 image_ID,
gint32 drawable_ID,
WebPSaveParams *params,
GError **error);
gboolean save_image (const gchar *filename,
gint32 nLayers,
gint32 *allLayers,
gint32 image_ID,
gint32 drawable_ID,
GimpMetadata *metadata,
GimpMetadataSaveFlags metadata_flags,
WebPSaveParams *params,
GError **error);
#endif /* __WEBP_SAVE_H__ */
......@@ -174,10 +174,12 @@ run (const gchar *name,
}
else if (! strcmp (name, SAVE_PROC))
{
WebPSaveParams params;
GimpExportReturn export = GIMP_EXPORT_CANCEL;
gint32 *layers = NULL;
gint32 n_layers;
GimpMetadata *metadata = NULL;
GimpMetadataSaveFlags metadata_flags;
WebPSaveParams params;
GimpExportReturn export = GIMP_EXPORT_CANCEL;
gint32 *layers = NULL;
gint32 n_layers;
if (run_mode == GIMP_RUN_INTERACTIVE ||
run_mode == GIMP_RUN_WITH_LAST_VALS)
......@@ -205,6 +207,14 @@ run (const gchar *name,
params.delay = 200;
params.force_delay = FALSE;
/* Override the defaults with preferences. */
metadata = gimp_image_metadata_save_prepare (image_ID,
"image/webp",
&metadata_flags);
params.exif = (metadata_flags & GIMP_METADATA_SAVE_EXIF) != 0;
params.xmp = (metadata_flags & GIMP_METADATA_SAVE_XMP) != 0;
params.iptc = (metadata_flags & GIMP_METADATA_SAVE_IPTC) != 0;
/* Possibly override with session data */
gimp_get_data (SAVE_PROC, &params);
......@@ -275,6 +285,7 @@ run (const gchar *name,
n_layers, layers,
image_ID,
drawable_ID,
metadata, metadata_flags,
&params,
&error))
{
......@@ -288,6 +299,9 @@ run (const gchar *name,
if (export == GIMP_EXPORT_EXPORT)
gimp_image_delete (image_ID);
if (metadata)
g_object_unref (metadata);
if (status == GIMP_PDB_SUCCESS)
{
/* save parameters for later */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment