Commit 915ac64a authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

use GError for error reporting in PDB invoker methods.

2007-12-02  Sven Neumann  <sven@gimp.org>

	* tools/pdbgen/app.pl: use GError for error reporting in PDB
	invoker methods.

	* tools/pdbgen/pdb/vectors.pdb: use the GError for the 
procedures
	introduced for bug #497159.

	* tools/pdbgen/pdb/fileops.pdb: use the GError from file-load 
and
	file-save procedures.

	* app/pdb/*_cmds.c: regenerated.

	* app/pdb/Makefile.am

	* app/pdb/gimppdberror.[ch]: new file introducing the
	GIMP_PDB_ERROR domain.

	* app/actions/plug-in-commands.c
	* app/actions/vectors-commands.c
	* app/batch.c
	* app/core/gimpimagefile.c
	* app/core/gimppdbprogress.c
	* app/file/file-open.[ch]
	* app/file/file-save.c
	* app/plug-in/gimpplugin-message.c
	* app/plug-in/gimppluginmanager-restore.c
	* app/plug-in/gimppluginprocedure.c
	* app/plug-in/gimptemporaryprocedure.c
	* app/plug-in/plug-in-icc-profile.c
	* app/widgets/gimpbrushselect.c
	* app/widgets/gimpfontselect.c
	* app/widgets/gimpgradientselect.c
	* app/widgets/gimphelp.c
	* app/widgets/gimppaletteselect.c
	* app/widgets/gimppatternselect.c
	* app/widgets/gimppdbdialog.[ch]: changed accordingly.


svn path=/trunk/; revision=24255
parent b43c095c
2007-12-02 Sven Neumann <sven@gimp.org>
* tools/pdbgen/app.pl: use GError for error reporting in PDB
invoker methods.
* tools/pdbgen/pdb/vectors.pdb: use the GError for the procedures
introduced for bug #497159.
* tools/pdbgen/pdb/fileops.pdb: use the GError from file-load and
file-save procedures.
* app/pdb/*_cmds.c: regenerated.
* app/pdb/Makefile.am
* app/pdb/gimppdberror.[ch]: new file introducing the
GIMP_PDB_ERROR domain.
* app/actions/plug-in-commands.c
* app/actions/vectors-commands.c
* app/batch.c
* app/core/gimpimagefile.c
* app/core/gimppdbprogress.c
* app/file/file-open.[ch]
* app/file/file-save.c
* app/plug-in/gimpplugin-message.c
* app/plug-in/gimppluginmanager-restore.c
* app/plug-in/gimppluginprocedure.c
* app/plug-in/gimptemporaryprocedure.c
* app/plug-in/plug-in-icc-profile.c
* app/widgets/gimpbrushselect.c
* app/widgets/gimpfontselect.c
* app/widgets/gimpgradientselect.c
* app/widgets/gimphelp.c
* app/widgets/gimppaletteselect.c
* app/widgets/gimppatternselect.c
* app/widgets/gimppdbdialog.[ch]: changed accordingly.
2007-12-02 Sven Neumann <sven@gimp.org> 2007-12-02 Sven Neumann <sven@gimp.org>
* plug-ins/common/tiff-load.c (load_image): removed pointless and * plug-ins/common/tiff-load.c (load_image): removed pointless and
......
...@@ -294,19 +294,30 @@ plug_in_procedure_execute (GimpPlugInProcedure *procedure, ...@@ -294,19 +294,30 @@ plug_in_procedure_execute (GimpPlugInProcedure *procedure,
GValueArray *args, GValueArray *args,
gint n_args) gint n_args)
{ {
GError *error = NULL;
gimp_value_array_truncate (args, n_args); gimp_value_array_truncate (args, n_args);
/* run the plug-in procedure */ /* run the plug-in procedure */
gimp_procedure_execute_async (GIMP_PROCEDURE (procedure), gimp, gimp_procedure_execute_async (GIMP_PROCEDURE (procedure), gimp,
gimp_get_user_context (gimp), gimp_get_user_context (gimp),
GIMP_PROGRESS (display), args, GIMP_PROGRESS (display), args,
GIMP_OBJECT (display)); GIMP_OBJECT (display), &error);
/* remember only image plug-ins */ if (error)
if (GIMP_PROCEDURE (procedure)->num_args >= 2 && {
GIMP_IS_PARAM_SPEC_IMAGE_ID (GIMP_PROCEDURE (procedure)->args[1])) gimp_message (gimp, G_OBJECT (display), GIMP_MESSAGE_ERROR,
"%s", error->message);
g_error_free (error);
}
else
{ {
gimp_plug_in_manager_history_add (gimp->plug_in_manager, procedure); /* remember only image plug-ins */
if (GIMP_PROCEDURE (procedure)->num_args >= 2 &&
GIMP_IS_PARAM_SPEC_IMAGE_ID (GIMP_PROCEDURE (procedure)->args[1]))
{
gimp_plug_in_manager_history_add (gimp->plug_in_manager, procedure);
}
} }
} }
......
...@@ -310,6 +310,7 @@ vectors_selection_to_vectors_cmd_callback (GtkAction *action, ...@@ -310,6 +310,7 @@ vectors_selection_to_vectors_cmd_callback (GtkAction *action,
GimpProcedure *procedure; GimpProcedure *procedure;
GValueArray *args; GValueArray *args;
GimpDisplay *display; GimpDisplay *display;
GError *error = NULL;
return_if_no_image (image, data); return_if_no_image (image, data);
return_if_no_widget (widget, data); return_if_no_widget (widget, data);
...@@ -338,9 +339,16 @@ vectors_selection_to_vectors_cmd_callback (GtkAction *action, ...@@ -338,9 +339,16 @@ vectors_selection_to_vectors_cmd_callback (GtkAction *action,
gimp_procedure_execute_async (procedure, image->gimp, gimp_procedure_execute_async (procedure, image->gimp,
action_data_get_context (data), action_data_get_context (data),
GIMP_PROGRESS (display), args, GIMP_PROGRESS (display), args,
GIMP_OBJECT (display)); GIMP_OBJECT (display), &error);
g_value_array_free (args); g_value_array_free (args);
if (error)
{
gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_ERROR,
"%s", error->message);
g_error_free (error);
}
} }
void void
......
...@@ -140,7 +140,8 @@ batch_run_cmd (Gimp *gimp, ...@@ -140,7 +140,8 @@ batch_run_cmd (Gimp *gimp,
{ {
GValueArray *args; GValueArray *args;
GValueArray *return_vals; GValueArray *return_vals;
gint i = 0; GError *error = NULL;
gint i = 0;
args = gimp_procedure_get_arguments (procedure); args = gimp_procedure_get_arguments (procedure);
...@@ -153,26 +154,45 @@ batch_run_cmd (Gimp *gimp, ...@@ -153,26 +154,45 @@ batch_run_cmd (Gimp *gimp,
return_vals = return_vals =
gimp_pdb_execute_procedure_by_name_args (gimp->pdb, gimp_pdb_execute_procedure_by_name_args (gimp->pdb,
gimp_get_user_context (gimp), gimp_get_user_context (gimp),
NULL, NULL, &error,
proc_name, args); proc_name, args);
switch (g_value_get_enum (&return_vals->values[0])) switch (g_value_get_enum (&return_vals->values[0]))
{ {
case GIMP_PDB_EXECUTION_ERROR: case GIMP_PDB_EXECUTION_ERROR:
g_printerr ("batch command: experienced an execution error.\n"); if (error)
{
g_printerr ("batch command experienced an execution error: %s\n",
error->message);
}
else
{
g_printerr ("batch command experienced an execution error\n");
}
break; break;
case GIMP_PDB_CALLING_ERROR: case GIMP_PDB_CALLING_ERROR:
g_printerr ("batch command: experienced a calling error.\n"); if (error)
{
g_printerr ("batch command experienced a calling error: %s\n",
error->message);
}
else
{
g_printerr ("batch command experienced a calling error\n");
}
break; break;
case GIMP_PDB_SUCCESS: case GIMP_PDB_SUCCESS:
g_printerr ("batch command: executed successfully.\n"); g_printerr ("batch command executed successfully\n");
break; break;
} }
g_value_array_free (return_vals); g_value_array_free (return_vals);
g_value_array_free (args); g_value_array_free (args);
if (error)
g_error_free (error);
return; return;
} }
...@@ -247,7 +247,7 @@ gimp_imagefile_create_thumbnail (GimpImagefile *imagefile, ...@@ -247,7 +247,7 @@ gimp_imagefile_create_thumbnail (GimpImagefile *imagefile,
image = file_open_thumbnail (imagefile->gimp, context, progress, image = file_open_thumbnail (imagefile->gimp, context, progress,
thumbnail->image_uri, size, thumbnail->image_uri, size,
&mime_type, &width, &height); &mime_type, &width, &height, NULL);
if (image) if (image)
{ {
......
...@@ -275,7 +275,7 @@ gimp_pdb_progress_run_callback (GimpPdbProgress *progress, ...@@ -275,7 +275,7 @@ gimp_pdb_progress_run_callback (GimpPdbProgress *progress,
return_vals = return_vals =
gimp_pdb_execute_procedure_by_name (progress->pdb, gimp_pdb_execute_procedure_by_name (progress->pdb,
progress->context, progress->context,
NULL, NULL, NULL,
progress->callback_name, progress->callback_name,
GIMP_TYPE_INT32, command, GIMP_TYPE_INT32, command,
G_TYPE_STRING, text, G_TYPE_STRING, text,
......
...@@ -146,7 +146,7 @@ file_open_image (Gimp *gimp, ...@@ -146,7 +146,7 @@ file_open_image (Gimp *gimp,
return_vals = return_vals =
gimp_pdb_execute_procedure_by_name (gimp->pdb, gimp_pdb_execute_procedure_by_name (gimp->pdb,
context, progress, context, progress, error,
GIMP_OBJECT (file_proc)->name, GIMP_OBJECT (file_proc)->name,
GIMP_TYPE_INT32, run_mode, GIMP_TYPE_INT32, run_mode,
G_TYPE_STRING, filename, G_TYPE_STRING, filename,
...@@ -176,18 +176,21 @@ file_open_image (Gimp *gimp, ...@@ -176,18 +176,21 @@ file_open_image (Gimp *gimp,
} }
else else
{ {
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, if (error && ! *error)
_("%s plug-in returned SUCCESS but did not " g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
"return an image"), _("%s plug-in returned SUCCESS but did not "
gimp_plug_in_procedure_get_label (file_proc)); "return an image"),
gimp_plug_in_procedure_get_label (file_proc));
*status = GIMP_PDB_EXECUTION_ERROR; *status = GIMP_PDB_EXECUTION_ERROR;
} }
} }
else if (*status != GIMP_PDB_CANCEL) else if (*status != GIMP_PDB_CANCEL)
{ {
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, if (error && ! *error)
_("%s plug-In could not open image"), g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
gimp_plug_in_procedure_get_label (file_proc)); _("%s plug-In could not open image"),
gimp_plug_in_procedure_get_label (file_proc));
} }
g_value_array_free (return_vals); g_value_array_free (return_vals);
...@@ -209,7 +212,8 @@ file_open_thumbnail (Gimp *gimp, ...@@ -209,7 +212,8 @@ file_open_thumbnail (Gimp *gimp,
gint size, gint size,
const gchar **mime_type, const gchar **mime_type,
gint *image_width, gint *image_width,
gint *image_height) gint *image_height,
GError **error)
{ {
GimpPlugInProcedure *file_proc; GimpPlugInProcedure *file_proc;
GimpProcedure *procedure; GimpProcedure *procedure;
...@@ -220,6 +224,7 @@ file_open_thumbnail (Gimp *gimp, ...@@ -220,6 +224,7 @@ file_open_thumbnail (Gimp *gimp,
g_return_val_if_fail (mime_type != NULL, NULL); g_return_val_if_fail (mime_type != NULL, NULL);
g_return_val_if_fail (image_width != NULL, NULL); g_return_val_if_fail (image_width != NULL, NULL);
g_return_val_if_fail (image_height != NULL, NULL); g_return_val_if_fail (image_height != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
*image_width = 0; *image_width = 0;
*image_height = 0; *image_height = 0;
...@@ -246,7 +251,7 @@ file_open_thumbnail (Gimp *gimp, ...@@ -246,7 +251,7 @@ file_open_thumbnail (Gimp *gimp,
return_vals = return_vals =
gimp_pdb_execute_procedure_by_name (gimp->pdb, gimp_pdb_execute_procedure_by_name (gimp->pdb,
context, progress, context, progress, error,
GIMP_OBJECT (procedure)->name, GIMP_OBJECT (procedure)->name,
G_TYPE_STRING, filename, G_TYPE_STRING, filename,
GIMP_TYPE_INT32, size, GIMP_TYPE_INT32, size,
......
...@@ -41,7 +41,8 @@ GimpImage * file_open_thumbnail (Gimp *gimp, ...@@ -41,7 +41,8 @@ GimpImage * file_open_thumbnail (Gimp *gimp,
gint size, gint size,
const gchar **mime_type, const gchar **mime_type,
gint *image_width, gint *image_width,
gint *image_height); gint *image_height,
GError **error);
GimpImage * file_open_with_display (Gimp *gimp, GimpImage * file_open_with_display (Gimp *gimp,
GimpContext *context, GimpContext *context,
GimpProgress *progress, GimpProgress *progress,
......
...@@ -135,7 +135,7 @@ file_save (GimpImage *image, ...@@ -135,7 +135,7 @@ file_save (GimpImage *image,
return_vals = return_vals =
gimp_pdb_execute_procedure_by_name (image->gimp->pdb, gimp_pdb_execute_procedure_by_name (image->gimp->pdb,
context, progress, context, progress, error,
GIMP_OBJECT (file_proc)->name, GIMP_OBJECT (file_proc)->name,
GIMP_TYPE_INT32, run_mode, GIMP_TYPE_INT32, run_mode,
GIMP_TYPE_IMAGE_ID, image_ID, GIMP_TYPE_IMAGE_ID, image_ID,
...@@ -189,9 +189,12 @@ file_save (GimpImage *image, ...@@ -189,9 +189,12 @@ file_save (GimpImage *image,
} }
else if (status != GIMP_PDB_CANCEL) else if (status != GIMP_PDB_CANCEL)
{ {
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, if (error && *error == NULL)
_("%s plug-in could not save image"), {
gimp_plug_in_procedure_get_label (file_proc)); g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("%s plug-in could not save image"),
gimp_plug_in_procedure_get_label (file_proc));
}
} }
g_object_unref (image); g_object_unref (image);
......
...@@ -11,6 +11,8 @@ libapppdb_a_SOURCES = \ ...@@ -11,6 +11,8 @@ libapppdb_a_SOURCES = \
gimppdb.h \ gimppdb.h \
gimppdb-query.c \ gimppdb-query.c \
gimppdb-query.h \ gimppdb-query.h \
gimppdberror.c \
gimppdberror.h \
gimpprocedure.c \ gimpprocedure.c \
gimpprocedure.h gimpprocedure.h
......
...@@ -41,11 +41,12 @@ ...@@ -41,11 +41,12 @@
static GValueArray * static GValueArray *
brush_new_invoker (GimpProcedure *procedure, brush_new_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
GimpContext *context, GimpContext *context,
GimpProgress *progress, GimpProgress *progress,
const GValueArray *args) const GValueArray *args,
GError **error)
{ {
gboolean success = TRUE; gboolean success = TRUE;
GValueArray *return_vals; GValueArray *return_vals;
...@@ -73,11 +74,12 @@ brush_new_invoker (GimpProcedure *procedure, ...@@ -73,11 +74,12 @@ brush_new_invoker (GimpProcedure *procedure,
} }
static GValueArray * static GValueArray *
brush_duplicate_invoker (GimpProcedure *procedure, brush_duplicate_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
GimpContext *context, GimpContext *context,
GimpProgress *progress, GimpProgress *progress,
const GValueArray *args) const GValueArray *args,
GError **error)
{ {
gboolean success = TRUE; gboolean success = TRUE;
GValueArray *return_vals; GValueArray *return_vals;
...@@ -115,11 +117,12 @@ brush_duplicate_invoker (GimpProcedure *procedure, ...@@ -115,11 +117,12 @@ brush_duplicate_invoker (GimpProcedure *procedure,
} }
static GValueArray * static GValueArray *
brush_is_generated_invoker (GimpProcedure *procedure, brush_is_generated_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
GimpContext *context, GimpContext *context,
GimpProgress *progress, GimpProgress *progress,
const GValueArray *args) const GValueArray *args,
GError **error)
{ {
gboolean success = TRUE; gboolean success = TRUE;
GValueArray *return_vals; GValueArray *return_vals;
...@@ -148,11 +151,12 @@ brush_is_generated_invoker (GimpProcedure *procedure, ...@@ -148,11 +151,12 @@ brush_is_generated_invoker (GimpProcedure *procedure,
} }
static GValueArray * static GValueArray *
brush_rename_invoker (GimpProcedure *procedure, brush_rename_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
GimpContext *context, GimpContext *context,
GimpProgress *progress, GimpProgress *progress,
const GValueArray *args) const GValueArray *args,
GError **error)
{ {
gboolean success = TRUE; gboolean success = TRUE;
GValueArray *return_vals; GValueArray *return_vals;
...@@ -186,11 +190,12 @@ brush_rename_invoker (GimpProcedure *procedure, ...@@ -186,11 +190,12 @@ brush_rename_invoker (GimpProcedure *procedure,
} }
static GValueArray * static GValueArray *
brush_delete_invoker (GimpProcedure *procedure, brush_delete_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
GimpContext *context, GimpContext *context,
GimpProgress *progress, GimpProgress *progress,
const GValueArray *args) const GValueArray *args,
GError **error)
{ {
gboolean success = TRUE; gboolean success = TRUE;
const gchar *name; const gchar *name;
...@@ -225,11 +230,12 @@ brush_delete_invoker (GimpProcedure *procedure, ...@@ -225,11 +230,12 @@ brush_delete_invoker (GimpProcedure *procedure,
} }
static GValueArray * static GValueArray *
brush_is_editable_invoker (GimpProcedure *procedure, brush_is_editable_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
GimpContext *context, GimpContext *context,
GimpProgress *progress, GimpProgress *progress,
const GValueArray *args) const GValueArray *args,
GError **error)
{ {
gboolean success = TRUE; gboolean success = TRUE;
GValueArray *return_vals; GValueArray *return_vals;
...@@ -258,11 +264,12 @@ brush_is_editable_invoker (GimpProcedure *procedure, ...@@ -258,11 +264,12 @@ brush_is_editable_invoker (GimpProcedure *procedure,
} }
static GValueArray * static GValueArray *
brush_get_info_invoker (GimpProcedure *procedure, brush_get_info_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
GimpContext *context, GimpContext *context,
GimpProgress *progress, GimpProgress *progress,
const GValueArray *args) const GValueArray *args,
GError **error)
{ {
gboolean success = TRUE; gboolean success = TRUE;
GValueArray *return_vals; GValueArray *return_vals;
...@@ -304,11 +311,12 @@ brush_get_info_invoker (GimpProcedure *procedure, ...@@ -304,11 +311,12 @@ brush_get_info_invoker (GimpProcedure *procedure,
} }
static GValueArray * static GValueArray *
brush_get_pixels_invoker (GimpProcedure *procedure, brush_get_pixels_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
GimpContext *context, GimpContext *context,
GimpProgress *progress, GimpProgress *progress,
const GValueArray *args) const GValueArray *args,
GError **error)
{ {
gboolean success = TRUE; gboolean success = TRUE;
GValueArray *return_vals; GValueArray *return_vals;
...@@ -369,11 +377,12 @@ brush_get_pixels_invoker (GimpProcedure *procedure, ...@@ -369,11 +377,12 @@ brush_get_pixels_invoker (GimpProcedure *procedure,
} }
static GValueArray * static GValueArray *
brush_get_spacing_invoker (GimpProcedure *procedure, brush_get_spacing_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
GimpContext *context, GimpContext *context,
GimpProgress *progress, GimpProgress *progress,
const GValueArray *args) const GValueArray *args,
GError **error)
{ {
gboolean success = TRUE; gboolean success = TRUE;
GValueArray *return_vals; GValueArray *return_vals;
...@@ -402,11 +411,12 @@ brush_get_spacing_invoker (GimpProcedure *procedure, ...@@ -402,11 +411,12 @@ brush_get_spacing_invoker (GimpProcedure *procedure,
} }
static GValueArray * static GValueArray *
brush_set_spacing_invoker (GimpProcedure *procedure, brush_set_spacing_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
GimpContext *context, GimpContext *context,
GimpProgress *progress, GimpProgress *progress,
const GValueArray *args) const GValueArray *args,
GError **error)
{ {
gboolean success = TRUE; gboolean success = TRUE;
const gchar *name; const gchar *name;
...@@ -430,11 +440,12 @@ brush_set_spacing_invoker (GimpProcedure *procedure, ...@@ -430,11 +440,12 @@ brush_set_spacing_invoker (GimpProcedure *procedure,
} }
static GValueArray * static GValueArray *
brush_get_shape_invoker (GimpProcedure *procedure, brush_get_shape_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
GimpContext *context, GimpContext *context,
GimpProgress *progress, GimpProgress *progress,
const GValueArray *args) const GValueArray *args,
GError **error)
{ {
gboolean success = TRUE; gboolean success = TRUE;
GValueArray *return_vals; GValueArray *return_vals;
...@@ -463,11 +474,12 @@ brush_get_shape_invoker (GimpProcedure *procedure, ...@@ -463,11 +474,12 @@ brush_get_shape_invoker (GimpProcedure *procedure,
} }
static GValueArray * static GValueArray *
brush_get_radius_invoker (GimpProcedure *procedure, brush_get_radius_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
GimpContext *context, GimpContext *context,
GimpProgress *progress, GimpProgress *progress,
const GValueArray *args) const GValueArray *args,
GError **error)
{ {
gboolean success = TRUE; gboolean success = TRUE;
GValueArray *return_vals; GValueArray *return_vals;
...@@ -496,11 +508,12 @@ brush_get_radius_invoker (GimpProcedure *procedure, ...@@ -496,11 +508,12 @@ brush_get_radius_invoker (GimpProcedure *procedure,
} }
static GValueArray * static GValueArray *
brush_get_spikes_invoker (GimpProcedure *procedure, brush_get_spikes_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
GimpContext *context, GimpContext *context,
GimpProgress *progress, GimpProgress *progress,
const GValueArray *args) const GValueArray *args,
GError **error)
{ {
gboolean success = TRUE; gboolean success = TRUE;
GValueArray *return_vals; GValueArray *return_vals;
...@@ -529,11 +542,12 @@ brush_get_spikes_invoker (GimpProcedure *procedure, ...@@ -529,11 +542,12 @@ brush_get_spikes_invoker (GimpProcedure *procedure,