palette-cmds.c 46.1 KB
Newer Older
1
/* GIMP - The GNU Image Manipulation Program
2 3
 * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
7 8 9 10 11 12 13 14
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 17
 */

18
/* NOTE: This file is auto-generated by pdbgen.pl. */
19 20 21

#include "config.h"

22
#include <cairo.h>
23 24
#include <string.h>

25
#include <gegl.h>
26 27 28 29 30 31 32 33 34

#include "libgimpcolor/gimpcolor.h"

#include "pdb-types.h"

#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpdatafactory.h"
#include "core/gimppalette.h"
35
#include "core/gimpparamspecs.h"
36

37 38 39
#include "gimppdb.h"
#include "gimppdb-utils.h"
#include "gimpprocedure.h"
40
#include "internal-procs.h"
41

42

43
static GValueArray *
44 45 46 47 48 49
palette_new_invoker (GimpProcedure      *procedure,
                     Gimp               *gimp,
                     GimpContext        *context,
                     GimpProgress       *progress,
                     const GValueArray  *args,
                     GError            **error)
50 51
{
  gboolean success = TRUE;
52
  GValueArray *return_vals;
53
  const gchar *name;
54
  gchar *actual_name = NULL;
55

56
  name = g_value_get_string (&args->values[0]);
57 58 59

  if (success)
    {
60
      GimpData *data = gimp_data_factory_data_new (gimp->palette_factory,
61
                                                   context, name);
62

63
      if (data)
64
        actual_name = g_strdup (gimp_object_get_name (data));
65 66
      else
        success = FALSE;
67 68
    }

69 70
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
71 72

  if (success)
73
    g_value_take_string (&return_vals->values[1], actual_name);
74

75
  return return_vals;
76 77
}

78
static GValueArray *
79 80 81 82 83 84
palette_duplicate_invoker (GimpProcedure      *procedure,
                           Gimp               *gimp,
                           GimpContext        *context,
                           GimpProgress       *progress,
                           const GValueArray  *args,
                           GError            **error)
85 86
{
  gboolean success = TRUE;
87
  GValueArray *return_vals;
88
  const gchar *name;
89
  gchar *copy_name = NULL;
90

91
  name = g_value_get_string (&args->values[0]);
92 93 94

  if (success)
    {
95
      GimpPalette *palette = gimp_pdb_get_palette (gimp, name, FALSE, error);
96 97 98

      if (palette)
        {
99
          GimpPalette *palette_copy = (GimpPalette *)
100 101 102
            gimp_data_factory_data_duplicate (gimp->palette_factory,
                                              GIMP_DATA (palette));

103
          if (palette_copy)
104
            copy_name = g_strdup (gimp_object_get_name (palette_copy));
105 106
          else
            success = FALSE;
107 108 109 110 111
        }
      else
        success = FALSE;
    }

112 113
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
114 115

  if (success)
116
    g_value_take_string (&return_vals->values[1], copy_name);
117

118
  return return_vals;
119 120
}

121
static GValueArray *
122 123 124 125 126 127
palette_rename_invoker (GimpProcedure      *procedure,
                        Gimp               *gimp,
                        GimpContext        *context,
                        GimpProgress       *progress,
                        const GValueArray  *args,
                        GError            **error)
128 129
{
  gboolean success = TRUE;
130
  GValueArray *return_vals;
131 132
  const gchar *name;
  const gchar *new_name;
133
  gchar *actual_name = NULL;
134

135 136
  name = g_value_get_string (&args->values[0]);
  new_name = g_value_get_string (&args->values[1]);
137 138 139

  if (success)
    {
140
      GimpPalette *palette = gimp_pdb_get_palette (gimp, name, TRUE, error);
141

142
      if (palette)
143 144
        {
          gimp_object_set_name (GIMP_OBJECT (palette), new_name);
145
          actual_name = g_strdup (gimp_object_get_name (palette));
146
        }
147 148 149 150
      else
        success = FALSE;
    }

151 152
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
153 154

  if (success)
155
    g_value_take_string (&return_vals->values[1], actual_name);
156

157
  return return_vals;
158 159
}

160
static GValueArray *
161 162 163 164 165 166
palette_delete_invoker (GimpProcedure      *procedure,
                        Gimp               *gimp,
                        GimpContext        *context,
                        GimpProgress       *progress,
                        const GValueArray  *args,
                        GError            **error)
