mirror of https://github.com/GNOME/gimp.git
libgimp: add a "status" parameter to gimp_procedure_config_end_run()
and require it to be always called paired with begin_run(), which is more straightforward and makes the resulting code more future-proof.
This commit is contained in:
parent
1793a08548
commit
58bf1d431d
|
@ -380,11 +380,11 @@ gimp_procedure_config_begin_run (GimpProcedureConfig *config,
|
||||||
* @config: a #GimpProcedureConfig
|
* @config: a #GimpProcedureConfig
|
||||||
* @image: a #GimpImage or %NULL
|
* @image: a #GimpImage or %NULL
|
||||||
* @run_mode: the #GimpRunMode passed to a #GimpProcedure's run()
|
* @run_mode: the #GimpRunMode passed to a #GimpProcedure's run()
|
||||||
|
* @status: the return status of the #GimpProcedure's run()
|
||||||
*
|
*
|
||||||
* This function is the counterpart of
|
* This function is the counterpart of
|
||||||
* gimp_procedure_conig_begin_run() and should be used upon successful
|
* gimp_procedure_conig_begin_run() and must always be called in pairs
|
||||||
* completion of a procedure's run(), before returning
|
* in a procedure's run(), before returning return values.
|
||||||
* %GIMP_PDB_SUCCESS return values.
|
|
||||||
*
|
*
|
||||||
* If @run_mode is %GIMP_RUN_INTERACTIVE, @config is saved as last
|
* If @run_mode is %GIMP_RUN_INTERACTIVE, @config is saved as last
|
||||||
* used values to be used when the procedure runs again. Additionally,
|
* used values to be used when the procedure runs again. Additionally,
|
||||||
|
@ -403,7 +403,8 @@ gimp_procedure_config_begin_run (GimpProcedureConfig *config,
|
||||||
void
|
void
|
||||||
gimp_procedure_config_end_run (GimpProcedureConfig *config,
|
gimp_procedure_config_end_run (GimpProcedureConfig *config,
|
||||||
GimpImage *image,
|
GimpImage *image,
|
||||||
GimpRunMode run_mode)
|
GimpRunMode run_mode,
|
||||||
|
GimpPDBStatusType status)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GIMP_IS_PROCEDURE_CONFIG (config));
|
g_return_if_fail (GIMP_IS_PROCEDURE_CONFIG (config));
|
||||||
g_return_if_fail (image == NULL || GIMP_IS_IMAGE (image));
|
g_return_if_fail (image == NULL || GIMP_IS_IMAGE (image));
|
||||||
|
@ -411,7 +412,8 @@ gimp_procedure_config_end_run (GimpProcedureConfig *config,
|
||||||
if (run_mode != GIMP_RUN_NONINTERACTIVE)
|
if (run_mode != GIMP_RUN_NONINTERACTIVE)
|
||||||
gimp_displays_flush ();
|
gimp_displays_flush ();
|
||||||
|
|
||||||
if (run_mode == GIMP_RUN_INTERACTIVE)
|
if (status == GIMP_PDB_SUCCESS &&
|
||||||
|
run_mode == GIMP_RUN_INTERACTIVE)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,8 @@ void gimp_procedure_config_begin_run (GimpProcedureConfig *config,
|
||||||
const GimpValueArray *args);
|
const GimpValueArray *args);
|
||||||
void gimp_procedure_config_end_run (GimpProcedureConfig *config,
|
void gimp_procedure_config_end_run (GimpProcedureConfig *config,
|
||||||
GimpImage *image,
|
GimpImage *image,
|
||||||
GimpRunMode run_mode);
|
GimpRunMode run_mode,
|
||||||
|
GimpPDBStatusType status);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -252,7 +252,7 @@ despeckle_run (GimpProcedure *procedure,
|
||||||
|
|
||||||
despeckle (drawable, G_OBJECT (config));
|
despeckle (drawable, G_OBJECT (config));
|
||||||
|
|
||||||
gimp_procedure_config_end_run (config, NULL, run_mode);
|
gimp_procedure_config_end_run (config, NULL, run_mode, GIMP_PDB_SUCCESS);
|
||||||
g_object_unref (config);
|
g_object_unref (config);
|
||||||
|
|
||||||
return gimp_procedure_new_return_values (procedure, GIMP_PDB_SUCCESS, NULL);
|
return gimp_procedure_new_return_values (procedure, GIMP_PDB_SUCCESS, NULL);
|
||||||
|
|
|
@ -226,10 +226,7 @@ gbr_save (GimpProcedure *procedure,
|
||||||
if (run_mode == GIMP_RUN_INTERACTIVE)
|
if (run_mode == GIMP_RUN_INTERACTIVE)
|
||||||
{
|
{
|
||||||
if (! save_dialog (procedure, G_OBJECT (config)))
|
if (! save_dialog (procedure, G_OBJECT (config)))
|
||||||
{
|
status = GIMP_PDB_CANCEL;
|
||||||
status = GIMP_PDB_CANCEL;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status == GIMP_PDB_SUCCESS)
|
if (status == GIMP_PDB_SUCCESS)
|
||||||
|
@ -255,11 +252,7 @@ gbr_save (GimpProcedure *procedure,
|
||||||
|
|
||||||
g_free (description);
|
g_free (description);
|
||||||
|
|
||||||
if (GIMP_VALUES_GET_ENUM (save_retvals, 0) == GIMP_PDB_SUCCESS)
|
if (GIMP_VALUES_GET_ENUM (save_retvals, 0) != GIMP_PDB_SUCCESS)
|
||||||
{
|
|
||||||
gimp_procedure_config_end_run (config, orig_image, run_mode);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
g_set_error (&error, 0, 0,
|
g_set_error (&error, 0, 0,
|
||||||
"Running procedure 'file-gbr-save-internal' "
|
"Running procedure 'file-gbr-save-internal' "
|
||||||
|
@ -272,7 +265,7 @@ gbr_save (GimpProcedure *procedure,
|
||||||
gimp_value_array_unref (save_retvals);
|
gimp_value_array_unref (save_retvals);
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
gimp_procedure_config_end_run (config, orig_image, run_mode, status);
|
||||||
g_object_unref (config);
|
g_object_unref (config);
|
||||||
|
|
||||||
if (export == GIMP_EXPORT_EXPORT)
|
if (export == GIMP_EXPORT_EXPORT)
|
||||||
|
|
|
@ -310,8 +310,6 @@ heif_save (GimpProcedure *procedure,
|
||||||
file, NULL);
|
file, NULL);
|
||||||
g_object_unref (metadata);
|
g_object_unref (metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_procedure_config_end_run (config, orig_image, run_mode);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -319,6 +317,7 @@ heif_save (GimpProcedure *procedure,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gimp_procedure_config_end_run (config, orig_image, run_mode, status);
|
||||||
g_object_unref (config);
|
g_object_unref (config);
|
||||||
|
|
||||||
if (export == GIMP_EXPORT_EXPORT)
|
if (export == GIMP_EXPORT_EXPORT)
|
||||||
|
|
|
@ -225,11 +225,7 @@ pat_save (GimpProcedure *procedure,
|
||||||
G_TYPE_STRING, description,
|
G_TYPE_STRING, description,
|
||||||
G_TYPE_NONE);
|
G_TYPE_NONE);
|
||||||
|
|
||||||
if (GIMP_VALUES_GET_ENUM (save_retvals, 0) == GIMP_PDB_SUCCESS)
|
if (GIMP_VALUES_GET_ENUM (save_retvals, 0) != GIMP_PDB_SUCCESS)
|
||||||
{
|
|
||||||
gimp_procedure_config_end_run (config, orig_image, run_mode);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
g_set_error (&error, 0, 0,
|
g_set_error (&error, 0, 0,
|
||||||
"Running procedure 'file-pat-save-internal' "
|
"Running procedure 'file-pat-save-internal' "
|
||||||
|
@ -242,6 +238,7 @@ pat_save (GimpProcedure *procedure,
|
||||||
gimp_value_array_unref (save_retvals);
|
gimp_value_array_unref (save_retvals);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gimp_procedure_config_end_run (config, orig_image, run_mode, status);
|
||||||
g_object_unref (config);
|
g_object_unref (config);
|
||||||
|
|
||||||
if (export == GIMP_EXPORT_EXPORT)
|
if (export == GIMP_EXPORT_EXPORT)
|
||||||
|
|
|
@ -543,8 +543,6 @@ png_save (GimpProcedure *procedure,
|
||||||
|
|
||||||
g_object_unref (metadata);
|
g_object_unref (metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_procedure_config_end_run (config, orig_image, run_mode);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -552,6 +550,7 @@ png_save (GimpProcedure *procedure,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gimp_procedure_config_end_run (config, orig_image, run_mode, status);
|
||||||
g_object_unref (config);
|
g_object_unref (config);
|
||||||
|
|
||||||
if (export == GIMP_EXPORT_EXPORT)
|
if (export == GIMP_EXPORT_EXPORT)
|
||||||
|
|
|
@ -274,17 +274,14 @@ sgi_save (GimpProcedure *procedure,
|
||||||
|
|
||||||
if (status == GIMP_PDB_SUCCESS)
|
if (status == GIMP_PDB_SUCCESS)
|
||||||
{
|
{
|
||||||
if (save_image (file, image, drawable, G_OBJECT (config),
|
if (! save_image (file, image, drawable, G_OBJECT (config),
|
||||||
&error))
|
&error))
|
||||||
{
|
|
||||||
gimp_procedure_config_end_run (config, orig_image, run_mode);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
status = GIMP_PDB_EXECUTION_ERROR;
|
status = GIMP_PDB_EXECUTION_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gimp_procedure_config_end_run (config, orig_image, run_mode, status);
|
||||||
g_object_unref (config);
|
g_object_unref (config);
|
||||||
|
|
||||||
if (export == GIMP_EXPORT_EXPORT)
|
if (export == GIMP_EXPORT_EXPORT)
|
||||||
|
|
Loading…
Reference in New Issue