brush-cmds.c 70.3 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 22 23

#include "config.h"

#include <string.h>

24
#include <gegl.h>
25 26 27 28 29 30

#include "pdb-types.h"

#include "base/temp-buf.h"
#include "core/gimp.h"
#include "core/gimpbrush.h"
31
#include "core/gimpbrushgenerated.h"
32 33
#include "core/gimpcontext.h"
#include "core/gimpdatafactory.h"
34
#include "core/gimpparamspecs.h"
35

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

41

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

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

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

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

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

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

74
  return return_vals;
75 76
}

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

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

  if (success)
    {
94
      GimpBrush *brush = gimp_pdb_get_brush (gimp, name, FALSE, error);
95 96 97

      if (brush)
        {
98
          GimpBrush *brush_copy = (GimpBrush *)
99 100 101
            gimp_data_factory_data_duplicate (gimp->brush_factory,
                                              GIMP_DATA (brush));

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

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

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

117
  return return_vals;
118 119
}

120
static GValueArray *
121 122 123 124 125 126
brush_is_generated_invoker (GimpProcedure      *procedure,
                            Gimp               *gimp,
                            GimpContext        *context,
                            GimpProgress       *progress,
                            const GValueArray  *args,
                            GError            **error)
127 128
{
  gboolean success = TRUE;
129
  GValueArray *return_vals;
130
  const gchar *name;
131
  gboolean generated = FALSE;
132

133
  name = g_value_get_string (&args->values[0]);
134 135 136

  if (success)
    {
137
      GimpBrush *brush = gimp_pdb_get_brush (gimp, name, FALSE, error);
138 139

      if (brush)
140
        generated = GIMP_IS_BRUSH_GENERATED (brush);
141 142 143 144
      else
        success = FALSE;
    }

145 146
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
147 148

  if (success)
149
    g_value_set_boolean (&return_vals->values[1], generated);
150

151
  return return_vals;
152 153
}

154
static GValueArray *
155 156 157 158 159 160
brush_rename_invoker (GimpProcedure      *procedure,
                      Gimp               *gimp,
                      GimpContext        *context,
                      GimpProgress       *progress,
                      const GValueArray  *args,
                      GError            **error)
161 162
{
  gboolean success = TRUE;
163
  GValueArray *return_vals;
164 165
  const gchar *name;
  const gchar *new_name;
166
  gchar *actual_name = NULL;
167

168 169
  name = g_value_get_string (&args->values[0]);
  new_name = g_value_get_string (&args->values[1]);
170 171 172

  if (success)
    {
173
      GimpBrush *brush = gimp_pdb_get_brush (gimp, name, TRUE, error);
174

175
      if (brush)
176 177
        {
          gimp_object_set_name (GIMP_OBJECT (brush), new_name);
178
          actual_name = g_strdup (gimp_object_get_name (brush));
179
        }
180 181 182 183
      else
        success = FALSE;
    }

184 185
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
186 187

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

190
  return return_vals;
191 192
}

193
static GValueArray *
194 195 196 197 198 199
brush_delete_invoker (GimpProcedure      *procedure,
                      Gimp               *gimp,
                      GimpContext        *context,
                      GimpProgress       *progress,
                      const GValueArray  *args,
                      GError            **error)
200 201
{
  gboolean success = TRUE;
202
  const gchar *name;
203

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

  if (success)
    {
208
      GimpBrush *brush = gimp_pdb_get_brush (gimp, name, FALSE, error);
209

210
      if (brush && gimp_data_is_deletable (GIMP_DATA (brush)))
211 212 213
        success = gimp_data_factory_data_delete (gimp->brush_factory,
                                                 GIMP_DATA (brush),
                                                 TRUE, error);
214 215 216 217
      else
        success = FALSE;
    }

218 219
  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
220 221
}

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

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

  if (success)
    {
239
      GimpBrush *brush = gimp_pdb_get_brush (gimp, name, FALSE, error);
240 241

      if (brush)
242
        editable = gimp_data_is_writable (GIMP_DATA (brush));
243 244 245 246
      else
        success = FALSE;
    }

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

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

253
  return return_vals;
254 255
}

256
static GValueArray *
257 258 259 260 261 262
brush_get_info_invoker (GimpProcedure      *procedure,
                        Gimp               *gimp,
                        GimpContext        *context,
                        GimpProgress       *progress,
                        const GValueArray  *args,
                        GError            **error)