167 168
{
  gboolean success = TRUE;
169
  const gchar *name;
170

171
  name = g_value_get_string (&args->values[0]);
172 173 174

  if (success)
    {
175
      GimpPalette *palette = gimp_pdb_get_palette (gimp, name, FALSE, error);
176

177
      if (palette && gimp_data_is_deletable (GIMP_DATA (palette)))
178 179 180
        success = gimp_data_factory_data_delete (gimp->palette_factory,
                                                 GIMP_DATA (palette),
                                                 TRUE, error);
181 182 183 184
      else
        success = FALSE;
    }

185 186
  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
187 188
}

189
static GValueArray *
190 191 192 193 194 195
palette_is_editable_invoker (GimpProcedure      *procedure,
                             Gimp               *gimp,
                             GimpContext        *context,
                             GimpProgress       *progress,
                             const GValueArray  *args,
                             GError            **error)
196 197
{
  gboolean success = TRUE;
198
  GValueArray *return_vals;
199
  const gchar *name;
200
  gboolean editable = FALSE;
201

202
  name = g_value_get_string (&args->values[0]);
203 204 205

  if (success)
    {
206
      GimpPalette *palette = gimp_pdb_get_palette (gimp, name, FALSE, error);
207 208

      if (palette)
209
        editable = gimp_data_is_writable (GIMP_DATA (palette));
210 211 212 213
      else
        success = FALSE;
    }

214 215
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
216 217

  if (success)
218
    g_value_set_boolean (&return_vals->values[1], editable);
219

220
  return return_vals;
221 222
}

223
static GValueArray *
224 225 226 227 228 229
palette_get_info_invoker (GimpProcedure      *procedure,
                          Gimp               *gimp,
                          GimpContext        *context,
                          GimpProgress       *progress,
                          const GValueArray  *args,
                          GError            **error)
230 231
{
  gboolean success = TRUE;
232
  GValueArray *return_vals;
233
  const gchar *name;
234
  gint32 num_colors = 0;
235

236
  name = g_value_get_string (&args->values[0]);
237 238 239

  if (success)
    {
240
      GimpPalette *palette = gimp_pdb_get_palette (gimp, name, FALSE, error);
241

242
      if (palette)
243
        num_colors = gimp_palette_get_n_colors (palette);
244 245
      else
        success = FALSE;
246 247
    }

248 249
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
250 251

  if (success)
252
    g_value_set_int (&return_vals->values[1], num_colors);
253

254
  return return_vals;
255 256
}

257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
static GValueArray *
palette_get_colors_invoker (GimpProcedure      *procedure,
                            Gimp               *gimp,
                            GimpContext        *context,
                            GimpProgress       *progress,
                            const GValueArray  *args,
                            GError            **error)
{
  gboolean success = TRUE;
  GValueArray *return_vals;
  const gchar *name;
  gint32 num_colors = 0;
  GimpRGB *colors = NULL;

  name = g_value_get_string (&args->values[0]);

  if (success)
    {
      GimpPalette *palette = gimp_pdb_get_palette (gimp, name, FALSE, error);

      if (palette)
        {
279
          GList *list = gimp_palette_get_colors (palette);
280 281
          gint   i;

282
          num_colors = gimp_palette_get_n_colors (palette);
283 284 285
          colors     = g_new (GimpRGB, num_colors);

          for (i = 0; i < num_colors; i++, list = g_list_next (list))
286 287 288 289 290
            {
              GimpPaletteEntry *entry = list->data;

              colors[i] = entry->color;
            }
291 292
        }
      else
293
        success = FALSE;
294 295
    }

296 297
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
298 299 300 301 302 303 304 305 306 307

  if (success)
    {
      g_value_set_int (&return_vals->values[1], num_colors);
      gimp_value_take_colorarray (&return_vals->values[2], colors, num_colors);
    }

  return return_vals;
}

308
static GValueArray *
309 310 311 312 313 314
palette_get_columns_invoker (GimpProcedure      *procedure,
                             Gimp               *gimp,
                             GimpContext        *context,
                             GimpProgress       *progress,
                             const GValueArray  *args,
                             GError            **error)
