gimpgradient_pdb.c 40.4 KB
Newer Older
1 2 3
/* LIBGIMP - The GIMP Library
 * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
 *
4
 * gimpgradient_pdb.c
5
 *
6
 * This library is free software: you can redistribute it and/or
7 8
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
9
 * version 3 of the License, or (at your option) any later version.
10 11 12 13 14 15 16
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with this library.  If not, see
18
 * <https://www.gnu.org/licenses/>.
19 20
 */

21
/* NOTE: This file is auto-generated by pdbgen.pl */
22 23 24

#include "config.h"

25 26
#include <string.h>

27 28
#include "gimp.h"

29 30 31 32 33 34 35 36 37 38

/**
 * SECTION: gimpgradient
 * @title: gimpgradient
 * @short_description: Functions operating on a single gradient.
 *
 * Functions operating on a single gradient.
 **/


39 40 41 42 43 44 45 46 47 48
/**
 * gimp_gradient_new:
 * @name: The requested name of the new gradient.
 *
 * Creates a new gradient
 *
 * This procedure creates a new, uninitialized gradient
 *
 * Returns: The actual new gradient name.
 *
49
 * Since: 2.2
50
 **/
51 52 53 54 55
gchar *
gimp_gradient_new (const gchar *name)
{
  GimpParam *return_vals;
  gint nreturn_vals;
56
  gchar *actual_name = NULL;
57

58
  return_vals = gimp_run_procedure ("gimp-gradient-new",
59 60 61
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_END);
62 63

  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
64
    actual_name = g_strdup (return_vals[1].data.d_string);
65 66 67

  gimp_destroy_params (return_vals, nreturn_vals);

68
  return actual_name;
69 70 71 72
}

/**
 * gimp_gradient_duplicate:
73
 * @name: The gradient name.
74 75 76 77 78 79 80
 *
 * Duplicates a gradient
 *
 * This procedure creates an identical gradient by a different name
 *
 * Returns: The name of the gradient's copy.
 *
81
 * Since: 2.2
82
 **/
83 84 85 86 87
gchar *
gimp_gradient_duplicate (const gchar *name)
{
  GimpParam *return_vals;
  gint nreturn_vals;
88
  gchar *copy_name = NULL;
89

90
  return_vals = gimp_run_procedure ("gimp-gradient-duplicate",
91 92 93
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_END);
94 95

  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
96
    copy_name = g_strdup (return_vals[1].data.d_string);
97 98 99

  gimp_destroy_params (return_vals, nreturn_vals);

100
  return copy_name;
101 102
}

103 104 105 106 107 108
/**
 * gimp_gradient_is_editable:
 * @name: The gradient name.
 *
 * Tests if gradient can be edited
 *
109
 * Returns TRUE if you have permission to change the gradient
110
 *
111
 * Returns: TRUE if the gradient can be edited.
112
 *
113
 * Since: 2.4
114
 **/
115 116 117 118 119 120 121
gboolean
gimp_gradient_is_editable (const gchar *name)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean editable = FALSE;

122
  return_vals = gimp_run_procedure ("gimp-gradient-is-editable",
123 124 125
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_END);
126 127 128 129 130 131 132 133 134

  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
    editable = return_vals[1].data.d_int32;

  gimp_destroy_params (return_vals, nreturn_vals);

  return editable;
}

135 136
/**
 * gimp_gradient_rename:
137
 * @name: The gradient name.
138 139 140 141 142 143 144 145
 * @new_name: The new name of the gradient.
 *
 * Rename a gradient
 *
 * This procedure renames a gradient
 *
 * Returns: The actual new name of the gradient.
 *
146
 * Since: 2.2
147
 **/
148 149
gchar *
gimp_gradient_rename (const gchar *name,
150
                      const gchar *new_name)
151 152 153
{
  GimpParam *return_vals;
  gint nreturn_vals;
154
  gchar *actual_name = NULL;
155

156
  return_vals = gimp_run_procedure ("gimp-gradient-rename",
157 158 159 160
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_STRING, new_name,
                                    GIMP_PDB_END);
161 162

  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
163
    actual_name = g_strdup (return_vals[1].data.d_string);
164 165 166

  gimp_destroy_params (return_vals, nreturn_vals);

167
  return actual_name;
168 169 170 171
}