263 264
{
  gboolean success = TRUE;
265
  GValueArray *return_vals;
266
  const gchar *name;
267 268 269 270
  gint32 width = 0;
  gint32 height = 0;
  gint32 mask_bpp = 0;
  gint32 color_bpp = 0;
271

272
  name = g_value_get_string (&args->values[0]);
273 274 275

  if (success)
    {
276
      GimpBrush *brush = gimp_pdb_get_brush (gimp, name, FALSE, error);
277

278 279 280 281 282 283 284 285 286
      if (brush)
        {
          width     = brush->mask->width;
          height    = brush->mask->height;
          mask_bpp  = brush->mask->bytes;
          color_bpp = brush->pixmap ? brush->pixmap->bytes : 0;
        }
      else
        success = FALSE;
287 288
    }

289 290
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
291 292 293

  if (success)
    {
294 295 296 297
      g_value_set_int (&return_vals->values[1], width);
      g_value_set_int (&return_vals->values[2], height);
      g_value_set_int (&return_vals->values[3], mask_bpp);
      g_value_set_int (&return_vals->values[4], color_bpp);
298 299
    }

300
  return return_vals;
301 302
}

303
static GValueArray *
304 305 306 307 308 309
brush_get_pixels_invoker (GimpProcedure      *procedure,
                          Gimp               *gimp,
                          GimpContext        *context,
                          GimpProgress       *progress,
                          const GValueArray  *args,
                          GError            **error)
310 311
{
  gboolean success = TRUE;
312
  GValueArray *return_vals;
313
  const gchar *name;
314 315
  gint32 width = 0;
  gint32 height = 0;
316
  gint32 mask_bpp = 0;
317 318
  gint32 num_mask_bytes = 0;
  guint8 *mask_bytes = NULL;
319 320 321
  gint32 color_bpp = 0;
  gint32 num_color_bytes = 0;
  guint8 *color_bytes = NULL;
322

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

  if (success)
    {
327
      GimpBrush *brush = gimp_pdb_get_brush (gimp, name, FALSE, error);
328 329 330

      if (brush)
        {
331 332
          width          = brush->mask->width;
          height         = brush->mask->height;
333
          mask_bpp       = brush->mask->bytes;
334 335
          num_mask_bytes = brush->mask->height * brush->mask->width *
                           brush->mask->bytes;
336
          mask_bytes     = g_memdup (temp_buf_get_data (brush->mask), num_mask_bytes);
337 338 339 340

          if (brush->pixmap)
            {
              color_bpp       = brush->pixmap->bytes;
341 342
              num_color_bytes = brush->pixmap->height * brush->pixmap->width *
                                brush->pixmap->bytes;
343
              color_bytes     = g_memdup (temp_buf_get_data (brush->pixmap),
344 345
                                          num_color_bytes);
            }
346 347 348 349 350
        }
      else
        success = FALSE;
    }

351 352
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
353 354 355

  if (success)
    {
356 357 358 359 360 361 362 363
      g_value_set_int (&return_vals->values[1], width);
      g_value_set_int (&return_vals->values[2], height);
      g_value_set_int (&return_vals->values[3], mask_bpp);
      g_value_set_int (&return_vals->values[4], num_mask_bytes);
      gimp_value_take_int8array (&return_vals->values[5], mask_bytes, num_mask_bytes);
      g_value_set_int (&return_vals->values[6], color_bpp);
      g_value_set_int (&return_vals->values[7], num_color_bytes);
      gimp_value_take_int8array (&return_vals->values[8], color_bytes, num_color_bytes);
364 365
    }

366
  return return_vals;
367 368
}

369
static GValueArray *
370 371 372 373 374 375
brush_get_spacing_invoker (GimpProcedure      *procedure,
                           Gimp               *gimp,
                           GimpContext        *context,
                           GimpProgress       *progress,
                           const GValueArray  *args,
                           GError            **error)