315 316
{
  gboolean success = TRUE;
317
  GValueArray *return_vals;
318
  const gchar *name;
319
  gint32 num_columns = 0;
320

321
  name = g_value_get_string (&args->values[0]);
322 323 324

  if (success)
    {
325
      GimpPalette *palette = gimp_pdb_get_palette (gimp, name, FALSE, error);
326

327
      if (palette)
328
        num_columns = gimp_palette_get_columns (palette);
329 330
      else
        success = FALSE;
331 332
    }

333 334
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
335 336

  if (success)
337
    g_value_set_int (&return_vals->values[1], num_columns);
338

339
  return return_vals;
340 341
}

342
static GValueArray *
343 344 345 346 347 348
palette_set_columns_invoker (GimpProcedure      *procedure,
                             Gimp               *gimp,
                             GimpContext        *context,
                             GimpProgress       *progress,
                             const GValueArray  *args,
                             GError            **error)
349 350
{
  gboolean success = TRUE;
351
  const gchar *name;
352 353
  gint32 columns;

354 355
  name = g_value_get_string (&args->values[0]);
  columns = g_value_get_int (&args->values[1]);
356 357 358

  if (success)
    {
359
      GimpPalette *palette = gimp_pdb_get_palette (gimp, name, TRUE, error);
360

361
      if (palette)
362
        gimp_palette_set_columns (palette, columns);
363 364 365 366
      else
        success = FALSE;
    }

367 368
  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
369 370
}

371
static GValueArray *
372 373 374 375 376 377
palette_add_entry_invoker (GimpProcedure      *procedure,
                           Gimp               *gimp,
                           GimpContext        *context,
                           GimpProgress       *progress,
                           const GValueArray  *args,
                           GError            **error)
378 379
{
  gboolean success = TRUE;
380
  GValueArray *return_vals;
381 382
  const gchar *name;
  const gchar *entry_name;
383
  GimpRGB color;
384
  gint32 entry_num = 0;
385

386 387 388
  name = g_value_get_string (&args->values[0]);
  entry_name = g_value_get_string (&args->values[1]);
  gimp_value_get_rgb (&args->values[2], &color);
389 390 391

  if (success)
    {
392
      GimpPalette *palette = gimp_pdb_get_palette (gimp, name, TRUE, error);
393

394
      if (palette)
395 396 397 398 399 400
        {
          GimpPaletteEntry *entry =
            gimp_palette_add_entry (palette, -1, entry_name, &color);

          entry_num = entry->position;
        }
401 402 403 404
      else
        success = FALSE;
    }

405 406
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
407 408

  if (success)
409
    g_value_set_int (&return_vals->values[1], entry_num);
410

411
  return return_vals;
412 413
}

414
static GValueArray *
415 416 417 418 419 420
palette_delete_entry_invoker (GimpProcedure      *procedure,
                              Gimp               *gimp,
                              GimpContext        *context,
                              GimpProgress       *progress,
                              const GValueArray  *args,
                              GError            **error)
421 422
{
  gboolean success = TRUE;
423
  const gchar *name;
424 425
  gint32 entry_num;

426 427
  name = g_value_get_string (&args->values[0]);
  entry_num = g_value_get_int (&args->values[1]);
428 429 430

  if (success)
    {
431
      GimpPalette *palette = gimp_pdb_get_palette (gimp, name, TRUE, error);
432

433
      if (palette)
434
        {
435
          GimpPaletteEntry *entry = gimp_palette_get_entry (palette, entry_num);
436

437 438
          if (entry)
            gimp_palette_delete_entry (palette, entry);
439 440 441 442 443 444 445
          else
            success = FALSE;
        }
      else
        success = FALSE;
    }

446 447
  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
448 449
}

450
static GValueArray *
451 452 453 454 455 456
palette_entry_get_color_invoker (GimpProcedure      *procedure,
                                 Gimp               *gimp,
                                 GimpContext        *context,
                                 GimpProgress       *progress,
                                 const GValueArray  *args,
                                 GError            **error)
457 458
{
  gboolean success = TRUE;
459
  GValueArray *return_vals;
460
  const gchar *name;
461
  gint32 entry_num;
462
  GimpRGB color = { 0.0, 0.0, 0.0, 1.0 };
463

464 465
  name = g_value_get_string (&args->values[0]);
  entry_num = g_value_get_int (&args->values[1]);
466 467 468

  if (success)
    {
469
      GimpPalette *palette = gimp_pdb_get_palette (gimp, name, FALSE, error);
470 471 472

      if (palette)
        {
473
          GimpPaletteEntry *entry = gimp_palette_get_entry (palette, entry_num);
474

475 476
          if (entry)
            color = entry->color;
477 478 479 480 481 482 483
          else
            success = FALSE;
        }
      else
        success = FALSE;
    }

484 485
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
486 487

  if (success)
488
    gimp_value_set_rgb (&return_vals->values[1], &color);
489

490
  return return_vals;
491 492
}