/**
 * gimp_gradient_delete:
172
 * @name: The gradient name.
173 174 175 176 177 178 179
 *
 * Deletes a gradient
 *
 * This procedure deletes a gradient
 *
 * Returns: TRUE on success.
 *
180
 * Since: 2.2
181
 **/
182 183 184 185 186 187 188
gboolean
gimp_gradient_delete (const gchar *name)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

189
  return_vals = gimp_run_procedure ("gimp-gradient-delete",
190 191 192
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_END);
193 194 195 196 197 198 199 200

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

201 202 203 204 205 206 207 208 209 210 211
/**
 * gimp_gradient_get_number_of_segments:
 * @name: The gradient name.
 *
 * Returns the number of segments of the specified gradient
 *
 * This procedure returns the number of segments of the specified
 * gradient.
 *
 * Returns: Number of segments.
 *
212
 * Since: 2.6
213
 **/
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
gint
gimp_gradient_get_number_of_segments (const gchar *name)
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gint num_segments = 0;

  return_vals = gimp_run_procedure ("gimp-gradient-get-number-of-segments",
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_END);

  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
    num_segments = return_vals[1].data.d_int32;

  gimp_destroy_params (return_vals, nreturn_vals);

  return num_segments;
}

234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
/**
 * gimp_gradient_get_uniform_samples:
 * @name: The gradient name.
 * @num_samples: The number of samples to take.
 * @reverse: Use the reverse gradient.
 * @num_color_samples: Length of the color_samples array (4 * num_samples).
 * @color_samples: Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }.
 *
 * Sample the specified in uniform parts.
 *
 * 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 }.
 *
 * Returns: TRUE on success.
 *
254
 * Since: 2.2
255
 **/
256 257
gboolean
gimp_gradient_get_uniform_samples (const gchar  *name,
258 259 260 261
                                   gint          num_samples,
                                   gboolean      reverse,
                                   gint         *num_color_samples,
                                   gdouble     **color_samples)
262 263 264 265 266
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

267
  return_vals = gimp_run_procedure ("gimp-gradient-get-uniform-samples",
268 269 270 271 272
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, num_samples,
                                    GIMP_PDB_INT32, reverse,
                                    GIMP_PDB_END);
273 274 275 276 277 278 279 280 281 282

  *num_color_samples = 0;
  *color_samples = NULL;

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  if (success)
    {
      *num_color_samples = return_vals[1].data.d_int32;
      *color_samples = g_new (gdouble, *num_color_samples);
283 284 285
      memcpy (*color_samples,
              return_vals[2].data.d_floatarray,
              *num_color_samples * sizeof (gdouble));
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
    }

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_gradient_get_custom_samples:
 * @name: The gradient name.
 * @num_samples: The number of samples to take.
 * @positions: The list of positions to sample along the gradient.
 * @reverse: Use the reverse gradient.
 * @num_color_samples: Length of the color_samples array (4 * num_samples).
 * @color_samples: Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }.
 *
302
 * Sample the specified gradient in custom positions.
303 304 305 306 307 308 309 310 311 312
 *
 * 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.
 *
 * Returns: TRUE on success.
 *
313
 * Since: 2.2
314
 **/
315 316
gboolean
gimp_gradient_get_custom_samples (const gchar    *name,
317 318 319 320 321
                                  gint            num_samples,
                                  const gdouble  *positions,
                                  gboolean        reverse,
                                  gint           *num_color_samples,
                                  gdouble       **color_samples)
322 323 324 325 326
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

327
  return_vals = gimp_run_procedure ("gimp-gradient-get-custom-samples",
328 329 330 331 332 333
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, num_samples,
                                    GIMP_PDB_FLOATARRAY, positions,
                                    GIMP_PDB_INT32, reverse,
                                    GIMP_PDB_END);
334 335 336 337 338 339 340 341 342 343

  *num_color_samples = 0;
  *color_samples = NULL;

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  if (success)
    {
      *num_color_samples = return_vals[1].data.d_int32;
      *color_samples = g_new (gdouble, *num_color_samples);
344 345 346
      memcpy (*color_samples,
              return_vals[2].data.d_floatarray,
              *num_color_samples * sizeof (gdouble));
347 348 349 350 351 352 353
    }

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