376 377
{
  gboolean success = TRUE;
378
  GValueArray *return_vals;
379
  const gchar *name;
380
  gint32 spacing = 0;
381

382
  name = g_value_get_string (&args->values[0]);
383 384 385

  if (success)
    {
386
      GimpBrush *brush = gimp_pdb_get_brush (gimp, name, FALSE, error);
387

388 389 390 391
      if (brush)
        spacing = gimp_brush_get_spacing (brush);
      else
        success = FALSE;
392 393
    }

394 395
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
396 397

  if (success)
398
    g_value_set_int (&return_vals->values[1], spacing);
399

400
  return return_vals;
401 402
}

403
static GValueArray *
404 405 406 407 408 409
brush_set_spacing_invoker (GimpProcedure      *procedure,
                           Gimp               *gimp,
                           GimpContext        *context,
                           GimpProgress       *progress,
                           const GValueArray  *args,
                           GError            **error)
410 411
{
  gboolean success = TRUE;
412
  const gchar *name;
413 414
  gint32 spacing;

415 416
  name = g_value_get_string (&args->values[0]);
  spacing = g_value_get_int (&args->values[1]);
417 418 419

  if (success)
    {
420
      GimpBrush *brush = gimp_pdb_get_brush (gimp, name, TRUE, error);
421

422
      if (brush)
423 424 425 426 427
        gimp_brush_set_spacing (brush, spacing);
      else
        success = FALSE;
    }

428 429
  return gimp_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
430 431 432
}

static GValueArray *
433 434 435 436 437 438
brush_get_shape_invoker (GimpProcedure      *procedure,
                         Gimp               *gimp,
                         GimpContext        *context,
                         GimpProgress       *progress,
                         const GValueArray  *args,
                         GError            **error)
439 440 441 442 443 444 445 446 447 448
{
  gboolean success = TRUE;
  GValueArray *return_vals;
  const gchar *name;
  gint32 shape = 0;

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

  if (success)
    {
449
      GimpBrush *brush = gimp_pdb_get_generated_brush (gimp, name, FALSE, error);
450

451
      if (brush)
452 453 454 455 456
        shape = GIMP_BRUSH_GENERATED (brush)->shape;
      else
        success = FALSE;
    }

457 458
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
459 460 461 462 463 464 465 466

  if (success)
    g_value_set_enum (&return_vals->values[1], shape);

  return return_vals;
}

static GValueArray *
467 468 469 470 471 472
brush_set_shape_invoker (GimpProcedure      *procedure,
                         Gimp               *gimp,
                         GimpContext        *context,
                         GimpProgress       *progress,
                         const GValueArray  *args,
                         GError            **error)
473 474 475 476
{
  gboolean success = TRUE;
  GValueArray *return_vals;
  const gchar *name;
477 478
  gint32 shape_in;
  gint32 shape_out = 0;
479 480

  name = g_value_get_string (&args->values[0]);
481
  shape_in = g_value_get_enum (&args->values[1]);
482 483 484

  if (success)
    {
485
      GimpBrush *brush = gimp_pdb_get_generated_brush (gimp, name, TRUE, error);
486

487
      if (brush)
488 489 490 491 492
        {
          gimp_brush_generated_set_shape (GIMP_BRUSH_GENERATED (brush),
                                          shape_in);
          shape_out = GIMP_BRUSH_GENERATED (brush)->shape;
        }
493 494 495 496
      else
        success = FALSE;
    }

497 498
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
499 500

  if (success)
501
    g_value_set_enum (&return_vals->values[1], shape_out);
502 503 504 505 506

  return return_vals;
}

static GValueArray *
507
brush_get_radius_invoker (GimpProcedure      *procedure,
508 509 510 511 512
                          Gimp               *gimp,
                          GimpContext        *context,
                          GimpProgress       *progress,
                          const GValueArray  *args,
                          GError            **error)
513 514 515 516
{
  gboolean success = TRUE;
  GValueArray *return_vals;
  const gchar *name;
517
  gdouble radius = 0.0;
518 519 520 521 522

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

  if (success)
    {
523
      GimpBrush *brush = gimp_pdb_get_generated_brush (gimp, name, FALSE, error);
524

525
      if (brush)
526
        radius = GIMP_BRUSH_GENERATED (brush)->radius;
527 528 529 530
      else
        success = FALSE;
    }

531 532
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
533 534

  if (success)
535
    g_value_set_double (&return_vals->values[1], radius);
536 537 538 539 540

  return return_vals;
}

