mirror of https://github.com/GNOME/gimp.git
libgimp: fix disabling various metadata export per Preferences.
Preferences > Image Import and Export tab has various Export Policies, which are mostly for safety reasons. One may want to default at never exporting specific metadata. This got broken and anyway the logic was not good enough. Now these policies are followed in interactive mode, unless an export has already happened for this specific export plug-in on this specific file (in this case, we reuse the last values). We don't want settings to unexpectedly change in such a case. In last-vals and non-interactive run-mode though, we don't follow the Preferences policies, since in the former case, we want to reuse exactly the same settings (e.g. we don't want an Export discarding metadata which explicitly checked in the Export As) and in the latter case, it is the developer's responsibility to set up expected options.
This commit is contained in:
parent
68ee943200
commit
12ad579843
|
@ -161,7 +161,7 @@ gimp_batch_procedure_run (GimpProcedure *procedure,
|
|||
}
|
||||
|
||||
config = _gimp_procedure_create_run_config (procedure);
|
||||
_gimp_procedure_config_begin_run (config, NULL, run_mode, remaining);
|
||||
_gimp_procedure_config_begin_run (config, NULL, run_mode, remaining, NULL);
|
||||
gimp_value_array_unref (remaining);
|
||||
|
||||
return_values = batch_proc->run_func (procedure, run_mode,
|
||||
|
|
|
@ -175,7 +175,7 @@ gimp_image_procedure_run (GimpProcedure *procedure,
|
|||
}
|
||||
|
||||
config = _gimp_procedure_create_run_config (procedure);
|
||||
_gimp_procedure_config_begin_run (config, image, run_mode, remaining);
|
||||
_gimp_procedure_config_begin_run (config, image, run_mode, remaining, NULL);
|
||||
|
||||
return_values = image_proc->run_func (procedure, run_mode,
|
||||
image, n_drawables, drawables,
|
||||
|
|
|
@ -246,7 +246,7 @@ gimp_load_procedure_run (GimpProcedure *procedure,
|
|||
if (metadata == NULL)
|
||||
metadata = gimp_metadata_new ();
|
||||
|
||||
_gimp_procedure_config_begin_run (config, image, run_mode, remaining);
|
||||
_gimp_procedure_config_begin_run (config, image, run_mode, remaining, NULL);
|
||||
|
||||
return_values = priv->run_func (procedure, run_mode,
|
||||
file, metadata, &flags,
|
||||
|
|
|
@ -517,7 +517,7 @@ gimp_procedure_real_run (GimpProcedure *procedure,
|
|||
}
|
||||
|
||||
config = _gimp_procedure_create_run_config (procedure);
|
||||
_gimp_procedure_config_begin_run (config, image, run_mode, args);
|
||||
_gimp_procedure_config_begin_run (config, image, run_mode, args, NULL);
|
||||
|
||||
retvals = priv->run_func (procedure, config, priv->run_data);
|
||||
|
||||
|
|
|
@ -31,7 +31,8 @@ G_GNUC_INTERNAL void _gimp_procedure_config_get_values (GimpProcedur
|
|||
G_GNUC_INTERNAL void _gimp_procedure_config_begin_run (GimpProcedureConfig *config,
|
||||
GimpImage *image,
|
||||
GimpRunMode run_mode,
|
||||
const GimpValueArray *args);
|
||||
const GimpValueArray *args,
|
||||
gboolean *editable_properties);
|
||||
G_GNUC_INTERNAL void _gimp_procedure_config_end_run (GimpProcedureConfig *config,
|
||||
GimpPDBStatusType status);
|
||||
|
||||
|
|
|
@ -553,6 +553,8 @@ _gimp_procedure_config_get_values (GimpProcedureConfig *config,
|
|||
* @image: (nullable): a #GimpImage or %NULL
|
||||
* @run_mode: the #GimpRunMode passed to a [class@Procedure]'s run()
|
||||
* @args: the #GimpValueArray passed to a [class@Procedure]'s run()
|
||||
* @editable_properties: whether you may tweak the properties for
|
||||
* metadata export.
|
||||
*
|
||||
* Populates @config with values for a [class@Procedure]'s run(),
|
||||
* depending on @run_mode.
|
||||
|
@ -579,7 +581,15 @@ _gimp_procedure_config_get_values (GimpProcedureConfig *config,
|
|||
* [func@get_default_comment] if there is no "gimp-comment" parasite.
|
||||
*
|
||||
* After calling this function, the @args passed to run() should be
|
||||
* left alone and @config be treated as the procedure's arguments.
|
||||
* left alone and @config be treated as the procedure's arguments, with
|
||||
* some exception, such as metadata export properties (which may be
|
||||
* overwritten for safety measure), and only if @editable_properties is
|
||||
* returned as %TRUE, which should only happen in interactive @run_mode
|
||||
* when this is the first run with @image in particular (i.e. there is
|
||||
* no config parasite on @image stored for this procedure). In
|
||||
* particular, in non-interactive, we will use exactly @args; and in
|
||||
* last-vals run, or if a config parasite was found on image, we will
|
||||
* use exactly the last-run arguments.
|
||||
*
|
||||
* It is possible to get @config's resulting values back into @args by
|
||||
* calling [method@ProcedureConfig.get_values], as long as modified
|
||||
|
@ -596,7 +606,8 @@ void
|
|||
_gimp_procedure_config_begin_run (GimpProcedureConfig *config,
|
||||
GimpImage *image,
|
||||
GimpRunMode run_mode,
|
||||
const GimpValueArray *args)
|
||||
const GimpValueArray *args,
|
||||
gboolean *editable_properties)
|
||||
{
|
||||
GimpProcedureConfigPrivate *priv;
|
||||
GParamSpec *run_mode_pspec;
|
||||
|
@ -615,6 +626,9 @@ _gimp_procedure_config_begin_run (GimpProcedureConfig *config,
|
|||
priv->image = image;
|
||||
priv->run_mode = run_mode;
|
||||
|
||||
if (editable_properties)
|
||||
*editable_properties = FALSE;
|
||||
|
||||
gimp_procedure_config_set_values (config, args);
|
||||
|
||||
switch (run_mode)
|
||||
|
@ -633,12 +647,20 @@ _gimp_procedure_config_begin_run (GimpProcedureConfig *config,
|
|||
}
|
||||
}
|
||||
|
||||
if (! loaded &&
|
||||
! gimp_procedure_config_load_last (config, &error) && error)
|
||||
if (! loaded)
|
||||
{
|
||||
g_printerr ("Loading last used values from disk failed: %s\n",
|
||||
error->message);
|
||||
g_clear_error (&error);
|
||||
if (! gimp_procedure_config_load_last (config, &error) && error)
|
||||
{
|
||||
g_printerr ("Loading last used values from disk failed: %s\n",
|
||||
error->message);
|
||||
g_clear_error (&error);
|
||||
|
||||
if (editable_properties)
|
||||
*editable_properties = TRUE;
|
||||
}
|
||||
|
||||
if (run_mode == GIMP_RUN_INTERACTIVE && editable_properties)
|
||||
*editable_properties = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -840,6 +862,7 @@ _gimp_procedure_config_begin_export (GimpProcedureConfig *config,
|
|||
{
|
||||
GimpProcedureConfigPrivate *priv;
|
||||
GObjectClass *object_class;
|
||||
gboolean editable_properties;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PROCEDURE_CONFIG (config), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (original_image), NULL);
|
||||
|
@ -849,6 +872,13 @@ _gimp_procedure_config_begin_export (GimpProcedureConfig *config,
|
|||
|
||||
object_class = G_OBJECT_GET_CLASS (config);
|
||||
|
||||
/* This must be run before we process the metadata, because we may
|
||||
* overwrite various metadata export properties when they are globally
|
||||
* disabled in Preferences, for security reasons.
|
||||
*/
|
||||
_gimp_procedure_config_begin_run (config, original_image, run_mode, args,
|
||||
&editable_properties);
|
||||
|
||||
if (mime_type)
|
||||
{
|
||||
GimpMetadataSaveFlags metadata_flags;
|
||||
|
@ -865,28 +895,27 @@ _gimp_procedure_config_begin_export (GimpProcedureConfig *config,
|
|||
priv->metadata_flags = metadata_flags;
|
||||
}
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (metadata_properties); i++)
|
||||
{
|
||||
/* we only disable properties based on metadata flags here
|
||||
* and never enable them, so we don't override the user's
|
||||
* saved default values that are passed to us via "args"
|
||||
*/
|
||||
if (! (metadata_flags & metadata_properties[i].flag))
|
||||
{
|
||||
const gchar *prop_name = metadata_properties[i].name;
|
||||
GParamSpec *pspec;
|
||||
if (editable_properties)
|
||||
for (i = 0; i < G_N_ELEMENTS (metadata_properties); i++)
|
||||
{
|
||||
/* we only disable properties based on metadata flags here
|
||||
* and never enable them, so we don't override the user's
|
||||
* saved default values that are passed to us via "args"
|
||||
*/
|
||||
if (! (metadata_flags & metadata_properties[i].flag))
|
||||
{
|
||||
const gchar *prop_name = metadata_properties[i].name;
|
||||
GParamSpec *pspec;
|
||||
|
||||
pspec = g_object_class_find_property (object_class, prop_name);
|
||||
if (pspec)
|
||||
g_object_set (config,
|
||||
prop_name, FALSE,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
pspec = g_object_class_find_property (object_class, prop_name);
|
||||
if (pspec)
|
||||
g_object_set (config,
|
||||
prop_name, FALSE,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_gimp_procedure_config_begin_run (config, original_image, run_mode, args);
|
||||
|
||||
return priv->metadata;
|
||||
}
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ gimp_thumbnail_procedure_run (GimpProcedure *procedure,
|
|||
}
|
||||
|
||||
config = _gimp_procedure_create_run_config (procedure);
|
||||
_gimp_procedure_config_begin_run (config, NULL, GIMP_RUN_NONINTERACTIVE, remaining);
|
||||
_gimp_procedure_config_begin_run (config, NULL, GIMP_RUN_NONINTERACTIVE, remaining, NULL);
|
||||
gimp_value_array_unref (remaining);
|
||||
|
||||
return_values = thumbnail_proc->run_func (procedure, file, size,
|
||||
|
|
|
@ -243,7 +243,7 @@ gimp_vector_load_procedure_run (GimpProcedure *procedure,
|
|||
if (metadata == NULL)
|
||||
metadata = gimp_metadata_new ();
|
||||
|
||||
_gimp_procedure_config_begin_run (config, image, run_mode, remaining);
|
||||
_gimp_procedure_config_begin_run (config, image, run_mode, remaining, NULL);
|
||||
|
||||
g_object_get (config, "pixel-density", &resolution, NULL);
|
||||
|
||||
|
|
Loading…
Reference in New Issue