354 355
/**
 * gimp_gradient_segment_get_left_color:
356
 * @name: The gradient name.
357 358 359 360
 * @segment: The index of the segment within the gradient.
 * @color: The return color.
 * @opacity: The opacity of the endpoint.
 *
361
 * Retrieves the left endpoint color of the specified segment
362 363 364 365 366
 *
 * This procedure retrieves the left endpoint color of the specified
 * segment of the specified gradient.
 *
 * Returns: TRUE on success.
367
 *
368
 * Since: 2.2
369
 **/
370 371
gboolean
gimp_gradient_segment_get_left_color (const gchar *name,
372 373 374
                                      gint         segment,
                                      GimpRGB     *color,
                                      gdouble     *opacity)
375 376 377 378 379
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

380
  return_vals = gimp_run_procedure ("gimp-gradient-segment-get-left-color",
381 382 383 384
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, segment,
                                    GIMP_PDB_END);
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402

  *opacity = 0.0;

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  if (success)
    {
      *color = return_vals[1].data.d_color;
      *opacity = return_vals[2].data.d_float;
    }

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_gradient_segment_set_left_color:
403
 * @name: The gradient name.
404 405 406 407
 * @segment: The index of the segment within the gradient.
 * @color: The color to set.
 * @opacity: The opacity to set for the endpoint.
 *
Simon Budig's avatar
Simon Budig committed
408
 * Sets the left endpoint color of the specified segment
409
 *
Simon Budig's avatar
Simon Budig committed
410 411
 * This procedure sets the left endpoint color of the specified segment
 * of the specified gradient.
412 413
 *
 * Returns: TRUE on success.
414
 *
415
 * Since: 2.2
416
 **/
417 418
gboolean
gimp_gradient_segment_set_left_color (const gchar   *name,
419 420 421
                                      gint           segment,
                                      const GimpRGB *color,
                                      gdouble        opacity)
422 423 424 425 426
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

427
  return_vals = gimp_run_procedure ("gimp-gradient-segment-set-left-color",
428 429 430 431 432 433
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, segment,
                                    GIMP_PDB_COLOR, color,
                                    GIMP_PDB_FLOAT, opacity,
                                    GIMP_PDB_END);
434 435 436 437 438 439 440 441 442 443

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_gradient_segment_get_right_color:
444
 * @name: The gradient name.
445 446 447 448
 * @segment: The index of the segment within the gradient.
 * @color: The return color.
 * @opacity: The opacity of the endpoint.
 *
449
 * Retrieves the right endpoint color of the specified segment
450 451 452 453 454
 *
 * This procedure retrieves the right endpoint color of the specified
 * segment of the specified gradient.
 *
 * Returns: TRUE on success.
455
 *
456
 * Since: 2.2
457
 **/
458 459
gboolean
gimp_gradient_segment_get_right_color (const gchar *name,
460 461 462
                                       gint         segment,
                                       GimpRGB     *color,
                                       gdouble     *opacity)
463 464 465 466 467
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

468
  return_vals = gimp_run_procedure ("gimp-gradient-segment-get-right-color",
469 470 471 472
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, segment,
                                    GIMP_PDB_END);
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490

  *opacity = 0.0;

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  if (success)
    {
      *color = return_vals[1].data.d_color;
      *opacity = return_vals[2].data.d_float;
    }

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_gradient_segment_set_right_color:
491
 * @name: The gradient name.
492 493 494 495
 * @segment: The index of the segment within the gradient.
 * @color: The color to set.
 * @opacity: The opacity to set for the endpoint.
 *
Simon Budig's avatar
Simon Budig committed
496
 * Sets the right endpoint color of the specified segment
497
 *
Simon Budig's avatar
Simon Budig committed
498
 * This procedure sets the right endpoint color of the specified
499 500 501
 * segment of the specified gradient.
 *
 * Returns: TRUE on success.
502
 *
503
 * Since: 2.2
504
 **/
