libgimp: add gimp_procedure_extension_ready()

which must be called by GIMP_EXTENSION procedures when they are ready
to run their temporary procedures. Move gimp_extension_ack() to
gimpobsolete.[ch].
This commit is contained in:
Michael Natterer 2019-08-01 23:24:49 +02:00
parent a841e0fb06
commit 0601b7f9a8
8 changed files with 73 additions and 34 deletions

View File

@ -1228,28 +1228,6 @@ gimp_get_progname (void)
return progname; return progname;
} }
/**
* gimp_extension_ack:
*
* Notify the main GIMP application that the extension has been properly
* initialized and is ready to run.
*
* This function <emphasis>must</emphasis> be called from every
* procedure that was registered as #GIMP_EXTENSION.
*
* Subsequently, extensions can process temporary procedure run
* requests using either gimp_extension_enable() or
* gimp_extension_process().
*
* See also: gimp_install_procedure(), gimp_install_temp_proc()
**/
void
gimp_extension_ack (void)
{
if (! gp_extension_ack_write (_gimp_writechannel, NULL))
gimp_quit ();
}
/** /**
* gimp_extension_enable: * gimp_extension_enable:
* *

View File

@ -149,10 +149,6 @@ gint gimp_main (GType plug_in_type,
*/ */
void gimp_quit (void) G_GNUC_NORETURN; void gimp_quit (void) G_GNUC_NORETURN;
/* Notify the main GIMP application that the extension is ready to run
*/
void gimp_extension_ack (void);
/* Enable asynchronous processing of temp_procs /* Enable asynchronous processing of temp_procs
*/ */
void gimp_extension_enable (void); void gimp_extension_enable (void);

View File

@ -443,6 +443,28 @@ gimp_uninstall_temp_proc (const gchar *name)
} }
} }
/**
* gimp_extension_ack:
*
* Notify the main GIMP application that the extension has been properly
* initialized and is ready to run.
*
* This function <emphasis>must</emphasis> be called from every
* procedure that was registered as #GIMP_EXTENSION.
*
* Subsequently, extensions can process temporary procedure run
* requests using either gimp_extension_enable() or
* gimp_extension_process().
*
* See also: gimp_install_procedure(), gimp_install_temp_proc()
**/
void
gimp_extension_ack (void)
{
if (! gp_extension_ack_write (_gimp_writechannel, NULL))
gimp_quit ();
}
/** /**
* gimp_run_procedure: (skip) * gimp_run_procedure: (skip)
* @name: the name of the procedure to run * @name: the name of the procedure to run

View File

@ -261,6 +261,10 @@ void gimp_install_temp_proc (const gchar *name,
*/ */
void gimp_uninstall_temp_proc (const gchar *name); void gimp_uninstall_temp_proc (const gchar *name);
/* Notify the main GIMP application that the extension is ready to run
*/
void gimp_extension_ack (void);
/* Run a procedure in the procedure database. The parameters are /* Run a procedure in the procedure database. The parameters are
* specified via the variable length argument list. The return * specified via the variable length argument list. The return
* values are returned in the 'GimpParam*' array. * values are returned in the 'GimpParam*' array.

View File

@ -114,3 +114,10 @@ _gimp_procedure_unregister (GimpProcedure *procedure)
if (! gp_proc_uninstall_write (_gimp_writechannel, &proc_uninstall, NULL)) if (! gp_proc_uninstall_write (_gimp_writechannel, &proc_uninstall, NULL))
gimp_quit (); gimp_quit ();
} }
void
_gimp_procedure_extension_ready (GimpProcedure *procedure)
{
if (! gp_extension_ack_write (_gimp_writechannel, NULL))
gimp_quit ();
}

View File

@ -25,8 +25,9 @@
G_BEGIN_DECLS G_BEGIN_DECLS
void _gimp_procedure_register (GimpProcedure *procedure); void _gimp_procedure_register (GimpProcedure *procedure);
void _gimp_procedure_unregister (GimpProcedure *procedure); void _gimp_procedure_unregister (GimpProcedure *procedure);
void _gimp_procedure_extension_ready (GimpProcedure *procedure);
G_END_DECLS G_END_DECLS

View File

@ -29,6 +29,7 @@
#include "libgimpbase/gimpbase.h" #include "libgimpbase/gimpbase.h"
#include "gimp.h" #include "gimp.h"
#include "gimpprocedure-private.h"
#include "libgimp-intl.h" #include "libgimp-intl.h"
@ -173,15 +174,17 @@ gimp_procedure_finalize (GObject *object)
* overwrite an already existing procedure (overwrite procedures only * overwrite an already existing procedure (overwrite procedures only
* if you know what you're doing). * if you know what you're doing).
* *
* @proc_type should be %GIMP_PLUGIN for "normal" plug-ins. Using * @proc_type should be %GIMP_PLUGIN for "normal" plug-ins.
* %GIMP_EXTENSION means that the plug-in will add temporary *
* Using %GIMP_EXTENSION means that the plug-in will add temporary
* procedures. Therefore, the GIMP core will wait until the * procedures. Therefore, the GIMP core will wait until the
* %GIMP_EXTENSION procedure has called gimp_extension_ack(), which * %GIMP_EXTENSION procedure has called gimp_extension_ack(), which
* means that the procedure has done its initialization, installed its * means that the procedure has done its initialization, installed its
* temporary procedures and is ready to run. %GIMP_TEMPORARY must be * temporary procedures and is ready to run.
* used for temporary procedures that are created during a plug-ins *
* lifetime. They must be added to the #GimpPlugIn using * %GIMP_TEMPORARY must be used for temporary procedures that are
* gimp_plug_in_add_temp_procedure(). * created during a plug-ins lifetime. They must be added to the
* #GimpPlugIn using gimp_plug_in_add_temp_procedure().
* *
* Returns: a new #GimpProcedure. * Returns: a new #GimpProcedure.
**/ **/
@ -646,6 +649,32 @@ gimp_procedure_run (GimpProcedure *procedure,
return return_vals; return return_vals;
} }
/**
* gimp_procedure_extension_ready:
*
* Notify the main GIMP application that the extension has been
* properly initialized and is ready to run.
*
* This function <emphasis>must</emphasis> be called from every
* procedure's #GimpRunFunc that was created as #GIMP_EXTENSION.
*
* Subsequently, extensions can process temporary procedure run
* requests using either gimp_extension_enable() or
* gimp_extension_process().
*
* See also: gimp_procedure_new().
*
* Since: 3.0
**/
void
gimp_procedure_extension_ready (GimpProcedure *procedure)
{
g_return_if_fail (GIMP_IS_PROCEDURE (procedure));
g_return_if_fail (procedure->priv->proc_type == GIMP_EXTENSION);
_gimp_procedure_extension_ready (procedure);
}
/* private functions */ /* private functions */

View File

@ -123,6 +123,8 @@ GimpValueArray * gimp_procedure_new_return_values (GimpProcedure *procedure
GimpValueArray * gimp_procedure_run (GimpProcedure *procedure, GimpValueArray * gimp_procedure_run (GimpProcedure *procedure,
GimpValueArray *args); GimpValueArray *args);
void gimp_procedure_extension_ready (GimpProcedure *procedure);
G_END_DECLS G_END_DECLS