[gimp] pdb: move gimp_plugin_set, get_pdb_error_handler() to gimplegacy.[ch]



commit 0ef65bc647b987a758c2aedec6365efe74aedbde
Author: Michael Natterer <mitch gimp org>
Date:   Wed Aug 7 11:01:53 2019 +0200

    pdb: move gimp_plugin_set,get_pdb_error_handler() to gimplegacy.[ch]
    
    Hide the PDB wrappers and add the same API to GimpPlugIn.

 libgimp/gimp.def         |  2 ++
 libgimp/gimplegacy.c     | 48 ++++++++++++++++++++++++++++++++++++++++++++++
 libgimp/gimplegacy.h     | 16 ++++++++++------
 libgimp/gimpplugin.c     | 50 ++++++++++++++++++++++++++++++++++++++++++++++++
 libgimp/gimpplugin.h     |  5 +++++
 libgimp/gimpplugin_pdb.c |  8 ++++----
 libgimp/gimpplugin_pdb.h | 28 +++++++++++++--------------
 pdb/groups/plug_in.pdb   |  4 ++--
 8 files changed, 135 insertions(+), 26 deletions(-)
---
diff --git a/libgimp/gimp.def b/libgimp/gimp.def
index cde1c480c4..faef83b1aa 100644
--- a/libgimp/gimp.def
+++ b/libgimp/gimp.def
@@ -637,11 +637,13 @@ EXPORTS
        gimp_plug_in_create_procedure
        gimp_plug_in_extension_enable
        gimp_plug_in_extension_process
+       gimp_plug_in_get_pdb_error_handler
        gimp_plug_in_get_temp_procedure
        gimp_plug_in_get_temp_procedures
        gimp_plug_in_get_type
        gimp_plug_in_remove_temp_procedure
        gimp_plug_in_set_help_domain
+       gimp_plug_in_set_pdb_error_handler
        gimp_plug_in_set_translation_domain
        gimp_plugin_domain_register
        gimp_plugin_get_pdb_error_handler
diff --git a/libgimp/gimplegacy.c b/libgimp/gimplegacy.c
index d9d7b1a112..e778547b8b 100644
--- a/libgimp/gimplegacy.c
+++ b/libgimp/gimplegacy.c
@@ -1081,6 +1081,54 @@ gimp_plugin_menu_branch_register (const gchar *menu_path,
   return _gimp_plugin_menu_branch_register (menu_path, menu_name);
 }
 
+/**
+ * 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: 2.6
+ **/
+gboolean
+gimp_plugin_set_pdb_error_handler (GimpPDBErrorHandler handler)
+{
+  ASSERT_NO_PLUG_IN_EXISTS (G_STRFUNC);
+
+  return _gimp_plugin_set_pdb_error_handler (handler);
+}
+
+/**
+ * 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: 2.6
+ **/
+GimpPDBErrorHandler
+gimp_plugin_get_pdb_error_handler (void)
+{
+  ASSERT_NO_PLUG_IN_EXISTS (G_STRFUNC);
+
+  return _gimp_plugin_get_pdb_error_handler ();
+}
+
 /**
  * gimp_plugin_menu_register:
  * @procedure_name: The procedure for which to install the menu path.
diff --git a/libgimp/gimplegacy.h b/libgimp/gimplegacy.h
index 8b3900576b..90c7f2cc3b 100644
--- a/libgimp/gimplegacy.h
+++ b/libgimp/gimplegacy.h
@@ -289,12 +289,16 @@ void           gimp_destroy_paramdefs   (GimpParamDef    *paramdefs,
 /* gimp_plugin API that should now be done by using GimpPlugIn
  */
 
-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_branch_register (const gchar  *menu_path,
-                                             const gchar  *menu_name);
+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_branch_register  (const gchar         *menu_path,
+                                              const gchar         *menu_name);
+gboolean   gimp_plugin_set_pdb_error_handler (GimpPDBErrorHandler  handler);
+GimpPDBErrorHandler
+           gimp_plugin_get_pdb_error_handler (void);
+
 
 /* gimp_plugin API that should now be done by using GimpProcedure
  */
diff --git a/libgimp/gimpplugin.c b/libgimp/gimpplugin.c
index 5e2a5e2f05..6ce01caa62 100644
--- a/libgimp/gimpplugin.c
+++ b/libgimp/gimpplugin.c
@@ -602,6 +602,56 @@ gimp_plug_in_extension_process (GimpPlugIn *plug_in,
 #endif
 }
 
+/**
+ * gimp_plugin_set_pdb_error_handler:
+ * @plug_in: A #GimpPlugIn
+ * @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.
+ *
+ * Since: 3.0
+ **/
+void
+gimp_plug_in_set_pdb_error_handler (GimpPlugIn          *plug_in,
+                                    GimpPDBErrorHandler  handler)
+{
+  g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
+
+  _gimp_plugin_set_pdb_error_handler (handler);
+}
+
+/**
+ * gimp_plugin_get_pdb_error_handler:
+ * @plug_in: A #GimpPlugIn
+ *
+ * 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: 3.0
+ **/
+GimpPDBErrorHandler
+gimp_plug_in_get_pdb_error_handler (GimpPlugIn *plug_in)
+{
+  g_return_val_if_fail (GIMP_IS_PLUG_IN (plug_in),
+                        GIMP_PDB_ERROR_HANDLER_INTERNAL);
+
+  return _gimp_plugin_get_pdb_error_handler ();
+}
+
 
 /*  private functions  */
 