505 506
gboolean
gimp_gradient_segment_set_right_color (const gchar   *name,
507 508 509
                                       gint           segment,
                                       const GimpRGB *color,
                                       gdouble        opacity)
510 511 512 513 514
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

515
  return_vals = gimp_run_procedure ("gimp-gradient-segment-set-right-color",
516 517 518 519 520 521
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, segment,
                                    GIMP_PDB_COLOR, color,
                                    GIMP_PDB_FLOAT, opacity,
                                    GIMP_PDB_END);
522 523 524 525 526 527 528 529 530 531

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_gradient_segment_get_left_pos:
532
 * @name: The gradient name.
533 534 535
 * @segment: The index of the segment within the gradient.
 * @pos: The return position.
 *
536
 * Retrieves the left endpoint position of the specified segment
537 538 539 540 541
 *
 * This procedure retrieves the left endpoint position of the specified
 * segment of the specified gradient.
 *
 * Returns: TRUE on success.
542
 *
543
 * Since: 2.2
544
 **/
545 546
gboolean
gimp_gradient_segment_get_left_pos (const gchar *name,
547 548
                                    gint         segment,
                                    gdouble     *pos)
549 550 551 552 553
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

554
  return_vals = gimp_run_procedure ("gimp-gradient-segment-get-left-pos",
555 556 557 558
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, segment,
                                    GIMP_PDB_END);
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573

  *pos = 0.0;

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  if (success)
    *pos = return_vals[1].data.d_float;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_gradient_segment_set_left_pos:
574
 * @name: The gradient name.
575
 * @segment: The index of the segment within the gradient.
576
 * @pos: The position to set the guidepoint to.
577 578
 * @final_pos: The return position.
 *
579
 * Sets the left endpoint position of the specified segment
580 581 582 583
 *
 * 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
584
 * point of the current segment.
585
 * This procedure returns the final position.
586 587
 *
 * Returns: TRUE on success.
588
 *
589
 * Since: 2.2
590
 **/
591 592
gboolean
gimp_gradient_segment_set_left_pos (const gchar *name,
593 594 595
                                    gint         segment,
                                    gdouble      pos,
                                    gdouble     *final_pos)
596 597 598 599 600
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

601
  return_vals = gimp_run_procedure ("gimp-gradient-segment-set-left-pos",
602 603 604 605 606
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, segment,
                                    GIMP_PDB_FLOAT, pos,
                                    GIMP_PDB_END);
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621

  *final_pos = 0.0;

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  if (success)
    *final_pos = return_vals[1].data.d_float;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_gradient_segment_get_middle_pos:
622
 * @name: The gradient name.
623 624 625
 * @segment: The index of the segment within the gradient.
 * @pos: The return position.
 *
626
 * Retrieves the middle point position of the specified segment
627 628 629 630 631
 *
 * This procedure retrieves the middle point position of the specified
 * segment of the specified gradient.
 *
 * Returns: TRUE on success.
632
 *
633
 * Since: 2.2
634
 **/
635 636
gboolean
gimp_gradient_segment_get_middle_pos (const gchar *name,
637 638
                                      gint         segment,
                                      gdouble     *pos)
639 640 641 642 643
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

644
  return_vals = gimp_run_procedure ("gimp-gradient-segment-get-middle-pos",
645 646 647 648
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, segment,
                                    GIMP_PDB_END);
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663

  *pos = 0.0;

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  if (success)
    *pos = return_vals[1].data.d_float;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_gradient_segment_set_middle_pos:
664
 * @name: The gradient name.
665
 * @segment: The index of the segment within the gradient.
666
 * @pos: The position to set the guidepoint to.
667 668
 * @final_pos: The return position.
 *
669
 * Sets the middle point position of the specified segment
670 671 672
 *
 * This procedure sets the middle point position of the specified
 * segment of the specified gradient. The final position will be
673 674
 * between the two endpoints of the segment.
 * This procedure returns the final position.
675 676
 *
 * Returns: TRUE on success.
677
 *
678
 * Since: 2.2
679
 **/
680 681
gboolean
gimp_gradient_segment_set_middle_pos (const gchar *name,
682 683 684
                                      gint         segment,
                                      gdouble      pos,
                                      gdouble     *final_pos)
685 686 687 688 689
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