static GValueArray *
541 542 543 544 545 546
brush_set_radius_invoker (GimpProcedure      *procedure,
                          Gimp               *gimp,
                          GimpContext        *context,
                          GimpProgress       *progress,
                          const GValueArray  *args,
                          GError            **error)
547 548 549 550
{
  gboolean success = TRUE;
  GValueArray *return_vals;
  const gchar *name;
551 552
  gdouble radius_in;
  gdouble radius_out = 0.0;
553 554

  name = g_value_get_string (&args->values[0]);
555
  radius_in = g_value_get_double (&args->values[1]);
556 557 558

  if (success)
    {
559
      GimpBrush *brush = gimp_pdb_get_generated_brush (gimp, name, TRUE, error);
560

561
      if (brush)
562 563 564 565 566
        {
          gimp_brush_generated_set_radius (GIMP_BRUSH_GENERATED (brush),
                                           radius_in);
          radius_out = GIMP_BRUSH_GENERATED (brush)->radius;
        }
567 568 569 570
      else
        success = FALSE;
    }

571 572
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
573 574

  if (success)
575
    g_value_set_double (&return_vals->values[1], radius_out);
576 577 578 579 580

  return return_vals;
}

static GValueArray *
581 582 583 584 585 586
brush_get_spikes_invoker (GimpProcedure      *procedure,
                          Gimp               *gimp,
                          GimpContext        *context,
                          GimpProgress       *progress,
                          const GValueArray  *args,
                          GError            **error)
587 588 589 590
{
  gboolean success = TRUE;
  GValueArray *return_vals;
  const gchar *name;
591
  gint32 spikes = 0;
592 593 594 595 596

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

  if (success)
    {
597
      GimpBrush *brush = gimp_pdb_get_generated_brush (gimp, name, FALSE, error);
598

599
      if (brush)
600
        spikes = GIMP_BRUSH_GENERATED (brush)->spikes;
601 602 603 604
      else
        success = FALSE;
    }

605 606
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
607 608

  if (success)
609
    g_value_set_int (&return_vals->values[1], spikes);
610 611 612 613 614

  return return_vals;
}

static GValueArray *
615 616 617 618 619 620
brush_set_spikes_invoker (GimpProcedure      *procedure,
                          Gimp               *gimp,
                          GimpContext        *context,
                          GimpProgress       *progress,
                          const GValueArray  *args,
                          GError            **error)
621 622 623 624
{
  gboolean success = TRUE;
  GValueArray *return_vals;
  const gchar *name;
625 626
  gint32 spikes_in;
  gint32 spikes_out = 0;
627 628

  name = g_value_get_string (&args->values[0]);
629
  spikes_in = g_value_get_int (&args->values[1]);
630 631 632

  if (success)
    {
633
      GimpBrush *brush = gimp_pdb_get_generated_brush (gimp, name, TRUE, error);
634

635
      if (brush)
636 637 638 639 640
        {
          gimp_brush_generated_set_spikes (GIMP_BRUSH_GENERATED (brush),
                                           spikes_in);
          spikes_out = GIMP_BRUSH_GENERATED (brush)->spikes;
        }
641 642 643 644
      else
        success = FALSE;
    }

645 646
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
647 648

  if (success)
649
    g_value_set_int (&return_vals->values[1], spikes_out);
650 651

  return return_vals;
652 653
}

654
static GValueArray *
655 656 657 658 659 660
brush_get_hardness_invoker (GimpProcedure      *procedure,
                            Gimp               *gimp,
                            GimpContext        *context,
                            GimpProgress       *progress,
                            const GValueArray  *args,
                            GError            **error)
661 662
{
  gboolean success = TRUE;
663
  GValueArray *return_vals;
664
  const gchar *name;
665
  gdouble hardness = 0.0;
666

667
  name = g_value_get_string (&args->values[0]);
668 669 670

  if (success)
    {
671
      GimpBrush *brush = gimp_pdb_get_generated_brush (gimp, name, FALSE, error);
672

673
      if (brush)
674
        hardness = GIMP_BRUSH_GENERATED (brush)->hardness;
675 676
      else
        success = FALSE;
677 678
    }

679 680
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
681 682

  if (success)
683
    g_value_set_double (&return_vals->values[1], hardness);
684

685
  return return_vals;
686 687
}

