gimp r26656 - in trunk: . app/pdb app/plug-in libgimp libgimpbase plug-ins/common plug-ins/file-uri tools/pdbgen tools/pdbgen/pdb



Author: neo
Date: Mon Aug 18 22:54:26 2008
New Revision: 26656
URL: http://svn.gnome.org/viewvc/gimp?rev=26656&view=rev

Log:
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.



Modified:
   trunk/ChangeLog
   trunk/app/pdb/internal-procs.c
   trunk/app/pdb/plug-in-cmds.c
   trunk/app/plug-in/gimpplugin-message.c
   trunk/app/plug-in/gimpplugin.c
   trunk/app/plug-in/gimpplugin.h
   trunk/libgimp/gimpenums.c.tail
   trunk/libgimp/gimpplugin_pdb.c
   trunk/libgimp/gimpplugin_pdb.h
   trunk/libgimpbase/gimpbaseenums.c
   trunk/libgimpbase/gimpbaseenums.h
   trunk/plug-ins/common/file-compressor.c
   trunk/plug-ins/file-uri/uri.c
   trunk/tools/pdbgen/enums.pl
   trunk/tools/pdbgen/pdb/plug_in.pdb

Modified: trunk/app/pdb/internal-procs.c
==============================================================================
--- trunk/app/pdb/internal-procs.c	(original)
+++ trunk/app/pdb/internal-procs.c	Mon Aug 18 22:54:26 2008
@@ -29,7 +29,7 @@
 #include "internal-procs.h"
 
 
-/* 589 procedures registered total */
+/* 591 procedures registered total */
 
 void
 internal_procs_init (GimpPDB *pdb)

Modified: trunk/app/pdb/plug-in-cmds.c
==============================================================================
--- trunk/app/pdb/plug-in-cmds.c	(original)
+++ trunk/app/pdb/plug-in-cmds.c	Mon Aug 18 22:54:26 2008
@@ -278,6 +278,69 @@
                                            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 @@
                                                            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);
 }

Modified: trunk/app/plug-in/gimpplugin-message.c
==============================================================================
--- trunk/app/plug-in/gimpplugin-message.c	(original)
+++ trunk/app/plug-in/gimpplugin-message.c	Mon Aug 18 22:54:26 2008
@@ -407,6 +407,39 @@
 }
 
 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 @@
 
   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);
     }
 

Modified: trunk/app/plug-in/gimpplugin.c
==============================================================================
--- trunk/app/plug-in/gimpplugin.c	(original)
+++ trunk/app/plug-in/gimpplugin.c	Mon Aug 18 22:54:26 2008
@@ -162,6 +162,8 @@
 
   plug_in->temp_proc_frames   = NULL;
 
+  plug_in->error_handler      = GIMP_PDB_ERROR_HANDLER_INTERNAL;
+
   plug_in->plug_in_def        = NULL;
 }
 
@@ -939,6 +941,24 @@
 }
 
 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)
 {

Modified: trunk/app/plug-in/gimpplugin.h
==============================================================================
--- trunk/app/plug-in/gimpplugin.h	(original)
+++ trunk/app/plug-in/gimpplugin.h	Mon Aug 18 22:54:26 2008
@@ -68,6 +68,8 @@
 
   GList               *temp_proc_frames;
 
+  GimpPDBErrorHandler  error_handler;
+
   GimpPlugInDef       *plug_in_def;     /*  Valid during query() and init()   */
 };
 
@@ -77,43 +79,48 @@
 };
 
 
-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);
-
-gboolean      gimp_plug_in_open             (GimpPlugIn             *plug_in,
-                                             GimpPlugInCallMode      call_mode,
-                                             gboolean                synchronous);
-void          gimp_plug_in_close            (GimpPlugIn             *plug_in,
-                                             gboolean                kill_it);
+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);
 
 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);
-
-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);
-
-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);
+              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);
+
+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);
+
+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__ */

Modified: trunk/libgimp/gimpenums.c.tail
==============================================================================
--- trunk/libgimp/gimpenums.c.tail	(original)
+++ trunk/libgimp/gimpenums.c.tail	Mon Aug 18 22:54:26 2008
@@ -36,6 +36,7 @@
   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 @@
   "GimpOffsetType",
   "GimpOrientationType",
   "GimpPDBArgType",
+  "GimpPDBErrorHandler",
   "GimpPDBProcType",
   "GimpPDBStatusType",
   "GimpPaintApplicationMode",

Modified: trunk/libgimp/gimpplugin_pdb.c
==============================================================================
--- trunk/libgimp/gimpplugin_pdb.c	(original)
+++ trunk/libgimp/gimpplugin_pdb.c	Mon Aug 18 22:54:26 2008
@@ -209,3 +209,73 @@
 
   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;
+}

Modified: trunk/libgimp/gimpplugin_pdb.h
==============================================================================
--- trunk/libgimp/gimpplugin_pdb.h	(original)
+++ trunk/libgimp/gimpplugin_pdb.h	Mon Aug 18 22:54:26 2008
@@ -29,18 +29,20 @@
 /* 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

Modified: trunk/libgimpbase/gimpbaseenums.c
==============================================================================
--- trunk/libgimpbase/gimpbaseenums.c	(original)
+++ trunk/libgimpbase/gimpbaseenums.c	Mon Aug 18 22:54:26 2008
@@ -864,6 +864,35 @@
 }
 
 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)
 {
   static const GEnumValue values[] =

Modified: trunk/libgimpbase/gimpbaseenums.h
==============================================================================
--- trunk/libgimpbase/gimpbaseenums.h	(original)
+++ trunk/libgimpbase/gimpbaseenums.h	Mon Aug 18 22:54:26 2008
@@ -385,6 +385,17 @@
 } 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;

Modified: trunk/plug-ins/common/file-compressor.c
==============================================================================
--- trunk/plug-ins/common/file-compressor.c	(original)
+++ trunk/plug-ins/common/file-compressor.c	Mon Aug 18 22:54:26 2008
@@ -304,6 +304,11 @@
   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];

Modified: trunk/plug-ins/file-uri/uri.c
==============================================================================
--- trunk/plug-ins/file-uri/uri.c	(original)
+++ trunk/plug-ins/file-uri/uri.c	Mon Aug 18 22:54:26 2008
@@ -185,6 +185,11 @@
       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);

Modified: trunk/tools/pdbgen/enums.pl
==============================================================================
--- trunk/tools/pdbgen/enums.pl	(original)
+++ trunk/tools/pdbgen/enums.pl	Mon Aug 18 22:54:26 2008
@@ -294,6 +294,14 @@
 		       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',

Modified: trunk/tools/pdbgen/pdb/plug_in.pdb
==============================================================================
--- trunk/tools/pdbgen/pdb/plug_in.pdb	(original)
+++ trunk/tools/pdbgen/pdb/plug_in.pdb	Mon Aug 18 22:54:26 2008
@@ -278,6 +278,78 @@
     );
 }
 
+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 @@
             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';
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]