diff --git a/libgimp/gimpplugin.h b/libgimp/gimpplugin.h
index f8df217807..a59bb331eb 100644
--- a/libgimp/gimpplugin.h
+++ b/libgimp/gimpplugin.h
@@ -159,6 +159,11 @@ void            gimp_plug_in_extension_enable       (GimpPlugIn    *plug_in);
 void            gimp_plug_in_extension_process      (GimpPlugIn    *plug_in,
                                                      guint          timeout);
 
+void            gimp_plug_in_set_pdb_error_handler  (GimpPlugIn    *plug_in,
+                                                     GimpPDBErrorHandler  handler);
+GimpPDBErrorHandler
+                gimp_plug_in_get_pdb_error_handler  (GimpPlugIn    *plug_in);
+
 
 G_END_DECLS
 
diff --git a/libgimp/gimpplugin_pdb.c b/libgimp/gimpplugin_pdb.c
index 8ddd4ee8d3..76ec84e375 100644
--- a/libgimp/gimpplugin_pdb.c
+++ b/libgimp/gimpplugin_pdb.c
@@ -264,7 +264,7 @@ _gimp_plugin_icon_register (const gchar  *procedure_name,
 }
 
 /**
- * gimp_plugin_set_pdb_error_handler:
+ * _gimp_plugin_set_pdb_error_handler:
  * @handler: Who is responsible for handling procedure call errors.
  *
  * Sets an error handler for procedure calls.
@@ -283,7 +283,7 @@ _gimp_plugin_icon_register (const gchar  *procedure_name,
  * Since: 2.6
  **/
 gboolean
-gimp_plugin_set_pdb_error_handler (GimpPDBErrorHandler handler)
+_gimp_plugin_set_pdb_error_handler (GimpPDBErrorHandler handler)
 {
   GimpPDB        *pdb = gimp_get_pdb ();
   GimpValueArray *args;
@@ -311,7 +311,7 @@ gimp_plugin_set_pdb_error_handler (GimpPDBErrorHandler handler)
 }
 
 /**
- * gimp_plugin_get_pdb_error_handler:
+ * _gimp_plugin_get_pdb_error_handler:
  *
  * Retrieves the active error handler for procedure calls.
  *
@@ -324,7 +324,7 @@ gimp_plugin_set_pdb_error_handler (GimpPDBErrorHandler handler)
  * Since: 2.6
  **/
 GimpPDBErrorHandler
-gimp_plugin_get_pdb_error_handler (void)
+_gimp_plugin_get_pdb_error_handler (void)
 {
   GimpPDB        *pdb = gimp_get_pdb ();
   GimpValueArray *args;
diff --git a/libgimp/gimpplugin_pdb.h b/libgimp/gimpplugin_pdb.h
index 1c0a5ec8d8..1d515a9f02 100644
--- a/libgimp/gimpplugin_pdb.h
+++ b/libgimp/gimpplugin_pdb.h
@@ -32,20 +32,20 @@ G_BEGIN_DECLS
 /* For information look into the C source or the html documentation */
 
 
-G_GNUC_INTERNAL gboolean _gimp_plugin_domain_register      (const gchar         *domain_name,
-                                                            const gchar         *domain_path);
-G_GNUC_INTERNAL gboolean _gimp_plugin_help_register        (const gchar         *domain_name,
-                                                            const gchar         *domain_uri);
-G_GNUC_INTERNAL gboolean _gimp_plugin_menu_branch_register (const gchar         *menu_path,
-                                                            const gchar         *menu_name);
-G_GNUC_INTERNAL gboolean _gimp_plugin_menu_register        (const gchar         *procedure_name,
-                                                            const gchar         *menu_path);
-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_GNUC_INTERNAL gboolean            _gimp_plugin_domain_register       (const gchar         *domain_name,
+                                                                        const gchar         *domain_path);
+G_GNUC_INTERNAL gboolean            _gimp_plugin_help_register         (const gchar         *domain_name,
+                                                                        const gchar         *domain_uri);
+G_GNUC_INTERNAL gboolean            _gimp_plugin_menu_branch_register  (const gchar         *menu_path,
+                                                                        const gchar         *menu_name);
+G_GNUC_INTERNAL gboolean            _gimp_plugin_menu_register         (const gchar         *procedure_name,
+                                                                        const gchar         *menu_path);
+G_GNUC_INTERNAL gboolean            _gimp_plugin_icon_register         (const gchar         *procedure_name,
+                                                                        GimpIconType         icon_type,
+                                                                        gint                 
icon_data_length,
+                                                                        const guint8        *icon_data);
+G_GNUC_INTERNAL gboolean            _gimp_plugin_set_pdb_error_handler (GimpPDBErrorHandler  handler);
+G_GNUC_INTERNAL GimpPDBErrorHandler _gimp_plugin_get_pdb_error_handler (void);
 
 
 G_END_DECLS
diff --git a/pdb/groups/plug_in.pdb b/pdb/groups/plug_in.pdb
index ba4050793d..c244c116d2 100644
--- a/pdb/groups/plug_in.pdb
+++ b/pdb/groups/plug_in.pdb
@@ -297,7 +297,7 @@ HELP
     &neo_pdb_misc('2008', '2.6');
 
     @inargs = (
-       { name => 'handler', type => 'enum GimpPDBErrorHandler',
+       { name => 'handler', type => 'enum GimpPDBErrorHandler', wrap => 1,
          desc => "Who is responsible for handling procedure call errors" }
     );
 
@@ -331,7 +331,7 @@ HELP
     &neo_pdb_misc('2008', '2.6');
 
     @outargs = (
-       { name => 'handler', type => 'enum GimpPDBErrorHandler',
+       { name => 'handler', type => 'enum GimpPDBErrorHandler', wrap => 1,
          desc => "Who is responsible for handling procedure call errors" }
     );
 


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