493
static GValueArray *
494 495 496 497 498 499
palette_entry_set_color_invoker (GimpProcedure      *procedure,
                                 Gimp               *gimp,
                                 GimpContext        *context,
                                 GimpProgress       *progress,
                                 const GValueArray  *args,
                                 GError            **error)
500 501
{
  gboolean success = TRUE;
502
  const gchar *name;
503 504 505
  gint32 entry_num;
  GimpRGB color;

506 507 508
  name = g_value_get_string (&args->values[0]);
  entry_num = g_value_get_int (&args->values[1]);
  gimp_value_get_rgb (&args->values[2], &color);
509 510 511

  if (success)
    {
512
      GimpPalette *palette = gimp_pdb_get_palette (gimp, name, TRUE, error);
513

514
      if (palette)
515
        success = gimp_palette_set_entry_color (palette, entry_num, &color);
516 517 518 519
      else
        success = FALSE;
    }

520 521
  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
522 523
}

524
static GValueArray *
525 526 527 528 529 530
palette_entry_get_name_invoker (GimpProcedure      *procedure,
                                Gimp               *gimp,
                                GimpContext        *context,
                                GimpProgress       *progress,
                                const GValueArray  *args,
                                GError            **error)
531 532 533 534 535 536 537 538 539 540 541 542
{
  gboolean success = TRUE;
  GValueArray *return_vals;
  const gchar *name;
  gint32 entry_num;
  gchar *entry_name = NULL;

  name = g_value_get_string (&args->values[0]);
  entry_num = g_value_get_int (&args->values[1]);

  if (success)
    {
543
      GimpPalette *palette = gimp_pdb_get_palette (gimp, name, FALSE, error);
544 545 546

      if (palette)
        {
547
          GimpPaletteEntry *entry = gimp_palette_get_entry (palette, entry_num);
548

549 550
          if (entry)
            entry_name = g_strdup (entry->name);
551 552 553 554 555 556 557
          else
            success = FALSE;
        }
      else
        success = FALSE;
    }

558 559
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
560 561 562 563 564 565 566 567

  if (success)
    g_value_take_string (&return_vals->values[1], entry_name);

  return return_vals;
}

static GValueArray *
568 569 570 571 572 573
palette_entry_set_name_invoker (GimpProcedure      *procedure,
                                Gimp               *gimp,
                                GimpContext        *context,
                                GimpProgress       *progress,
                                const GValueArray  *args,
                                GError            **error)
574 575 576 577 578 579 580 581 582 583 584 585
{
  gboolean success = TRUE;
  const gchar *name;
  gint32 entry_num;
  const gchar *entry_name;

  name = g_value_get_string (&args->values[0]);
  entry_num = g_value_get_int (&args->values[1]);
  entry_name = g_value_get_string (&args->values[2]);

  if (success)
    {
586
      GimpPalette *palette = gimp_pdb_get_palette (gimp, name, TRUE, error);
587

588
      if (palette)
589
        success = gimp_palette_set_entry_name (palette, entry_num, entry_name);
590 591 592 593
      else
        success = FALSE;
    }

594 595
  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
596 597 598
}