688
static GValueArray *
689 690 691 692 693 694
brush_set_hardness_invoker (GimpProcedure      *procedure,
                            Gimp               *gimp,
                            GimpContext        *context,
                            GimpProgress       *progress,
                            const GValueArray  *args,
                            GError            **error)
695 696
{
  gboolean success = TRUE;
697
  GValueArray *return_vals;
698
  const gchar *name;
699 700
  gdouble hardness_in;
  gdouble hardness_out = 0.0;
701

702
  name = g_value_get_string (&args->values[0]);
703
  hardness_in = g_value_get_double (&args->values[1]);
704 705 706

  if (success)
    {
707
      GimpBrush *brush = gimp_pdb_get_generated_brush (gimp, name, TRUE, error);
708

709
      if (brush)
710
        {
711 712 713
          gimp_brush_generated_set_hardness (GIMP_BRUSH_GENERATED (brush),
                                             hardness_in);
          hardness_out = GIMP_BRUSH_GENERATED (brush)->hardness;
714
        }
715 716
      else
        success = FALSE;
717 718
    }

719 720
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
721 722

  if (success)
723
    g_value_set_double (&return_vals->values[1], hardness_out);
724

725
  return return_vals;
726 727
}

728
static GValueArray *
729 730 731 732 733 734
brush_get_aspect_ratio_invoker (GimpProcedure      *procedure,
                                Gimp               *gimp,
                                GimpContext        *context,
                                GimpProgress       *progress,
                                const GValueArray  *args,
                                GError            **error)
735 736
{
  gboolean success = TRUE;
737
  GValueArray *return_vals;
738
  const gchar *name;
739
  gdouble aspect_ratio = 0.0;
740

741
  name = g_value_get_string (&args->values[0]);
742 743 744

  if (success)
    {
745
      GimpBrush *brush = gimp_pdb_get_generated_brush (gimp, name, FALSE, error);
746

747
      if (brush)
748
        aspect_ratio = GIMP_BRUSH_GENERATED (brush)->aspect_ratio;
749 750
      else
        success = FALSE;
751 752
    }

753 754
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
755 756

  if (success)
757
    g_value_set_double (&return_vals->values[1], aspect_ratio);
758

759
  return return_vals;
760 761
}

762
static GValueArray *
763 764 765 766 767 768
brush_set_aspect_ratio_invoker (GimpProcedure      *procedure,
                                Gimp               *gimp,
                                GimpContext        *context,
                                GimpProgress       *progress,
                                const GValueArray  *args,
                                GError            **error)
769 770
{
  gboolean success = TRUE;
771
  GValueArray *return_vals;
772
  const gchar *name;
773 774
  gdouble aspect_ratio_in;
  gdouble aspect_ratio_out = 0.0;
775

776
  name = g_value_get_string (&args->values[0]);
777
  aspect_ratio_in = g_value_get_double (&args->values[1]);
778 779 780

  if (success)
    {
781
      GimpBrush *brush = gimp_pdb_get_generated_brush (gimp, name, TRUE, error);
782

783
      if (brush)
784
        {
785 786 787
          gimp_brush_generated_set_aspect_ratio (GIMP_BRUSH_GENERATED (brush),
                                                 aspect_ratio_in);
          aspect_ratio_out = GIMP_BRUSH_GENERATED (brush)->aspect_ratio;
788
        }
789 790
      else
        success = FALSE;
791 792
    }

793 794
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
795 796

  if (success)
797
    g_value_set_double (&return_vals->values[1], aspect_ratio_out);
798

799
  return return_vals;
800 801
}

802
static GValueArray *
803 804 805 806 807 808
brush_get_angle_invoker (GimpProcedure      *procedure,
                         Gimp               *gimp,
                         GimpContext        *context,
                         GimpProgress       *progress,
                         const GValueArray  *args,
                         GError            **error)
809 810
{
  gboolean success = TRUE;
811
  GValueArray *return_vals;
812
  const gchar *name;
813
  gdouble angle = 0.0;
814

815
  name = g_value_get_string (&args->values[0]);
816 817 818

  if (success)
    {
819
      GimpBrush *brush = gimp_pdb_get_generated_brush (gimp, name, FALSE, error);
820

821
      if (brush)
822
        angle = GIMP_BRUSH_GENERATED (brush)->angle;
823 824
      else
        success = FALSE;
825 826
    }

827 828
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
829 830

  if (success)
831
    g_value_set_double (&return_vals->values[1], angle);
832

833
  return return_vals;
834 835
}