690
  return_vals = gimp_run_procedure ("gimp-gradient-segment-set-middle-pos",
691 692 693 694 695
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, segment,
                                    GIMP_PDB_FLOAT, pos,
                                    GIMP_PDB_END);
696 697 698 699 700 701 702 703 704 705 706 707 708 709 710

  *final_pos = 0.0;

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  if (success)
    *final_pos = return_vals[1].data.d_float;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_gradient_segment_get_right_pos:
711
 * @name: The gradient name.
712 713 714
 * @segment: The index of the segment within the gradient.
 * @pos: The return position.
 *
715
 * Retrieves the right endpoint position of the specified segment
716 717 718 719 720
 *
 * This procedure retrieves the right endpoint position of the
 * specified segment of the specified gradient.
 *
 * Returns: TRUE on success.
721
 *
722
 * Since: 2.2
723
 **/
724 725
gboolean
gimp_gradient_segment_get_right_pos (const gchar *name,
726 727
                                     gint         segment,
                                     gdouble     *pos)
728 729 730 731 732
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

733
  return_vals = gimp_run_procedure ("gimp-gradient-segment-get-right-pos",
734 735 736 737
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, segment,
                                    GIMP_PDB_END);
738 739 740 741 742 743 744 745 746 747 748 749 750 751 752

  *pos = 0.0;

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  if (success)
    *pos = return_vals[1].data.d_float;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_gradient_segment_set_right_pos:
753
 * @name: The gradient name.
754
 * @segment: The index of the segment within the gradient.
755
 * @pos: The position to set the guidepoint to.
756 757
 * @final_pos: The return position.
 *
758
 * Sets the right endpoint position of the specified segment
759 760 761 762
 *
 * 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
763 764
 * the middle point of the segment to the right.
 * This procedure returns the final position.
765 766
 *
 * Returns: TRUE on success.
767
 *
768
 * Since: 2.2
769
 **/
770 771
gboolean
gimp_gradient_segment_set_right_pos (const gchar *name,
772 773 774
                                     gint         segment,
                                     gdouble      pos,
                                     gdouble     *final_pos)
775 776 777 778 779
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

780
  return_vals = gimp_run_procedure ("gimp-gradient-segment-set-right-pos",
781 782 783 784 785
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, segment,
                                    GIMP_PDB_FLOAT, pos,
                                    GIMP_PDB_END);
786 787 788 789 790 791 792 793 794 795 796 797 798 799 800

  *final_pos = 0.0;

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  if (success)
    *final_pos = return_vals[1].data.d_float;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_gradient_segment_get_blending_function:
801
 * @name: The gradient name.
802 803 804 805 806 807 808 809 810
 * @segment: The index of the segment within the gradient.
 * @blend_func: The blending function of the segment.
 *
 * Retrieves the gradient segment's blending function
 *
 * This procedure retrieves the blending function of the segment at the
 * specified gradient name and segment index.
 *
 * Returns: TRUE on success.
811
 *
812
 * Since: 2.2
813
 **/
814
gboolean
815
gimp_gradient_segment_get_blending_function (const gchar             *name,
816 817
                                             gint                     segment,
                                             GimpGradientSegmentType *blend_func)
818 819 820 821 822
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

823
  return_vals = gimp_run_procedure ("gimp-gradient-segment-get-blending-function",
824 825 826 827
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, segment,
                                    GIMP_PDB_END);
828 829 830 831 832 833 834 835 836 837 838 839 840 841

  *blend_func = 0;

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  if (success)
    *blend_func = return_vals[1].data.d_int32;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
842
 * gimp_gradient_segment_get_coloring_type:
843
 * @name: The gradient name.
844 845
 * @segment: The index of the segment within the gradient.
 * @coloring_type: The coloring type of the segment.
846
 *
847
 * Retrieves the gradient segment's coloring type
848
 *
849 850
 * This procedure retrieves the coloring type of the segment at the
 * specified gradient name and segment index.
851 852
 *
 * Returns: TRUE on success.
853
 *
854
 * Since: 2.2
855
 **/
856
gboolean
857
gimp_gradient_segment_get_coloring_type (const gchar              *name,
858 859
                                         gint                      segment,
                                         GimpGradientSegmentColor *coloring_type)
