Commit 5026bd50 authored by BST 1999  Austin Donnelly's avatar BST 1999 Austin Donnelly Committed by Austin Donnelly
Browse files

add the new args to gimp-paintbrush PDB calls.

Tue Apr 20 23:38:26 BST 1999  Austin Donnelly  <austin@gimp.org>

	* app/bezier_select.c: add the new args to gimp-paintbrush PDB
	    calls.

	* app/blend.c
	* app/bucket_fill.c
	* app/invert.c: check return from procedural_db_run_proc() rather
	    than dereferencing NULL.

	* app/paintbrush.c: plumb the non-gui fade_out option into the
	    functions that actually do the work, rather than using
	    an uninitialised value.

	* app/procedural_db.c: better error messages on PDB typecheck fail
	    in procedural_db_run_proc.  Also now valid to
	    procedural_db_destroy_args() on a NULL pointer.
	* app/procedural_db.h: pdb_type_name() function added, plus
	    comment urging people to keep the enum and strings in step.

	* tools/pdbgen/README: added paragraph on how to run pdbgen.pl

	* tools/pdbgen/pdb/tools.pdb: fade_out parameter is valid to be 0
	* app/tools_cmds.c: new version of generated file
parent ff2c915a
Tue Apr 20 23:38:26 BST 1999 Austin Donnelly <austin@gimp.org>
* app/bezier_select.c: add the new args to gimp-paintbrush PDB
calls.
* app/blend.c
* app/bucket_fill.c
* app/invert.c: check return from procedural_db_run_proc() rather
than dereferencing NULL.
* app/paintbrush.c: plumb the non-gui fade_out option into the
functions that actually do the work, rather than using
an uninitialised value.
* app/procedural_db.c: better error messages on PDB typecheck fail
in procedural_db_run_proc. Also now valid to
procedural_db_destroy_args() on a NULL pointer.
* app/procedural_db.h: pdb_type_name() function added, plus
comment urging people to keep the enum and strings in step.
* tools/pdbgen/README: added paragraph on how to run pdbgen.pl
* tools/pdbgen/pdb/tools.pdb: fade_out parameter is valid to be 0
* app/tools_cmds.c: new version of generated file
Tue Apr 20 21:18:10 MEST 1999 Sven Neumann <sven@gimp.org>
* app/blend.c: moved the "Adaptive supersampling" option into
......
......@@ -2348,9 +2348,11 @@ bezier_stroke (BezierSelect *bezier_sel,
PDB_FLOAT, (gdouble) 0,
PDB_INT32, (gint32) rpnts->num_stroke_points * 2,
PDB_FLOATARRAY, rpnts->stroke_points,
PDB_INT32, 0 /* continuous */,
PDB_FLOAT, (gdouble) 0 /*no grad*/,
PDB_END);
if (return_vals[0].value.pdb_int == PDB_SUCCESS)
if (return_vals && return_vals[0].value.pdb_int == PDB_SUCCESS)
{
if (redraw)
{
......
......@@ -647,7 +647,7 @@ blend_button_release (Tool *tool,
PDB_FLOAT, (gdouble) blend_tool->endy,
PDB_END);
if (return_vals[0].value.pdb_int == PDB_SUCCESS)
if (return_vals && return_vals[0].value.pdb_int == PDB_SUCCESS)
gdisplays_flush ();
else
g_message (_("Blend operation failed."));
......
......@@ -343,7 +343,7 @@ bucket_fill_button_release (Tool *tool,
PDB_FLOAT, (gdouble) bucket_tool->target_y,
PDB_END);
if (return_vals[0].value.pdb_int == PDB_SUCCESS)
if (return_vals && return_vals[0].value.pdb_int == PDB_SUCCESS)
gdisplays_flush ();
else
g_message (_("Bucket Fill operation failed."));
......
......@@ -647,7 +647,7 @@ blend_button_release (Tool *tool,
PDB_FLOAT, (gdouble) blend_tool->endy,
PDB_END);
if (return_vals[0].value.pdb_int == PDB_SUCCESS)
if (return_vals && return_vals[0].value.pdb_int == PDB_SUCCESS)
gdisplays_flush ();
else
g_message (_("Blend operation failed."));
......
......@@ -52,7 +52,7 @@ image_invert (GImage *gimage)
PDB_DRAWABLE, drawable_ID (drawable),
PDB_END);
if (return_vals[0].value.pdb_int != PDB_SUCCESS)
if (!return_vals || return_vals[0].value.pdb_int != PDB_SUCCESS)
g_message (_("Invert operation failed."));
procedural_db_destroy_args (return_vals, nreturn_vals);
......
......@@ -52,7 +52,7 @@ image_invert (GImage *gimage)
PDB_DRAWABLE, drawable_ID (drawable),
PDB_END);
if (return_vals[0].value.pdb_int != PDB_SUCCESS)
if (!return_vals || return_vals[0].value.pdb_int != PDB_SUCCESS)
g_message (_("Invert operation failed."));
procedural_db_destroy_args (return_vals, nreturn_vals);
......
......@@ -52,7 +52,7 @@ image_invert (GImage *gimage)
PDB_DRAWABLE, drawable_ID (drawable),
PDB_END);
if (return_vals[0].value.pdb_int != PDB_SUCCESS)
if (!return_vals || return_vals[0].value.pdb_int != PDB_SUCCESS)
g_message (_("Invert operation failed."));
procedural_db_destroy_args (return_vals, nreturn_vals);
......
......@@ -467,11 +467,11 @@ paintbrush_non_gui (GimpDrawable *drawable,
if (paint_core_init (&non_gui_paint_core, drawable,
stroke_array[0], stroke_array[1]))
{
non_gui_fade_out = fade_out;
non_gui_gradient_length = gradient_length;
non_gui_gradient_type = LOOP_TRIANGLE;
non_gui_incremental = method;
/* Set the paint core's paint func */
non_gui_paint_core.paint_func = paintbrush_non_gui_paint_func;
......
......@@ -61,7 +61,7 @@ struct _PDBData
/* Local functions */
static Argument * procedural_db_dump (Argument *);
static void procedural_db_print_entry (gpointer, gpointer, gpointer);
static void output_string (char *);
static void output_string (const char *);
static Argument * procedural_db_proc_info (Argument *);
static Argument * procedural_db_proc_arg (Argument *);
static Argument * procedural_db_proc_val (Argument *);
......@@ -80,7 +80,7 @@ static GHashTable *procedural_ht = NULL;
static FILE *procedural_db_out = NULL;
static GList *data_list = NULL;
static char *type_str[] =
static const char * const type_str[] =
{
"PDB_INT32",
"PDB_INT16",
......@@ -704,7 +704,10 @@ procedural_db_run_proc (gchar *name,
{
if (proc->args[i].arg_type != (params[i].arg_type = va_arg (args, PDBArgType)))
{
g_message (_("Incorrect arguments passed to procedural_db_run_proc"));
g_message (_("Incorrect arguments passed to procedural_db_run_proc:\nArgument %d to '%s' should be a %s, but got passed a %s"),
i+1, proc->name,
pdb_type_name (proc->args[i].arg_type),
pdb_type_name (params[i].arg_type));
g_free (params);
return NULL;
}
......@@ -797,6 +800,8 @@ procedural_db_destroy_args (Argument *args,
int prev_val = 0;
char **strs;
if (!args) return;
for (i = 0; i < nargs; i++)
{
switch (args[i].arg_type)
......@@ -933,7 +938,7 @@ procedural_db_print_entry (gpointer key,
}
static void
output_string (char *string)
output_string (const char *string)
{
fprintf (procedural_db_out, "\"");
while (*string)
......@@ -1312,5 +1317,21 @@ GimpImage* pdb_id_to_image(gint id){
return g_hash_table_lookup(image_hash, &id);
}
const char *
pdb_type_name (gint type)
{
char *buf;
if (type >= 0 && type <= PDB_END)
{
return type_str[type];
}
else
{
buf = g_malloc (48);
g_snprintf (buf, 48, "(PDB type %d unknown)", type);
return buf;
/* Yeah, we leak the memory. But then you shouldn't try and
* get the name of a PDB type that doesn't exist, should you. */
}
}
......@@ -49,6 +49,8 @@ typedef enum
PDB_STATUS,
PDB_END
} PDBArgType;
/* NOTE: If you change the PDBArgType enum above, you _must_ change
* the type_str array in procedural_db.c to match. */
/* Error types */
......@@ -201,6 +203,9 @@ gint pdb_image_to_id(GimpImage* gimage);
GimpImage* pdb_id_to_image(gint id);
void pdb_remove_image(GimpImage* image);
/* "type" should really be a PDBArgType, but we can cope with
* out-of-range values. */
const char *pdb_type_name (gint type);
#endif /* __PROCEDURAL_DB_H__ */
......@@ -2348,9 +2348,11 @@ bezier_stroke (BezierSelect *bezier_sel,
PDB_FLOAT, (gdouble) 0,
PDB_INT32, (gint32) rpnts->num_stroke_points * 2,
PDB_FLOATARRAY, rpnts->stroke_points,
PDB_INT32, 0 /* continuous */,
PDB_FLOAT, (gdouble) 0 /*no grad*/,
PDB_END);
if (return_vals[0].value.pdb_int == PDB_SUCCESS)
if (return_vals && return_vals[0].value.pdb_int == PDB_SUCCESS)
{
if (redraw)
{
......
......@@ -647,7 +647,7 @@ blend_button_release (Tool *tool,
PDB_FLOAT, (gdouble) blend_tool->endy,
PDB_END);
if (return_vals[0].value.pdb_int == PDB_SUCCESS)
if (return_vals && return_vals[0].value.pdb_int == PDB_SUCCESS)
gdisplays_flush ();
else
g_message (_("Blend operation failed."));
......
......@@ -343,7 +343,7 @@ bucket_fill_button_release (Tool *tool,
PDB_FLOAT, (gdouble) bucket_tool->target_y,
PDB_END);
if (return_vals[0].value.pdb_int == PDB_SUCCESS)
if (return_vals && return_vals[0].value.pdb_int == PDB_SUCCESS)
gdisplays_flush ();
else
g_message (_("Bucket Fill operation failed."));
......
......@@ -647,7 +647,7 @@ blend_button_release (Tool *tool,
PDB_FLOAT, (gdouble) blend_tool->endy,
PDB_END);
if (return_vals[0].value.pdb_int == PDB_SUCCESS)
if (return_vals && return_vals[0].value.pdb_int == PDB_SUCCESS)
gdisplays_flush ();
else
g_message (_("Blend operation failed."));
......
......@@ -343,7 +343,7 @@ bucket_fill_button_release (Tool *tool,
PDB_FLOAT, (gdouble) bucket_tool->target_y,
PDB_END);
if (return_vals[0].value.pdb_int == PDB_SUCCESS)
if (return_vals && return_vals[0].value.pdb_int == PDB_SUCCESS)
gdisplays_flush ();
else
g_message (_("Bucket Fill operation failed."));
......
......@@ -467,11 +467,11 @@ paintbrush_non_gui (GimpDrawable *drawable,
if (paint_core_init (&non_gui_paint_core, drawable,
stroke_array[0], stroke_array[1]))
{
non_gui_fade_out = fade_out;
non_gui_gradient_length = gradient_length;
non_gui_gradient_type = LOOP_TRIANGLE;
non_gui_incremental = method;
/* Set the paint core's paint func */
non_gui_paint_core.paint_func = paintbrush_non_gui_paint_func;
......
......@@ -1479,7 +1479,7 @@ paintbrush_invoker (Argument *args)
success = FALSE;
fade_out = args[1].value.pdb_float;
if (fade_out <= 0.0)
if (fade_out < 0.0)
success = FALSE;
num_strokes = args[2].value.pdb_int;
......@@ -1515,7 +1515,7 @@ static ProcArg paintbrush_inargs[] =
{
PDB_FLOAT,
"fade_out",
"Fade out parameter: 0 < fade_out"
"Fade out parameter: 0 <= fade_out"
},
{
PDB_INT32,
......
......@@ -13,6 +13,15 @@ as libgimp wrappers for C plugins. It's written so that extending it
to provide support for CORBA and other languages suited to static
autogeneration.
How to invoke pdbgen from the command line:
Change into the ./tools/pdbgen directory
$ ./pdbgen.pl DIRNAME
where DIRNAME is either "lib" or "app", depending on which set of
files you want to generate. The files are written to ./app or ./lib
in the ./tools/pdbgen directory. Up to you to diff the file you
changed and when you're happy copy it into the actual ./app/ or ./lib/
directory where it gets built.
Anatomy of a PDB descriptor:
PDB descriptors are Perl code. You define a subroutine, which corresponds
to the PDB function you want to create. You then fill certain special
......
......@@ -712,7 +712,7 @@ HELP
@inargs = (
&drawable_arg,
{ name => 'fade_out', type => '0 < float',
{ name => 'fade_out', type => '0 <= float',
desc => 'Fade out parameter: %%desc%%' },
&stroke_arg,
{ name => 'method', type => 'enum PaintApplicationMode',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment