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

Hide the PDB wrappers and add the same API to GimpPlugIn.
This commit is contained in:
Michael Natterer 2019-08-07 11:01:53 +02:00
parent 1e6abab1d3
commit 0ef65bc647
8 changed files with 135 additions and 26 deletions

View File

@ -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

View File

@ -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.

View File

@ -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
*/

View File

@ -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 */

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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" }
);