860 861 862 863 864
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

865
  return_vals = gimp_run_procedure ("gimp-gradient-segment-get-coloring-type",
866 867 868 869
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, segment,
                                    GIMP_PDB_END);
870

871 872
  *coloring_type = 0;

873 874
  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

875 876 877
  if (success)
    *coloring_type = return_vals[1].data.d_int32;

878 879 880 881 882 883
  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
884
 * gimp_gradient_segment_range_set_blending_function:
885
 * @name: The gradient name.
886 887
 * @start_segment: The index of the first segment to operate on.
 * @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
888
 * @blending_function: The blending function.
889
 *
890
 * Change the blending function of a segments range
891
 *
892 893
 * This function changes the blending function of a segment range to
 * the specified blending function.
894 895
 *
 * Returns: TRUE on success.
896
 *
897
 * Since: 2.2
898
 **/
899
gboolean
900
gimp_gradient_segment_range_set_blending_function (const gchar             *name,
901 902 903
                                                   gint                     start_segment,
                                                   gint                     end_segment,
                                                   GimpGradientSegmentType  blending_function)
904 905 906 907 908
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

909
  return_vals = gimp_run_procedure ("gimp-gradient-segment-range-set-blending-function",
910 911 912 913 914 915
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, start_segment,
                                    GIMP_PDB_INT32, end_segment,
                                    GIMP_PDB_INT32, blending_function,
                                    GIMP_PDB_END);
916 917 918 919 920 921 922 923 924

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
925
 * gimp_gradient_segment_range_set_coloring_type:
926
 * @name: The gradient name.
927 928
 * @start_segment: The index of the first segment to operate on.
 * @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
929
 * @coloring_type: The coloring type.
930 931 932 933 934 935 936
 *
 * Change the coloring type of a segments range
 *
 * This function changes the coloring type of a segment range to the
 * specified coloring type.
 *
 * Returns: TRUE on success.
937
 *
938
 * Since: 2.2
939
 **/
940
gboolean
941
gimp_gradient_segment_range_set_coloring_type (const gchar              *name,
942 943 944
                                               gint                      start_segment,
                                               gint                      end_segment,
                                               GimpGradientSegmentColor  coloring_type)
945 946 947 948 949
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

950
  return_vals = gimp_run_procedure ("gimp-gradient-segment-range-set-coloring-type",
951 952 953 954 955 956
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, start_segment,
                                    GIMP_PDB_INT32, end_segment,
                                    GIMP_PDB_INT32, coloring_type,
                                    GIMP_PDB_END);
957 958 959 960 961 962 963 964 965 966

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_gradient_segment_range_flip:
967
 * @name: The gradient name.
968 969 970 971 972 973 974 975
 * @start_segment: The index of the first segment to operate on.
 * @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
 *
 * Flip the segment range
 *
 * This function flips a segment range.
 *
 * Returns: TRUE on success.
976
 *
977
 * Since: 2.2
978
 **/
979 980
gboolean
gimp_gradient_segment_range_flip (const gchar *name,
981 982
                                  gint         start_segment,
                                  gint         end_segment)
983 984 985 986 987
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

988
  return_vals = gimp_run_procedure ("gimp-gradient-segment-range-flip",
989 990 991 992 993
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, start_segment,
                                    GIMP_PDB_INT32, end_segment,
                                    GIMP_PDB_END);
994 995 996 997 998 999 1000 1001 1002 1003

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_gradient_segment_range_replicate:
1004
 * @name: The gradient name.
1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
 * @start_segment: The index of the first segment to operate on.
 * @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
 * @replicate_times: The number of times to replicate.
 *
 * Replicate the segment range
 *
 * 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.
 *
 * Returns: TRUE on success.
1016
 *
1017
 * Since: 2.2
1018
 **/
1019 1020
gboolean
gimp_gradient_segment_range_replicate (const gchar *name,
1021 1022 1023
                                       gint         start_segment,
                                       gint         end_segment,
                                       gint         replicate_times)
1024 1025 1026 1027 1028
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

