1 /* GIMP - The GNU Image Manipulation Program
2  * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
3  *
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 3 of the License, or
7  * (at your option) any later version.
8  *
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.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
16  */
17 
18 /* NOTE: This file is auto-generated by pdbgen.pl. */
19 
20 #include "config.h"
21 
22 #include <cairo.h>
23 #include <string.h>
24 
25 #include <gegl.h>
26 
27 #include <gdk-pixbuf/gdk-pixbuf.h>
28 
29 #include "libgimpcolor/gimpcolor.h"
30 
31 #include "libgimpbase/gimpbase.h"
32 
33 #include "pdb-types.h"
34 
35 #include "core/gimp.h"
36 #include "core/gimpcontext.h"
37 #include "core/gimpdatafactory.h"
38 #include "core/gimpgradient.h"
39 #include "core/gimpparamspecs.h"
40 
41 #include "gimppdb.h"
42 #include "gimppdb-utils.h"
43 #include "gimpprocedure.h"
44 #include "internal-procs.h"
45 
46 
47 static GimpGradient *
gradient_get(Gimp * gimp,const gchar * name,GimpPDBDataAccess access,gint segment,GimpGradientSegment ** seg,GError ** error)48 gradient_get (Gimp                 *gimp,
49               const gchar          *name,
50               GimpPDBDataAccess     access,
51               gint                  segment,
52               GimpGradientSegment **seg,
53               GError              **error)
54 {
55   GimpGradient *gradient = gimp_pdb_get_gradient (gimp, name, access, error);
56 
57   *seg = NULL;
58 
59   if (gradient)
60     *seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
61 
62   return gradient;
63 }
64 
65 static GimpGradient *
gradient_get_range(Gimp * gimp,const gchar * name,gint start_segment,gint end_segment,GimpGradientSegment ** start_seg,GimpGradientSegment ** end_seg,GError ** error)66 gradient_get_range (Gimp                 *gimp,
67                     const gchar          *name,
68                     gint                  start_segment,
69                     gint                  end_segment,
70                     GimpGradientSegment **start_seg,
71                     GimpGradientSegment **end_seg,
72                     GError              **error)
73 {
74   GimpGradient *gradient = gimp_pdb_get_gradient (gimp, name, GIMP_PDB_DATA_ACCESS_WRITE, error);
75 
76   *start_seg = NULL;
77   *end_seg   = NULL;
78 
79   if (end_segment >= 0 && end_segment < start_segment)
80     return NULL;
81 
82   if (gradient)
83     {
84       *start_seg = gimp_gradient_segment_get_nth (gradient->segments,
85                                                   start_segment);
86 
87       if (*start_seg && end_segment >= 0)
88         *end_seg = gimp_gradient_segment_get_nth (*start_seg,
89                                                   end_segment -
90                                                   start_segment);
91     }
92 
93   return gradient;
94 }
95 
96 static GimpValueArray *
gradient_new_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)97 gradient_new_invoker (GimpProcedure         *procedure,
98                       Gimp                  *gimp,
99                       GimpContext           *context,
100                       GimpProgress          *progress,
101                       const GimpValueArray  *args,
102                       GError               **error)
103 {
104   gboolean success = TRUE;
105   GimpValueArray *return_vals;
106   const gchar *name;
107   gchar *actual_name = NULL;
108 
109   name = g_value_get_string (gimp_value_array_index (args, 0));
110 
111   if (success)
112     {
113       GimpData *data = gimp_data_factory_data_new (gimp->gradient_factory,
114                                                    context, name);
115 
116       if (data)
117         actual_name = g_strdup (gimp_object_get_name (data));
118       else
119         success = FALSE;
120     }
121 
122   return_vals = gimp_procedure_get_return_values (procedure, success,
123                                                   error ? *error : NULL);
124 
125   if (success)
126     g_value_take_string (gimp_value_array_index (return_vals, 1), actual_name);
127 
128   return return_vals;
129 }
130 
131 static GimpValueArray *
gradient_duplicate_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)132 gradient_duplicate_invoker (GimpProcedure         *procedure,
133                             Gimp                  *gimp,
134                             GimpContext           *context,
135                             GimpProgress          *progress,
136                             const GimpValueArray  *args,
137                             GError               **error)
138 {
139   gboolean success = TRUE;
140   GimpValueArray *return_vals;
141   const gchar *name;
142   gchar *copy_name = NULL;
143 
144   name = g_value_get_string (gimp_value_array_index (args, 0));
145 
146   if (success)
147     {
148       GimpGradient *gradient = gimp_pdb_get_gradient (gimp, name, GIMP_PDB_DATA_ACCESS_READ, error);
149 
150       if (gradient)
151         {
152           GimpGradient *gradient_copy = (GimpGradient *)
153             gimp_data_factory_data_duplicate (gimp->gradient_factory,
154                                               GIMP_DATA (gradient));
155 
156           if (gradient_copy)
157             copy_name = g_strdup (gimp_object_get_name (gradient_copy));
158           else
159             success = FALSE;
160         }
161       else
162         success = FALSE;
163     }
164 
165   return_vals = gimp_procedure_get_return_values (procedure, success,
166                                                   error ? *error : NULL);
167 
168   if (success)
169     g_value_take_string (gimp_value_array_index (return_vals, 1), copy_name);
170 
171   return return_vals;
172 }
173 
174 static GimpValueArray *
gradient_is_editable_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)175 gradient_is_editable_invoker (GimpProcedure         *procedure,
176                               Gimp                  *gimp,
177                               GimpContext           *context,
178                               GimpProgress          *progress,
179                               const GimpValueArray  *args,
180                               GError               **error)
181 {
182   gboolean success = TRUE;
183   GimpValueArray *return_vals;
184   const gchar *name;
185   gboolean editable = FALSE;
186 
187   name = g_value_get_string (gimp_value_array_index (args, 0));
188 
189   if (success)
190     {
191       GimpGradient *gradient = gimp_pdb_get_gradient (gimp, name, GIMP_PDB_DATA_ACCESS_READ, error);
192 
193       if (gradient)
194         editable = gimp_data_is_writable (GIMP_DATA (gradient));
195       else
196         success = FALSE;
197     }
198 
199   return_vals = gimp_procedure_get_return_values (procedure, success,
200                                                   error ? *error : NULL);
201 
202   if (success)
203     g_value_set_boolean (gimp_value_array_index (return_vals, 1), editable);
204 
205   return return_vals;
206 }
207 
208 static GimpValueArray *
gradient_rename_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)209 gradient_rename_invoker (GimpProcedure         *procedure,
210                          Gimp                  *gimp,
211                          GimpContext           *context,
212                          GimpProgress          *progress,
213                          const GimpValueArray  *args,
214                          GError               **error)
215 {
216   gboolean success = TRUE;
217   GimpValueArray *return_vals;
218   const gchar *name;
219   const gchar *new_name;
220   gchar *actual_name = NULL;
221 
222   name = g_value_get_string (gimp_value_array_index (args, 0));
223   new_name = g_value_get_string (gimp_value_array_index (args, 1));
224 
225   if (success)
226     {
227       GimpGradient *gradient = gimp_pdb_get_gradient (gimp, name, GIMP_PDB_DATA_ACCESS_RENAME, error);
228 
229       if (gradient)
230         {
231           gimp_object_set_name (GIMP_OBJECT (gradient), new_name);
232           actual_name = g_strdup (gimp_object_get_name (gradient));
233         }
234       else
235         success = FALSE;
236     }
237 
238   return_vals = gimp_procedure_get_return_values (procedure, success,
239                                                   error ? *error : NULL);
240 
241   if (success)
242     g_value_take_string (gimp_value_array_index (return_vals, 1), actual_name);
243 
244   return return_vals;
245 }
246 
247 static GimpValueArray *
gradient_delete_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)248 gradient_delete_invoker (GimpProcedure         *procedure,
249                          Gimp                  *gimp,
250                          GimpContext           *context,
251                          GimpProgress          *progress,
252                          const GimpValueArray  *args,
253                          GError               **error)
254 {
255   gboolean success = TRUE;
256   const gchar *name;
257 
258   name = g_value_get_string (gimp_value_array_index (args, 0));
259 
260   if (success)
261     {
262       GimpGradient *gradient = gimp_pdb_get_gradient (gimp, name, GIMP_PDB_DATA_ACCESS_READ, error);
263 
264       if (gradient && gimp_data_is_deletable (GIMP_DATA (gradient)))
265         success = gimp_data_factory_data_delete (gimp->gradient_factory,
266                                                  GIMP_DATA (gradient),
267                                                  TRUE, error);
268       else
269         success = FALSE;
270     }
271 
272   return gimp_procedure_get_return_values (procedure, success,
273                                            error ? *error : NULL);
274 }
275 
276 static GimpValueArray *
gradient_get_number_of_segments_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)277 gradient_get_number_of_segments_invoker (GimpProcedure         *procedure,
278                                          Gimp                  *gimp,
279                                          GimpContext           *context,
280                                          GimpProgress          *progress,
281                                          const GimpValueArray  *args,
282                                          GError               **error)
283 {
284   gboolean success = TRUE;
285   GimpValueArray *return_vals;
286   const gchar *name;
287   gint32 num_segments = 0;
288 
289   name = g_value_get_string (gimp_value_array_index (args, 0));
290 
291   if (success)
292     {
293       GimpGradient        *gradient;
294       GimpGradientSegment *seg;
295 
296       gradient = gimp_pdb_get_gradient (gimp, name, GIMP_PDB_DATA_ACCESS_READ, error);
297 
298       if (gradient)
299         {
300           for (seg = gradient->segments; seg; seg = seg->next)
301             num_segments++;
302         }
303       else
304         success = FALSE;
305     }
306 
307   return_vals = gimp_procedure_get_return_values (procedure, success,
308                                                   error ? *error : NULL);
309 
310   if (success)
311     g_value_set_int (gimp_value_array_index (return_vals, 1), num_segments);
312 
313   return return_vals;
314 }
315 
316 static GimpValueArray *
gradient_get_uniform_samples_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)317 gradient_get_uniform_samples_invoker (GimpProcedure         *procedure,
318                                       Gimp                  *gimp,
319                                       GimpContext           *context,
320                                       GimpProgress          *progress,
321                                       const GimpValueArray  *args,
322                                       GError               **error)
323 {
324   gboolean success = TRUE;
325   GimpValueArray *return_vals;
326   const gchar *name;
327   gint32 num_samples;
328   gboolean reverse;
329   gint32 num_color_samples = 0;
330   gdouble *color_samples = NULL;
331 
332   name = g_value_get_string (gimp_value_array_index (args, 0));
333   num_samples = g_value_get_int (gimp_value_array_index (args, 1));
334   reverse = g_value_get_boolean (gimp_value_array_index (args, 2));
335 
336   if (success)
337     {
338       GimpGradient *gradient = gimp_pdb_get_gradient (gimp, name,
339                                                       GIMP_PDB_DATA_ACCESS_READ,
340                                                       error);
341 
342       if (gradient)
343         {
344           GimpGradientSegment *seg   = NULL;
345           gdouble              pos   = 0.0;
346           gdouble              delta = 1.0 / (num_samples - 1);
347           gdouble             *sample;
348 
349           num_color_samples = num_samples * 4;
350 
351           sample = color_samples = g_new (gdouble, num_color_samples);
352 
353           while (num_samples--)
354             {
355               GimpRGB color;
356 
357               seg = gimp_gradient_get_color_at (gradient, context, seg,
358                                                 pos, reverse,
359                                                 GIMP_GRADIENT_BLEND_RGB_PERCEPTUAL,
360                                                 &color);
361 
362               *sample++ = color.r;
363               *sample++ = color.g;
364               *sample++ = color.b;
365               *sample++ = color.a;
366 
367               pos += delta;
368             }
369         }
370       else
371         success = FALSE;
372     }
373 
374   return_vals = gimp_procedure_get_return_values (procedure, success,
375                                                   error ? *error : NULL);
376 
377   if (success)
378     {
379       g_value_set_int (gimp_value_array_index (return_vals, 1), num_color_samples);
380       gimp_value_take_floatarray (gimp_value_array_index (return_vals, 2), color_samples, num_color_samples);
381     }
382 
383   return return_vals;
384 }
385 
386 static GimpValueArray *
gradient_get_custom_samples_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)387 gradient_get_custom_samples_invoker (GimpProcedure         *procedure,
388                                      Gimp                  *gimp,
389                                      GimpContext           *context,
390                                      GimpProgress          *progress,
391                                      const GimpValueArray  *args,
392                                      GError               **error)
393 {
394   gboolean success = TRUE;
395   GimpValueArray *return_vals;
396   const gchar *name;
397   gint32 num_samples;
398   const gdouble *positions;
399   gboolean reverse;
400   gint32 num_color_samples = 0;
401   gdouble *color_samples = NULL;
402 
403   name = g_value_get_string (gimp_value_array_index (args, 0));
404   num_samples = g_value_get_int (gimp_value_array_index (args, 1));
405   positions = gimp_value_get_floatarray (gimp_value_array_index (args, 2));
406   reverse = g_value_get_boolean (gimp_value_array_index (args, 3));
407 
408   if (success)
409     {
410       GimpGradient *gradient = gimp_pdb_get_gradient (gimp, name,
411                                                       GIMP_PDB_DATA_ACCESS_READ,
412                                                       error);
413 
414       if (gradient)
415         {
416           GimpGradientSegment *seg = NULL;
417           gdouble             *sample;
418 
419           num_color_samples = num_samples * 4;
420 
421           sample = color_samples = g_new (gdouble, num_color_samples);
422 
423           while (num_samples--)
424             {
425               GimpRGB color;
426 
427               seg = gimp_gradient_get_color_at (gradient, context,
428                                                 seg, *positions,
429                                                 reverse,
430                                                 GIMP_GRADIENT_BLEND_RGB_PERCEPTUAL,
431                                                 &color);
432 
433               *sample++ = color.r;
434               *sample++ = color.g;
435               *sample++ = color.b;
436               *sample++ = color.a;
437 
438               positions++;
439             }
440         }
441       else
442         success = FALSE;
443     }
444 
445   return_vals = gimp_procedure_get_return_values (procedure, success,
446                                                   error ? *error : NULL);
447 
448   if (success)
449     {
450       g_value_set_int (gimp_value_array_index (return_vals, 1), num_color_samples);
451       gimp_value_take_floatarray (gimp_value_array_index (return_vals, 2), color_samples, num_color_samples);
452     }
453 
454   return return_vals;
455 }
456 
457 static GimpValueArray *
gradient_segment_get_left_color_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)458 gradient_segment_get_left_color_invoker (GimpProcedure         *procedure,
459                                          Gimp                  *gimp,
460                                          GimpContext           *context,
461                                          GimpProgress          *progress,
462                                          const GimpValueArray  *args,
463                                          GError               **error)
464 {
465   gboolean success = TRUE;
466   GimpValueArray *return_vals;
467   const gchar *name;
468   gint32 segment;
469   GimpRGB color = { 0.0, 0.0, 0.0, 1.0 };
470   gdouble opacity = 0.0;
471 
472   name = g_value_get_string (gimp_value_array_index (args, 0));
473   segment = g_value_get_int (gimp_value_array_index (args, 1));
474 
475   if (success)
476     {
477       GimpGradient        *gradient;
478       GimpGradientSegment *seg;
479 
480       gradient = gradient_get (gimp, name, GIMP_PDB_DATA_ACCESS_READ, segment,
481                                &seg, error);
482 
483       if (seg)
484         {
485           gimp_gradient_segment_get_left_color (gradient, seg, &color);
486           opacity = color.a * 100.0;
487         }
488       else
489         success = FALSE;
490     }
491 
492   return_vals = gimp_procedure_get_return_values (procedure, success,
493                                                   error ? *error : NULL);
494 
495   if (success)
496     {
497       gimp_value_set_rgb (gimp_value_array_index (return_vals, 1), &color);
498       g_value_set_double (gimp_value_array_index (return_vals, 2), opacity);
499     }
500 
501   return return_vals;
502 }
503 
504 static GimpValueArray *
gradient_segment_set_left_color_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)505 gradient_segment_set_left_color_invoker (GimpProcedure         *procedure,
506                                          Gimp                  *gimp,
507                                          GimpContext           *context,
508                                          GimpProgress          *progress,
509                                          const GimpValueArray  *args,
510                                          GError               **error)
511 {
512   gboolean success = TRUE;
513   const gchar *name;
514   gint32 segment;
515   GimpRGB color;
516   gdouble opacity;
517 
518   name = g_value_get_string (gimp_value_array_index (args, 0));
519   segment = g_value_get_int (gimp_value_array_index (args, 1));
520   gimp_value_get_rgb (gimp_value_array_index (args, 2), &color);
521   opacity = g_value_get_double (gimp_value_array_index (args, 3));
522 
523   if (success)
524     {
525       GimpGradient        *gradient;
526       GimpGradientSegment *seg;
527 
528       gradient = gradient_get (gimp, name, GIMP_PDB_DATA_ACCESS_WRITE, segment,
529                                &seg, error);
530 
531       if (seg)
532         {
533           color.a = opacity / 100.0;
534           gimp_gradient_segment_set_left_color (gradient, seg, &color);
535         }
536       else
537         success = FALSE;
538     }
539 
540   return gimp_procedure_get_return_values (procedure, success,
541                                            error ? *error : NULL);
542 }
543 
544 static GimpValueArray *
gradient_segment_get_right_color_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)545 gradient_segment_get_right_color_invoker (GimpProcedure         *procedure,
546                                           Gimp                  *gimp,
547                                           GimpContext           *context,
548                                           GimpProgress          *progress,
549                                           const GimpValueArray  *args,
550                                           GError               **error)
551 {
552   gboolean success = TRUE;
553   GimpValueArray *return_vals;
554   const gchar *name;
555   gint32 segment;
556   GimpRGB color = { 0.0, 0.0, 0.0, 1.0 };
557   gdouble opacity = 0.0;
558 
559   name = g_value_get_string (gimp_value_array_index (args, 0));
560   segment = g_value_get_int (gimp_value_array_index (args, 1));
561 
562   if (success)
563     {
564       GimpGradient        *gradient;
565       GimpGradientSegment *seg;
566 
567       gradient = gradient_get (gimp, name, GIMP_PDB_DATA_ACCESS_READ, segment,
568                                &seg, error);
569 
570       if (seg)
571         {
572           gimp_gradient_segment_get_right_color (gradient, seg, &color);
573           opacity = color.a * 100.0;
574         }
575       else
576         success = FALSE;
577     }
578 
579   return_vals = gimp_procedure_get_return_values (procedure, success,
580                                                   error ? *error : NULL);
581 
582   if (success)
583     {
584       gimp_value_set_rgb (gimp_value_array_index (return_vals, 1), &color);
585       g_value_set_double (gimp_value_array_index (return_vals, 2), opacity);
586     }
587 
588   return return_vals;
589 }
590 
591 static GimpValueArray *
gradient_segment_set_right_color_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)592 gradient_segment_set_right_color_invoker (GimpProcedure         *procedure,
593                                           Gimp                  *gimp,
594                                           GimpContext           *context,
595                                           GimpProgress          *progress,
596                                           const GimpValueArray  *args,
597                                           GError               **error)
598 {
599   gboolean success = TRUE;
600   const gchar *name;
601   gint32 segment;
602   GimpRGB color;
603   gdouble opacity;
604 
605   name = g_value_get_string (gimp_value_array_index (args, 0));
606   segment = g_value_get_int (gimp_value_array_index (args, 1));
607   gimp_value_get_rgb (gimp_value_array_index (args, 2), &color);
608   opacity = g_value_get_double (gimp_value_array_index (args, 3));
609 
610   if (success)
611     {
612       GimpGradient        *gradient;
613       GimpGradientSegment *seg;
614 
615       gradient = gradient_get (gimp, name, GIMP_PDB_DATA_ACCESS_WRITE, segment,
616                                &seg, error);
617 
618       if (seg)
619         {
620           color.a = opacity / 100.0;
621           gimp_gradient_segment_set_right_color (gradient, seg, &color);
622         }
623       else
624         success = FALSE;
625     }
626 
627   return gimp_procedure_get_return_values (procedure, success,
628                                            error ? *error : NULL);
629 }
630 
631 static GimpValueArray *
gradient_segment_get_left_pos_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)632 gradient_segment_get_left_pos_invoker (GimpProcedure         *procedure,
633                                        Gimp                  *gimp,
634                                        GimpContext           *context,
635                                        GimpProgress          *progress,
636                                        const GimpValueArray  *args,
637                                        GError               **error)
638 {
639   gboolean success = TRUE;
640   GimpValueArray *return_vals;
641   const gchar *name;
642   gint32 segment;
643   gdouble pos = 0.0;
644 
645   name = g_value_get_string (gimp_value_array_index (args, 0));
646   segment = g_value_get_int (gimp_value_array_index (args, 1));
647 
648   if (success)
649     {
650       GimpGradient        *gradient;
651       GimpGradientSegment *seg;
652 
653       gradient = gradient_get (gimp, name, GIMP_PDB_DATA_ACCESS_READ, segment,
654                                &seg, error);
655 
656       if (seg)
657         {
658           pos = gimp_gradient_segment_get_left_pos (gradient, seg);
659         }
660       else
661         success = FALSE;
662     }
663 
664   return_vals = gimp_procedure_get_return_values (procedure, success,
665                                                   error ? *error : NULL);
666 
667   if (success)
668     g_value_set_double (gimp_value_array_index (return_vals, 1), pos);
669 
670   return return_vals;
671 }
672 
673 static GimpValueArray *
gradient_segment_set_left_pos_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)674 gradient_segment_set_left_pos_invoker (GimpProcedure         *procedure,
675                                        Gimp                  *gimp,
676                                        GimpContext           *context,
677                                        GimpProgress          *progress,
678                                        const GimpValueArray  *args,
679                                        GError               **error)
680 {
681   gboolean success = TRUE;
682   GimpValueArray *return_vals;
683   const gchar *name;
684   gint32 segment;
685   gdouble pos;
686   gdouble final_pos = 0.0;
687 
688   name = g_value_get_string (gimp_value_array_index (args, 0));
689   segment = g_value_get_int (gimp_value_array_index (args, 1));
690   pos = g_value_get_double (gimp_value_array_index (args, 2));
691 
692   if (success)
693     {
694       GimpGradient        *gradient;
695       GimpGradientSegment *seg;
696 
697       gradient = gradient_get (gimp, name, GIMP_PDB_DATA_ACCESS_WRITE, segment,
698                                &seg, error);
699 
700       if (seg)
701         {
702           final_pos = gimp_gradient_segment_set_left_pos (gradient, seg, pos);
703         }
704       else
705         success = FALSE;
706     }
707 
708   return_vals = gimp_procedure_get_return_values (procedure, success,
709                                                   error ? *error : NULL);
710 
711   if (success)
712     g_value_set_double (gimp_value_array_index (return_vals, 1), final_pos);
713 
714   return return_vals;
715 }
716 
717 static GimpValueArray *
gradient_segment_get_middle_pos_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)718 gradient_segment_get_middle_pos_invoker (GimpProcedure         *procedure,
719                                          Gimp                  *gimp,
720                                          GimpContext           *context,
721                                          GimpProgress          *progress,
722                                          const GimpValueArray  *args,
723                                          GError               **error)
724 {
725   gboolean success = TRUE;
726   GimpValueArray *return_vals;
727   const gchar *name;
728   gint32 segment;
729   gdouble pos = 0.0;
730 
731   name = g_value_get_string (gimp_value_array_index (args, 0));
732   segment = g_value_get_int (gimp_value_array_index (args, 1));
733 
734   if (success)
735     {
736       GimpGradient        *gradient;
737       GimpGradientSegment *seg;
738 
739       gradient = gradient_get (gimp, name, GIMP_PDB_DATA_ACCESS_READ, segment,
740                                &seg, error);
741 
742       if (seg)
743         {
744           pos = gimp_gradient_segment_get_middle_pos (gradient, seg);
745         }
746       else
747         success = FALSE;
748     }
749 
750   return_vals = gimp_procedure_get_return_values (procedure, success,
751                                                   error ? *error : NULL);
752 
753   if (success)
754     g_value_set_double (gimp_value_array_index (return_vals, 1), pos);
755 
756   return return_vals;
757 }
758 
759 static GimpValueArray *
gradient_segment_set_middle_pos_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)760 gradient_segment_set_middle_pos_invoker (GimpProcedure         *procedure,
761                                          Gimp                  *gimp,
762                                          GimpContext           *context,
763                                          GimpProgress          *progress,
764                                          const GimpValueArray  *args,
765                                          GError               **error)
766 {
767   gboolean success = TRUE;
768   GimpValueArray *return_vals;
769   const gchar *name;
770   gint32 segment;
771   gdouble pos;
772   gdouble final_pos = 0.0;
773 
774   name = g_value_get_string (gimp_value_array_index (args, 0));
775   segment = g_value_get_int (gimp_value_array_index (args, 1));
776   pos = g_value_get_double (gimp_value_array_index (args, 2));
777 
778   if (success)
779     {
780       GimpGradient        *gradient;
781       GimpGradientSegment *seg;
782 
783       gradient = gradient_get (gimp, name, GIMP_PDB_DATA_ACCESS_WRITE, segment,
784                                &seg, error);
785 
786       if (seg)
787         {
788           final_pos =
789             gimp_gradient_segment_set_middle_pos (gradient, seg, pos);
790         }
791       else
792         success = FALSE;
793     }
794 
795   return_vals = gimp_procedure_get_return_values (procedure, success,
796                                                   error ? *error : NULL);
797 
798   if (success)
799     g_value_set_double (gimp_value_array_index (return_vals, 1), final_pos);
800 
801   return return_vals;
802 }
803 
804 static GimpValueArray *
gradient_segment_get_right_pos_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)805 gradient_segment_get_right_pos_invoker (GimpProcedure         *procedure,
806                                         Gimp                  *gimp,
807                                         GimpContext           *context,
808                                         GimpProgress          *progress,
809                                         const GimpValueArray  *args,
810                                         GError               **error)
811 {
812   gboolean success = TRUE;
813   GimpValueArray *return_vals;
814   const gchar *name;
815   gint32 segment;
816   gdouble pos = 0.0;
817 
818   name = g_value_get_string (gimp_value_array_index (args, 0));
819   segment = g_value_get_int (gimp_value_array_index (args, 1));
820 
821   if (success)
822     {
823       GimpGradient        *gradient;
824       GimpGradientSegment *seg;
825 
826       gradient = gradient_get (gimp, name, GIMP_PDB_DATA_ACCESS_READ, segment,
827                                &seg, error);
828 
829       if (seg)
830         {
831           pos = gimp_gradient_segment_get_right_pos (gradient, seg);
832         }
833       else
834         success = FALSE;
835     }
836 
837   return_vals = gimp_procedure_get_return_values (procedure, success,
838                                                   error ? *error : NULL);
839 
840   if (success)
841     g_value_set_double (gimp_value_array_index (return_vals, 1), pos);
842 
843   return return_vals;
844 }
845 
846 static GimpValueArray *
gradient_segment_set_right_pos_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)847 gradient_segment_set_right_pos_invoker (GimpProcedure         *procedure,
848                                         Gimp                  *gimp,
849                                         GimpContext           *context,
850                                         GimpProgress          *progress,
851                                         const GimpValueArray  *args,
852                                         GError               **error)
853 {
854   gboolean success = TRUE;
855   GimpValueArray *return_vals;
856   const gchar *name;
857   gint32 segment;
858   gdouble pos;
859   gdouble final_pos = 0.0;
860 
861   name = g_value_get_string (gimp_value_array_index (args, 0));
862   segment = g_value_get_int (gimp_value_array_index (args, 1));
863   pos = g_value_get_double (gimp_value_array_index (args, 2));
864 
865   if (success)
866     {
867       GimpGradient        *gradient;
868       GimpGradientSegment *seg;
869 
870       gradient = gradient_get (gimp, name, GIMP_PDB_DATA_ACCESS_WRITE, segment,
871                                &seg, error);
872 
873       if (seg)
874         {
875           final_pos =
876             gimp_gradient_segment_set_right_pos (gradient, seg, pos);
877         }
878       else
879         success = FALSE;
880     }
881 
882   return_vals = gimp_procedure_get_return_values (procedure, success,
883                                                   error ? *error : NULL);
884 
885   if (success)
886     g_value_set_double (gimp_value_array_index (return_vals, 1), final_pos);
887 
888   return return_vals;
889 }
890 
891 static GimpValueArray *
gradient_segment_get_blending_function_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)892 gradient_segment_get_blending_function_invoker (GimpProcedure         *procedure,
893                                                 Gimp                  *gimp,
894                                                 GimpContext           *context,
895                                                 GimpProgress          *progress,
896                                                 const GimpValueArray  *args,
897                                                 GError               **error)
898 {
899   gboolean success = TRUE;
900   GimpValueArray *return_vals;
901   const gchar *name;
902   gint32 segment;
903   gint32 blend_func = 0;
904 
905   name = g_value_get_string (gimp_value_array_index (args, 0));
906   segment = g_value_get_int (gimp_value_array_index (args, 1));
907 
908   if (success)
909     {
910       GimpGradient        *gradient;
911       GimpGradientSegment *seg;
912 
913       gradient = gradient_get (gimp, name, GIMP_PDB_DATA_ACCESS_READ, segment,
914                                &seg, error);
915 
916       if (seg)
917         {
918           blend_func = gimp_gradient_segment_get_blending_function (gradient, seg);
919         }
920       else
921         success = FALSE;
922     }
923 
924   return_vals = gimp_procedure_get_return_values (procedure, success,
925                                                   error ? *error : NULL);
926 
927   if (success)
928     g_value_set_enum (gimp_value_array_index (return_vals, 1), blend_func);
929 
930   return return_vals;
931 }
932 
933 static GimpValueArray *
gradient_segment_get_coloring_type_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)934 gradient_segment_get_coloring_type_invoker (GimpProcedure         *procedure,
935                                             Gimp                  *gimp,
936                                             GimpContext           *context,
937                                             GimpProgress          *progress,
938                                             const GimpValueArray  *args,
939                                             GError               **error)
940 {
941   gboolean success = TRUE;
942   GimpValueArray *return_vals;
943   const gchar *name;
944   gint32 segment;
945   gint32 coloring_type = 0;
946 
947   name = g_value_get_string (gimp_value_array_index (args, 0));
948   segment = g_value_get_int (gimp_value_array_index (args, 1));
949 
950   if (success)
951     {
952       GimpGradient        *gradient;
953       GimpGradientSegment *seg;
954 
955       gradient = gradient_get (gimp, name, GIMP_PDB_DATA_ACCESS_READ, segment,
956                                &seg, error);
957 
958       if (seg)
959         {
960           coloring_type = gimp_gradient_segment_get_coloring_type (gradient, seg);
961         }
962       else
963         success = FALSE;
964     }
965 
966   return_vals = gimp_procedure_get_return_values (procedure, success,
967                                                   error ? *error : NULL);
968 
969   if (success)
970     g_value_set_enum (gimp_value_array_index (return_vals, 1), coloring_type);
971 
972   return return_vals;
973 }
974 
975 static GimpValueArray *
gradient_segment_range_set_blending_function_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)976 gradient_segment_range_set_blending_function_invoker (GimpProcedure         *procedure,
977                                                       Gimp                  *gimp,
978                                                       GimpContext           *context,
979                                                       GimpProgress          *progress,
980                                                       const GimpValueArray  *args,
981                                                       GError               **error)
982 {
983   gboolean success = TRUE;
984   const gchar *name;
985   gint32 start_segment;
986   gint32 end_segment;
987   gint32 blending_function;
988 
989   name = g_value_get_string (gimp_value_array_index (args, 0));
990   start_segment = g_value_get_int (gimp_value_array_index (args, 1));
991   end_segment = g_value_get_int (gimp_value_array_index (args, 2));
992   blending_function = g_value_get_enum (gimp_value_array_index (args, 3));
993 
994   if (success)
995     {
996       GimpGradient        *gradient;
997       GimpGradientSegment *start_seg;
998       GimpGradientSegment *end_seg;
999 
1000       gradient = gradient_get_range (gimp, name, start_segment, end_segment,
1001                                      &start_seg, &end_seg, error);
1002 
1003       if (start_seg)
1004         {
1005           gimp_gradient_segment_range_set_blending_function (gradient,
1006                                                              start_seg, end_seg,
1007                                                              blending_function);
1008         }
1009       else
1010         success = FALSE;
1011     }
1012 
1013   return gimp_procedure_get_return_values (procedure, success,
1014                                            error ? *error : NULL);
1015 }
1016 
1017 static GimpValueArray *
gradient_segment_range_set_coloring_type_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)1018 gradient_segment_range_set_coloring_type_invoker (GimpProcedure         *procedure,
1019                                                   Gimp                  *gimp,
1020                                                   GimpContext           *context,
1021                                                   GimpProgress          *progress,
1022                                                   const GimpValueArray  *args,
1023                                                   GError               **error)
1024 {
1025   gboolean success = TRUE;
1026   const gchar *name;
1027   gint32 start_segment;
1028   gint32 end_segment;
1029   gint32 coloring_type;
1030 
1031   name = g_value_get_string (gimp_value_array_index (args, 0));
1032   start_segment = g_value_get_int (gimp_value_array_index (args, 1));
1033   end_segment = g_value_get_int (gimp_value_array_index (args, 2));
1034   coloring_type = g_value_get_enum (gimp_value_array_index (args, 3));
1035 
1036   if (success)
1037     {
1038       GimpGradient        *gradient;
1039       GimpGradientSegment *start_seg;
1040       GimpGradientSegment *end_seg;
1041 
1042       gradient = gradient_get_range (gimp, name, start_segment, end_segment,
1043                                      &start_seg, &end_seg, error);
1044 
1045       if (start_seg)
1046         {
1047           gimp_gradient_segment_range_set_coloring_type (gradient,
1048                                                          start_seg, end_seg,
1049                                                          coloring_type);
1050         }
1051       else
1052         success = FALSE;
1053     }
1054 
1055   return gimp_procedure_get_return_values (procedure, success,
1056                                            error ? *error : NULL);
1057 }
1058 
1059 static GimpValueArray *
gradient_segment_range_flip_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)1060 gradient_segment_range_flip_invoker (GimpProcedure         *procedure,
1061                                      Gimp                  *gimp,
1062                                      GimpContext           *context,
1063                                      GimpProgress          *progress,
1064                                      const GimpValueArray  *args,
1065                                      GError               **error)
1066 {
1067   gboolean success = TRUE;
1068   const gchar *name;
1069   gint32 start_segment;
1070   gint32 end_segment;
1071 
1072   name = g_value_get_string (gimp_value_array_index (args, 0));
1073   start_segment = g_value_get_int (gimp_value_array_index (args, 1));
1074   end_segment = g_value_get_int (gimp_value_array_index (args, 2));
1075 
1076   if (success)
1077     {
1078       GimpGradient        *gradient;
1079       GimpGradientSegment *start_seg;
1080       GimpGradientSegment *end_seg;
1081 
1082       gradient = gradient_get_range (gimp, name, start_segment, end_segment,
1083                                      &start_seg, &end_seg, error);
1084 
1085       if (start_seg)
1086         {
1087           gimp_gradient_segment_range_flip (gradient,
1088                                             start_seg, end_seg,
1089                                             NULL, NULL);
1090         }
1091       else
1092         success = FALSE;
1093     }
1094 
1095   return gimp_procedure_get_return_values (procedure, success,
1096                                            error ? *error : NULL);
1097 }
1098 
1099 static GimpValueArray *
gradient_segment_range_replicate_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)1100 gradient_segment_range_replicate_invoker (GimpProcedure         *procedure,
1101                                           Gimp                  *gimp,
1102                                           GimpContext           *context,
1103                                           GimpProgress          *progress,
1104                                           const GimpValueArray  *args,
1105                                           GError               **error)
1106 {
1107   gboolean success = TRUE;
1108   const gchar *name;
1109   gint32 start_segment;
1110   gint32 end_segment;
1111   gint32 replicate_times;
1112 
1113   name = g_value_get_string (gimp_value_array_index (args, 0));
1114   start_segment = g_value_get_int (gimp_value_array_index (args, 1));
1115   end_segment = g_value_get_int (gimp_value_array_index (args, 2));
1116   replicate_times = g_value_get_int (gimp_value_array_index (args, 3));
1117 
1118   if (success)
1119     {
1120       GimpGradient        *gradient;
1121       GimpGradientSegment *start_seg;
1122       GimpGradientSegment *end_seg;
1123 
1124       gradient = gradient_get_range (gimp, name, start_segment, end_segment,
1125                                      &start_seg, &end_seg, error);
1126 
1127       if (start_seg && gimp_data_is_writable (GIMP_DATA (gradient)))
1128         {
1129           gimp_gradient_segment_range_replicate (gradient,
1130                                                  start_seg, end_seg,
1131                                                  replicate_times,
1132                                                  NULL, NULL);
1133         }
1134       else
1135         success = FALSE;
1136     }
1137 
1138   return gimp_procedure_get_return_values (procedure, success,
1139                                            error ? *error : NULL);
1140 }
1141 
1142 static GimpValueArray *
gradient_segment_range_split_midpoint_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)1143 gradient_segment_range_split_midpoint_invoker (GimpProcedure         *procedure,
1144                                                Gimp                  *gimp,
1145                                                GimpContext           *context,
1146                                                GimpProgress          *progress,
1147                                                const GimpValueArray  *args,
1148                                                GError               **error)
1149 {
1150   gboolean success = TRUE;
1151   const gchar *name;
1152   gint32 start_segment;
1153   gint32 end_segment;
1154 
1155   name = g_value_get_string (gimp_value_array_index (args, 0));
1156   start_segment = g_value_get_int (gimp_value_array_index (args, 1));
1157   end_segment = g_value_get_int (gimp_value_array_index (args, 2));
1158 
1159   if (success)
1160     {
1161       GimpGradient        *gradient;
1162       GimpGradientSegment *start_seg;
1163       GimpGradientSegment *end_seg;
1164 
1165       gradient = gradient_get_range (gimp, name, start_segment, end_segment,
1166                                      &start_seg, &end_seg, error);
1167 
1168       if (start_seg)
1169         {
1170           gimp_gradient_segment_range_split_midpoint (gradient, context,
1171                                                       start_seg, end_seg,
1172                                                       GIMP_GRADIENT_BLEND_RGB_PERCEPTUAL,
1173                                                       NULL, NULL);
1174         }
1175       else
1176         success = FALSE;
1177     }
1178 
1179   return gimp_procedure_get_return_values (procedure, success,
1180                                            error ? *error : NULL);
1181 }
1182 
1183 static GimpValueArray *
gradient_segment_range_split_uniform_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)1184 gradient_segment_range_split_uniform_invoker (GimpProcedure         *procedure,
1185                                               Gimp                  *gimp,
1186                                               GimpContext           *context,
1187                                               GimpProgress          *progress,
1188                                               const GimpValueArray  *args,
1189                                               GError               **error)
1190 {
1191   gboolean success = TRUE;
1192   const gchar *name;
1193   gint32 start_segment;
1194   gint32 end_segment;
1195   gint32 split_parts;
1196 
1197   name = g_value_get_string (gimp_value_array_index (args, 0));
1198   start_segment = g_value_get_int (gimp_value_array_index (args, 1));
1199   end_segment = g_value_get_int (gimp_value_array_index (args, 2));
1200   split_parts = g_value_get_int (gimp_value_array_index (args, 3));
1201 
1202   if (success)
1203     {
1204       GimpGradient        *gradient;
1205       GimpGradientSegment *start_seg;
1206       GimpGradientSegment *end_seg;
1207 
1208       gradient = gradient_get_range (gimp, name, start_segment, end_segment,
1209                                      &start_seg, &end_seg, error);
1210 
1211       if (start_seg)
1212         {
1213           gimp_gradient_segment_range_split_uniform (gradient, context,
1214                                                      start_seg, end_seg,
1215                                                      split_parts,
1216                                                      GIMP_GRADIENT_BLEND_RGB_PERCEPTUAL,
1217                                                      NULL, NULL);
1218         }
1219       else
1220         success = FALSE;
1221     }
1222 
1223   return gimp_procedure_get_return_values (procedure, success,
1224                                            error ? *error : NULL);
1225 }
1226 
1227 static GimpValueArray *
gradient_segment_range_delete_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)1228 gradient_segment_range_delete_invoker (GimpProcedure         *procedure,
1229                                        Gimp                  *gimp,
1230                                        GimpContext           *context,
1231                                        GimpProgress          *progress,
1232                                        const GimpValueArray  *args,
1233                                        GError               **error)
1234 {
1235   gboolean success = TRUE;
1236   const gchar *name;
1237   gint32 start_segment;
1238   gint32 end_segment;
1239 
1240   name = g_value_get_string (gimp_value_array_index (args, 0));
1241   start_segment = g_value_get_int (gimp_value_array_index (args, 1));
1242   end_segment = g_value_get_int (gimp_value_array_index (args, 2));
1243 
1244   if (success)
1245     {
1246       GimpGradient        *gradient;
1247       GimpGradientSegment *start_seg;
1248       GimpGradientSegment *end_seg;
1249 
1250       gradient = gradient_get_range (gimp, name, start_segment, end_segment,
1251                                      &start_seg, &end_seg, error);
1252 
1253       if (start_seg)
1254         {
1255           gimp_gradient_segment_range_delete (gradient,
1256                                               start_seg, end_seg,
1257                                               NULL, NULL);
1258         }
1259       else
1260         success = FALSE;
1261     }
1262 
1263   return gimp_procedure_get_return_values (procedure, success,
1264                                            error ? *error : NULL);
1265 }
1266 
1267 static GimpValueArray *
gradient_segment_range_redistribute_handles_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)1268 gradient_segment_range_redistribute_handles_invoker (GimpProcedure         *procedure,
1269                                                      Gimp                  *gimp,
1270                                                      GimpContext           *context,
1271                                                      GimpProgress          *progress,
1272                                                      const GimpValueArray  *args,
1273                                                      GError               **error)
1274 {
1275   gboolean success = TRUE;
1276   const gchar *name;
1277   gint32 start_segment;
1278   gint32 end_segment;
1279 
1280   name = g_value_get_string (gimp_value_array_index (args, 0));
1281   start_segment = g_value_get_int (gimp_value_array_index (args, 1));
1282   end_segment = g_value_get_int (gimp_value_array_index (args, 2));
1283 
1284   if (success)
1285     {
1286       GimpGradient        *gradient;
1287       GimpGradientSegment *start_seg;
1288       GimpGradientSegment *end_seg;
1289 
1290       gradient = gradient_get_range (gimp, name, start_segment, end_segment,
1291                                      &start_seg, &end_seg, error);
1292 
1293       if (start_seg)
1294         {
1295           gimp_gradient_segment_range_redistribute_handles (gradient,
1296                                                             start_seg, end_seg);
1297         }
1298       else
1299         success = FALSE;
1300     }
1301 
1302   return gimp_procedure_get_return_values (procedure, success,
1303                                            error ? *error : NULL);
1304 }
1305 
1306 static GimpValueArray *
gradient_segment_range_blend_colors_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)1307 gradient_segment_range_blend_colors_invoker (GimpProcedure         *procedure,
1308                                              Gimp                  *gimp,
1309                                              GimpContext           *context,
1310                                              GimpProgress          *progress,
1311                                              const GimpValueArray  *args,
1312                                              GError               **error)
1313 {
1314   gboolean success = TRUE;
1315   const gchar *name;
1316   gint32 start_segment;
1317   gint32 end_segment;
1318 
1319   name = g_value_get_string (gimp_value_array_index (args, 0));
1320   start_segment = g_value_get_int (gimp_value_array_index (args, 1));
1321   end_segment = g_value_get_int (gimp_value_array_index (args, 2));
1322 
1323   if (success)
1324     {
1325       GimpGradient        *gradient;
1326       GimpGradientSegment *start_seg;
1327       GimpGradientSegment *end_seg;
1328 
1329       gradient = gradient_get_range (gimp, name, start_segment, end_segment,
1330                                      &start_seg, &end_seg, error);
1331 
1332       if (start_seg)
1333         {
1334           if (!end_seg)
1335             end_seg = gimp_gradient_segment_get_last (start_seg);
1336 
1337           gimp_gradient_segment_range_blend (gradient,
1338                                              start_seg, end_seg,
1339                                              &start_seg->left_color,
1340                                              &end_seg->right_color,
1341                                              TRUE, FALSE);
1342         }
1343       else
1344         success = FALSE;
1345     }
1346 
1347   return gimp_procedure_get_return_values (procedure, success,
1348                                            error ? *error : NULL);
1349 }
1350 
1351 static GimpValueArray *
gradient_segment_range_blend_opacity_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)1352 gradient_segment_range_blend_opacity_invoker (GimpProcedure         *procedure,
1353                                               Gimp                  *gimp,
1354                                               GimpContext           *context,
1355                                               GimpProgress          *progress,
1356                                               const GimpValueArray  *args,
1357                                               GError               **error)
1358 {
1359   gboolean success = TRUE;
1360   const gchar *name;
1361   gint32 start_segment;
1362   gint32 end_segment;
1363 
1364   name = g_value_get_string (gimp_value_array_index (args, 0));
1365   start_segment = g_value_get_int (gimp_value_array_index (args, 1));
1366   end_segment = g_value_get_int (gimp_value_array_index (args, 2));
1367 
1368   if (success)
1369     {
1370       GimpGradient        *gradient;
1371       GimpGradientSegment *start_seg;
1372       GimpGradientSegment *end_seg;
1373 
1374       gradient = gradient_get_range (gimp, name, start_segment, end_segment,
1375                                      &start_seg, &end_seg, error);
1376 
1377       if (start_seg)
1378         {
1379           if (!end_seg)
1380             end_seg = gimp_gradient_segment_get_last (start_seg);
1381 
1382           gimp_gradient_segment_range_blend (gradient,
1383                                              start_seg, end_seg,
1384                                              &start_seg->left_color,
1385                                              &end_seg->right_color,
1386                                              FALSE, TRUE);
1387         }
1388       else
1389         success = FALSE;
1390     }
1391 
1392   return gimp_procedure_get_return_values (procedure, success,
1393                                            error ? *error : NULL);
1394 }
1395 
1396 static GimpValueArray *
gradient_segment_range_move_invoker(GimpProcedure * procedure,Gimp * gimp,GimpContext * context,GimpProgress * progress,const GimpValueArray * args,GError ** error)1397 gradient_segment_range_move_invoker (GimpProcedure         *procedure,
1398                                      Gimp                  *gimp,
1399                                      GimpContext           *context,
1400                                      GimpProgress          *progress,
1401                                      const GimpValueArray  *args,
1402                                      GError               **error)
1403 {
1404   gboolean success = TRUE;
1405   GimpValueArray *return_vals;
1406   const gchar *name;
1407   gint32 start_segment;
1408   gint32 end_segment;
1409   gdouble delta;
1410   gboolean control_compress;
1411   gdouble final_delta = 0.0;
1412 
1413   name = g_value_get_string (gimp_value_array_index (args, 0));
1414   start_segment = g_value_get_int (gimp_value_array_index (args, 1));
1415   end_segment = g_value_get_int (gimp_value_array_index (args, 2));
1416   delta = g_value_get_double (gimp_value_array_index (args, 3));
1417   control_compress = g_value_get_boolean (gimp_value_array_index (args, 4));
1418 
1419   if (success)
1420     {
1421       GimpGradient        *gradient;
1422       GimpGradientSegment *start_seg;
1423       GimpGradientSegment *end_seg;
1424 
1425       gradient = gradient_get_range (gimp, name, start_segment, end_segment,
1426                                      &start_seg, &end_seg, error);
1427 
1428       if (start_seg)
1429         {
1430           final_delta = gimp_gradient_segment_range_move (gradient,
1431                                                           start_seg, end_seg,
1432                                                           delta,
1433                                                           control_compress);
1434         }
1435       else
1436         success = FALSE;
1437     }
1438 
1439   return_vals = gimp_procedure_get_return_values (procedure, success,
1440                                                   error ? *error : NULL);
1441 
1442   if (success)
1443     g_value_set_double (gimp_value_array_index (return_vals, 1), final_delta);
1444 
1445   return return_vals;
1446 }
1447 
1448 void
register_gradient_procs(GimpPDB * pdb)1449 register_gradient_procs (GimpPDB *pdb)
1450 {
1451   GimpProcedure *procedure;
1452 
1453   /*
1454    * gimp-gradient-new
1455    */
1456   procedure = gimp_procedure_new (gradient_new_invoker);
1457   gimp_object_set_static_name (GIMP_OBJECT (procedure),
1458                                "gimp-gradient-new");
1459   gimp_procedure_set_static_strings (procedure,
1460                                      "gimp-gradient-new",
1461                                      "Creates a new gradient",
1462                                      "This procedure creates a new, uninitialized gradient",
1463                                      "Shlomi Fish <shlomif@iglu.org.il>",
1464                                      "Shlomi Fish",
1465                                      "2003",
1466                                      NULL);
1467   gimp_procedure_add_argument (procedure,
1468                                gimp_param_spec_string ("name",
1469                                                        "name",
1470                                                        "The requested name of the new gradient",
1471                                                        FALSE, FALSE, TRUE,
1472                                                        NULL,
1473                                                        GIMP_PARAM_READWRITE));
1474   gimp_procedure_add_return_value (procedure,
1475                                    gimp_param_spec_string ("actual-name",
1476                                                            "actual name",
1477                                                            "The actual new gradient name",
1478                                                            FALSE, FALSE, FALSE,
1479                                                            NULL,
1480                                                            GIMP_PARAM_READWRITE));
1481   gimp_pdb_register_procedure (pdb, procedure);
1482   g_object_unref (procedure);
1483 
1484   /*
1485    * gimp-gradient-duplicate
1486    */
1487   procedure = gimp_procedure_new (gradient_duplicate_invoker);
1488   gimp_object_set_static_name (GIMP_OBJECT (procedure),
1489                                "gimp-gradient-duplicate");
1490   gimp_procedure_set_static_strings (procedure,
1491                                      "gimp-gradient-duplicate",
1492                                      "Duplicates a gradient",
1493                                      "This procedure creates an identical gradient by a different name",
1494                                      "Shlomi Fish <shlomif@iglu.org.il>",
1495                                      "Shlomi Fish",
1496                                      "2003",
1497                                      NULL);
1498   gimp_procedure_add_argument (procedure,
1499                                gimp_param_spec_string ("name",
1500                                                        "name",
1501                                                        "The gradient name",
1502                                                        FALSE, FALSE, TRUE,
1503                                                        NULL,
1504                                                        GIMP_PARAM_READWRITE));
1505   gimp_procedure_add_return_value (procedure,
1506                                    gimp_param_spec_string ("copy-name",
1507                                                            "copy name",
1508                                                            "The name of the gradient's copy",
1509                                                            FALSE, FALSE, FALSE,
1510                                                            NULL,
1511                                                            GIMP_PARAM_READWRITE));
1512   gimp_pdb_register_procedure (pdb, procedure);
1513   g_object_unref (procedure);
1514 
1515   /*
1516    * gimp-gradient-is-editable
1517    */
1518   procedure = gimp_procedure_new (gradient_is_editable_invoker);
1519   gimp_object_set_static_name (GIMP_OBJECT (procedure),
1520                                "gimp-gradient-is-editable");
1521   gimp_procedure_set_static_strings (procedure,
1522                                      "gimp-gradient-is-editable",
1523                                      "Tests if gradient can be edited",
1524                                      "Returns TRUE if you have permission to change the gradient",
1525                                      "Bill Skaggs <weskaggs@primate.ucdavis.edu>",
1526                                      "Bill Skaggs",
1527                                      "2004",
1528                                      NULL);
1529   gimp_procedure_add_argument (procedure,
1530                                gimp_param_spec_string ("name",
1531                                                        "name",
1532                                                        "The gradient name",
1533                                                        FALSE, FALSE, TRUE,
1534                                                        NULL,
1535                                                        GIMP_PARAM_READWRITE));
1536   gimp_procedure_add_return_value (procedure,
1537                                    g_param_spec_boolean ("editable",
1538                                                          "editable",
1539                                                          "TRUE if the gradient can be edited",
1540                                                          FALSE,
1541                                                          GIMP_PARAM_READWRITE));
1542   gimp_pdb_register_procedure (pdb, procedure);
1543   g_object_unref (procedure);
1544 
1545   /*
1546    * gimp-gradient-rename
1547    */
1548   procedure = gimp_procedure_new (gradient_rename_invoker);
1549   gimp_object_set_static_name (GIMP_OBJECT (procedure),
1550                                "gimp-gradient-rename");
1551   gimp_procedure_set_static_strings (procedure,
1552                                      "gimp-gradient-rename",
1553                                      "Rename a gradient",
1554                                      "This procedure renames a gradient",
1555                                      "Shlomi Fish <shlomif@iglu.org.il>",
1556                                      "Shlomi Fish",
1557                                      "2003",
1558                                      NULL);
1559   gimp_procedure_add_argument (procedure,
1560                                gimp_param_spec_string ("name",
1561                                                        "name",
1562                                                        "The gradient name",
1563                                                        FALSE, FALSE, TRUE,
1564                                                        NULL,
1565                                                        GIMP_PARAM_READWRITE));
1566   gimp_procedure_add_argument (procedure,
1567                                gimp_param_spec_string ("new-name",
1568                                                        "new name",
1569                                                        "The new name of the gradient",
1570                                                        FALSE, FALSE, TRUE,
1571                                                        NULL,
1572                                                        GIMP_PARAM_READWRITE));
1573   gimp_procedure_add_return_value (procedure,
1574                                    gimp_param_spec_string ("actual-name",
1575                                                            "actual name",
1576                                                            "The actual new name of the gradient",
1577                                                            FALSE, FALSE, FALSE,
1578                                                            NULL,
1579                                                            GIMP_PARAM_READWRITE));
1580   gimp_pdb_register_procedure (pdb, procedure);
1581   g_object_unref (procedure);
1582 
1583   /*
1584    * gimp-gradient-delete
1585    */
1586   procedure = gimp_procedure_new (gradient_delete_invoker);
1587   gimp_object_set_static_name (GIMP_OBJECT (procedure),
1588                                "gimp-gradient-delete");
1589   gimp_procedure_set_static_strings (procedure,
1590                                      "gimp-gradient-delete",
1591                                      "Deletes a gradient",
1592                                      "This procedure deletes a gradient",
1593                                      "Shlomi Fish <shlomif@iglu.org.il>",
1594                                      "Shlomi Fish",
1595                                      "2003",
1596                                      NULL);
1597   gimp_procedure_add_argument (procedure,
1598                                gimp_param_spec_string ("name",
1599                                                        "name",
1600                                                        "The gradient name",
1601                                                        FALSE, FALSE, TRUE,
1602                                                        NULL,
1603                                                        GIMP_PARAM_READWRITE));
1604   gimp_pdb_register_procedure (pdb, procedure);
1605   g_object_unref (procedure);
1606 
1607   /*
1608    * gimp-gradient-get-number-of-segments
1609    */
1610   procedure = gimp_procedure_new (gradient_get_number_of_segments_invoker);
1611   gimp_object_set_static_name (GIMP_OBJECT (procedure),
1612                                "gimp-gradient-get-number-of-segments");
1613   gimp_procedure_set_static_strings (procedure,
1614                                      "gimp-gradient-get-number-of-segments",
1615                                      "Returns the number of segments of the specified gradient",
1616                                      "This procedure returns the number of segments of the specified gradient.",
1617                                      "Lars-Peter Clausen <lars@metafoo.de>",
1618                                      "Lars-Peter Clausen",
1619                                      "2008",
1620                                      NULL);
1621   gimp_procedure_add_argument (procedure,
1622                                gimp_param_spec_string ("name",
1623                                                        "name",
1624                                                        "The gradient name",
1625                                                        FALSE, FALSE, TRUE,
1626                                                        NULL,
1627                                                        GIMP_PARAM_READWRITE));
1628   gimp_procedure_add_return_value (procedure,
1629                                    gimp_param_spec_int32 ("num-segments",
1630                                                           "num segments",
1631                                                           "Number of segments",
1632                                                           G_MININT32, G_MAXINT32, 0,
1633                                                           GIMP_PARAM_READWRITE));
1634   gimp_pdb_register_procedure (pdb, procedure);
1635   g_object_unref (procedure);
1636 
1637   /*
1638    * gimp-gradient-get-uniform-samples
1639    */
1640   procedure = gimp_procedure_new (gradient_get_uniform_samples_invoker);
1641   gimp_object_set_static_name (GIMP_OBJECT (procedure),
1642                                "gimp-gradient-get-uniform-samples");
1643   gimp_procedure_set_static_strings (procedure,
1644                                      "gimp-gradient-get-uniform-samples",
1645                                      "Sample the specified in uniform parts.",
1646                                      "This procedure samples the active gradient in the specified number of uniform parts. It returns a list of floating-point values which correspond to the RGBA values for each sample. The minimum number of samples to take is 2, in which case the returned colors will correspond to the { 0.0, 1.0 } positions in the gradient. For example, if the number of samples is 3, the procedure will return the colors at positions { 0.0, 0.5, 1.0 }.",
1647                                      "Federico Mena Quintero",
1648                                      "Federico Mena Quintero",
1649                                      "1997",
1650                                      NULL);
1651   gimp_procedure_add_argument (procedure,
1652                                gimp_param_spec_string ("name",
1653                                                        "name",
1654                                                        "The gradient name",
1655                                                        FALSE, FALSE, TRUE,
1656                                                        NULL,
1657                                                        GIMP_PARAM_READWRITE));
1658   gimp_procedure_add_argument (procedure,
1659                                gimp_param_spec_int32 ("num-samples",
1660                                                       "num samples",
1661                                                       "The number of samples to take",
1662                                                       2, G_MAXINT32, 2,
1663                                                       GIMP_PARAM_READWRITE));
1664   gimp_procedure_add_argument (procedure,
1665                                g_param_spec_boolean ("reverse",
1666                                                      "reverse",
1667                                                      "Use the reverse gradient",
1668                                                      FALSE,
1669                                                      GIMP_PARAM_READWRITE));
1670   gimp_procedure_add_return_value (procedure,
1671                                    gimp_param_spec_int32 ("num-color-samples",
1672                                                           "num color samples",
1673                                                           "Length of the color_samples array (4 * num_samples)",
1674                                                           0, G_MAXINT32, 0,
1675                                                           GIMP_PARAM_READWRITE));
1676   gimp_procedure_add_return_value (procedure,
1677                                    gimp_param_spec_float_array ("color-samples",
1678                                                                 "color samples",
1679                                                                 "Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }",
1680                                                                 GIMP_PARAM_READWRITE));
1681   gimp_pdb_register_procedure (pdb, procedure);
1682   g_object_unref (procedure);
1683 
1684   /*
1685    * gimp-gradient-get-custom-samples
1686    */
1687   procedure = gimp_procedure_new (gradient_get_custom_samples_invoker);
1688   gimp_object_set_static_name (GIMP_OBJECT (procedure),
1689                                "gimp-gradient-get-custom-samples");
1690   gimp_procedure_set_static_strings (procedure,
1691                                      "gimp-gradient-get-custom-samples",
1692                                      "Sample the specified gradient in custom positions.",
1693                                      "This procedure samples the active gradient in the specified number of points. The procedure will sample the gradient in the specified positions from the list. The left endpoint of the gradient corresponds to position 0.0, and the right endpoint corresponds to 1.0. The procedure returns a list of floating-point values which correspond to the RGBA values for each sample.",
1694                                      "Federico Mena Quintero",
1695                                      "Federico Mena Quintero",
1696                                      "1997",
1697                                      NULL);
1698   gimp_procedure_add_argument (procedure,
1699                                gimp_param_spec_string ("name",
1700                                                        "name",
1701                                                        "The gradient name",
1702                                                        FALSE, FALSE, TRUE,
1703                                                        NULL,
1704                                                        GIMP_PARAM_READWRITE));
1705   gimp_procedure_add_argument (procedure,
1706                                gimp_param_spec_int32 ("num-samples",
1707                                                       "num samples",
1708                                                       "The number of samples to take",
1709                                                       1, G_MAXINT32, 1,
1710                                                       GIMP_PARAM_READWRITE));
1711   gimp_procedure_add_argument (procedure,
1712                                gimp_param_spec_float_array ("positions",
1713                                                             "positions",
1714                                                             "The list of positions to sample along the gradient",
1715                                                             GIMP_PARAM_READWRITE));
1716   gimp_procedure_add_argument (procedure,
1717                                g_param_spec_boolean ("reverse",
1718                                                      "reverse",
1719                                                      "Use the reverse gradient",
1720                                                      FALSE,
1721                                                      GIMP_PARAM_READWRITE));
1722   gimp_procedure_add_return_value (procedure,
1723                                    gimp_param_spec_int32 ("num-color-samples",
1724                                                           "num color samples",
1725                                                           "Length of the color_samples array (4 * num_samples)",
1726                                                           0, G_MAXINT32, 0,
1727                                                           GIMP_PARAM_READWRITE));
1728   gimp_procedure_add_return_value (procedure,
1729                                    gimp_param_spec_float_array ("color-samples",
1730                                                                 "color samples",
1731                                                                 "Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }",
1732                                                                 GIMP_PARAM_READWRITE));
1733   gimp_pdb_register_procedure (pdb, procedure);
1734   g_object_unref (procedure);
1735 
1736   /*
1737    * gimp-gradient-segment-get-left-color
1738    */
1739   procedure = gimp_procedure_new (gradient_segment_get_left_color_invoker);
1740   gimp_object_set_static_name (GIMP_OBJECT (procedure),
1741                                "gimp-gradient-segment-get-left-color");
1742   gimp_procedure_set_static_strings (procedure,
1743                                      "gimp-gradient-segment-get-left-color",
1744                                      "Retrieves the left endpoint color of the specified segment",
1745                                      "This procedure retrieves the left endpoint color of the specified segment of the specified gradient.",
1746                                      "Shlomi Fish <shlomif@iglu.org.il>",
1747                                      "Shlomi Fish",
1748                                      "2003",
1749                                      NULL);
1750   gimp_procedure_add_argument (procedure,
1751                                gimp_param_spec_string ("name",
1752                                                        "name",
1753                                                        "The gradient name",
1754                                                        FALSE, FALSE, TRUE,
1755                                                        NULL,
1756                                                        GIMP_PARAM_READWRITE));
1757   gimp_procedure_add_argument (procedure,
1758                                gimp_param_spec_int32 ("segment",
1759                                                       "segment",
1760                                                       "The index of the segment within the gradient",
1761                                                       0, G_MAXINT32, 0,
1762                                                       GIMP_PARAM_READWRITE));
1763   gimp_procedure_add_return_value (procedure,
1764                                    gimp_param_spec_rgb ("color",
1765                                                         "color",
1766                                                         "The return color",
1767                                                         FALSE,
1768                                                         NULL,
1769                                                         GIMP_PARAM_READWRITE));
1770   gimp_procedure_add_return_value (procedure,
1771                                    g_param_spec_double ("opacity",
1772                                                         "opacity",
1773                                                         "The opacity of the endpoint",
1774                                                         -G_MAXDOUBLE, G_MAXDOUBLE, 0,
1775                                                         GIMP_PARAM_READWRITE));
1776   gimp_pdb_register_procedure (pdb, procedure);
1777   g_object_unref (procedure);
1778 
1779   /*
1780    * gimp-gradient-segment-set-left-color
1781    */
1782   procedure = gimp_procedure_new (gradient_segment_set_left_color_invoker);
1783   gimp_object_set_static_name (GIMP_OBJECT (procedure),
1784                                "gimp-gradient-segment-set-left-color");
1785   gimp_procedure_set_static_strings (procedure,
1786                                      "gimp-gradient-segment-set-left-color",
1787                                      "Sets the left endpoint color of the specified segment",
1788                                      "This procedure sets the left endpoint color of the specified segment of the specified gradient.",
1789                                      "Shlomi Fish <shlomif@iglu.org.il>",
1790                                      "Shlomi Fish",
1791                                      "2003",
1792                                      NULL);
1793   gimp_procedure_add_argument (procedure,
1794                                gimp_param_spec_string ("name",
1795                                                        "name",
1796                                                        "The gradient name",
1797                                                        FALSE, FALSE, TRUE,
1798                                                        NULL,
1799                                                        GIMP_PARAM_READWRITE));
1800   gimp_procedure_add_argument (procedure,
1801                                gimp_param_spec_int32 ("segment",
1802                                                       "segment",
1803                                                       "The index of the segment within the gradient",
1804                                                       0, G_MAXINT32, 0,
1805                                                       GIMP_PARAM_READWRITE));
1806   gimp_procedure_add_argument (procedure,
1807                                gimp_param_spec_rgb ("color",
1808                                                     "color",
1809                                                     "The color to set",
1810                                                     FALSE,
1811                                                     NULL,
1812                                                     GIMP_PARAM_READWRITE));
1813   gimp_procedure_add_argument (procedure,
1814                                g_param_spec_double ("opacity",
1815                                                     "opacity",
1816                                                     "The opacity to set for the endpoint",
1817                                                     0, 100.0, 0,
1818                                                     GIMP_PARAM_READWRITE));
1819   gimp_pdb_register_procedure (pdb, procedure);
1820   g_object_unref (procedure);
1821 
1822   /*
1823    * gimp-gradient-segment-get-right-color
1824    */
1825   procedure = gimp_procedure_new (gradient_segment_get_right_color_invoker);
1826   gimp_object_set_static_name (GIMP_OBJECT (procedure),
1827                                "gimp-gradient-segment-get-right-color");
1828   gimp_procedure_set_static_strings (procedure,
1829                                      "gimp-gradient-segment-get-right-color",
1830                                      "Retrieves the right endpoint color of the specified segment",
1831                                      "This procedure retrieves the right endpoint color of the specified segment of the specified gradient.",
1832                                      "Shlomi Fish <shlomif@iglu.org.il>",
1833                                      "Shlomi Fish",
1834                                      "2003",
1835                                      NULL);
1836   gimp_procedure_add_argument (procedure,
1837                                gimp_param_spec_string ("name",
1838                                                        "name",
1839                                                        "The gradient name",
1840                                                        FALSE, FALSE, TRUE,
1841                                                        NULL,
1842                                                        GIMP_PARAM_READWRITE));
1843   gimp_procedure_add_argument (procedure,
1844                                gimp_param_spec_int32 ("segment",
1845                                                       "segment",
1846                                                       "The index of the segment within the gradient",
1847                                                       0, G_MAXINT32, 0,
1848                                                       GIMP_PARAM_READWRITE));
1849   gimp_procedure_add_return_value (procedure,
1850                                    gimp_param_spec_rgb ("color",
1851                                                         "color",
1852                                                         "The return color",
1853                                                         FALSE,
1854                                                         NULL,
1855                                                         GIMP_PARAM_READWRITE));
1856   gimp_procedure_add_return_value (procedure,
1857                                    g_param_spec_double ("opacity",
1858                                                         "opacity",
1859                                                         "The opacity of the endpoint",
1860                                                         -G_MAXDOUBLE, G_MAXDOUBLE, 0,
1861                                                         GIMP_PARAM_READWRITE));
1862   gimp_pdb_register_procedure (pdb, procedure);
1863   g_object_unref (procedure);
1864 
1865   /*
1866    * gimp-gradient-segment-set-right-color
1867    */
1868   procedure = gimp_procedure_new (gradient_segment_set_right_color_invoker);
1869   gimp_object_set_static_name (GIMP_OBJECT (procedure),
1870                                "gimp-gradient-segment-set-right-color");
1871   gimp_procedure_set_static_strings (procedure,
1872                                      "gimp-gradient-segment-set-right-color",
1873                                      "Sets the right endpoint color of the specified segment",
1874                                      "This procedure sets the right endpoint color of the specified segment of the specified gradient.",
1875                                      "Shlomi Fish <shlomif@iglu.org.il>",
1876                                      "Shlomi Fish",
1877                                      "2003",
1878                                      NULL);
1879   gimp_procedure_add_argument (procedure,
1880                                gimp_param_spec_string ("name",
1881                                                        "name",
1882                                                        "The gradient name",
1883                                                        FALSE, FALSE, TRUE,
1884                                                        NULL,
1885                                                        GIMP_PARAM_READWRITE));
1886   gimp_procedure_add_argument (procedure,
1887                                gimp_param_spec_int32 ("segment",
1888                                                       "segment",
1889                                                       "The index of the segment within the gradient",
1890                                                       0, G_MAXINT32, 0,
1891                                                       GIMP_PARAM_READWRITE));
1892   gimp_procedure_add_argument (procedure,
1893                                gimp_param_spec_rgb ("color",
1894                                                     "color",
1895                                                     "The color to set",
1896                                                     FALSE,
1897                                                     NULL,
1898                                                     GIMP_PARAM_READWRITE));
1899   gimp_procedure_add_argument (procedure,
1900                                g_param_spec_double ("opacity",
1901                                                     "opacity",
1902                                                     "The opacity to set for the endpoint",
1903                                                     0, 100.0, 0,
1904                                                     GIMP_PARAM_READWRITE));
1905   gimp_pdb_register_procedure (pdb, procedure);
1906   g_object_unref (procedure);
1907 
1908   /*
1909    * gimp-gradient-segment-get-left-pos
1910    */
1911   procedure = gimp_procedure_new (gradient_segment_get_left_pos_invoker);
1912   gimp_object_set_static_name (GIMP_OBJECT (procedure),
1913                                "gimp-gradient-segment-get-left-pos");
1914   gimp_procedure_set_static_strings (procedure,
1915                                      "gimp-gradient-segment-get-left-pos",
1916                                      "Retrieves the left endpoint position of the specified segment",
1917                                      "This procedure retrieves the left endpoint position of the specified segment of the specified gradient.",
1918                                      "Shlomi Fish <shlomif@iglu.org.il>",
1919                                      "Shlomi Fish",
1920                                      "2003",
1921                                      NULL);
1922   gimp_procedure_add_argument (procedure,
1923                                gimp_param_spec_string ("name",
1924                                                        "name",
1925                                                        "The gradient name",
1926                                                        FALSE, FALSE, TRUE,
1927                                                        NULL,
1928                                                        GIMP_PARAM_READWRITE));
1929   gimp_procedure_add_argument (procedure,
1930                                gimp_param_spec_int32 ("segment",
1931                                                       "segment",
1932                                                       "The index of the segment within the gradient",
1933                                                       0, G_MAXINT32, 0,
1934                                                       GIMP_PARAM_READWRITE));
1935   gimp_procedure_add_return_value (procedure,
1936                                    g_param_spec_double ("pos",
1937                                                         "pos",
1938                                                         "The return position",
1939                                                         -G_MAXDOUBLE, G_MAXDOUBLE, 0,
1940                                                         GIMP_PARAM_READWRITE));
1941   gimp_pdb_register_procedure (pdb, procedure);
1942   g_object_unref (procedure);
1943 
1944   /*
1945    * gimp-gradient-segment-set-left-pos
1946    */
1947   procedure = gimp_procedure_new (gradient_segment_set_left_pos_invoker);
1948   gimp_object_set_static_name (GIMP_OBJECT (procedure),
1949                                "gimp-gradient-segment-set-left-pos");
1950   gimp_procedure_set_static_strings (procedure,
1951                                      "gimp-gradient-segment-set-left-pos",
1952                                      "Sets the left endpoint position of the specified segment",
1953                                      "This procedure sets the left endpoint position of the specified segment of the specified gradient. The final position will be between the position of the middle point to the left to the middle point of the current segment.\n"
1954                                      "This procedure returns the final position.",
1955                                      "Shlomi Fish <shlomif@iglu.org.il>",
1956                                      "Shlomi Fish",
1957                                      "2003",
1958                                      NULL);
1959   gimp_procedure_add_argument (procedure,
1960                                gimp_param_spec_string ("name",
1961                                                        "name",
1962                                                        "The gradient name",
1963                                                        FALSE, FALSE, TRUE,
1964                                                        NULL,
1965                                                        GIMP_PARAM_READWRITE));
1966   gimp_procedure_add_argument (procedure,
1967                                gimp_param_spec_int32 ("segment",
1968                                                       "segment",
1969                                                       "The index of the segment within the gradient",
1970                                                       0, G_MAXINT32, 0,
1971                                                       GIMP_PARAM_READWRITE));
1972   gimp_procedure_add_argument (procedure,
1973                                g_param_spec_double ("pos",
1974                                                     "pos",
1975                                                     "The position to set the guidepoint to",
1976                                                     0.0, 1.0, 0.0,
1977                                                     GIMP_PARAM_READWRITE));
1978   gimp_procedure_add_return_value (procedure,
1979                                    g_param_spec_double ("final-pos",
1980                                                         "final pos",
1981                                                         "The return position",
1982                                                         -G_MAXDOUBLE, G_MAXDOUBLE, 0,
1983                                                         GIMP_PARAM_READWRITE));
1984   gimp_pdb_register_procedure (pdb, procedure);
1985   g_object_unref (procedure);
1986 
1987   /*
1988    * gimp-gradient-segment-get-middle-pos
1989    */
1990   procedure = gimp_procedure_new (gradient_segment_get_middle_pos_invoker);
1991   gimp_object_set_static_name (GIMP_OBJECT (procedure),
1992                                "gimp-gradient-segment-get-middle-pos");
1993   gimp_procedure_set_static_strings (procedure,
1994                                      "gimp-gradient-segment-get-middle-pos",
1995                                      "Retrieves the middle point position of the specified segment",
1996                                      "This procedure retrieves the middle point position of the specified segment of the specified gradient.",
1997                                      "Shlomi Fish <shlomif@iglu.org.il>",
1998                                      "Shlomi Fish",
1999                                      "2003",
2000                                      NULL);
2001   gimp_procedure_add_argument (procedure,
2002                                gimp_param_spec_string ("name",
2003                                                        "name",
2004                                                        "The gradient name",
2005                                                        FALSE, FALSE, TRUE,
2006                                                        NULL,
2007                                                        GIMP_PARAM_READWRITE));
2008   gimp_procedure_add_argument (procedure,
2009                                gimp_param_spec_int32 ("segment",
2010                                                       "segment",
2011                                                       "The index of the segment within the gradient",
2012                                                       0, G_MAXINT32, 0,
2013                                                       GIMP_PARAM_READWRITE));
2014   gimp_procedure_add_return_value (procedure,
2015                                    g_param_spec_double ("pos",
2016                                                         "pos",
2017                                                         "The return position",
2018                                                         -G_MAXDOUBLE, G_MAXDOUBLE, 0,
2019                                                         GIMP_PARAM_READWRITE));
2020   gimp_pdb_register_procedure (pdb, procedure);
2021   g_object_unref (procedure);
2022 
2023   /*
2024    * gimp-gradient-segment-set-middle-pos
2025    */
2026   procedure = gimp_procedure_new (gradient_segment_set_middle_pos_invoker);
2027   gimp_object_set_static_name (GIMP_OBJECT (procedure),
2028                                "gimp-gradient-segment-set-middle-pos");
2029   gimp_procedure_set_static_strings (procedure,
2030                                      "gimp-gradient-segment-set-middle-pos",
2031                                      "Sets the middle point position of the specified segment",
2032                                      "This procedure sets the middle point position of the specified segment of the specified gradient. The final position will be between the two endpoints of the segment.\n"
2033                                      "This procedure returns the final position.",
2034                                      "Shlomi Fish <shlomif@iglu.org.il>",
2035                                      "Shlomi Fish",
2036                                      "2003",
2037                                      NULL);
2038   gimp_procedure_add_argument (procedure,
2039                                gimp_param_spec_string ("name",
2040                                                        "name",
2041                                                        "The gradient name",
2042                                                        FALSE, FALSE, TRUE,
2043                                                        NULL,
2044                                                        GIMP_PARAM_READWRITE));
2045   gimp_procedure_add_argument (procedure,
2046                                gimp_param_spec_int32 ("segment",
2047                                                       "segment",
2048                                                       "The index of the segment within the gradient",
2049                                                       0, G_MAXINT32, 0,
2050                                                       GIMP_PARAM_READWRITE));
2051   gimp_procedure_add_argument (procedure,
2052                                g_param_spec_double ("pos",
2053                                                     "pos",
2054                                                     "The position to set the guidepoint to",
2055                                                     0.0, 1.0, 0.0,
2056                                                     GIMP_PARAM_READWRITE));
2057   gimp_procedure_add_return_value (procedure,
2058                                    g_param_spec_double ("final-pos",
2059                                                         "final pos",
2060                                                         "The return position",
2061                                                         -G_MAXDOUBLE, G_MAXDOUBLE, 0,
2062                                                         GIMP_PARAM_READWRITE));
2063   gimp_pdb_register_procedure (pdb, procedure);
2064   g_object_unref (procedure);
2065 
2066   /*
2067    * gimp-gradient-segment-get-right-pos
2068    */
2069   procedure = gimp_procedure_new (gradient_segment_get_right_pos_invoker);
2070   gimp_object_set_static_name (GIMP_OBJECT (procedure),
2071                                "gimp-gradient-segment-get-right-pos");
2072   gimp_procedure_set_static_strings (procedure,
2073                                      "gimp-gradient-segment-get-right-pos",
2074                                      "Retrieves the right endpoint position of the specified segment",
2075                                      "This procedure retrieves the right endpoint position of the specified segment of the specified gradient.",
2076                                      "Shlomi Fish <shlomif@iglu.org.il>",
2077                                      "Shlomi Fish",
2078                                      "2003",
2079                                      NULL);
2080   gimp_procedure_add_argument (procedure,
2081                                gimp_param_spec_string ("name",
2082                                                        "name",
2083                                                        "The gradient name",
2084                                                        FALSE, FALSE, TRUE,
2085                                                        NULL,
2086                                                        GIMP_PARAM_READWRITE));
2087   gimp_procedure_add_argument (procedure,
2088                                gimp_param_spec_int32 ("segment",
2089                                                       "segment",
2090                                                       "The index of the segment within the gradient",
2091                                                       0, G_MAXINT32, 0,
2092                                                       GIMP_PARAM_READWRITE));
2093   gimp_procedure_add_return_value (procedure,
2094                                    g_param_spec_double ("pos",
2095                                                         "pos",
2096                                                         "The return position",
2097                                                         -G_MAXDOUBLE, G_MAXDOUBLE, 0,
2098                                                         GIMP_PARAM_READWRITE));
2099   gimp_pdb_register_procedure (pdb, procedure);
2100   g_object_unref (procedure);
2101 
2102   /*
2103    * gimp-gradient-segment-set-right-pos
2104    */
2105   procedure = gimp_procedure_new (gradient_segment_set_right_pos_invoker);
2106   gimp_object_set_static_name (GIMP_OBJECT (procedure),
2107                                "gimp-gradient-segment-set-right-pos");
2108   gimp_procedure_set_static_strings (procedure,
2109                                      "gimp-gradient-segment-set-right-pos",
2110                                      "Sets the right endpoint position of the specified segment",
2111                                      "This procedure sets the right endpoint position of the specified segment of the specified gradient. The final position will be between the position of the middle point of the current segment and the middle point of the segment to the right.\n"
2112                                      "This procedure returns the final position.",
2113                                      "Shlomi Fish <shlomif@iglu.org.il>",
2114                                      "Shlomi Fish",
2115                                      "2003",
2116                                      NULL);
2117   gimp_procedure_add_argument (procedure,
2118                                gimp_param_spec_string ("name",
2119                                                        "name",
2120                                                        "The gradient name",
2121                                                        FALSE, FALSE, TRUE,
2122                                                        NULL,
2123                                                        GIMP_PARAM_READWRITE));
2124   gimp_procedure_add_argument (procedure,
2125                                gimp_param_spec_int32 ("segment",
2126                                                       "segment",
2127                                                       "The index of the segment within the gradient",
2128                                                       0, G_MAXINT32, 0,
2129                                                       GIMP_PARAM_READWRITE));
2130   gimp_procedure_add_argument (procedure,
2131                                g_param_spec_double ("pos",
2132                                                     "pos",
2133                                                     "The position to set the guidepoint to",
2134                                                     0.0, 1.0, 0.0,
2135                                                     GIMP_PARAM_READWRITE));
2136   gimp_procedure_add_return_value (procedure,
2137                                    g_param_spec_double ("final-pos",
2138                                                         "final pos",
2139                                                         "The return position",
2140                                                         -G_MAXDOUBLE, G_MAXDOUBLE, 0,
2141                                                         GIMP_PARAM_READWRITE));
2142   gimp_pdb_register_procedure (pdb, procedure);
2143   g_object_unref (procedure);
2144 
2145   /*
2146    * gimp-gradient-segment-get-blending-function
2147    */
2148   procedure = gimp_procedure_new (gradient_segment_get_blending_function_invoker);
2149   gimp_object_set_static_name (GIMP_OBJECT (procedure),
2150                                "gimp-gradient-segment-get-blending-function");
2151   gimp_procedure_set_static_strings (procedure,
2152                                      "gimp-gradient-segment-get-blending-function",
2153                                      "Retrieves the gradient segment's blending function",
2154                                      "This procedure retrieves the blending function of the segment at the specified gradient name and segment index.",
2155                                      "Shlomi Fish <shlomif@iglu.org.il>",
2156                                      "Shlomi Fish",
2157                                      "2003",
2158                                      NULL);
2159   gimp_procedure_add_argument (procedure,
2160                                gimp_param_spec_string ("name",
2161                                                        "name",
2162                                                        "The gradient name",
2163                                                        FALSE, FALSE, TRUE,
2164                                                        NULL,
2165                                                        GIMP_PARAM_READWRITE));
2166   gimp_procedure_add_argument (procedure,
2167                                gimp_param_spec_int32 ("segment",
2168                                                       "segment",
2169                                                       "The index of the segment within the gradient",
2170                                                       0, G_MAXINT32, 0,
2171                                                       GIMP_PARAM_READWRITE));
2172   gimp_procedure_add_return_value (procedure,
2173                                    g_param_spec_enum ("blend-func",
2174                                                       "blend func",
2175                                                       "The blending function of the segment",
2176                                                       GIMP_TYPE_GRADIENT_SEGMENT_TYPE,
2177                                                       GIMP_GRADIENT_SEGMENT_LINEAR,
2178                                                       GIMP_PARAM_READWRITE));
2179   gimp_pdb_register_procedure (pdb, procedure);
2180   g_object_unref (procedure);
2181 
2182   /*
2183    * gimp-gradient-segment-get-coloring-type
2184    */
2185   procedure = gimp_procedure_new (gradient_segment_get_coloring_type_invoker);
2186   gimp_object_set_static_name (GIMP_OBJECT (procedure),
2187                                "gimp-gradient-segment-get-coloring-type");
2188   gimp_procedure_set_static_strings (procedure,
2189                                      "gimp-gradient-segment-get-coloring-type",
2190                                      "Retrieves the gradient segment's coloring type",
2191                                      "This procedure retrieves the coloring type of the segment at the specified gradient name and segment index.",
2192                                      "Shlomi Fish <shlomif@iglu.org.il>",
2193                                      "Shlomi Fish",
2194                                      "2003",
2195                                      NULL);
2196   gimp_procedure_add_argument (procedure,
2197                                gimp_param_spec_string ("name",
2198                                                        "name",
2199                                                        "The gradient name",
2200                                                        FALSE, FALSE, TRUE,
2201                                                        NULL,
2202                                                        GIMP_PARAM_READWRITE));
2203   gimp_procedure_add_argument (procedure,
2204                                gimp_param_spec_int32 ("segment",
2205                                                       "segment",
2206                                                       "The index of the segment within the gradient",
2207                                                       0, G_MAXINT32, 0,
2208                                                       GIMP_PARAM_READWRITE));
2209   gimp_procedure_add_return_value (procedure,
2210                                    g_param_spec_enum ("coloring-type",
2211                                                       "coloring type",
2212                                                       "The coloring type of the segment",
2213                                                       GIMP_TYPE_GRADIENT_SEGMENT_COLOR,
2214                                                       GIMP_GRADIENT_SEGMENT_RGB,
2215                                                       GIMP_PARAM_READWRITE));
2216   gimp_pdb_register_procedure (pdb, procedure);
2217   g_object_unref (procedure);
2218 
2219   /*
2220    * gimp-gradient-segment-range-set-blending-function
2221    */
2222   procedure = gimp_procedure_new (gradient_segment_range_set_blending_function_invoker);
2223   gimp_object_set_static_name (GIMP_OBJECT (procedure),
2224                                "gimp-gradient-segment-range-set-blending-function");
2225   gimp_procedure_set_static_strings (procedure,
2226                                      "gimp-gradient-segment-range-set-blending-function",
2227                                      "Change the blending function of a segments range",
2228                                      "This function changes the blending function of a segment range to the specified blending function.",
2229                                      "Shlomi Fish <shlomif@iglu.org.il>",
2230                                      "Shlomi Fish",
2231                                      "2003",
2232                                      NULL);
2233   gimp_procedure_add_argument (procedure,
2234                                gimp_param_spec_string ("name",
2235                                                        "name",
2236                                                        "The gradient name",
2237                                                        FALSE, FALSE, TRUE,
2238                                                        NULL,
2239                                                        GIMP_PARAM_READWRITE));
2240   gimp_procedure_add_argument (procedure,
2241                                gimp_param_spec_int32 ("start-segment",
2242                                                       "start segment",
2243                                                       "The index of the first segment to operate on",
2244                                                       0, G_MAXINT32, 0,
2245                                                       GIMP_PARAM_READWRITE));
2246   gimp_procedure_add_argument (procedure,
2247                                gimp_param_spec_int32 ("end-segment",
2248                                                       "end segment",
2249                                                       "The index of the last segment to operate on. If negative, the selection will extend to the end of the string.",
2250                                                       G_MININT32, G_MAXINT32, 0,
2251                                                       GIMP_PARAM_READWRITE));
2252   gimp_procedure_add_argument (procedure,
2253                                g_param_spec_enum ("blending-function",
2254                                                   "blending function",
2255                                                   "The blending function",
2256                                                   GIMP_TYPE_GRADIENT_SEGMENT_TYPE,
2257                                                   GIMP_GRADIENT_SEGMENT_LINEAR,
2258                                                   GIMP_PARAM_READWRITE));
2259   gimp_pdb_register_procedure (pdb, procedure);
2260   g_object_unref (procedure);
2261 
2262   /*
2263    * gimp-gradient-segment-range-set-coloring-type
2264    */
2265   procedure = gimp_procedure_new (gradient_segment_range_set_coloring_type_invoker);
2266   gimp_object_set_static_name (GIMP_OBJECT (procedure),
2267                                "gimp-gradient-segment-range-set-coloring-type");
2268   gimp_procedure_set_static_strings (procedure,
2269                                      "gimp-gradient-segment-range-set-coloring-type",
2270                                      "Change the coloring type of a segments range",
2271                                      "This function changes the coloring type of a segment range to the specified coloring type.",
2272                                      "Shlomi Fish <shlomif@iglu.org.il>",
2273                                      "Shlomi Fish",
2274                                      "2003",
2275                                      NULL);
2276   gimp_procedure_add_argument (procedure,
2277                                gimp_param_spec_string ("name",
2278                                                        "name",
2279                                                        "The gradient name",
2280                                                        FALSE, FALSE, TRUE,
2281                                                        NULL,
2282                                                        GIMP_PARAM_READWRITE));
2283   gimp_procedure_add_argument (procedure,
2284                                gimp_param_spec_int32 ("start-segment",
2285                                                       "start segment",
2286                                                       "The index of the first segment to operate on",
2287                                                       0, G_MAXINT32, 0,
2288                                                       GIMP_PARAM_READWRITE));
2289   gimp_procedure_add_argument (procedure,
2290                                gimp_param_spec_int32 ("end-segment",
2291                                                       "end segment",
2292                                                       "The index of the last segment to operate on. If negative, the selection will extend to the end of the string.",
2293                                                       G_MININT32, G_MAXINT32, 0,
2294                                                       GIMP_PARAM_READWRITE));
2295   gimp_procedure_add_argument (procedure,
2296                                g_param_spec_enum ("coloring-type",
2297                                                   "coloring type",
2298                                                   "The coloring type",
2299                                                   GIMP_TYPE_GRADIENT_SEGMENT_COLOR,
2300                                                   GIMP_GRADIENT_SEGMENT_RGB,
2301                                                   GIMP_PARAM_READWRITE));
2302   gimp_pdb_register_procedure (pdb, procedure);
2303   g_object_unref (procedure);
2304 
2305   /*
2306    * gimp-gradient-segment-range-flip
2307    */
2308   procedure = gimp_procedure_new (gradient_segment_range_flip_invoker);
2309   gimp_object_set_static_name (GIMP_OBJECT (procedure),
2310                                "gimp-gradient-segment-range-flip");
2311   gimp_procedure_set_static_strings (procedure,
2312                                      "gimp-gradient-segment-range-flip",
2313                                      "Flip the segment range",
2314                                      "This function flips a segment range.",
2315                                      "Shlomi Fish <shlomif@iglu.org.il>",
2316                                      "Shlomi Fish",
2317                                      "2003",
2318                                      NULL);
2319   gimp_procedure_add_argument (procedure,
2320                                gimp_param_spec_string ("name",
2321                                                        "name",
2322                                                        "The gradient name",
2323                                                        FALSE, FALSE, TRUE,
2324                                                        NULL,
2325                                                        GIMP_PARAM_READWRITE));
2326   gimp_procedure_add_argument (procedure,
2327                                gimp_param_spec_int32 ("start-segment",
2328                                                       "start segment",
2329                                                       "The index of the first segment to operate on",
2330                                                       0, G_MAXINT32, 0,
2331                                                       GIMP_PARAM_READWRITE));
2332   gimp_procedure_add_argument (procedure,
2333                                gimp_param_spec_int32 ("end-segment",
2334                                                       "end segment",
2335                                                       "The index of the last segment to operate on. If negative, the selection will extend to the end of the string.",
2336                                                       G_MININT32, G_MAXINT32, 0,
2337                                                       GIMP_PARAM_READWRITE));
2338   gimp_pdb_register_procedure (pdb, procedure);
2339   g_object_unref (procedure);
2340 
2341   /*
2342    * gimp-gradient-segment-range-replicate
2343    */
2344   procedure = gimp_procedure_new (gradient_segment_range_replicate_invoker);
2345   gimp_object_set_static_name (GIMP_OBJECT (procedure),
2346                                "gimp-gradient-segment-range-replicate");
2347   gimp_procedure_set_static_strings (procedure,
2348                                      "gimp-gradient-segment-range-replicate",
2349                                      "Replicate the segment range",
2350                                      "This function replicates a segment range a given number of times. Instead of the original segment range, several smaller scaled copies of it will appear in equal widths.",
2351                                      "Shlomi Fish <shlomif@iglu.org.il>",
2352                                      "Shlomi Fish",
2353                                      "2003",
2354                                      NULL);
2355   gimp_procedure_add_argument (procedure,
2356                                gimp_param_spec_string ("name",
2357                                                        "name",
2358                                                        "The gradient name",
2359                                                        FALSE, FALSE, TRUE,
2360                                                        NULL,
2361                                                        GIMP_PARAM_READWRITE));
2362   gimp_procedure_add_argument (procedure,
2363                                gimp_param_spec_int32 ("start-segment",
2364                                                       "start segment",
2365                                                       "The index of the first segment to operate on",
2366                                                       0, G_MAXINT32, 0,
2367                                                       GIMP_PARAM_READWRITE));
2368   gimp_procedure_add_argument (procedure,
2369                                gimp_param_spec_int32 ("end-segment",
2370                                                       "end segment",
2371                                                       "The index of the last segment to operate on. If negative, the selection will extend to the end of the string.",
2372                                                       G_MININT32, G_MAXINT32, 0,
2373                                                       GIMP_PARAM_READWRITE));
2374   gimp_procedure_add_argument (procedure,
2375                                gimp_param_spec_int32 ("replicate-times",
2376                                                       "replicate times",
2377                                                       "The number of times to replicate",
2378                                                       2, 20, 2,
2379                                                       GIMP_PARAM_READWRITE));
2380   gimp_pdb_register_procedure (pdb, procedure);
2381   g_object_unref (procedure);
2382 
2383   /*
2384    * gimp-gradient-segment-range-split-midpoint
2385    */
2386   procedure = gimp_procedure_new (gradient_segment_range_split_midpoint_invoker);
2387   gimp_object_set_static_name (GIMP_OBJECT (procedure),
2388                                "gimp-gradient-segment-range-split-midpoint");
2389   gimp_procedure_set_static_strings (procedure,
2390                                      "gimp-gradient-segment-range-split-midpoint",
2391                                      "Splits each segment in the segment range at midpoint",
2392                                      "This function splits each segment in the segment range at its midpoint.",
2393                                      "Shlomi Fish <shlomif@iglu.org.il>",
2394                                      "Shlomi Fish",
2395                                      "2003",
2396                                      NULL);
2397   gimp_procedure_add_argument (procedure,
2398                                gimp_param_spec_string ("name",
2399                                                        "name",
2400                                                        "The gradient name",
2401                                                        FALSE, FALSE, TRUE,
2402                                                        NULL,
2403                                                        GIMP_PARAM_READWRITE));
2404   gimp_procedure_add_argument (procedure,
2405                                gimp_param_spec_int32 ("start-segment",
2406                                                       "start segment",
2407                                                       "The index of the first segment to operate on",
2408                                                       0, G_MAXINT32, 0,
2409                                                       GIMP_PARAM_READWRITE));
2410   gimp_procedure_add_argument (procedure,
2411                                gimp_param_spec_int32 ("end-segment",
2412                                                       "end segment",
2413                                                       "The index of the last segment to operate on. If negative, the selection will extend to the end of the string.",
2414                                                       G_MININT32, G_MAXINT32, 0,
2415                                                       GIMP_PARAM_READWRITE));
2416   gimp_pdb_register_procedure (pdb, procedure);
2417   g_object_unref (procedure);
2418 
2419   /*
2420    * gimp-gradient-segment-range-split-uniform
2421    */
2422   procedure = gimp_procedure_new (gradient_segment_range_split_uniform_invoker);
2423   gimp_object_set_static_name (GIMP_OBJECT (procedure),
2424                                "gimp-gradient-segment-range-split-uniform");
2425   gimp_procedure_set_static_strings (procedure,
2426                                      "gimp-gradient-segment-range-split-uniform",
2427                                      "Splits each segment in the segment range uniformly",
2428                                      "This function splits each segment in the segment range uniformly according to the number of times specified by the parameter.",
2429                                      "Shlomi Fish <shlomif@iglu.org.il>",
2430                                      "Shlomi Fish",
2431                                      "2003",
2432                                      NULL);
2433   gimp_procedure_add_argument (procedure,
2434                                gimp_param_spec_string ("name",
2435                                                        "name",
2436                                                        "The gradient name",
2437                                                        FALSE, FALSE, TRUE,
2438                                                        NULL,
2439                                                        GIMP_PARAM_READWRITE));
2440   gimp_procedure_add_argument (procedure,
2441                                gimp_param_spec_int32 ("start-segment",
2442                                                       "start segment",
2443                                                       "The index of the first segment to operate on",
2444                                                       0, G_MAXINT32, 0,
2445                                                       GIMP_PARAM_READWRITE));
2446   gimp_procedure_add_argument (procedure,
2447                                gimp_param_spec_int32 ("end-segment",
2448                                                       "end segment",
2449                                                       "The index of the last segment to operate on. If negative, the selection will extend to the end of the string.",
2450                                                       G_MININT32, G_MAXINT32, 0,
2451                                                       GIMP_PARAM_READWRITE));
2452   gimp_procedure_add_argument (procedure,
2453                                gimp_param_spec_int32 ("split-parts",
2454                                                       "split parts",
2455                                                       "The number of uniform divisions to split each segment to",
2456                                                       2, 1024, 2,
2457                                                       GIMP_PARAM_READWRITE));
2458   gimp_pdb_register_procedure (pdb, procedure);
2459   g_object_unref (procedure);
2460 
2461   /*
2462    * gimp-gradient-segment-range-delete
2463    */
2464   procedure = gimp_procedure_new (gradient_segment_range_delete_invoker);
2465   gimp_object_set_static_name (GIMP_OBJECT (procedure),
2466                                "gimp-gradient-segment-range-delete");
2467   gimp_procedure_set_static_strings (procedure,
2468                                      "gimp-gradient-segment-range-delete",
2469                                      "Delete the segment range",
2470                                      "This function deletes a segment range.",
2471                                      "Shlomi Fish <shlomif@iglu.org.il>",
2472                                      "Shlomi Fish",
2473                                      "2003",
2474                                      NULL);
2475   gimp_procedure_add_argument (procedure,
2476                                gimp_param_spec_string ("name",
2477                                                        "name",
2478                                                        "The gradient name",
2479                                                        FALSE, FALSE, TRUE,
2480                                                        NULL,
2481                                                        GIMP_PARAM_READWRITE));
2482   gimp_procedure_add_argument (procedure,
2483                                gimp_param_spec_int32 ("start-segment",
2484                                                       "start segment",
2485                                                       "The index of the first segment to operate on",
2486                                                       0, G_MAXINT32, 0,
2487                                                       GIMP_PARAM_READWRITE));
2488   gimp_procedure_add_argument (procedure,
2489                                gimp_param_spec_int32 ("end-segment",
2490                                                       "end segment",
2491                                                       "The index of the last segment to operate on. If negative, the selection will extend to the end of the string.",
2492                                                       G_MININT32, G_MAXINT32, 0,
2493                                                       GIMP_PARAM_READWRITE));
2494   gimp_pdb_register_procedure (pdb, procedure);
2495   g_object_unref (procedure);
2496 
2497   /*
2498    * gimp-gradient-segment-range-redistribute-handles
2499    */
2500   procedure = gimp_procedure_new (gradient_segment_range_redistribute_handles_invoker);
2501   gimp_object_set_static_name (GIMP_OBJECT (procedure),
2502                                "gimp-gradient-segment-range-redistribute-handles");
2503   gimp_procedure_set_static_strings (procedure,
2504                                      "gimp-gradient-segment-range-redistribute-handles",
2505                                      "Uniformly redistribute the segment range's handles",
2506                                      "This function redistributes the handles of the specified segment range of the specified gradient, so they'll be evenly spaced.",
2507                                      "Shlomi Fish <shlomif@iglu.org.il>",
2508                                      "Shlomi Fish",
2509                                      "2003",
2510                                      NULL);
2511   gimp_procedure_add_argument (procedure,
2512                                gimp_param_spec_string ("name",
2513                                                        "name",
2514                                                        "The gradient name",
2515                                                        FALSE, FALSE, TRUE,
2516                                                        NULL,
2517                                                        GIMP_PARAM_READWRITE));
2518   gimp_procedure_add_argument (procedure,
2519                                gimp_param_spec_int32 ("start-segment",
2520                                                       "start segment",
2521                                                       "The index of the first segment to operate on",
2522                                                       0, G_MAXINT32, 0,
2523                                                       GIMP_PARAM_READWRITE));
2524   gimp_procedure_add_argument (procedure,
2525                                gimp_param_spec_int32 ("end-segment",
2526                                                       "end segment",
2527                                                       "The index of the last segment to operate on. If negative, the selection will extend to the end of the string.",
2528                                                       G_MININT32, G_MAXINT32, 0,
2529                                                       GIMP_PARAM_READWRITE));
2530   gimp_pdb_register_procedure (pdb, procedure);
2531   g_object_unref (procedure);
2532 
2533   /*
2534    * gimp-gradient-segment-range-blend-colors
2535    */
2536   procedure = gimp_procedure_new (gradient_segment_range_blend_colors_invoker);
2537   gimp_object_set_static_name (GIMP_OBJECT (procedure),
2538                                "gimp-gradient-segment-range-blend-colors");
2539   gimp_procedure_set_static_strings (procedure,
2540                                      "gimp-gradient-segment-range-blend-colors",
2541                                      "Blend the colors of the segment range.",
2542                                      "This function blends the colors (but not the opacity) of the segments' range of the gradient. Using it, the colors' transition will be uniform across the range.",
2543                                      "Shlomi Fish <shlomif@iglu.org.il>",
2544                                      "Shlomi Fish",
2545                                      "2003",
2546                                      NULL);
2547   gimp_procedure_add_argument (procedure,
2548                                gimp_param_spec_string ("name",
2549                                                        "name",
2550                                                        "The gradient name",
2551                                                        FALSE, FALSE, TRUE,
2552                                                        NULL,
2553                                                        GIMP_PARAM_READWRITE));
2554   gimp_procedure_add_argument (procedure,
2555                                gimp_param_spec_int32 ("start-segment",
2556                                                       "start segment",
2557                                                       "The index of the first segment to operate on",
2558                                                       0, G_MAXINT32, 0,
2559                                                       GIMP_PARAM_READWRITE));
2560   gimp_procedure_add_argument (procedure,
2561                                gimp_param_spec_int32 ("end-segment",
2562                                                       "end segment",
2563                                                       "The index of the last segment to operate on. If negative, the selection will extend to the end of the string.",
2564                                                       G_MININT32, G_MAXINT32, 0,
2565                                                       GIMP_PARAM_READWRITE));
2566   gimp_pdb_register_procedure (pdb, procedure);
2567   g_object_unref (procedure);
2568 
2569   /*
2570    * gimp-gradient-segment-range-blend-opacity
2571    */
2572   procedure = gimp_procedure_new (gradient_segment_range_blend_opacity_invoker);
2573   gimp_object_set_static_name (GIMP_OBJECT (procedure),
2574                                "gimp-gradient-segment-range-blend-opacity");
2575   gimp_procedure_set_static_strings (procedure,
2576                                      "gimp-gradient-segment-range-blend-opacity",
2577                                      "Blend the opacity of the segment range.",
2578                                      "This function blends the opacity (but not the colors) of the segments' range of the gradient. Using it, the opacity's transition will be uniform across the range.",
2579                                      "Shlomi Fish <shlomif@iglu.org.il>",
2580                                      "Shlomi Fish",
2581                                      "2003",
2582                                      NULL);
2583   gimp_procedure_add_argument (procedure,
2584                                gimp_param_spec_string ("name",
2585                                                        "name",
2586                                                        "The gradient name",
2587                                                        FALSE, FALSE, TRUE,
2588                                                        NULL,
2589                                                        GIMP_PARAM_READWRITE));
2590   gimp_procedure_add_argument (procedure,
2591                                gimp_param_spec_int32 ("start-segment",
2592                                                       "start segment",
2593                                                       "The index of the first segment to operate on",
2594                                                       0, G_MAXINT32, 0,
2595                                                       GIMP_PARAM_READWRITE));
2596   gimp_procedure_add_argument (procedure,
2597                                gimp_param_spec_int32 ("end-segment",
2598                                                       "end segment",
2599                                                       "The index of the last segment to operate on. If negative, the selection will extend to the end of the string.",
2600                                                       G_MININT32, G_MAXINT32, 0,
2601                                                       GIMP_PARAM_READWRITE));
2602   gimp_pdb_register_procedure (pdb, procedure);
2603   g_object_unref (procedure);
2604 
2605   /*
2606    * gimp-gradient-segment-range-move
2607    */
2608   procedure = gimp_procedure_new (gradient_segment_range_move_invoker);
2609   gimp_object_set_static_name (GIMP_OBJECT (procedure),
2610                                "gimp-gradient-segment-range-move");
2611   gimp_procedure_set_static_strings (procedure,
2612                                      "gimp-gradient-segment-range-move",
2613                                      "Move the position of an entire segment range by a delta.",
2614                                      "This function moves the position of an entire segment range by a delta. The actual delta (which is returned) will be limited by the control points of the neighboring segments.",
2615                                      "Shlomi Fish <shlomif@iglu.org.il>",
2616                                      "Shlomi Fish",
2617                                      "2003",
2618                                      NULL);
2619   gimp_procedure_add_argument (procedure,
2620                                gimp_param_spec_string ("name",
2621                                                        "name",
2622                                                        "The gradient name",
2623                                                        FALSE, FALSE, TRUE,
2624                                                        NULL,
2625                                                        GIMP_PARAM_READWRITE));
2626   gimp_procedure_add_argument (procedure,
2627                                gimp_param_spec_int32 ("start-segment",
2628                                                       "start segment",
2629                                                       "The index of the first segment to operate on",
2630                                                       0, G_MAXINT32, 0,
2631                                                       GIMP_PARAM_READWRITE));
2632   gimp_procedure_add_argument (procedure,
2633                                gimp_param_spec_int32 ("end-segment",
2634                                                       "end segment",
2635                                                       "The index of the last segment to operate on. If negative, the selection will extend to the end of the string.",
2636                                                       G_MININT32, G_MAXINT32, 0,
2637                                                       GIMP_PARAM_READWRITE));
2638   gimp_procedure_add_argument (procedure,
2639                                g_param_spec_double ("delta",
2640                                                     "delta",
2641                                                     "The delta to move the segment range",
2642                                                     -1.0, 1.0, -1.0,
2643                                                     GIMP_PARAM_READWRITE));
2644   gimp_procedure_add_argument (procedure,
2645                                g_param_spec_boolean ("control-compress",
2646                                                      "control compress",
2647                                                      "Whether or not to compress the neighboring segments",
2648                                                      FALSE,
2649                                                      GIMP_PARAM_READWRITE));
2650   gimp_procedure_add_return_value (procedure,
2651                                    g_param_spec_double ("final-delta",
2652                                                         "final delta",
2653                                                         "The final delta by which the range moved",
2654                                                         -G_MAXDOUBLE, G_MAXDOUBLE, 0,
2655                                                         GIMP_PARAM_READWRITE));
2656   gimp_pdb_register_procedure (pdb, procedure);
2657   g_object_unref (procedure);
2658 }
2659