added gimp_vectors_get_n_strokes (); Attempt to fill an array with IDs,

2005-05-17  Simon Budig  <simon@gimp.org>

	* app/vectors/gimpvectors.[ch]: added gimp_vectors_get_n_strokes ();
	* tools/pdbgen/pdb/vectors.pdb: Attempt to fill an array with IDs,
	does not yet work.

	* app/pdb/vectors_cmds.c
	* libgimp/gimpvectors_pdb.c: regenerated.
This commit is contained in:
Simon Budig 2005-05-16 23:26:54 +00:00 committed by Simon Budig
parent eacc064628
commit 13618e9143
6 changed files with 82 additions and 28 deletions

View File

@ -1,3 +1,12 @@
2005-05-17 Simon Budig <simon@gimp.org>
* app/vectors/gimpvectors.[ch]: added gimp_vectors_get_n_strokes ();
* tools/pdbgen/pdb/vectors.pdb: Attempt to fill an array with IDs,
does not yet work.
* app/pdb/vectors_cmds.c
* libgimp/gimpvectors_pdb.c: regenerated.
2005-05-16 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* plug-ins/jpeg/jpeg-load.c: Don't detach from drawable if

View File

@ -53,7 +53,9 @@ vectors_get_strokes_invoker (Gimp *gimp,
Argument *return_args;
GimpVectors *vectors;
gint32 num_strokes = 0;
gint32 *stroke_list = NULL;
gint32 *stroke_ids = NULL;
gint i;
GimpStroke *cur_stroke = NULL;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
@ -61,7 +63,21 @@ vectors_get_strokes_invoker (Gimp *gimp,
if (success)
{
/* nothing yet */
num_strokes = gimp_vectors_get_n_strokes (vectors);
if (num_strokes)
{
stroke_ids = g_new (gint32, num_strokes);
for (cur_stroke = gimp_vectors_stroke_get_next (vectors, NULL);
cur_stroke;
cur_stroke = gimp_vectors_stroke_get_next (vectors, cur_stroke))
{
stroke_ids[i] = gimp_stroke_get_ID (cur_stroke);
g_printerr ("%d ", gimp_stroke_get_ID (cur_stroke));
}
g_printerr ("\n");
}
}
return_args = procedural_db_return_args (&vectors_get_strokes_proc, success);
@ -69,7 +85,7 @@ vectors_get_strokes_invoker (Gimp *gimp,
if (success)
{
return_args[1].value.pdb_int = num_strokes;
return_args[2].value.pdb_pointer = stroke_list;
return_args[2].value.pdb_pointer = stroke_ids;
}
return return_args;
@ -93,8 +109,8 @@ static ProcArg vectors_get_strokes_outargs[] =
},
{
GIMP_PDB_INT32ARRAY,
"stroke_list",
"List of the paths belonging to this image."
"stroke_ids",
"List of the strokes belonging to the path."
}
};

View File

@ -731,19 +731,12 @@ gimp_vectors_real_stroke_remove (GimpVectors *vectors,
}
}
GimpStroke *
gimp_vectors_stroke_get_by_ID (const GimpVectors *vectors,
gint id)
gint
gimp_vectors_get_n_strokes (const GimpVectors *vectors)
{
GList *stroke;
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), 0);
for (stroke = vectors->strokes; stroke; stroke = g_list_next (stroke))
{
if (gimp_stroke_get_ID (stroke->data) == id)
return stroke->data;
}
return NULL;
return g_list_length (vectors->strokes);
}
@ -786,6 +779,23 @@ gimp_vectors_real_stroke_get (const GimpVectors *vectors,
return minstroke;
}
GimpStroke *
gimp_vectors_stroke_get_by_ID (const GimpVectors *vectors,
gint id)
{
GList *stroke;
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), NULL);
for (stroke = vectors->strokes; stroke; stroke = g_list_next (stroke))
{
if (gimp_stroke_get_ID (stroke->data) == id)
return stroke->data;
}
return NULL;
}
GimpStroke *
gimp_vectors_stroke_get_next (const GimpVectors *vectors,

View File

@ -139,10 +139,11 @@ void gimp_vectors_stroke_add (GimpVectors *vectors,
GimpStroke *stroke);
void gimp_vectors_stroke_remove (GimpVectors *vectors,
GimpStroke *stroke);
GimpStroke * gimp_vectors_stroke_get_by_ID (const GimpVectors *vectors,
gint id);
gint gimp_vectors_get_n_strokes (const GimpVectors *vectors);
GimpStroke * gimp_vectors_stroke_get (const GimpVectors *vectors,
const GimpCoords *coord);
GimpStroke * gimp_vectors_stroke_get_by_ID (const GimpVectors *vectors,
gint id);
/* prev == NULL: "first" stroke */
GimpStroke * gimp_vectors_stroke_get_next (const GimpVectors *vectors,

View File

@ -37,7 +37,7 @@
* Returns an Array with the stroke-IDs associated with the passed
* path.
*
* Returns: List of the paths belonging to this image.
* Returns: List of the strokes belonging to the path.
*
* Since: GIMP 2.4
*/
@ -47,7 +47,7 @@ gimp_vectors_get_strokes (gint32 vectors_ID,
{
GimpParam *return_vals;
gint nreturn_vals;
gint *stroke_list = NULL;
gint *stroke_ids = NULL;
return_vals = gimp_run_procedure ("gimp_vectors_get_strokes",
&nreturn_vals,
@ -59,12 +59,12 @@ gimp_vectors_get_strokes (gint32 vectors_ID,
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
*num_strokes = return_vals[1].data.d_int32;
stroke_list = g_new (gint32, *num_strokes);
memcpy (stroke_list, return_vals[2].data.d_int32array,
stroke_ids = g_new (gint32, *num_strokes);
memcpy (stroke_ids, return_vals[2].data.d_int32array,
*num_strokes * sizeof (gint32));
}
gimp_destroy_params (return_vals, nreturn_vals);
return stroke_list;
return stroke_ids;
}

View File

@ -42,18 +42,36 @@ HELP
@inargs = ( &vectors_arg );
@outargs = (
{ name => 'stroke_list', type => 'int32array',
desc => 'List of the paths belonging to this image.',
{ name => 'stroke_ids', type => 'int32array',
desc => 'List of the strokes belonging to the path.',
array => { name => 'num_strokes',
desc => 'The number of strokes returned.', init => 1 },
desc => 'The number of strokes returned.',
init => 1 },
init => 1 }
);
$invoke{code} = <<"CODE";
%invoke = (
vars => ['gint i', 'GimpStroke *cur_stroke = NULL'],
code => <<"CODE"
{
/* nothing yet */
num_strokes = gimp_vectors_get_n_strokes (vectors);
if (num_strokes)
{
stroke_ids = g_new (gint32, num_strokes);
for (cur_stroke = gimp_vectors_stroke_get_next (vectors, NULL);
cur_stroke;
cur_stroke = gimp_vectors_stroke_get_next (vectors, cur_stroke))
{
stroke_ids[i] = gimp_stroke_get_ID (cur_stroke);
g_printerr ("%d ", gimp_stroke_get_ID (cur_stroke));
}
g_printerr ("\\n");
}
}
CODE
);
}