1029
  return_vals = gimp_run_procedure ("gimp-gradient-segment-range-replicate",
1030 1031 1032 1033 1034 1035
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, start_segment,
                                    GIMP_PDB_INT32, end_segment,
                                    GIMP_PDB_INT32, replicate_times,
                                    GIMP_PDB_END);
1036 1037 1038 1039 1040 1041 1042 1043 1044 1045

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_gradient_segment_range_split_midpoint:
1046
 * @name: The gradient name.
1047 1048 1049 1050 1051 1052 1053 1054 1055
 * @start_segment: The index of the first segment to operate on.
 * @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
 *
 * Splits each segment in the segment range at midpoint
 *
 * This function splits each segment in the segment range at its
 * midpoint.
 *
 * Returns: TRUE on success.
1056
 *
1057
 * Since: 2.2
1058
 **/
1059 1060
gboolean
gimp_gradient_segment_range_split_midpoint (const gchar *name,
1061 1062
                                            gint         start_segment,
                                            gint         end_segment)
1063 1064 1065 1066 1067
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

1068
  return_vals = gimp_run_procedure ("gimp-gradient-segment-range-split-midpoint",
1069 1070 1071 1072 1073
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, start_segment,
                                    GIMP_PDB_INT32, end_segment,
                                    GIMP_PDB_END);
1074 1075 1076 1077 1078 1079 1080 1081 1082 1083

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_gradient_segment_range_split_uniform:
1084
 * @name: The gradient name.
1085 1086 1087 1088 1089 1090 1091 1092 1093 1094
 * @start_segment: The index of the first segment to operate on.
 * @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
 * @split_parts: The number of uniform divisions to split each segment to.
 *
 * Splits each segment in the segment range uniformly
 *
 * This function splits each segment in the segment range uniformly
 * according to the number of times specified by the parameter.
 *
 * Returns: TRUE on success.
1095
 *
1096
 * Since: 2.2
1097
 **/
1098 1099
gboolean
gimp_gradient_segment_range_split_uniform (const gchar *name,
1100 1101 1102
                                           gint         start_segment,
                                           gint         end_segment,
                                           gint         split_parts)
1103 1104 1105 1106 1107
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

1108
  return_vals = gimp_run_procedure ("gimp-gradient-segment-range-split-uniform",
1109 1110 1111 1112 1113 1114
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, start_segment,
                                    GIMP_PDB_INT32, end_segment,
                                    GIMP_PDB_INT32, split_parts,
                                    GIMP_PDB_END);
1115 1116 1117 1118 1119 1120 1121 1122 1123 1124

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_gradient_segment_range_delete:
1125
 * @name: The gradient name.
1126 1127 1128 1129 1130 1131 1132 1133
 * @start_segment: The index of the first segment to operate on.
 * @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
 *
 * Delete the segment range
 *
 * This function deletes a segment range.
 *
 * Returns: TRUE on success.
1134
 *
1135
 * Since: 2.2
1136
 **/
1137 1138
gboolean
gimp_gradient_segment_range_delete (const gchar *name,
1139 1140
                                    gint         start_segment,
                                    gint         end_segment)
1141 1142 1143 1144 1145
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

1146
  return_vals = gimp_run_procedure ("gimp-gradient-segment-range-delete",
1147 1148 1149 1150 1151
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, start_segment,
                                    GIMP_PDB_INT32, end_segment,
                                    GIMP_PDB_END);
1152 1153 1154 1155 1156 1157 1158 1159 1160 1161

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_gradient_segment_range_redistribute_handles:
1162
 * @name: The gradient name.
1163 1164 1165 1166 1167 1168 1169 1170 1171
 * @start_segment: The index of the first segment to operate on.
 * @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
 *
 * Uniformly redistribute the segment range's handles
 *
 * This function redistributes the handles of the specified segment
 * range of the specified gradient, so they'll be evenly spaced.
 *
 * Returns: TRUE on success.
1172
 *
1173
 * Since: 2.2
1174
 **/
1175 1176
gboolean
gimp_gradient_segment_range_redistribute_handles (const gchar *name,
1177 1178
                                                  gint         start_segment,
                                                  gint         end_segment)
1179 1180 1181 1182 1183
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

