Complements the fix for bug #344818:
2008-08-19 Sven Neumann <sven@gimp.org> Complements the fix for bug #344818: * libgimpbase/gimpbaseenums.[ch]: added new enum GimpPDBErrorHandler. * tools/pdbgen/enums.pl: regenerated. * app/plug-in/gimpplugin.[ch]: added error_handler to GimpPlugIn. * app/plug-in/gimpplugin-message.c (gimp_plug_in_handle_proc_run): only display an error message for a failed procedure call if the plug-in's error-handler is set to GIMP_PDB_ERROR_HANDLER_INTERNAL. * tools/pdbgen/pdb/plug_in.pdb: added PDB getter and setter for the plug-in's error-handler. * app/pdb/plug-in-cmds.c * app/pdb/internal-procs.c * libgimp/gimpenums.c.tail * libgimp/gimpplugin_pdb.[ch]: regenerated. * plug-ins/common/file-compressor.c * plug-ins/file-uri/uri.c: set the error-handler to GIMP_PDB_ERROR_HANDLER_PLUGIN as these plug-ins are forwarding the error with their return values. svn path=/trunk/; revision=26656
This commit is contained in:

committed by
Sven Neumann

parent
8b0384a70a
commit
369d991fd2
27
ChangeLog
27
ChangeLog
@ -1,3 +1,30 @@
|
||||
2008-08-19 Sven Neumann <sven@gimp.org>
|
||||
|
||||
Complements the fix for bug #344818:
|
||||
|
||||
* libgimpbase/gimpbaseenums.[ch]: added new enum GimpPDBErrorHandler.
|
||||
|
||||
* tools/pdbgen/enums.pl: regenerated.
|
||||
|
||||
* app/plug-in/gimpplugin.[ch]: added error_handler to GimpPlugIn.
|
||||
|
||||
* app/plug-in/gimpplugin-message.c (gimp_plug_in_handle_proc_run):
|
||||
only display an error message for a failed procedure call if the
|
||||
plug-in's error-handler is set to GIMP_PDB_ERROR_HANDLER_INTERNAL.
|
||||
|
||||
* tools/pdbgen/pdb/plug_in.pdb: added PDB getter and setter for
|
||||
the plug-in's error-handler.
|
||||
|
||||
* app/pdb/plug-in-cmds.c
|
||||
* app/pdb/internal-procs.c
|
||||
* libgimp/gimpenums.c.tail
|
||||
* libgimp/gimpplugin_pdb.[ch]: regenerated.
|
||||
|
||||
* plug-ins/common/file-compressor.c
|
||||
* plug-ins/file-uri/uri.c: set the error-handler to
|
||||
GIMP_PDB_ERROR_HANDLER_PLUGIN as these plug-ins are forwarding the
|
||||
error with their return values.
|
||||
|
||||
2008-08-18 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/file-uri/uri.c: pass error messages with the return
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "internal-procs.h"
|
||||
|
||||
|
||||
/* 589 procedures registered total */
|
||||
/* 591 procedures registered total */
|
||||
|
||||
void
|
||||
internal_procs_init (GimpPDB *pdb)
|
||||
|
@ -278,6 +278,69 @@ plugin_icon_register_invoker (GimpProcedure *procedure,
|
||||
error ? *error : NULL);
|
||||
}
|
||||
|
||||
static GValueArray *
|
||||
plugin_set_pdb_error_handler_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
gint32 handler;
|
||||
|
||||
handler = g_value_get_enum (&args->values[0]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
gimp_plug_in_set_error_handler (plug_in, handler);
|
||||
}
|
||||
else
|
||||
{
|
||||
success = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
}
|
||||
|
||||
static GValueArray *
|
||||
plugin_get_pdb_error_handler_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GValueArray *return_vals;
|
||||
gint32 handler = 0;
|
||||
|
||||
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
handler = gimp_plug_in_get_error_handler (plug_in);
|
||||
}
|
||||
else
|
||||
{
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
g_value_set_enum (&return_vals->values[1], handler);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
void
|
||||
register_plug_in_procs (GimpPDB *pdb)
|
||||
{
|
||||
@ -538,4 +601,52 @@ register_plug_in_procs (GimpPDB *pdb)
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-plugin-set-pdb-error-handler
|
||||
*/
|
||||
procedure = gimp_procedure_new (plugin_set_pdb_error_handler_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-plugin-set-pdb-error-handler");
|
||||
gimp_procedure_set_static_strings (procedure,
|
||||
"gimp-plugin-set-pdb-error-handler",
|
||||
"Sets an error handler for procedure calls.",
|
||||
"This procedure changes the way that errors in procedure calls are handled. By default GIMP will raise an error dialog if a procedure call made by a plug-in fails. Using this procedure the plug-in can change this behavior. If the error handler is set to %GIMP_PDB_ERROR_HANDLER_PLUGIN, then the plug-in is responsible for calling 'gimp-get-pdb-error' and handling the error whenever one if its procedure calls fails. It can do this by displaying the error message or by forwarding it in its own return values.",
|
||||
"Sven Neumann <sven@gimp.org>",
|
||||
"Sven Neumann",
|
||||
"2008",
|
||||
NULL);
|
||||
gimp_procedure_add_argument (procedure,
|
||||
g_param_spec_enum ("handler",
|
||||
"handler",
|
||||
"Who is responsible for handling procedure call errors",
|
||||
GIMP_TYPE_PDB_ERROR_HANDLER,
|
||||
GIMP_PDB_ERROR_HANDLER_INTERNAL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-plugin-get-pdb-error-handler
|
||||
*/
|
||||
procedure = gimp_procedure_new (plugin_get_pdb_error_handler_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-plugin-get-pdb-error-handler");
|
||||
gimp_procedure_set_static_strings (procedure,
|
||||
"gimp-plugin-get-pdb-error-handler",
|
||||
"Retrieves the active error handler for procedure calls.",
|
||||
"This procedure retrieves the currently active error handler for procedure calls made by the calling plug-in. See 'gimp-plugin-set-pdb-error-handler' for details.",
|
||||
"Sven Neumann <sven@gimp.org>",
|
||||
"Sven Neumann",
|
||||
"2008",
|
||||
NULL);
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
g_param_spec_enum ("handler",
|
||||
"handler",
|
||||
"Who is responsible for handling procedure call errors",
|
||||
GIMP_TYPE_PDB_ERROR_HANDLER,
|
||||
GIMP_PDB_ERROR_HANDLER_INTERNAL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
}
|
||||
|
@ -406,6 +406,39 @@ gimp_plug_in_handle_tile_get (GimpPlugIn *plug_in,
|
||||
gimp_wire_destroy (&msg);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_plug_in_handle_proc_error (GimpPlugIn *plug_in,
|
||||
GimpProgress *progress,
|
||||
const gchar *name,
|
||||
const GError *error)
|
||||
{
|
||||
switch (gimp_plug_in_get_error_handler (plug_in))
|
||||
{
|
||||
case GIMP_PDB_ERROR_HANDLER_INTERNAL:
|
||||
if (error->domain == GIMP_PDB_ERROR)
|
||||
{
|
||||
gimp_message (plug_in->manager->gimp, G_OBJECT (progress),
|
||||
GIMP_MESSAGE_ERROR,
|
||||
_("Calling error for procedure '%s':\n"
|
||||
"%s"),
|
||||
name, error->message);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_message (plug_in->manager->gimp, G_OBJECT (progress),
|
||||
GIMP_MESSAGE_ERROR,
|
||||
_("Execution error for procedure '%s':\n"
|
||||
"%s"),
|
||||
name, error->message);
|
||||
}
|
||||
break;
|
||||
|
||||
case GIMP_PDB_ERROR_HANDLER_PLUGIN:
|
||||
/* the plug-in is responsible for this error */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_plug_in_handle_proc_run (GimpPlugIn *plug_in,
|
||||
GPProcRun *proc_run)
|
||||
@ -503,23 +536,8 @@ gimp_plug_in_handle_proc_run (GimpPlugIn *plug_in,
|
||||
|
||||
if (error)
|
||||
{
|
||||
if (error->domain == GIMP_PDB_ERROR)
|
||||
{
|
||||
gimp_message (plug_in->manager->gimp, G_OBJECT (proc_frame->progress),
|
||||
GIMP_MESSAGE_ERROR,
|
||||
_("Calling error for procedure '%s':\n"
|
||||
"%s"),
|
||||
canonical, error->message);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_message (plug_in->manager->gimp, G_OBJECT (proc_frame->progress),
|
||||
GIMP_MESSAGE_ERROR,
|
||||
_("Execution error for procedure '%s':\n"
|
||||
"%s"),
|
||||
canonical, error->message);
|
||||
}
|
||||
|
||||
gimp_plug_in_handle_proc_error (plug_in, proc_frame->progress,
|
||||
canonical, error);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
|
@ -162,6 +162,8 @@ gimp_plug_in_init (GimpPlugIn *plug_in)
|
||||
|
||||
plug_in->temp_proc_frames = NULL;
|
||||
|
||||
plug_in->error_handler = GIMP_PDB_ERROR_HANDLER_INTERNAL;
|
||||
|
||||
plug_in->plug_in_def = NULL;
|
||||
}
|
||||
|
||||
@ -938,6 +940,24 @@ gimp_plug_in_menu_register (GimpPlugIn *plug_in,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_plug_in_set_error_handler (GimpPlugIn *plug_in,
|
||||
GimpPDBErrorHandler handler)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
|
||||
|
||||
plug_in->error_handler = handler;
|
||||
}
|
||||
|
||||
GimpPDBErrorHandler
|
||||
gimp_plug_in_get_error_handler (GimpPlugIn *plug_in)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in),
|
||||
GIMP_PDB_ERROR_HANDLER_INTERNAL);
|
||||
|
||||
return plug_in->error_handler;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_plug_in_add_temp_proc (GimpPlugIn *plug_in,
|
||||
GimpTemporaryProcedure *proc)
|
||||
|
@ -68,6 +68,8 @@ struct _GimpPlugIn
|
||||
|
||||
GList *temp_proc_frames;
|
||||
|
||||
GimpPDBErrorHandler error_handler;
|
||||
|
||||
GimpPlugInDef *plug_in_def; /* Valid during query() and init() */
|
||||
};
|
||||
|
||||
@ -77,43 +79,48 @@ struct _GimpPlugInClass
|
||||
};
|
||||
|
||||
|
||||
GType gimp_plug_in_get_type (void) G_GNUC_CONST;
|
||||
GType gimp_plug_in_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GimpPlugIn * gimp_plug_in_new (GimpPlugInManager *manager,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
GimpPlugInProcedure *procedure,
|
||||
const gchar *prog);
|
||||
GimpPlugIn * gimp_plug_in_new (GimpPlugInManager *manager,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
GimpPlugInProcedure *procedure,
|
||||
const gchar *prog);
|
||||
|
||||
gboolean gimp_plug_in_open (GimpPlugIn *plug_in,
|
||||
GimpPlugInCallMode call_mode,
|
||||
gboolean synchronous);
|
||||
void gimp_plug_in_close (GimpPlugIn *plug_in,
|
||||
gboolean kill_it);
|
||||
gboolean gimp_plug_in_open (GimpPlugIn *plug_in,
|
||||
GimpPlugInCallMode call_mode,
|
||||
gboolean synchronous);
|
||||
void gimp_plug_in_close (GimpPlugIn *plug_in,
|
||||
gboolean kill_it);
|
||||
|
||||
GimpPlugInProcFrame *
|
||||
gimp_plug_in_get_proc_frame (GimpPlugIn *plug_in);
|
||||
gimp_plug_in_get_proc_frame (GimpPlugIn *plug_in);
|
||||
|
||||
GimpPlugInProcFrame *
|
||||
gimp_plug_in_proc_frame_push (GimpPlugIn *plug_in,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
GimpTemporaryProcedure *procedure);
|
||||
void gimp_plug_in_proc_frame_pop (GimpPlugIn *plug_in);
|
||||
gimp_plug_in_proc_frame_push (GimpPlugIn *plug_in,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
GimpTemporaryProcedure *procedure);
|
||||
void gimp_plug_in_proc_frame_pop (GimpPlugIn *plug_in);
|
||||
|
||||
void gimp_plug_in_main_loop (GimpPlugIn *plug_in);
|
||||
void gimp_plug_in_main_loop_quit (GimpPlugIn *plug_in);
|
||||
void gimp_plug_in_main_loop (GimpPlugIn *plug_in);
|
||||
void gimp_plug_in_main_loop_quit (GimpPlugIn *plug_in);
|
||||
|
||||
const gchar * gimp_plug_in_get_undo_desc (GimpPlugIn *plug_in);
|
||||
const gchar * gimp_plug_in_get_undo_desc (GimpPlugIn *plug_in);
|
||||
|
||||
gboolean gimp_plug_in_menu_register (GimpPlugIn *plug_in,
|
||||
const gchar *proc_name,
|
||||
const gchar *menu_path);
|
||||
gboolean gimp_plug_in_menu_register (GimpPlugIn *plug_in,
|
||||
const gchar *proc_name,
|
||||
const gchar *menu_path);
|
||||
|
||||
void gimp_plug_in_add_temp_proc (GimpPlugIn *plug_in,
|
||||
GimpTemporaryProcedure *procedure);
|
||||
void gimp_plug_in_remove_temp_proc (GimpPlugIn *plug_in,
|
||||
GimpTemporaryProcedure *procedure);
|
||||
void gimp_plug_in_add_temp_proc (GimpPlugIn *plug_in,
|
||||
GimpTemporaryProcedure *procedure);
|
||||
void gimp_plug_in_remove_temp_proc (GimpPlugIn *plug_in,
|
||||
GimpTemporaryProcedure *procedure);
|
||||
|
||||
void gimp_plug_in_set_error_handler (GimpPlugIn *plug_in,
|
||||
GimpPDBErrorHandler handler);
|
||||
GimpPDBErrorHandler
|
||||
gimp_plug_in_get_error_handler (GimpPlugIn *plug_in);
|
||||
|
||||
|
||||
#endif /* __GIMP_PLUG_IN_H__ */
|
||||
|
@ -36,6 +36,7 @@ static const GimpGetTypeFunc get_type_funcs[] =
|
||||
gimp_offset_type_get_type,
|
||||
gimp_orientation_type_get_type,
|
||||
gimp_pdb_arg_type_get_type,
|
||||
gimp_pdb_error_handler_get_type,
|
||||
gimp_pdb_proc_type_get_type,
|
||||
gimp_pdb_status_type_get_type,
|
||||
gimp_paint_application_mode_get_type,
|
||||
@ -90,6 +91,7 @@ static const gchar * const type_names[] =
|
||||
"GimpOffsetType",
|
||||
"GimpOrientationType",
|
||||
"GimpPDBArgType",
|
||||
"GimpPDBErrorHandler",
|
||||
"GimpPDBProcType",
|
||||
"GimpPDBStatusType",
|
||||
"GimpPaintApplicationMode",
|
||||
|
@ -209,3 +209,73 @@ _gimp_plugin_icon_register (const gchar *procedure_name,
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_plugin_set_pdb_error_handler:
|
||||
* @handler: Who is responsible for handling procedure call errors.
|
||||
*
|
||||
* Sets an error handler for procedure calls.
|
||||
*
|
||||
* This procedure changes the way that errors in procedure calls are
|
||||
* handled. By default GIMP will raise an error dialog if a procedure
|
||||
* call made by a plug-in fails. Using this procedure the plug-in can
|
||||
* change this behavior. If the error handler is set to
|
||||
* %GIMP_PDB_ERROR_HANDLER_PLUGIN, then the plug-in is responsible for
|
||||
* calling gimp_get_pdb_error() and handling the error whenever one if
|
||||
* its procedure calls fails. It can do this by displaying the error
|
||||
* message or by forwarding it in its own return values.
|
||||
*
|
||||
* Returns: TRUE on success.
|
||||
*
|
||||
* Since: GIMP 2.6
|
||||
*/
|
||||
gboolean
|
||||
gimp_plugin_set_pdb_error_handler (GimpPDBErrorHandler handler)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gboolean success = TRUE;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp-plugin-set-pdb-error-handler",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_INT32, handler,
|
||||
GIMP_PDB_END);
|
||||
|
||||
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_plugin_get_pdb_error_handler:
|
||||
*
|
||||
* Retrieves the active error handler for procedure calls.
|
||||
*
|
||||
* This procedure retrieves the currently active error handler for
|
||||
* procedure calls made by the calling plug-in. See
|
||||
* gimp_plugin_set_pdb_error_handler() for details.
|
||||
*
|
||||
* Returns: Who is responsible for handling procedure call errors.
|
||||
*
|
||||
* Since: GIMP 2.6
|
||||
*/
|
||||
GimpPDBErrorHandler
|
||||
gimp_plugin_get_pdb_error_handler (void)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
GimpPDBErrorHandler handler = 0;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp-plugin-get-pdb-error-handler",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
handler = return_vals[1].data.d_int32;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return handler;
|
||||
}
|
||||
|
@ -29,18 +29,20 @@ G_BEGIN_DECLS
|
||||
/* For information look into the C source or the html documentation */
|
||||
|
||||
|
||||
gboolean gimp_plugin_domain_register (const gchar *domain_name,
|
||||
const gchar *domain_path);
|
||||
gboolean gimp_plugin_help_register (const gchar *domain_name,
|
||||
const gchar *domain_uri);
|
||||
gboolean gimp_plugin_menu_register (const gchar *procedure_name,
|
||||
const gchar *menu_path);
|
||||
gboolean gimp_plugin_menu_branch_register (const gchar *menu_path,
|
||||
const gchar *menu_name);
|
||||
G_GNUC_INTERNAL gboolean _gimp_plugin_icon_register (const gchar *procedure_name,
|
||||
GimpIconType icon_type,
|
||||
gint icon_data_length,
|
||||
const guint8 *icon_data);
|
||||
gboolean gimp_plugin_domain_register (const gchar *domain_name,
|
||||
const gchar *domain_path);
|
||||
gboolean gimp_plugin_help_register (const gchar *domain_name,
|
||||
const gchar *domain_uri);
|
||||
gboolean gimp_plugin_menu_register (const gchar *procedure_name,
|
||||
const gchar *menu_path);
|
||||
gboolean gimp_plugin_menu_branch_register (const gchar *menu_path,
|
||||
const gchar *menu_name);
|
||||
G_GNUC_INTERNAL gboolean _gimp_plugin_icon_register (const gchar *procedure_name,
|
||||
GimpIconType icon_type,
|
||||
gint icon_data_length,
|
||||
const guint8 *icon_data);
|
||||
gboolean gimp_plugin_set_pdb_error_handler (GimpPDBErrorHandler handler);
|
||||
GimpPDBErrorHandler gimp_plugin_get_pdb_error_handler (void);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -863,6 +863,35 @@ gimp_pdb_arg_type_get_type (void)
|
||||
return type;
|
||||
}
|
||||
|
||||
GType
|
||||
gimp_pdb_error_handler_get_type (void)
|
||||
{
|
||||
static const GEnumValue values[] =
|
||||
{
|
||||
{ GIMP_PDB_ERROR_HANDLER_INTERNAL, "GIMP_PDB_ERROR_HANDLER_INTERNAL", "internal" },
|
||||
{ GIMP_PDB_ERROR_HANDLER_PLUGIN, "GIMP_PDB_ERROR_HANDLER_PLUGIN", "plugin" },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static const GimpEnumDesc descs[] =
|
||||
{
|
||||
{ GIMP_PDB_ERROR_HANDLER_INTERNAL, "GIMP_PDB_ERROR_HANDLER_INTERNAL", NULL },
|
||||
{ GIMP_PDB_ERROR_HANDLER_PLUGIN, "GIMP_PDB_ERROR_HANDLER_PLUGIN", NULL },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static GType type = 0;
|
||||
|
||||
if (! type)
|
||||
{
|
||||
type = g_enum_register_static ("GimpPDBErrorHandler", values);
|
||||
gimp_type_set_translation_domain (type, GETTEXT_PACKAGE "-libgimp");
|
||||
gimp_enum_set_value_descriptions (type, descs);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
GType
|
||||
gimp_pdb_proc_type_get_type (void)
|
||||
{
|
||||
|
@ -385,6 +385,17 @@ typedef enum
|
||||
} GimpPDBArgType;
|
||||
|
||||
|
||||
#define GIMP_TYPE_PDB_ERROR_HANDLER (gimp_pdb_error_handler_get_type ())
|
||||
|
||||
GType gimp_pdb_error_handler_get_type (void) G_GNUC_CONST;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GIMP_PDB_ERROR_HANDLER_INTERNAL,
|
||||
GIMP_PDB_ERROR_HANDLER_PLUGIN
|
||||
} GimpPDBErrorHandler;
|
||||
|
||||
|
||||
#define GIMP_TYPE_PDB_PROC_TYPE (gimp_pdb_proc_type_get_type ())
|
||||
|
||||
GType gimp_pdb_proc_type_get_type (void) G_GNUC_CONST;
|
||||
|
@ -304,6 +304,11 @@ run (const gchar *name,
|
||||
values[0].type = GIMP_PDB_STATUS;
|
||||
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
|
||||
|
||||
/* We handle PDB errors by forwarding them to the caller in
|
||||
* our return values.
|
||||
*/
|
||||
gimp_plugin_set_pdb_error_handler (GIMP_PDB_ERROR_HANDLER_PLUGIN);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (compressors); i++)
|
||||
{
|
||||
const Compressor *compressor = &compressors[i];
|
||||
|
@ -185,6 +185,11 @@ run (const gchar *name,
|
||||
return;
|
||||
}
|
||||
|
||||
/* We handle PDB errors by forwarding them to the caller in
|
||||
* our return values.
|
||||
*/
|
||||
gimp_plugin_set_pdb_error_handler (GIMP_PDB_ERROR_HANDLER_PLUGIN);
|
||||
|
||||
if (! strcmp (name, LOAD_PROC) && uri_backend_get_load_protocols ())
|
||||
{
|
||||
image_ID = load_image (param[2].data.d_string, run_mode, &error);
|
||||
|
@ -294,6 +294,14 @@ package Gimp::CodeGen::enums;
|
||||
GIMP_PDB_PATH => 'GIMP_PDB_VECTORS',
|
||||
GIMP_PDB_BOUNDARY => 'GIMP_PDB_COLORARRAY' }
|
||||
},
|
||||
GimpPDBErrorHandler =>
|
||||
{ contig => 1,
|
||||
header => 'libgimpbase/gimpbaseenums.h',
|
||||
symbols => [ qw(GIMP_PDB_ERROR_HANDLER_INTERNAL
|
||||
GIMP_PDB_ERROR_HANDLER_PLUGIN) ],
|
||||
mapping => { GIMP_PDB_ERROR_HANDLER_INTERNAL => '0',
|
||||
GIMP_PDB_ERROR_HANDLER_PLUGIN => '1' }
|
||||
},
|
||||
GimpPDBProcType =>
|
||||
{ contig => 1,
|
||||
header => 'libgimpbase/gimpbaseenums.h',
|
||||
|
@ -278,6 +278,78 @@ CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub plugin_set_pdb_error_handler {
|
||||
$blurb = "Sets an error handler for procedure calls.";
|
||||
|
||||
$help = <<HELP;
|
||||
This procedure changes the way that errors in procedure calls are
|
||||
handled. By default GIMP will raise an error dialog if a procedure
|
||||
call made by a plug-in fails. Using this procedure the plug-in can
|
||||
change this behavior. If the error handler is set to
|
||||
%GIMP_PDB_ERROR_HANDLER_PLUGIN, then the plug-in is responsible for
|
||||
calling gimp_get_pdb_error() and handling the error whenever one if
|
||||
its procedure calls fails. It can do this by displaying the error
|
||||
message or by forwarding it in its own return values.
|
||||
HELP
|
||||
|
||||
&neo_pdb_misc('2008', '2.6');
|
||||
|
||||
@inargs = (
|
||||
{ name => 'handler', type => 'enum GimpPDBErrorHandler',
|
||||
desc => "Who is responsible for handling procedure call errors" }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
gimp_plug_in_set_error_handler (plug_in, handler);
|
||||
}
|
||||
else
|
||||
{
|
||||
success = FALSE;
|
||||
}
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub plugin_get_pdb_error_handler {
|
||||
$blurb = "Retrieves the active error handler for procedure calls.";
|
||||
|
||||
$help = <<HELP;
|
||||
This procedure retrieves the currently active error handler for
|
||||
procedure calls made by the calling plug-in. See
|
||||
gimp_plugin_set_pdb_error_handler() for details.
|
||||
HELP
|
||||
|
||||
&neo_pdb_misc('2008', '2.6');
|
||||
|
||||
@outargs = (
|
||||
{ name => 'handler', type => 'enum GimpPDBErrorHandler',
|
||||
desc => "Who is responsible for handling procedure call errors" }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
GimpPlugIn *plug_in = gimp->plug_in_manager->current_plug_in;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
handler = gimp_plug_in_get_error_handler (plug_in);
|
||||
}
|
||||
else
|
||||
{
|
||||
success = FALSE;
|
||||
}
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
@headers = qw(<string.h>
|
||||
<stdlib.h>
|
||||
@ -295,9 +367,11 @@ CODE
|
||||
plugin_help_register
|
||||
plugin_menu_register
|
||||
plugin_menu_branch_register
|
||||
plugin_icon_register);
|
||||
plugin_icon_register
|
||||
plugin_set_pdb_error_handler
|
||||
plugin_get_pdb_error_handler);
|
||||
|
||||
%exports = (app => [@procs], lib => [@procs[1,2,3,4,5]]);
|
||||
%exports = (app => [@procs], lib => [@procs[1,2,3,4,5,6,7]]);
|
||||
|
||||
$desc = 'Plug-in';
|
||||
|
||||
|
Reference in New Issue
Block a user