applied patch from Lars-Peter Clausen which adds

2008-05-17  Michael Natterer  <mitch@gimp.org>

	* tools/pdbgen/pdb/gradient.pdb: applied patch from Lars-Peter
	Clausen which adds gimp-gradient-get-number-of-segments. Fixes
	bug #533474.

	* app/pdb/gradient-cmds.c
	* app/pdb/internal-procs.c
	* libgimp/gimpgradient_pdb.[ch]: regenerated.

	* libgimp/gimp.def: add the new symbol.


svn path=/trunk/; revision=25683
This commit is contained in:
Michael Natterer 2008-05-17 09:19:58 +00:00 committed by Michael Natterer
parent dd76454a8c
commit 18502898f8
7 changed files with 161 additions and 2 deletions

View File

@ -1,3 +1,15 @@
2008-05-17 Michael Natterer <mitch@gimp.org>
* tools/pdbgen/pdb/gradient.pdb: applied patch from Lars-Peter
Clausen which adds gimp-gradient-get-number-of-segments. Fixes
bug #533474.
* app/pdb/gradient-cmds.c
* app/pdb/internal-procs.c
* libgimp/gimpgradient_pdb.[ch]: regenerated.
* libgimp/gimp.def: add the new symbol.
2008-05-17 Michael Natterer <mitch@gimp.org>
* plug-ins/twain/Makefile.am: add -framework options to

View File

@ -263,6 +263,45 @@ gradient_delete_invoker (GimpProcedure *procedure,
return gimp_procedure_get_return_values (procedure, success);
}
static GValueArray *
gradient_get_number_of_segments_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
GValueArray *return_vals;
const gchar *name;
gint32 num_segments = 0;
name = g_value_get_string (&args->values[0]);
if (success)
{
GimpGradient *gradient;
GimpGradientSegment *seg;
gradient = gimp_pdb_get_gradient (gimp, name, FALSE, error);
if (gradient)
{
for (seg = gradient->segments; seg; seg = seg->next)
num_segments++;
}
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
g_value_set_int (&return_vals->values[1], num_segments);
return return_vals;
}
static GValueArray *
gradient_get_uniform_samples_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -1501,6 +1540,36 @@ register_gradient_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-gradient-get-number-of-segments
*/
procedure = gimp_procedure_new (gradient_get_number_of_segments_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-gradient-get-number-of-segments");
gimp_procedure_set_static_strings (procedure,
"gimp-gradient-get-number-of-segments",
"Returns the number of segments of the specified gradient",
"This procedure returns the number of segments of the specified gradient.",
"Lars-Peter Clausen <lars@metafoo.de>",
"Lars-Peter Clausen",
"2008",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("name",
"name",
"The gradient name",
FALSE, FALSE, TRUE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_int32 ("num-segments",
"num segments",
"Number of segments",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-gradient-get-uniform-samples
*/

View File

@ -29,7 +29,7 @@
#include "internal-procs.h"
/* 585 procedures registered total */
/* 586 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)

View File

@ -243,6 +243,7 @@ EXPORTS
gimp_gradient_delete
gimp_gradient_duplicate
gimp_gradient_get_custom_samples
gimp_gradient_get_number_of_segments
gimp_gradient_get_uniform_samples
gimp_gradient_is_editable
gimp_gradient_new

View File

@ -189,6 +189,39 @@ gimp_gradient_delete (const gchar *name)
return success;
}
/**
* gimp_gradient_get_number_of_segments:
* @name: The gradient name.
*
* Returns the number of segments of the specified gradient
*
* This procedure returns the number of segments of the specified
* gradient.
*
* Returns: Number of segments.
*
* Since: GIMP 2.6
*/
gint
gimp_gradient_get_number_of_segments (const gchar *name)
{
GimpParam *return_vals;
gint nreturn_vals;
gint num_segments = 0;
return_vals = gimp_run_procedure ("gimp-gradient-get-number-of-segments",
&nreturn_vals,
GIMP_PDB_STRING, name,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
num_segments = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return num_segments;
}
/**
* gimp_gradient_get_uniform_samples:
* @name: The gradient name.

View File

@ -35,6 +35,7 @@ gboolean gimp_gradient_is_editable (const gchar
gchar* gimp_gradient_rename (const gchar *name,
const gchar *new_name);
gboolean gimp_gradient_delete (const gchar *name);
gint gimp_gradient_get_number_of_segments (const gchar *name);
gboolean gimp_gradient_get_uniform_samples (const gchar *name,
gint num_samples,
gboolean reverse,

View File

@ -176,6 +176,48 @@ CODE
);
}
sub gradient_get_number_of_segments {
$blurb = 'Returns the number of segments of the specified gradient';
$help = <<'HELP';
This procedure returns the number of segments of the specified gradient.
HELP
$author = 'Lars-Peter Clausen <lars@metafoo.de>';
$copyright = 'Lars-Peter Clausen';
$date = '2008';
$since = '2.6';
@inargs = (
{ name => 'name', type => 'string', non_empty => 1,
desc => 'The gradient name' }
);
@outargs = (
{ name => 'num_segments', type => 'int32',
init => 0, desc => 'Number of segments' }
);
%invoke = (
code => <<'CODE'
{
GimpGradient *gradient;
GimpGradientSegment *seg;
gradient = gimp_pdb_get_gradient (gimp, name, FALSE, error);
if (gradient)
{
for (seg = gradient->segments; seg; seg = seg->next)
num_segments++;
}
else
success = FALSE;
}
CODE
);
}
sub gradient_get_uniform_samples {
$blurb = 'Sample the specified in uniform parts.';
@ -1385,8 +1427,9 @@ CODE
@procs = qw(gradient_new
gradient_duplicate
gradient_is_editable
gradient_rename
gradient_rename
gradient_delete
gradient_get_number_of_segments
gradient_get_uniform_samples gradient_get_custom_samples
gradient_segment_get_left_color gradient_segment_set_left_color
gradient_segment_get_right_color gradient_segment_set_right_color