836
static GValueArray *
837 838 839 840 841 842
brush_set_angle_invoker (GimpProcedure      *procedure,
                         Gimp               *gimp,
                         GimpContext        *context,
                         GimpProgress       *progress,
                         const GValueArray  *args,
                         GError            **error)
843 844
{
  gboolean success = TRUE;
845
  GValueArray *return_vals;
846
  const gchar *name;
847 848
  gdouble angle_in;
  gdouble angle_out = 0.0;
849

850
  name = g_value_get_string (&args->values[0]);
851
  angle_in = g_value_get_double (&args->values[1]);
852 853 854

  if (success)
    {
855
      GimpBrush *brush = gimp_pdb_get_generated_brush (gimp, name, TRUE, error);
856

857
      if (brush)
858 859 860 861 862
        {
          gimp_brush_generated_set_angle (GIMP_BRUSH_GENERATED (brush),
                                          angle_in);
          angle_out = GIMP_BRUSH_GENERATED (brush)->angle;
        }
863 864
      else
        success = FALSE;
865 866
    }

867 868
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
869 870

  if (success)
871
    g_value_set_double (&return_vals->values[1], angle_out);
872

873
  return return_vals;
874 875
}

876
void
877
register_brush_procs (GimpPDB *pdb)
878
{
879
  GimpProcedure *procedure;
880

881 882 883
  /*
   * gimp-brush-new
   */
884
  procedure = gimp_procedure_new (brush_new_invoker);
885 886
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-brush-new");
887 888 889 890 891 892 893 894 895 896 897 898
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-brush-new",
                                     "Creates a new brush",
                                     "This procedure creates a new, uninitialized brush",
                                     "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 brush",
899
                                                       FALSE, FALSE, TRUE,
900 901 902 903 904 905
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string ("actual-name",
                                                           "actual name",
                                                           "The actual new brush name",
906
                                                           FALSE, FALSE, FALSE,
907 908
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
909
  gimp_pdb_register_procedure (pdb, procedure);
910
  g_object_unref (procedure);
911

912 913 914
  /*
   * gimp-brush-duplicate
   */
915
  procedure = gimp_procedure_new (brush_duplicate_invoker);
916 917
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-brush-duplicate");
918 919 920 921 922 923 924 925 926 927 928 929
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-brush-duplicate",
                                     "Duplicates a brush",
                                     "This procedure creates an identical brush 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 brush name",
930
                                                       FALSE, FALSE, TRUE,
931 932 933 934 935 936
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string ("copy-name",
                                                           "copy name",
                                                           "The name of the brush's copy",
937
                                                           FALSE, FALSE, FALSE,
938 939
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
940
  gimp_pdb_register_procedure (pdb, procedure);
941
  g_object_unref (procedure);
942

943 944 945
  /*
   * gimp-brush-is-generated
   */
946
  procedure = gimp_procedure_new (brush_is_generated_invoker);
947 948
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-brush-is-generated");
949 950 951 952 953 954 955 956 957 958 959 960
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-brush-is-generated",
                                     "Tests if brush is generated",
                                     "Returns TRUE if this brush is parametric, FALSE for other types",
                                     "Bill Skaggs <weskaggs@primate.ucdavis.edu>",
                                     "Bill Skaggs",
                                     "2004",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("name",
                                                       "name",
                                                       "The brush name",
961
                                                       FALSE, FALSE, TRUE,
962 963 964 965 966 967 968 969
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   g_param_spec_boolean ("generated",
                                                         "generated",
                                                         "TRUE if the brush is generated",
                                                         FALSE,
                                                         GIMP_PARAM_READWRITE));
970
  gimp_pdb_register_procedure (pdb, procedure);
971
  g_object_unref (procedure);
972

973 974 975
  /*
   * gimp-brush-rename
   */
976
  procedure = gimp_procedure_new (brush_rename_invoker);
977 978
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-brush-rename");
979 980 981 982 983 984 985 986 987 988 989 990
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-brush-rename",
                                     "Rename a brush",
                                     "This procedure renames a brush",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2004",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("name",
                                                       "name",
                                                       "The brush name",