Commit ecb0b584 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

Changed the semantics of GIMP_EXTENSION and (to some extent) of

2003-06-19  Michael Natterer  <mitch@gimp.org>

	Changed the semantics of GIMP_EXTENSION and (to some extent)
	of GIMP_PLUGIN:

	The old meaning of EXTENSION was "I live in the toolbox" and
	PLUGIN meant "I take RUN-MODE,IMAGE,DRAWABLE args (but only if I
	am invoked interactively)". This is completely useless, since
	living in the toolbox means having "<Toolbox>" in the menu_path
	and taking RUN-MODE,IMAGE,DRAWABLE means just that, regardless of
	what type of procedure we are.

	The new meaning of GIMP_PLUGIN is just "I am an ordinary procedure,
	I am invoked, do my job and finish", while GIMP_EXTENSION means
	"I will install temporary procedures and I will keep running to
	keep them available".

	(A GIMP_EXTENSION *must* call gimp_extension_ack() now to tell the
	core that it's ready to run, or the core will block waiting for
	the message !!!).

	* configure.in: bumped version number to 1.3.16.

	* libgimpbase/gimpprotocol.h: increased protocol version number so
	old extensions will refuse to load.

	* app/gui/plug-in-commands.c (plug_in_run_cmd_callback): don't
	blindly pass RUN-MODE,IMAGE,DRAWABLE to GIMP_PLUGIN procedures but
	look at their parameters and pass them either RUN-MODE, or
	RUN-MODE,IMAGE, or RUN-MODE,IMAGE,DRAWABLE.

	* app/pdb/procedural_db.c: cleaned up, better error reporting,
	replaced an impossible error message by g_return_if_fail()

	* app/plug-in/plug-in-message.c (plug_in_handle_proc_install):
	better error messages.

	* app/plug-in/plug-in-params.c: allocate parameter arrays using
	g_new0() so we don't have to worry about uninitialized stuff
	later.

	* app/plug-in/plug-in-run.c (plug_in_run): wait for
	gimp_extension_ack() installation confirmation for ALL extensions,
	not just for automatically started ones.

	* app/plug-in/plug-ins.c: cleanup.

	* libgimp/gimp.[ch]: cleaned up and API-documented massively. Made
	all magic values given in the GPConfig message static and added
	accessor functions for them. Added gimp_tile_width()/height().
	Added new function gimp_extension_enable() which turns on
	asynchronous processing of temp_proc run requests without having
	to enter an endless gimp_extension_process() loop. Moved all
	private functions to the end of the file. Added tons of
	g_return_if_fail() all over the place.  Call gimp_run_procedure2()
	from gimp_run_procedure() instead of duplicating the
	code. Indentation, spacing, stuff...

	* libgimp/gimptile.[ch]: removed gimp_tile_width()/height().

	* libgimp/gimpdrawable.c
	* libgimp/gimppixelrgn.c
	* libgimp/gimptile.c: use the gimp_tile_width()/height() accessor
	functions.

	* libgimp/gimp.def: added gimp_extension_enable.

	* libgimp/gimpmenu.c: removed evil code which connected to
	_readchannel manually and use gimp_extension_enable() for watching
	temp_procs.

	* plug-ins/helpbrowser/helpbrowser.c: removed the same evil code
	here and call gimp_extension_enable(). Call gimp_extension_ack()
	to let the core know that the temp_proc is installed.

	* plug-ins/script-fu/script-fu.c: made all procedures except the
	permanently running "extension_script_fu" ordinary GIMP_PLUGIN
	procedures.

	* plug-ins/common/curve_bend.c
	* plug-ins/common/plugindetails.c
	* plug-ins/common/screenshot.c
	* plug-ins/common/uniteditor.c
	* plug-ins/common/winclipboard.c
	* plug-ins/dbbrowser/dbbrowser.c
	* plug-ins/gfli/gfli.c
	* plug-ins/twain/twain.c
	* plug-ins/webbrowser/webbrowser.c
	* plug-ins/winsnap/winsnap.c: made them all ordinary GIMP_PLUGIN
	procedures and renamed them from "extension_*" to "plug_in_*".
	Random cleanups.

	* app/widgets/gimphelp.c
	* plug-ins/maze/maze_face.c: call "plug_in_web_browser" now.