1184
  return_vals = gimp_run_procedure ("gimp-gradient-segment-range-redistribute-handles",
1185 1186 1187 1188 1189
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, start_segment,
                                    GIMP_PDB_INT32, end_segment,
                                    GIMP_PDB_END);
1190 1191 1192 1193 1194 1195 1196 1197 1198 1199

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_gradient_segment_range_blend_colors:
1200
 * @name: The gradient name.
1201 1202 1203 1204 1205 1206 1207 1208 1209 1210
 * @start_segment: The index of the first segment to operate on.
 * @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
 *
 * Blend the colors of the segment range.
 *
 * 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.
 *
 * Returns: TRUE on success.
1211
 *
1212
 * Since: 2.2
1213
 **/
1214 1215
gboolean
gimp_gradient_segment_range_blend_colors (const gchar *name,
1216 1217
                                          gint         start_segment,
                                          gint         end_segment)
1218 1219 1220 1221 1222
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

1223
  return_vals = gimp_run_procedure ("gimp-gradient-segment-range-blend-colors",
1224 1225 1226 1227 1228
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, start_segment,
                                    GIMP_PDB_INT32, end_segment,
                                    GIMP_PDB_END);
1229 1230 1231 1232 1233 1234 1235 1236 1237 1238

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_gradient_segment_range_blend_opacity:
1239
 * @name: The gradient name.
1240 1241 1242 1243 1244 1245 1246 1247 1248 1249
 * @start_segment: The index of the first segment to operate on.
 * @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
 *
 * Blend the opacity of the segment range.
 *
 * 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.
 *
 * Returns: TRUE on success.
1250
 *
1251
 * Since: 2.2
1252
 **/
1253 1254
gboolean
gimp_gradient_segment_range_blend_opacity (const gchar *name,
1255 1256
                                           gint         start_segment,
                                           gint         end_segment)
1257 1258 1259 1260 1261
{
  GimpParam *return_vals;
  gint nreturn_vals;
  gboolean success = TRUE;

1262
  return_vals = gimp_run_procedure ("gimp-gradient-segment-range-blend-opacity",
1263 1264 1265 1266 1267
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, start_segment,
                                    GIMP_PDB_INT32, end_segment,
                                    GIMP_PDB_END);
1268 1269 1270 1271 1272 1273 1274 1275 1276 1277

  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;

  gimp_destroy_params (return_vals, nreturn_vals);

  return success;
}

/**
 * gimp_gradient_segment_range_move:
1278
 * @name: The gradient name.
1279 1280 1281 1282 1283 1284 1285
 * @start_segment: The index of the first segment to operate on.
 * @end_segment: The index of the last segment to operate on. If negative, the selection will extend to the end of the string.
 * @delta: The delta to move the segment range.
 * @control_compress: Whether or not to compress the neighboring segments.
 *
 * Move the position of an entire segment range by a delta.
 *
1286
 * This function moves the position of an entire segment range by a
1287 1288 1289 1290
 * delta. The actual delta (which is returned) will be limited by the
 * control points of the neighboring segments.
 *
 * Returns: The final delta by which the range moved.
1291
 *
1292
 * Since: 2.2
1293
 **/
1294 1295
gdouble
gimp_gradient_segment_range_move (const gchar *name,
1296 1297 1298 1299
                                  gint         start_segment,
                                  gint         end_segment,
                                  gdouble      delta,
                                  gboolean     control_compress)
1300 1301 1302
{
  GimpParam *return_vals;
  gint nreturn_vals;
1303
  gdouble final_delta = 0.0;
1304

1305
  return_vals = gimp_run_procedure ("gimp-gradient-segment-range-move",
1306 1307 1308 1309 1310 1311 1312
                                    &nreturn_vals,
                                    GIMP_PDB_STRING, name,
                                    GIMP_PDB_INT32, start_segment,
                                    GIMP_PDB_INT32, end_segment,
                                    GIMP_PDB_FLOAT, delta,
                                    GIMP_PDB_INT32, control_compress,
                                    GIMP_PDB_END);
1313 1314 1315 1316 1317 1318 1319 1320

  if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
    final_delta = return_vals[1].data.d_float;

  gimp_destroy_params (return_vals, nreturn_vals);

  return final_delta;
}