void
599
register_palette_procs (GimpPDB *pdb)
600 601 602 603 604 605
{
  GimpProcedure *procedure;

  /*
   * gimp-palette-new
   */
606
  procedure = gimp_procedure_new (palette_new_invoker);
607 608
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-palette-new");
609 610 611 612 613 614 615 616 617 618 619 620
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-palette-new",
                                     "Creates a new palette",
                                     "This procedure creates a new, uninitialized palette",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2004",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("name",
                                                       "name",
                                                       "The requested name of the new palette",
621
                                                       FALSE, FALSE, TRUE,
622 623 624 625 626 627
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string ("actual-name",
                                                           "actual name",
                                                           "The actual new palette name",
628
                                                           FALSE, FALSE, FALSE,
629 630
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
631
  gimp_pdb_register_procedure (pdb, procedure);
632
  g_object_unref (procedure);
633 634 635 636

  /*
   * gimp-palette-duplicate
   */
637
  procedure = gimp_procedure_new (palette_duplicate_invoker);
638 639
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-palette-duplicate");
640 641 642 643 644 645 646 647 648 649 650 651
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-palette-duplicate",
                                     "Duplicates a palette",
                                     "This procedure creates an identical palette by a different name",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2004",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("name",
                                                       "name",
                                                       "The palette name",
652
                                                       FALSE, FALSE, TRUE,
653 654 655 656 657 658
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string ("copy-name",
                                                           "copy name",
                                                           "The name of the palette's copy",
659
                                                           FALSE, FALSE, TRUE,
660 661
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
662
  gimp_pdb_register_procedure (pdb, procedure);
663
  g_object_unref (procedure);
664 665 666 667

  /*
   * gimp-palette-rename
   */
668
  procedure = gimp_procedure_new (palette_rename_invoker);
669 670
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-palette-rename");
671 672 673 674 675 676 677 678 679 680 681 682
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-palette-rename",
                                     "Rename a palette",
                                     "This procedure renames a palette",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2004",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("name",
                                                       "name",
                                                       "The palette name",
683
                                                       FALSE, FALSE, TRUE,
684 685 686 687 688 689
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("new-name",
                                                       "new name",
                                                       "The new name of the palette",
690
                                                       FALSE, FALSE, TRUE,
691 692 693 694 695 696
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string ("actual-name",
                                                           "actual name",
                                                           "The actual new name of the palette",
697
                                                           FALSE, FALSE, FALSE,
698 699
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
700
  gimp_pdb_register_procedure (pdb, procedure);
701
  g_object_unref (procedure);
702 703 704 705

  /*
   * gimp-palette-delete
   */
706
  procedure = gimp_procedure_new (palette_delete_invoker);
707 708
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-palette-delete");
709 710 711 712 713 714 715 716 717 718 719 720
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-palette-delete",
                                     "Deletes a palette",
                                     "This procedure deletes a palette",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2004",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("name",
                                                       "name",
                                                       "The palette name",
721
                                                       FALSE, FALSE, TRUE,
722 723
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
724
  gimp_pdb_register_procedure (pdb, procedure);
725
  g_object_unref (procedure);
726 727 728 729

  /*
   * gimp-palette-is-editable
   */
730
  procedure = gimp_procedure_new (palette_is_editable_invoker);
731 732
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-palette-is-editable");
733 734 735 736 737 738 739 740 741 742 743 744
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-palette-is-editable",
                                     "Tests if palette can be edited",
                                     "Returns TRUE if you have permission to change the palette",
                                     "Bill Skaggs <weskaggs@primate.ucdavis.edu>",
                                     "Bill Skaggs",
                                     "2004",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("name",
                                                       "name",
                                                       "The palette name",
745
                                                       FALSE, FALSE, TRUE,
746 747 748 749 750 751 752 753
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   g_param_spec_boolean ("editable",
                                                         "editable",
                                                         "TRUE if the palette can be edited",
                                                         FALSE,
                                                         GIMP_PARAM_READWRITE));
754
  gimp_pdb_register_procedure (pdb, procedure);
755
  g_object_unref (procedure);
756 757 758 759

  /*
   * gimp-palette-get-info
   */
760
  procedure = gimp_procedure_new (palette_get_info_invoker);
761 762
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-palette-get-info");
763 764 765 766 767 768 769 770 771 772 773 774
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-palette-get-info",
                                     "Retrieve information about the specified palette.",
                                     "This procedure retrieves information about the specified palette. This includes the name, and the number of colors.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2004",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("name",
                                                       "name",
                                                       "The palette name",
775
                                                       FALSE, FALSE, TRUE,
776 777 778 779 780 781 782 783
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_int32 ("num-colors",
                                                          "num colors",
                                                          "The number of colors in the palette",
                                                          G_MININT32, G_MAXINT32, 0,
                                                          GIMP_PARAM_READWRITE));
784
  gimp_pdb_register_procedure (pdb, procedure);
785
  g_object_unref (procedure);
786

787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821
  /*
   * gimp-palette-get-colors
   */
  procedure = gimp_procedure_new (palette_get_colors_invoker);
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-palette-get-colors");
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-palette-get-colors",
                                     "Gets all colors from the specified palette.",
                                     "This procedure retrieves all color entries of the specified palette.",
                                     "Sven Neumann <sven@gimp.org>",
                                     "Sven Neumann",
                                     "2006",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("name",
                                                       "name",
                                                       "The palette name",
                                                       FALSE, FALSE, TRUE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_int32 ("num-colors",
                                                          "num colors",
                                                          "Length of the colors array",
                                                          0, G_MAXINT32, 0,
                                                          GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_color_array ("colors",
                                                                "colors",
                                                                "The colors in the palette",
                                                                GIMP_PARAM_READWRITE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

822 823 824
  /*
   * gimp-palette-get-columns
   */
825
  procedure = gimp_procedure_new (palette_get_columns_invoker);
826 827
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-palette-get-columns");
828 829 830 831 832 833 834 835 836 837 838 839
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-palette-get-columns",
                                     "Retrieves the number of columns to use to display this palette",
                                     "This procedures retrieves the prefered number of columns to use when the palette is being displayed.",
                                     "Sven Neumann <sven@gimp.org>",
                                     "Sven Neumann",
                                     "2005",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("name",
                                                       "name",
                                                       "The palette name",
840
                                                       FALSE, FALSE, TRUE,
841 842 843 844 845 846 847 848
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_int32 ("num-columns",
                                                          "num columns",
                                                          "The number of columns used to display this palette",
                                                          G_MININT32, G_MAXINT32, 0,
                                                          GIMP_PARAM_READWRITE));
849
  gimp_pdb_register_procedure (pdb, procedure);
850
  g_object_unref (procedure);
851

852 853 854
  /*
   * gimp-palette-set-columns
   */
855
  procedure = gimp_procedure_new (palette_set_columns_invoker);
856 857
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-palette-set-columns");
858 859 860 861 862 863 864 865 866 867 868 869
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-palette-set-columns",
                                     "Sets the number of columns to use when displaying the palette",
                                     "This procedures allows to control how many colors are shown per row when the palette is being displayed. This value can only be changed if the palette is writable. The maximum allowed value is 64.",
                                     "Sven Neumann <sven@gimp.org>",
                                     "Sven Neumann",
                                     "2005",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("name",
                                                       "name",
                                                       "The palette name",
870
                                                       FALSE, FALSE, TRUE,
871 872 873 874 875 876 877 878
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_int32 ("columns",
                                                      "columns",
                                                      "The new number of columns",
                                                      0, 64, 0,
                                                      GIMP_PARAM_READWRITE));
879
  gimp_pdb_register_procedure (pdb, procedure);
880
  g_object_unref (procedure);
881

882 883 884
  /*
   * gimp-palette-add-entry
   */
885
  procedure = gimp_procedure_new (palette_add_entry_invoker);
886 887
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-palette-add-entry");
888 889 890 891 892 893 894 895 896 897 898 899
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-palette-add-entry",
                                     "Adds a palette entry to the specified palette.",
                                     "This procedure adds an entry to the specifed palette. It returns an error if the entry palette does not exist.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2004",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("name",
                                                       "name",
                                                       "The palette name",
900
                                                       FALSE, FALSE, TRUE,
901 902 903 904 905 906
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("entry-name",
                                                       "entry name",
                                                       "The name of the entry",
907
                                                       FALSE, TRUE, FALSE,
908 909 910 911 912 913
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_rgb ("color",
                                                    "color",
                                                    "The new entry's color color",
914
                                                    FALSE,
915 916 917 918 919 920 921 922
                                                    NULL,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_int32 ("entry-num",
                                                          "entry num",
                                                          "The index of the added entry",
                                                          G_MININT32, G_MAXINT32, 0,
                                                          GIMP_PARAM_READWRITE));
923
  gimp_pdb_register_procedure (pdb, procedure);
924
  g_object_unref (procedure);
925

926 927 928
  /*
   * gimp-palette-delete-entry
   */
929
  procedure = gimp_procedure_new (palette_delete_entry_invoker);
930 931
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-palette-delete-entry");
932 933 934 935 936 937 938 939 940 941 942 943
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-palette-delete-entry",
                                     "Deletes a palette entry from the specified palette.",
                                     "This procedure deletes an entry from the specifed palette. It returns an error if the entry palette does not exist.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2004",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("name",
                                                       "name",
                                                       "The palette name",
944
                                                       FALSE, FALSE, TRUE,
945 946 947 948 949 950 951 952
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_int32 ("entry-num",
                                                      "entry num",
                                                      "The index of the added entry",
                                                      G_MININT32, G_MAXINT32, 0,
                                                      GIMP_PARAM_READWRITE));
953
  gimp_pdb_register_procedure (pdb, procedure);
954
  g_object_unref (procedure);
955

956 957 958
  /*
   * gimp-palette-entry-get-color
   */
959
  procedure = gimp_procedure_new (palette_entry_get_color_invoker);
960 961
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-palette-entry-get-color");
962 963 964 965 966 967 968 969 970 971 972 973
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-palette-entry-get-color",
                                     "Gets the specified palette entry from the specified palette.",
                                     "This procedure retrieves the color of the zero-based entry specifed for the specified palette. It returns an error if the entry does not exist.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2004",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("name",
                                                       "name",
                                                       "The palette name",
974
                                                       FALSE, FALSE, TRUE,
975 976 977 978 979 980 981 982 983 984 985 986
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_int32 ("entry-num",
                                                      "entry num",
                                                      "The entry to retrieve",
                                                      G_MININT32, G_MAXINT32, 0,
                                                      GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_rgb ("color",
                                                        "color",
                                                        "The color requested",
987
                                                        FALSE,
988 989
                                                        NULL,
                                                        GIMP_PARAM_READWRITE));
990
  gimp_pdb_register_procedure (pdb, procedure);
991
  g_object_unref (procedure);
992

993 994 995
  /*
   * gimp-palette-entry-set-color
   */
996
  procedure = gimp_procedure_new (palette_entry_set_color_invoker);
997 998
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-palette-entry-set-color");
999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-palette-entry-set-color",
                                     "Sets the specified palette entry in the specified palette.",
                                     "This procedure sets the color of the zero-based entry specifed for the specified palette. It returns an error if the entry does not exist.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2004",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("name",
                                                       "name",
                                                       "The palette name",
1011
                                                       FALSE, FALSE, TRUE,
1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_int32 ("entry-num",
                                                      "entry num",
                                                      "The entry to retrieve",
                                                      G_MININT32, G_MAXINT32, 0,
                                                      GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_rgb ("color",
                                                    "color",
                                                    "The new color",
1024
                                                    FALSE,
1025 1026
                                                    NULL,
                                                    GIMP_PARAM_READWRITE));
1027
  gimp_pdb_register_procedure (pdb, procedure);
1028
  g_object_unref (procedure);
1029

1030 1031 1032
  /*
   * gimp-palette-entry-get-name
   */
1033
  procedure = gimp_procedure_new (palette_entry_get_name_invoker);
1034 1035
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-palette-entry-get-name");
1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-palette-entry-get-name",
                                     "Gets the specified palette entry from the specified palette.",
                                     "This procedure retrieves the name of the zero-based entry specifed for the specified palette. It returns an error if the entry does not exist.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2004",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("name",
                                                       "name",
                                                       "The palette name",
1048
                                                       FALSE, FALSE, TRUE,
1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_int32 ("entry-num",
                                                      "entry num",
                                                      "The entry to retrieve",
                                                      G_MININT32, G_MAXINT32, 0,
                                                      GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string ("entry-name",
                                                           "entry name",
                                                           "The name requested",
1061
                                                           FALSE, FALSE, FALSE,
1062 1063
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
1064
  gimp_pdb_register_procedure (pdb, procedure);
1065
  g_object_unref (procedure);
1066

1067 1068 1069
  /*
   * gimp-palette-entry-set-name
   */
1070
  procedure = gimp_procedure_new (palette_entry_set_name_invoker);
1071 1072
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-palette-entry-set-name");
1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-palette-entry-set-name",
                                     "Sets the specified palette entry in the specified palette.",
                                     "This procedure sets the name of the zero-based entry specifed for the specified palette. It returns an error if the entry does not exist.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2004",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("name",
                                                       "name",
                                                       "The palette name",
1085
                                                       FALSE, FALSE, TRUE,
1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_int32 ("entry-num",
                                                      "entry num",
                                                      "The entry to retrieve",
                                                      G_MININT32, G_MAXINT32, 0,
                                                      GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("entry-name",
                                                       "entry name",
                                                       "The new name",
1098
                                                       FALSE, TRUE, FALSE,
1099 1100
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
1101
  gimp_pdb_register_procedure (pdb, procedure);
1102
  g_object_unref (procedure);
1103
}