parent 267ea34a
2003-06-19 Michael Natterer <mitch@gimp.org>
Changed the semantics of GIMP_EXTENSION and (to some extent)
of GIMP_PLUGIN:
The old meaning of EXTENSION was "I live in the toolbox" and
PLUGIN meant "I take RUN-MODE,IMAGE,DRAWABLE args (but only if I
am invoked interactively)". This is completely useless, since
living in the toolbox means having "<Toolbox>" in the menu_path
and taking RUN-MODE,IMAGE,DRAWABLE means just that, regardless of
what type of procedure we are.
The new meaning of GIMP_PLUGIN is just "I am an ordinary procedure,
I am invoked, do my job and finish", while GIMP_EXTENSION means
"I will install temporary procedures and I will keep running to
keep them available".
(A GIMP_EXTENSION *must* call gimp_extension_ack() now to tell the
core that it's ready to run, or the core will block waiting for
the message !!!).
* configure.in: bumped version number to 1.3.16.
* libgimpbase/gimpprotocol.h: increased protocol version number so
old extensions will refuse to load.
* app/gui/plug-in-commands.c (plug_in_run_cmd_callback): don't
blindly pass RUN-MODE,IMAGE,DRAWABLE to GIMP_PLUGIN procedures but
look at their parameters and pass them either RUN-MODE, or
RUN-MODE,IMAGE, or RUN-MODE,IMAGE,DRAWABLE.
* app/pdb/procedural_db.c: cleaned up, better error reporting,
replaced an impossible error message by g_return_if_fail()
* app/plug-in/plug-in-message.c (plug_in_handle_proc_install):
better error messages.
* app/plug-in/plug-in-params.c: allocate parameter arrays using
g_new0() so we don't have to worry about uninitialized stuff
later.
* app/plug-in/plug-in-run.c (plug_in_run): wait for
gimp_extension_ack() installation confirmation for ALL extensions,
not just for automatically started ones.
* app/plug-in/plug-ins.c: cleanup.
* libgimp/gimp.[ch]: cleaned up and API-documented massively. Made
all magic values given in the GPConfig message static and added
accessor functions for them. Added gimp_tile_width()/height().
Added new function gimp_extension_enable() which turns on
asynchronous processing of temp_proc run requests without having
to enter an endless gimp_extension_process() loop. Moved all
private functions to the end of the file. Added tons of
g_return_if_fail() all over the place. Call gimp_run_procedure2()
from gimp_run_procedure() instead of duplicating the
code. Indentation, spacing, stuff...
* libgimp/gimptile.[ch]: removed gimp_tile_width()/height().
* libgimp/gimpdrawable.c
* libgimp/gimppixelrgn.c
* libgimp/gimptile.c: use the gimp_tile_width()/height() accessor
functions.
* libgimp/gimp.def: added gimp_extension_enable.
* libgimp/gimpmenu.c: removed evil code which connected to
_readchannel manually and use gimp_extension_enable() for watching
temp_procs.
* plug-ins/helpbrowser/helpbrowser.c: removed the same evil code
here and call gimp_extension_enable(). Call gimp_extension_ack()
to let the core know that the temp_proc is installed.
* plug-ins/script-fu/script-fu.c: made all procedures except the
permanently running "extension_script_fu" ordinary GIMP_PLUGIN
procedures.
* plug-ins/common/curve_bend.c
* plug-ins/common/plugindetails.c
* plug-ins/common/screenshot.c
* plug-ins/common/uniteditor.c
* plug-ins/common/winclipboard.c
* plug-ins/dbbrowser/dbbrowser.c
* plug-ins/gfli/gfli.c
* plug-ins/twain/twain.c
* plug-ins/webbrowser/webbrowser.c
* plug-ins/winsnap/winsnap.c: made them all ordinary GIMP_PLUGIN
procedures and renamed them from "extension_*" to "plug_in_*".
Random cleanups.
* app/widgets/gimphelp.c
* plug-ins/maze/maze_face.c: call "plug_in_web_browser" now.
2003-06-19 Sven Neumann <sven@gimp.org>
* libgimp/gimpmenu.c: when idle dispatching calls to plug-ins, use
......@@ -57,20 +57,16 @@ plug_in_run_cmd_callback (GtkWidget *widget,
{
GtkItemFactory *item_factory;
Gimp *gimp;
GimpDisplay *gdisplay;
ProcRecord *proc_rec;
Argument *args;
gint i;
gint gdisp_ID = -1;
gint i;
gint argc = 0; /* calm down a gcc warning. */
item_factory = gtk_item_factory_from_widget (widget);
gimp = GIMP_ITEM_FACTORY (item_factory)->gimp;
/* get the active gdisplay */
gdisplay = gimp_context_get_display (gimp_get_user_context (gimp));
proc_rec = (ProcRecord *) data;
/* construct the procedures arguments */
......@@ -80,54 +76,56 @@ plug_in_run_cmd_callback (GtkWidget *widget,
for (i = 0; i < proc_rec->num_args; i++)
args[i].arg_type = proc_rec->args[i].arg_type;
/* initialize the first argument */
args[0].value.pdb_int = GIMP_RUN_INTERACTIVE;
argc = 1;
switch (proc_rec->proc_type)
{
case GIMP_EXTENSION:
/* initialize the first argument */
args[0].value.pdb_int = GIMP_RUN_INTERACTIVE;
argc = 1;
break;
case GIMP_PLUGIN:
if (gdisplay)
{
gdisp_ID = gimp_display_get_ID (gdisplay);
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = GIMP_RUN_INTERACTIVE;
args[1].value.pdb_int = gimp_image_get_ID (gdisplay->gimage);
args[2].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (gimp_image_active_drawable (gdisplay->gimage)));
argc = 3;
}
else
{
g_warning ("Uh-oh, no active gdisplay for the plug-in!");
g_free (args);
return;
}
break;
case GIMP_TEMPORARY:
args[0].value.pdb_int = GIMP_RUN_INTERACTIVE;
argc = 1;
if (proc_rec->num_args >= 3 &&
proc_rec->args[1].arg_type == GIMP_PDB_IMAGE &&
proc_rec->args[2].arg_type == GIMP_PDB_DRAWABLE)
{
if (gdisplay)
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = gimp_image_get_ID (gdisplay->gimage);
args[2].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (gimp_image_active_drawable (gdisplay->gimage)));
argc = 3;
}
else
{
g_warning ("Uh-oh, no active gdisplay for the temporary procedure!");
g_free (args);
return;
}
if (proc_rec->num_args >= 2 &&
proc_rec->args[1].arg_type == GIMP_PDB_IMAGE)
{
GimpDisplay *gdisplay;
gdisplay = gimp_context_get_display (gimp_get_user_context (gimp));
if (gdisplay)
{
args[1].value.pdb_int = gimp_image_get_ID (gdisplay->gimage);
argc++;
if (proc_rec->num_args >= 2 &&
proc_rec->args[2].arg_type == GIMP_PDB_DRAWABLE)
{
GimpDrawable *drawable;
drawable = gimp_image_active_drawable (gdisplay->gimage);
if (drawable)
{
args[2].value.pdb_int =
gimp_item_get_ID (GIMP_ITEM (drawable));
argc++;
}
else
{
g_warning ("Uh-oh, no active drawable for the plug-in!");
g_free (args);
return;
}
}
}
else
{
g_warning ("Uh-oh, no active display for the plug-in!");
g_free (args);
return;
}
}
break;
......@@ -140,8 +138,14 @@ plug_in_run_cmd_callback (GtkWidget *widget,
/* run the plug-in procedure */
plug_in_run (gimp, proc_rec, args, argc, FALSE, TRUE, gdisp_ID);
if (proc_rec->proc_type == GIMP_PLUGIN)
gimp->last_plug_in = proc_rec;
/* remember only "standard" plug-ins */
if (proc_rec->proc_type == GIMP_PLUGIN &&
proc_rec->num_args >= 2 &&
proc_rec->args[1].arg_type == GIMP_PDB_IMAGE &&
proc_rec->args[2].arg_type == GIMP_PDB_DRAWABLE)
{
gimp->last_plug_in = proc_rec;
}
g_free (args);
}
......
......@@ -57,20 +57,16 @@ plug_in_run_cmd_callback (GtkWidget *widget,
{
GtkItemFactory *item_factory;
Gimp *gimp;
GimpDisplay *gdisplay;
ProcRecord *proc_rec;
Argument *args;
gint i;
gint gdisp_ID = -1;
gint i;
gint argc = 0; /* calm down a gcc warning. */
item_factory = gtk_item_factory_from_widget (widget);
gimp = GIMP_ITEM_FACTORY (item_factory)->gimp;
/* get the active gdisplay */
gdisplay = gimp_context_get_display (gimp_get_user_context (gimp));
proc_rec = (ProcRecord *) data;
/* construct the procedures arguments */
......@@ -80,54 +76,56 @@ plug_in_run_cmd_callback (GtkWidget *widget,
for (i = 0; i < proc_rec->num_args; i++)
args[i].arg_type = proc_rec->args[i].arg_type;
/* initialize the first argument */
args[0].value.pdb_int = GIMP_RUN_INTERACTIVE;
argc = 1;
switch (proc_rec->proc_type)
{
case GIMP_EXTENSION:
/* initialize the first argument */
args[0].value.pdb_int = GIMP_RUN_INTERACTIVE;
argc = 1;
break;
case GIMP_PLUGIN:
if (gdisplay)
{
gdisp_ID = gimp_display_get_ID (gdisplay);
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = GIMP_RUN_INTERACTIVE;
args[1].value.pdb_int = gimp_image_get_ID (gdisplay->gimage);
args[2].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (gimp_image_active_drawable (gdisplay->gimage)));
argc = 3;
}
else
{
g_warning ("Uh-oh, no active gdisplay for the plug-in!");
g_free (args);
return;
}
break;
case GIMP_TEMPORARY:
args[0].value.pdb_int = GIMP_RUN_INTERACTIVE;
argc = 1;
if (proc_rec->num_args >= 3 &&
proc_rec->args[1].arg_type == GIMP_PDB_IMAGE &&
proc_rec->args[2].arg_type == GIMP_PDB_DRAWABLE)
{
if (gdisplay)
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = gimp_image_get_ID (gdisplay->gimage);
args[2].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (gimp_image_active_drawable (gdisplay->gimage)));
argc = 3;
}
else
{
g_warning ("Uh-oh, no active gdisplay for the temporary procedure!");
g_free (args);
return;
}
if (proc_rec->num_args >= 2 &&
proc_rec->args[1].arg_type == GIMP_PDB_IMAGE)
{
GimpDisplay *gdisplay;
gdisplay = gimp_context_get_display (gimp_get_user_context (gimp));
if (gdisplay)
{
args[1].value.pdb_int = gimp_image_get_ID (gdisplay->gimage);
argc++;
if (proc_rec->num_args >= 2 &&
proc_rec->args[2].arg_type == GIMP_PDB_DRAWABLE)
{
GimpDrawable *drawable;
drawable = gimp_image_active_drawable (gdisplay->gimage);
if (drawable)
{
args[2].value.pdb_int =
gimp_item_get_ID (GIMP_ITEM (drawable));
argc++;
}
else
{
g_warning ("Uh-oh, no active drawable for the plug-in!");
g_free (args);
return;
}
}
}
else
{
g_warning ("Uh-oh, no active display for the plug-in!");
g_free (args);
return;
}
}
break;
......@@ -140,8 +138,14 @@ plug_in_run_cmd_callback (GtkWidget *widget,
/* run the plug-in procedure */
plug_in_run (gimp, proc_rec, args, argc, FALSE, TRUE, gdisp_ID);
if (proc_rec->proc_type == GIMP_PLUGIN)
gimp->last_plug_in = proc_rec;
/* remember only "standard" plug-ins */
if (proc_rec->proc_type == GIMP_PLUGIN &&
proc_rec->num_args >= 2 &&
proc_rec->args[1].arg_type == GIMP_PDB_IMAGE &&
proc_rec->args[2].arg_type == GIMP_PDB_DRAWABLE)
{
gimp->last_plug_in = proc_rec;
}
g_free (args);
}
......
......@@ -164,21 +164,17 @@ procedural_db_execute (Gimp *gimp,
const gchar *name,
Argument *args)
{
ProcRecord *procedure;
Argument *return_args;
GList *list;
gint i;
Argument *return_args = NULL;
GList *list;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (name != NULL, NULL);
return_args = NULL;
list = g_hash_table_lookup (gimp->procedural_ht, (gpointer) name);
if (list == NULL)
{
g_message (_("PDB calling error %s not found"), name);
g_message (_("PDB calling error:\nprocedure '%s' not found"), name);
return_args = g_new (Argument, 1);
return_args->arg_type = GIMP_PDB_STATUS;
......@@ -186,12 +182,21 @@ procedural_db_execute (Gimp *gimp,
return return_args;
}
for (; list; list = g_list_next (list))
{
if ((procedure = (ProcRecord *) list->data) == NULL)
ProcRecord *procedure;
gint i;
procedure = (ProcRecord *) list->data;
#ifdef __GNUC__
#warning: FIXME: this is impossible, right? --mitch
#endif
#if 0
if (procedure == NULL)
{
g_message (_("PDB calling error %s not found"), name);
g_warning ("PDB calling error %s not found", name);
return_args = g_new (Argument, 1);
return_args->arg_type = GIMP_PDB_STATUS;
......@@ -199,18 +204,24 @@ procedural_db_execute (Gimp *gimp,
return return_args;
}
#endif
g_return_val_if_fail (procedure != NULL, NULL);
/* check the arguments */
for (i = 0; i < procedure->num_args; i++)
{
if (args[i].arg_type != procedure->args[i].arg_type)
{
g_message (_("PDB calling error for procedure '%s':\n"
"Argument #%d type mismatch (expected %s, got %s)"),
procedure->name, i + 1,
pdb_type_name (procedure->args[i].arg_type),
pdb_type_name (args[i].arg_type));
return_args = g_new (Argument, 1);
return_args->arg_type = GIMP_PDB_STATUS;
return_args->value.pdb_int = GIMP_PDB_CALLING_ERROR;
g_message (_("PDB calling error %s"), procedure->name);
return return_args;
}
}
......@@ -219,16 +230,15 @@ procedural_db_execute (Gimp *gimp,
switch (procedure->proc_type)
{
case GIMP_INTERNAL:
return_args =
return_args =
(* procedure->exec_method.internal.marshal_func) (gimp, args);
break;
case GIMP_PLUGIN:
case GIMP_EXTENSION:
case GIMP_TEMPORARY:
return_args = plug_in_run (gimp,
procedure,
args, procedure->num_args,
return_args = plug_in_run (gimp, procedure,
args, procedure->num_args,
TRUE, FALSE, -1);
break;
......@@ -301,9 +311,9 @@ procedural_db_run_proc (Gimp *gimp,
if (proc->args[i].arg_type !=
(params[i].arg_type = va_arg (args, GimpPDBArgType)))
{
g_message (_("Incorrect arguments passed to procedural_db_run_proc:\n"
"Argument %d to '%s' should be a %s, but got passed a %s"),
i+1, proc->name,
g_message (_("PDB calling error for procedure '%s':\n"
"Argument #%d type mismatch (expected %s, got %s)"),
proc->name, i + 1,
pdb_type_name (proc->args[i].arg_type),
pdb_type_name (params[i].arg_type));
g_free (params);
......@@ -384,22 +394,18 @@ procedural_db_return_args (ProcRecord *procedure,
g_return_val_if_fail (procedure != NULL, NULL);
return_args = g_new (Argument, procedure->num_values + 1);
return_args = g_new0 (Argument, procedure->num_values + 1);
return_args[0].arg_type = GIMP_PDB_STATUS;
if (success)
{
return_args[0].arg_type = GIMP_PDB_STATUS;
return_args[0].value.pdb_int = GIMP_PDB_SUCCESS;
}
return_args[0].value.pdb_int = GIMP_PDB_SUCCESS;
else
{
return_args[0].arg_type = GIMP_PDB_STATUS;
return_args[0].value.pdb_int = GIMP_PDB_EXECUTION_ERROR;
}
return_args[0].value.pdb_int = GIMP_PDB_EXECUTION_ERROR;
/* Set the arg types for the return values */
for (i = 0; i < procedure->num_values; i++)
return_args[i+1].arg_type = procedure->values[i].arg_type;
return_args[i + 1].arg_type = procedure->values[i].arg_type;
return return_args;
}
......
......@@ -164,21 +164,17 @@ procedural_db_execute (Gimp *gimp,
const gchar *name,
Argument *args)
{
ProcRecord *procedure;
Argument *return_args;
GList *list;
gint i;
Argument *return_args = NULL;
GList *list;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (name != NULL, NULL);
return_args = NULL;
list = g_hash_table_lookup (gimp->procedural_ht, (gpointer) name);
if (list == NULL)
{
g_message (_("PDB calling error %s not found"), name);
g_message (_("PDB calling error:\nprocedure '%s' not found"), name);
return_args = g_new (Argument, 1);
return_args->arg_type = GIMP_PDB_STATUS;
......@@ -186,12 +182,21 @@ procedural_db_execute (Gimp *gimp,
return return_args;
}
for (; list; list = g_list_next (list))
{
if ((procedure = (ProcRecord *) list->data) == NULL)
ProcRecord *procedure;
gint i;
procedure = (ProcRecord *) list->data;
#ifdef __GNUC__
#warning: FIXME: this is impossible, right? --mitch
#endif
#if 0
if (procedure == NULL)
{
g_message (_("PDB calling error %s not found"), name);
g_warning ("PDB calling error %s not found", name);
return_args = g_new (Argument, 1);
return_args->arg_type = GIMP_PDB_STATUS;
......@@ -199,18 +204,24 @@ procedural_db_execute (Gimp *gimp,
return return_args;
}
#endif
g_return_val_if_fail (procedure != NULL, NULL);
/* check the arguments */
for (i = 0; i < procedure->num_args; i++)
{
if (args[i].arg_type != procedure->args[i].arg_type)
{
g_message (_("PDB calling error for procedure '%s':\n"
"Argument #%d type mismatch (expected %s, got %s)"),
procedure->name, i + 1,
pdb_type_name (procedure->args[i].arg_type),
pdb_type_name (args[i].arg_type));
return_args = g_new (Argument, 1);
return_args->arg_type = GIMP_PDB_STATUS;
return_args->value.pdb_int = GIMP_PDB_CALLING_ERROR;
g_message (_("PDB calling error %s"), procedure->name);
return return_args;
}
}
......@@ -219,16 +230,15 @@ procedural_db_execute (Gimp *gimp,
switch (procedure->proc_type)
{
case GIMP_INTERNAL:
return_args =
return_args =
(* procedure->exec_method.internal.marshal_func) (gimp, args);
break;
case GIMP_PLUGIN:
case GIMP_EXTENSION:
case GIMP_TEMPORARY:
return_args = plug_in_run (gimp,
procedure,
args, procedure->num_args,
return_args = plug_in_run (gimp, procedure,
args, procedure->num_args,
TRUE, FALSE, -1);
break;
......@@ -301,9 +311,9 @@ procedural_db_run_proc (Gimp *gimp,
if (proc->args[i].arg_type !=
(params[i].arg_type = va_arg (args, GimpPDBArgType)))
{
g_message (_("Incorrect arguments passed to procedural_db_run_proc:\n"
"Argument %d to '%s' should be a %s, but got passed a %s"),
i+1, proc->name,
g_message (_("PDB calling error for procedure '%s':\n"
"Argument #%d type mismatch (expected %s, got %s)"),
proc->name, i + 1,
pdb_type_name (proc->args[i].arg_type),
pdb_type_name (params[i].arg_type));
g_free (params);
......@@ -384,22 +394,18 @@ procedural_db_return_args (ProcRecord *procedure,
g_return_val_if_fail (procedure != NULL, NULL);
return_args = g_new (Argument, procedure->num_values + 1);
return_args = g_new0 (Argument, procedure->num_values + 1);
return_args[0].arg_type = GIMP_PDB_STATUS;
if (success)
{
return_args[0].arg_type = GIMP_PDB_STATUS;
return_args[0].value.pdb_int = GIMP_PDB_SUCCESS;
}
return_args[0].value.pdb_int = GIMP_PDB_SUCCESS;
else
{
return_args[0].arg_type = GIMP_PDB_STATUS;
return_args[0].value.pdb_int = GIMP_PDB_EXECUTION_ERROR;
}
return_args[0].value.pdb_int = GIMP_PDB_EXECUTION_ERROR;
/* Set the arg types for the return values */
for (i = 0; i < procedure->num_values; i++)
return_args[i+1].arg_type = procedure->values[i].arg_type;
return_args[i + 1].arg_type = procedure->values[i].arg_type;
return return_args;
}
......
......@@ -164,21 +164,17 @@ procedural_db_execute (Gimp *gimp,
const gchar *name,
Argument *args)
{
ProcRecord *procedure;
Argument *return_args;
GList *list;
gint i;
Argument *return_args = NULL;
GList *list;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (name != NULL, NULL);
return_args = NULL;
list = g_hash_table_lookup (gimp->procedural_ht, (gpointer) name);
if (list == NULL)
{
g_message (_("PDB calling error %s not found"), name);
g_message (_("PDB calling error:\nprocedure '%s' not found"), name);
return_args = g_new (Argument, 1);
return_args->arg_type = GIMP_PDB_STATUS;
......@@ -186,12 +182,21 @@ procedural_db_execute (Gimp *gimp,
return return_args;
}
for (; list; list = g_list_next (list))
{
if ((procedure = (ProcRecord *) list->data) == NULL)
ProcRecord *procedure;
gint i;
procedure = (ProcRecord *) list->data;
#ifdef __GNUC__
#warning: FIXME: this is impossible, right? --mitch
#endif
#if 0
if (procedure == NULL)
{
g_message (_("PDB calling error %s not found"), name);
g_warning ("PDB calling error %s not found", name);
return_args = g_new (Argument, 1);
return_args->arg_type = GIMP_PDB_STATUS;
......@@ -199,18 +204,24 @@ procedural_db_execute (Gimp *gimp,
return return_args;
}
#endif
g_return_val_if_fail (procedure != NULL, NULL);
/* check the arguments */
for (i = 0; i < procedure->num_args; i++)
{
if (args[i].arg_type != procedure->args[i].arg_type)
{
g_message (_("PDB calling error for procedure '%s':\n"
"Argument #%d type mismatch (expected %s, got %s)"),
procedure->name, i + 1,
pdb_type_name (procedure->args[i].arg_type),
pdb_type_name (args[i].arg_type));
return_args = g_new (Argument, 1);
return_args->arg_type = GIMP_PDB_STATUS;
return_args->value.pdb_int = GIMP_PDB_CALLING_ERROR;
g_message (_("PDB calling error %s"), procedure->name);
return return_args;
}
}
......@@ -219,16 +230,15 @@ procedural_db_execute (Gimp *gimp,
switch (procedure->proc_type)
{
case GIMP_INTERNAL:
return_args =
return_args =
(* procedure->exec_method.internal.marshal_func) (gimp, args);
break;
case GIMP_PLUGIN: