1
/* GIMP - The GNU Image Manipulation Program
2
* Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
/* NOTE: This file is auto-generated by pdbgen.pl. */
25
#include <glib-object.h>
27
#include "pdb-types.h"
29
#include "core/gimp.h"
30
#include "core/gimpcontainer-filter.h"
31
#include "core/gimpcontext.h"
32
#include "core/gimpdatafactory.h"
33
#include "core/gimpgradient.h"
34
#include "core/gimpparamspecs.h"
37
#include "gimppdb-utils.h"
38
#include "gimpprocedure.h"
39
#include "internal-procs.h"
43
gradients_refresh_invoker (GimpProcedure *procedure,
46
GimpProgress *progress,
47
const GValueArray *args,
50
gimp_data_factory_data_refresh (gimp->gradient_factory);
52
return gimp_procedure_get_return_values (procedure, TRUE, NULL);
56
gradients_get_list_invoker (GimpProcedure *procedure,
59
GimpProgress *progress,
60
const GValueArray *args,
63
gboolean success = TRUE;
64
GValueArray *return_vals;
66
gint32 num_gradients = 0;
67
gchar **gradient_list = NULL;
69
filter = g_value_get_string (&args->values[0]);
73
gradient_list = gimp_container_get_filtered_name_array (gimp->gradient_factory->container,
74
filter, &num_gradients);
77
return_vals = gimp_procedure_get_return_values (procedure, success,
78
error ? *error : NULL);
82
g_value_set_int (&return_vals->values[1], num_gradients);
83
gimp_value_take_stringarray (&return_vals->values[2], gradient_list, num_gradients);
90
gradients_sample_uniform_invoker (GimpProcedure *procedure,
93
GimpProgress *progress,
94
const GValueArray *args,
97
gboolean success = TRUE;
98
GValueArray *return_vals;
101
gint32 array_length = 0;
102
gdouble *color_samples = NULL;
104
num_samples = g_value_get_int (&args->values[0]);
105
reverse = g_value_get_boolean (&args->values[1]);
109
GimpGradient *gradient;
110
GimpGradientSegment *seg = NULL;
116
delta = 1.0 / (num_samples - 1);
118
array_length = num_samples * 4;
120
pv = color_samples = g_new (gdouble, array_length);
122
gradient = gimp_context_get_gradient (context);
124
while (num_samples--)
126
seg = gimp_gradient_get_color_at (gradient, context, seg,
127
pos, reverse, &color);
138
return_vals = gimp_procedure_get_return_values (procedure, success,
139
error ? *error : NULL);
143
g_value_set_int (&return_vals->values[1], array_length);
144
gimp_value_take_floatarray (&return_vals->values[2], color_samples, array_length);
151
gradients_sample_custom_invoker (GimpProcedure *procedure,
153
GimpContext *context,
154
GimpProgress *progress,
155
const GValueArray *args,
158
gboolean success = TRUE;
159
GValueArray *return_vals;
161
const gdouble *positions;
163
gint32 array_length = 0;
164
gdouble *color_samples = NULL;
166
num_samples = g_value_get_int (&args->values[0]);
167
positions = gimp_value_get_floatarray (&args->values[1]);
168
reverse = g_value_get_boolean (&args->values[2]);
172
GimpGradient *gradient;
173
GimpGradientSegment *seg = NULL;
177
array_length = num_samples * 4;
179
pv = color_samples = g_new (gdouble, array_length);
181
gradient = gimp_context_get_gradient (context);
183
while (num_samples--)
185
seg = gimp_gradient_get_color_at (gradient, context, seg,
186
*positions, reverse, &color);
197
return_vals = gimp_procedure_get_return_values (procedure, success,
198
error ? *error : NULL);
202
g_value_set_int (&return_vals->values[1], array_length);
203
gimp_value_take_floatarray (&return_vals->values[2], color_samples, array_length);
210
gradients_get_gradient_data_invoker (GimpProcedure *procedure,
212
GimpContext *context,
213
GimpProgress *progress,
214
const GValueArray *args,
217
gboolean success = TRUE;
218
GValueArray *return_vals;
222
gchar *actual_name = NULL;
224
gdouble *grad_data = NULL;
226
name = g_value_get_string (&args->values[0]);
227
sample_size = g_value_get_int (&args->values[1]);
228
reverse = g_value_get_boolean (&args->values[2]);
232
GimpGradient *gradient;
234
if (sample_size < 1 || sample_size > 10000)
235
sample_size = GIMP_GRADIENT_DEFAULT_SAMPLE_SIZE;
237
if (name && strlen (name))
238
gradient = gimp_pdb_get_gradient (gimp, name, FALSE, error);
240
gradient = gimp_context_get_gradient (context);
244
GimpGradientSegment *seg = NULL;
250
delta = 1.0 / (sample_size - 1);
252
actual_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (gradient)));
253
grad_data = g_new (gdouble, sample_size * 4);
254
width = sample_size * 4;
260
seg = gimp_gradient_get_color_at (gradient, context, seg,
261
pos, reverse, &color);
275
return_vals = gimp_procedure_get_return_values (procedure, success,
276
error ? *error : NULL);
280
g_value_take_string (&return_vals->values[1], actual_name);
281
g_value_set_int (&return_vals->values[2], width);
282
gimp_value_take_floatarray (&return_vals->values[3], grad_data, width);
289
register_gradients_procs (GimpPDB *pdb)
291
GimpProcedure *procedure;
294
* gimp-gradients-refresh
296
procedure = gimp_procedure_new (gradients_refresh_invoker);
297
gimp_object_set_static_name (GIMP_OBJECT (procedure),
298
"gimp-gradients-refresh");
299
gimp_procedure_set_static_strings (procedure,
300
"gimp-gradients-refresh",
301
"Refresh current gradients. This function always succeeds.",
302
"This procedure retrieves all gradients currently in the user's gradient path and updates the gradient dialogs accordingly.",
303
"Michael Natterer <mitch@gimp.org>",
307
gimp_pdb_register_procedure (pdb, procedure);
308
g_object_unref (procedure);
311
* gimp-gradients-get-list
313
procedure = gimp_procedure_new (gradients_get_list_invoker);
314
gimp_object_set_static_name (GIMP_OBJECT (procedure),
315
"gimp-gradients-get-list");
316
gimp_procedure_set_static_strings (procedure,
317
"gimp-gradients-get-list",
318
"Retrieve the list of loaded gradients.",
319
"This procedure returns a list of the gradients that are currently loaded. You can later use the 'gimp-context-set-gradient' function to set the active gradient.",
320
"Federico Mena Quintero",
321
"Federico Mena Quintero",
324
gimp_procedure_add_argument (procedure,
325
gimp_param_spec_string ("filter",
327
"An optional regular expression used to filter the list",
330
GIMP_PARAM_READWRITE));
331
gimp_procedure_add_return_value (procedure,
332
gimp_param_spec_int32 ("num-gradients",
334
"The number of loaded gradients",
336
GIMP_PARAM_READWRITE));
337
gimp_procedure_add_return_value (procedure,
338
gimp_param_spec_string_array ("gradient-list",
340
"The list of gradient names",
341
GIMP_PARAM_READWRITE));
342
gimp_pdb_register_procedure (pdb, procedure);
343
g_object_unref (procedure);
346
* gimp-gradients-sample-uniform
348
procedure = gimp_procedure_new (gradients_sample_uniform_invoker);
349
gimp_object_set_static_name (GIMP_OBJECT (procedure),
350
"gimp-gradients-sample-uniform");
351
gimp_procedure_set_static_strings (procedure,
352
"gimp-gradients-sample-uniform",
353
"This procedure is deprecated! Use 'gimp-gradient-get-uniform-samples' instead.",
354
"This procedure is deprecated! Use 'gimp-gradient-get-uniform-samples' instead.",
358
"gimp-gradient-get-uniform-samples");
359
gimp_procedure_add_argument (procedure,
360
gimp_param_spec_int32 ("num-samples",
362
"The number of samples to take",
364
GIMP_PARAM_READWRITE));
365
gimp_procedure_add_argument (procedure,
366
g_param_spec_boolean ("reverse",
368
"Use the reverse gradient",
370
GIMP_PARAM_READWRITE));
371
gimp_procedure_add_return_value (procedure,
372
gimp_param_spec_int32 ("array-length",
374
"Length of the color_samples array (4 * num_samples)",
376
GIMP_PARAM_READWRITE));
377
gimp_procedure_add_return_value (procedure,
378
gimp_param_spec_float_array ("color-samples",
380
"Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }",
381
GIMP_PARAM_READWRITE));
382
gimp_pdb_register_procedure (pdb, procedure);
383
g_object_unref (procedure);
386
* gimp-gradients-sample-custom
388
procedure = gimp_procedure_new (gradients_sample_custom_invoker);
389
gimp_object_set_static_name (GIMP_OBJECT (procedure),
390
"gimp-gradients-sample-custom");
391
gimp_procedure_set_static_strings (procedure,
392
"gimp-gradients-sample-custom",
393
"This procedure is deprecated! Use 'gimp-gradient-get-custom-samples' instead.",
394
"This procedure is deprecated! Use 'gimp-gradient-get-custom-samples' instead.",
398
"gimp-gradient-get-custom-samples");
399
gimp_procedure_add_argument (procedure,
400
gimp_param_spec_int32 ("num-samples",
402
"The number of samples to take",
404
GIMP_PARAM_READWRITE));
405
gimp_procedure_add_argument (procedure,
406
gimp_param_spec_float_array ("positions",
408
"The list of positions to sample along the gradient",
409
GIMP_PARAM_READWRITE));
410
gimp_procedure_add_argument (procedure,
411
g_param_spec_boolean ("reverse",
413
"Use the reverse gradient",
415
GIMP_PARAM_READWRITE));
416
gimp_procedure_add_return_value (procedure,
417
gimp_param_spec_int32 ("array-length",
419
"Length of the color_samples array (4 * num_samples)",
421
GIMP_PARAM_READWRITE));
422
gimp_procedure_add_return_value (procedure,
423
gimp_param_spec_float_array ("color-samples",
425
"Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }",
426
GIMP_PARAM_READWRITE));
427
gimp_pdb_register_procedure (pdb, procedure);
428
g_object_unref (procedure);
431
* gimp-gradients-get-gradient-data
433
procedure = gimp_procedure_new (gradients_get_gradient_data_invoker);
434
gimp_object_set_static_name (GIMP_OBJECT (procedure),
435
"gimp-gradients-get-gradient-data");
436
gimp_procedure_set_static_strings (procedure,
437
"gimp-gradients-get-gradient-data",
438
"This procedure is deprecated! Use 'gimp-gradient-get-uniform-samples' instead.",
439
"This procedure is deprecated! Use 'gimp-gradient-get-uniform-samples' instead.",
443
"gimp-gradient-get-uniform-samples");
444
gimp_procedure_add_argument (procedure,
445
gimp_param_spec_string ("name",
447
"The gradient name (\"\" means current active gradient)",
450
GIMP_PARAM_READWRITE));
451
gimp_procedure_add_argument (procedure,
452
gimp_param_spec_int32 ("sample-size",
454
"Size of the sample to return when the gradient is changed",
456
GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
457
gimp_procedure_add_argument (procedure,
458
g_param_spec_boolean ("reverse",
460
"Use the reverse gradient",
462
GIMP_PARAM_READWRITE));
463
gimp_procedure_add_return_value (procedure,
464
gimp_param_spec_string ("actual-name",
469
GIMP_PARAM_READWRITE));
470
gimp_procedure_add_return_value (procedure,
471
gimp_param_spec_int32 ("width",
473
"The gradient sample width (r,g,b,a)",
475
GIMP_PARAM_READWRITE));
476
gimp_procedure_add_return_value (procedure,
477
gimp_param_spec_float_array ("grad-data",
479
"The gradient sample data",
480
GIMP_PARAM_READWRITE));
481
gimp_pdb_register_procedure (pdb, procedure);
482
g_object_unref (procedure);