layer-cmds.c 79.8 KB
Newer Older
1
/* GIMP - The GNU Image Manipulation Program
2
 * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
Elliot Lee's avatar
Elliot Lee committed
3 4 5 6 7 8 9 10 11 12 13 14 15
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (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
 * along with this program; if not, write to the Free Software
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Elliot Lee's avatar
Elliot Lee committed
17 18
 */

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

21 22
#include "config.h"

23
#include <glib-object.h>
Elliot Lee's avatar
Elliot Lee committed
24

25 26
#include "libgimpbase/gimpbase.h"

27
#include "pdb-types.h"
28

29
#include "config/gimpcoreconfig.h"
30
#include "core/gimp.h"
31
#include "core/gimpdrawable.h"
32
#include "core/gimpimage-undo.h"
33
#include "core/gimpimage.h"
34
#include "core/gimpitem-linked.h"
35 36
#include "core/gimplayer.h"
#include "core/gimplayermask.h"
37
#include "core/gimpparamspecs.h"
38

39 40 41
#include "gimppdb.h"
#include "gimppdb-utils.h"
#include "gimpprocedure.h"
42
#include "internal-procs.h"
43

44 45
#include "gimp-intl.h"

Elliot Lee's avatar
Elliot Lee committed
46

47
static GValueArray *
48 49 50 51 52 53
layer_new_invoker (GimpProcedure      *procedure,
                   Gimp               *gimp,
                   GimpContext        *context,
                   GimpProgress       *progress,
                   const GValueArray  *args,
                   GError            **error)
Elliot Lee's avatar
Elliot Lee committed
54
{
55
  gboolean success = TRUE;
56
  GValueArray *return_vals;
57
  GimpImage *image;
58 59 60
  gint32 width;
  gint32 height;
  gint32 type;
61
  const gchar *name;
62
  gdouble opacity;
63 64
  gint32 mode;
  GimpLayer *layer = NULL;
Elliot Lee's avatar
Elliot Lee committed
65

66 67 68 69 70 71 72
  image = gimp_value_get_image (&args->values[0], gimp);
  width = g_value_get_int (&args->values[1]);
  height = g_value_get_int (&args->values[2]);
  type = g_value_get_enum (&args->values[3]);
  name = g_value_get_string (&args->values[4]);
  opacity = g_value_get_double (&args->values[5]);
  mode = g_value_get_enum (&args->values[6]);
Elliot Lee's avatar
Elliot Lee committed
73 74 75

  if (success)
    {
76
      layer = gimp_layer_new (image, width, height, type, name,
77
                              opacity / 100.0, mode);
78 79 80

      if (! layer)
        success = FALSE;
Elliot Lee's avatar
Elliot Lee committed
81 82
    }

83
  return_vals = gimp_procedure_get_return_values (procedure, success);
Elliot Lee's avatar
Elliot Lee committed
84 85

  if (success)
86
    gimp_value_set_layer (&return_vals->values[1], layer);
Elliot Lee's avatar
Elliot Lee committed
87

88
  return return_vals;
Elliot Lee's avatar
Elliot Lee committed
89 90
}

91
static GValueArray *
92 93 94 95 96 97
layer_new_from_drawable_invoker (GimpProcedure      *procedure,
                                 Gimp               *gimp,
                                 GimpContext        *context,
                                 GimpProgress       *progress,
                                 const GValueArray  *args,
                                 GError            **error)
98 99
{
  gboolean success = TRUE;
100
  GValueArray *return_vals;
101 102 103 104
  GimpDrawable *drawable;
  GimpImage *dest_image;
  GimpLayer *layer_copy = NULL;

105 106
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
  dest_image = gimp_value_get_image (&args->values[1], gimp);
107 108 109 110 111

  if (success)
    {
      GType     new_type;
      GimpItem *new_item;
112

113
      if (GIMP_IS_LAYER (drawable))
114
        new_type = G_TYPE_FROM_INSTANCE (drawable);
115
      else
116
        new_type = GIMP_TYPE_LAYER;
117

118
      if (dest_image == gimp_item_get_image (GIMP_ITEM (drawable)))
119
        new_item = gimp_item_duplicate (GIMP_ITEM (drawable), new_type);
120
      else
121
        new_item = gimp_item_convert (GIMP_ITEM (drawable), dest_image, new_type);
122

123
      if (new_item)
124
        layer_copy = GIMP_LAYER (new_item);
125
      else
126
        success = FALSE;
127 128
    }

129
  return_vals = gimp_procedure_get_return_values (procedure, success);
130 131

  if (success)
132
    gimp_value_set_layer (&return_vals->values[1], layer_copy);
133

134
  return return_vals;
135 136
}

137
static GValueArray *
138 139 140 141 142 143
layer_copy_invoker (GimpProcedure      *procedure,
                    Gimp               *gimp,
                    GimpContext        *context,
                    GimpProgress       *progress,
                    const GValueArray  *args,
                    GError            **error)
Elliot Lee's avatar
Elliot Lee committed
144
{
145
  gboolean success = TRUE;
146
  GValueArray *return_vals;
147 148
  GimpLayer *layer;
  gboolean add_alpha;
149
  GimpLayer *layer_copy = NULL;
Elliot Lee's avatar
Elliot Lee committed
150

151 152
  layer = gimp_value_get_layer (&args->values[0], gimp);
  add_alpha = g_value_get_boolean (&args->values[1]);
Elliot Lee's avatar
Elliot Lee committed
153 154

  if (success)
155 156
    {
      layer_copy = GIMP_LAYER (gimp_item_duplicate (GIMP_ITEM (layer),
157 158 159 160 161 162 163 164 165 166
                                                    G_TYPE_FROM_INSTANCE (layer)));
      if (layer_copy)
        {
          if (add_alpha)
            gimp_layer_add_alpha (layer_copy);
        }
      else
        {
          success = FALSE;
        }
167
    }
Elliot Lee's avatar
Elliot Lee committed
168

169
  return_vals = gimp_procedure_get_return_values (procedure, success);
Elliot Lee's avatar
Elliot Lee committed
170 171

  if (success)
172
    gimp_value_set_layer (&return_vals->values[1], layer_copy);
Elliot Lee's avatar
Elliot Lee committed
173

174
  return return_vals;
Elliot Lee's avatar
Elliot Lee committed
175 176
}

177
static GValueArray *
178 179 180 181 182 183
layer_add_alpha_invoker (GimpProcedure      *procedure,
                         Gimp               *gimp,
                         GimpContext        *context,
                         GimpProgress       *progress,
                         const GValueArray  *args,
                         GError            **error)
Elliot Lee's avatar
Elliot Lee committed
184
{
185 186
  gboolean success = TRUE;
  GimpLayer *layer;
Elliot Lee's avatar
Elliot Lee committed
187

188
  layer = gimp_value_get_layer (&args->values[0], gimp);
Elliot Lee's avatar
Elliot Lee committed
189 190

  if (success)
191 192 193
    {
      gimp_layer_add_alpha (layer);
    }
Elliot Lee's avatar
Elliot Lee committed
194

195
  return gimp_procedure_get_return_values (procedure, success);
Elliot Lee's avatar
Elliot Lee committed
196 197
}

198
static GValueArray *
199 200 201 202 203 204
layer_flatten_invoker (GimpProcedure      *procedure,
                       Gimp               *gimp,
                       GimpContext        *context,
                       GimpProgress       *progress,
                       const GValueArray  *args,
                       GError            **error)
205 206 207 208 209 210 211 212 213 214 215 216 217 218
{
  gboolean success = TRUE;
  GimpLayer *layer;

  layer = gimp_value_get_layer (&args->values[0], gimp);

  if (success)
    {
      gimp_layer_flatten (layer, context);
    }

  return gimp_procedure_get_return_values (procedure, success);
}

219
static GValueArray *
220 221 222 223 224 225
layer_scale_invoker (GimpProcedure      *procedure,
                     Gimp               *gimp,
                     GimpContext        *context,
                     GimpProgress       *progress,
                     const GValueArray  *args,
                     GError            **error)
Elliot Lee's avatar
Elliot Lee committed
226
{
227 228 229 230 231
  gboolean success = TRUE;
  GimpLayer *layer;
  gint32 new_width;
  gint32 new_height;
  gboolean local_origin;
Elliot Lee's avatar
Elliot Lee committed
232

233 234 235 236
  layer = gimp_value_get_layer (&args->values[0], gimp);
  new_width = g_value_get_int (&args->values[1]);
  new_height = g_value_get_int (&args->values[2]);
  local_origin = g_value_get_boolean (&args->values[3]);
Elliot Lee's avatar
Elliot Lee committed
237

238
  if (success)
239
    {
240
      if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), error))
241 242 243
        gimp_item_scale_by_origin (GIMP_ITEM (layer), new_width, new_height,
                                   gimp->config->interpolation_type, NULL,
                                   local_origin);
244 245
      else
        success = FALSE;
246
    }
Elliot Lee's avatar
Elliot Lee committed
247

248
  return gimp_procedure_get_return_values (procedure, success);
Elliot Lee's avatar
Elliot Lee committed
249 250
}

251
static GValueArray *
252 253 254 255 256 257
layer_resize_invoker (GimpProcedure      *procedure,
                      Gimp               *gimp,
                      GimpContext        *context,
                      GimpProgress       *progress,
                      const GValueArray  *args,
                      GError            **error)
Elliot Lee's avatar
Elliot Lee committed
258
{
259 260 261 262 263 264
  gboolean success = TRUE;
  GimpLayer *layer;
  gint32 new_width;
  gint32 new_height;
  gint32 offx;
  gint32 offy;
Elliot Lee's avatar
Elliot Lee committed
265

266 267 268 269 270
  layer = gimp_value_get_layer (&args->values[0], gimp);
  new_width = g_value_get_int (&args->values[1]);
  new_height = g_value_get_int (&args->values[2]);
  offx = g_value_get_int (&args->values[3]);
  offy = g_value_get_int (&args->values[4]);
Elliot Lee's avatar
Elliot Lee committed
271

272
  if (success)
273
    {
274
      if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), error))
275 276
        gimp_item_resize (GIMP_ITEM (layer), context,
                          new_width, new_height, offx, offy);
277 278
      else
        success = FALSE;
279
    }
Elliot Lee's avatar
Elliot Lee committed
280

281
  return gimp_procedure_get_return_values (procedure, success);
Elliot Lee's avatar
Elliot Lee committed
282 283
}

284
static GValueArray *
285 286 287 288 289 290
layer_resize_to_image_size_invoker (GimpProcedure      *procedure,
                                    Gimp               *gimp,
                                    GimpContext        *context,
                                    GimpProgress       *progress,
                                    const GValueArray  *args,
                                    GError            **error)
291 292 293 294
{
  gboolean success = TRUE;
  GimpLayer *layer;

295
  layer = gimp_value_get_layer (&args->values[0], gimp);
296 297 298

  if (success)
    {
299
      if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), error))
300
        gimp_layer_resize_to_image (layer, context);
301 302
      else
        success = FALSE;
303 304
    }

305
  return gimp_procedure_get_return_values (procedure, success);
306 307
}

308
static GValueArray *
309 310 311 312 313 314
layer_translate_invoker (GimpProcedure      *procedure,
                         Gimp               *gimp,
                         GimpContext        *context,
                         GimpProgress       *progress,
                         const GValueArray  *args,
                         GError            **error)
Elliot Lee's avatar
Elliot Lee committed
315
{
316 317 318 319
  gboolean success = TRUE;
  GimpLayer *layer;
  gint32 offx;
  gint32 offy;
Elliot Lee's avatar
Elliot Lee committed
320

321 322 323
  layer = gimp_value_get_layer (&args->values[0], gimp);
  offx = g_value_get_int (&args->values[1]);
  offy = g_value_get_int (&args->values[2]);
Elliot Lee's avatar
Elliot Lee committed
324

325 326
  if (success)
    {
327
      GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer));
328

329
      gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_DISPLACE,
330
                                   _("Move Layer"));
331

332
      gimp_item_translate (GIMP_ITEM (layer), offx, offy, TRUE);
333

334
      if (gimp_item_get_linked (GIMP_ITEM (layer)))
335
        gimp_item_linked_translate (GIMP_ITEM (layer), offx, offy, TRUE);
336

337
      gimp_image_undo_group_end (image);
Elliot Lee's avatar
Elliot Lee committed
338 339
    }

340
  return gimp_procedure_get_return_values (procedure, success);
Elliot Lee's avatar
Elliot Lee committed
341 342
}

343
static GValueArray *
344 345 346 347 348 349
layer_set_offsets_invoker (GimpProcedure      *procedure,
                           Gimp               *gimp,
                           GimpContext        *context,
                           GimpProgress       *progress,
                           const GValueArray  *args,
                           GError            **error)
Elliot Lee's avatar
Elliot Lee committed
350
{
351 352 353 354 355
  gboolean success = TRUE;
  GimpLayer *layer;
  gint32 offx;
  gint32 offy;

356 357 358
  layer = gimp_value_get_layer (&args->values[0], gimp);
  offx = g_value_get_int (&args->values[1]);
  offy = g_value_get_int (&args->values[2]);
Elliot Lee's avatar
Elliot Lee committed
359 360 361

  if (success)
    {
362
      GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer));
363

364
      gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_DISPLACE,
365
                                   _("Move Layer"));
366

367 368 369 370
      offx -= GIMP_ITEM (layer)->offset_x;
      offy -= GIMP_ITEM (layer)->offset_y;

      gimp_item_translate (GIMP_ITEM (layer), offx, offy, TRUE);
371

372
      if (gimp_item_get_linked (GIMP_ITEM (layer)))
373
        gimp_item_linked_translate (GIMP_ITEM (layer), offx, offy, TRUE);
374

375
      gimp_image_undo_group_end (image);
Elliot Lee's avatar
Elliot Lee committed
376 377
    }

378
  return gimp_procedure_get_return_values (procedure, success);
Elliot Lee's avatar
Elliot Lee committed
379 380
}

381
static GValueArray *
382 383 384 385 386 387
layer_create_mask_invoker (GimpProcedure      *procedure,
                           Gimp               *gimp,
                           GimpContext        *context,
                           GimpProgress       *progress,
                           const GValueArray  *args,
                           GError            **error)
388 389
{
  gboolean success = TRUE;
390
  GValueArray *return_vals;
391 392 393 394
  GimpLayer *layer;
  gint32 mask_type;
  GimpLayerMask *mask = NULL;

395 396
  layer = gimp_value_get_layer (&args->values[0], gimp);
  mask_type = g_value_get_enum (&args->values[1]);
397 398

  if (success)
399
    {
400
      GimpChannel *channel = NULL;
401

402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
      if (mask_type == GIMP_ADD_CHANNEL_MASK)
        {
          channel = gimp_image_get_active_channel (GIMP_ITEM (layer)->image);

          if (! channel)
            success = FALSE;
        }

      if (success)
        {
          mask = gimp_layer_create_mask (layer, mask_type, channel);

          if (! mask)
            success = FALSE;
        }
417
    }
418

419
  return_vals = gimp_procedure_get_return_values (procedure, success);
420 421

  if (success)
422
    gimp_value_set_layer_mask (&return_vals->values[1], mask);
423

424
  return return_vals;
425 426
}

427
static GValueArray *
428 429 430 431 432 433
layer_get_mask_invoker (GimpProcedure      *procedure,
                        Gimp               *gimp,
                        GimpContext        *context,
                        GimpProgress       *progress,
                        const GValueArray  *args,
                        GError            **error)
Elliot Lee's avatar
Elliot Lee committed
434
{
435
  gboolean success = TRUE;
436
  GValueArray *return_vals;
437
  GimpLayer *layer;
438
  GimpLayerMask *mask = NULL;
439

440
  layer = gimp_value_get_layer (&args->values[0], gimp);
Elliot Lee's avatar
Elliot Lee committed
441

442 443 444 445 446
  if (success)
    {
      mask = gimp_layer_get_mask (layer);
    }

447
  return_vals = gimp_procedure_get_return_values (procedure, success);
448

Elliot Lee's avatar
Elliot Lee committed
449
  if (success)
450
    gimp_value_set_layer_mask (&return_vals->values[1], mask);
Elliot Lee's avatar
Elliot Lee committed
451

452
  return return_vals;
Elliot Lee's avatar
Elliot Lee committed
453 454
}

455
static GValueArray *
456 457 458 459 460 461
layer_from_mask_invoker (GimpProcedure      *procedure,
                         Gimp               *gimp,
                         GimpContext        *context,
                         GimpProgress       *progress,
                         const GValueArray  *args,
                         GError            **error)
462 463
{
  gboolean success = TRUE;
464
  GValueArray *return_vals;
465 466 467
  GimpLayerMask *mask;
  GimpLayer *layer = NULL;

468
  mask = gimp_value_get_layer_mask (&args->values[0], gimp);
469 470 471 472 473 474

  if (success)
    {
      layer = gimp_layer_mask_get_layer (mask);
    }

475
  return_vals = gimp_procedure_get_return_values (procedure, success);
476 477

  if (success)
478
    gimp_value_set_layer (&return_vals->values[1], layer);
479

480
  return return_vals;
481 482
}

483
static GValueArray *
484 485 486 487 488 489
layer_add_mask_invoker (GimpProcedure      *procedure,
                        Gimp               *gimp,
                        GimpContext        *context,
                        GimpProgress       *progress,
                        const GValueArray  *args,
                        GError            **error)
490 491 492 493 494
{
  gboolean success = TRUE;
  GimpLayer *layer;
  GimpLayerMask *mask;

495 496
  layer = gimp_value_get_layer (&args->values[0], gimp);
  mask = gimp_value_get_layer_mask (&args->values[1], gimp);
497 498 499

  if (success)
    {
500
      if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), error))
501
        gimp_layer_add_mask (layer, mask, TRUE);
502 503
      else
        success = FALSE;
504 505
    }

506
  return gimp_procedure_get_return_values (procedure, success);
507 508
}

509
static GValueArray *
510 511 512 513 514 515
layer_remove_mask_invoker (GimpProcedure      *procedure,
                           Gimp               *gimp,
                           GimpContext        *context,
                           GimpProgress       *progress,
                           const GValueArray  *args,
                           GError            **error)
516 517 518 519 520
{
  gboolean success = TRUE;
  GimpLayer *layer;
  gint32 mode;

521 522
  layer = gimp_value_get_layer (&args->values[0], gimp);
  mode = g_value_get_enum (&args->values[1]);
523 524

  if (success)
525
    {
526
      if (gimp_pdb_item_is_attached (GIMP_ITEM (layer), error))
527
        gimp_layer_apply_mask (layer, mode, TRUE);
528 529
      else
        success = FALSE;
530
    }
531

532
  return gimp_procedure_get_return_values (procedure, success);
533 534
}

535
static GValueArray *
536 537 538 539 540 541
layer_is_floating_sel_invoker (GimpProcedure      *procedure,
                               Gimp               *gimp,
                               GimpContext        *context,
                               GimpProgress       *progress,
                               const GValueArray  *args,
                               GError            **error)
Elliot Lee's avatar
Elliot Lee committed
542
{
543
  gboolean success = TRUE;
544
  GValueArray *return_vals;
545
  GimpLayer *layer;
546
  gboolean is_floating_sel = FALSE;
Elliot Lee's avatar
Elliot Lee committed
547

548
  layer = gimp_value_get_layer (&args->values[0], gimp);
Elliot Lee's avatar
Elliot Lee committed
549

550 551 552 553 554
  if (success)
    {
      is_floating_sel = gimp_layer_is_floating_sel (layer);
    }

555 556 557 558 559 560 561 562 563
  return_vals = gimp_procedure_get_return_values (procedure, success);

  if (success)
    g_value_set_boolean (&return_vals->values[1], is_floating_sel);

  return return_vals;
}

static GValueArray *
564 565 566 567 568 569
layer_get_lock_alpha_invoker (GimpProcedure      *procedure,
                              Gimp               *gimp,
                              GimpContext        *context,
                              GimpProgress       *progress,
                              const GValueArray  *args,
                              GError            **error)
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591
{
  gboolean success = TRUE;
  GValueArray *return_vals;
  GimpLayer *layer;
  gboolean lock_alpha = FALSE;

  layer = gimp_value_get_layer (&args->values[0], gimp);

  if (success)
    {
      lock_alpha = gimp_layer_get_lock_alpha (layer);
    }

  return_vals = gimp_procedure_get_return_values (procedure, success);

  if (success)
    g_value_set_boolean (&return_vals->values[1], lock_alpha);

  return return_vals;
}

static GValueArray *
592 593 594 595 596 597
layer_set_lock_alpha_invoker (GimpProcedure      *procedure,
                              Gimp               *gimp,
                              GimpContext        *context,
                              GimpProgress       *progress,
                              const GValueArray  *args,
                              GError            **error)
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614
{
  gboolean success = TRUE;
  GimpLayer *layer;
  gboolean lock_alpha;

  layer = gimp_value_get_layer (&args->values[0], gimp);
  lock_alpha = g_value_get_boolean (&args->values[1]);

  if (success)
    {
      gimp_layer_set_lock_alpha (layer, lock_alpha, TRUE);
    }

  return gimp_procedure_get_return_values (procedure, success);
}

static GValueArray *
615 616 617 618 619 620
layer_get_apply_mask_invoker (GimpProcedure      *procedure,
                              Gimp               *gimp,
                              GimpContext        *context,
                              GimpProgress       *progress,
                              const GValueArray  *args,
                              GError            **error)
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645
{
  gboolean success = TRUE;
  GValueArray *return_vals;
  GimpLayer *layer;
  gboolean apply_mask = FALSE;

  layer = gimp_value_get_layer (&args->values[0], gimp);

  if (success)
    {
      if (layer->mask)
        apply_mask = gimp_layer_mask_get_apply (layer->mask);
      else
        apply_mask = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success);

  if (success)
    g_value_set_boolean (&return_vals->values[1], apply_mask);

  return return_vals;
}

static GValueArray *
646 647 648 649 650 651
layer_set_apply_mask_invoker (GimpProcedure      *procedure,
                              Gimp               *gimp,
                              GimpContext        *context,
                              GimpProgress       *progress,
                              const GValueArray  *args,
                              GError            **error)
652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671
{
  gboolean success = TRUE;
  GimpLayer *layer;
  gboolean apply_mask;

  layer = gimp_value_get_layer (&args->values[0], gimp);
  apply_mask = g_value_get_boolean (&args->values[1]);

  if (success)
    {
      if (layer->mask)
        gimp_layer_mask_set_apply (layer->mask, apply_mask, TRUE);
      else
        success = FALSE;
    }

  return gimp_procedure_get_return_values (procedure, success);
}

static GValueArray *
672 673 674 675 676 677
layer_get_show_mask_invoker (GimpProcedure      *procedure,
                             Gimp               *gimp,
                             GimpContext        *context,
                             GimpProgress       *progress,
                             const GValueArray  *args,
                             GError            **error)
678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702
{
  gboolean success = TRUE;
  GValueArray *return_vals;
  GimpLayer *layer;
  gboolean show_mask = FALSE;

  layer = gimp_value_get_layer (&args->values[0], gimp);

  if (success)
    {
      if (layer->mask)
        show_mask = gimp_layer_mask_get_show (layer->mask);
      else
        show_mask = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success);

  if (success)
    g_value_set_boolean (&return_vals->values[1], show_mask);

  return return_vals;
}

static GValueArray *
703 704 705 706 707 708
layer_set_show_mask_invoker (GimpProcedure      *procedure,
                             Gimp               *gimp,
                             GimpContext        *context,
                             GimpProgress       *progress,
                             const GValueArray  *args,
                             GError            **error)
709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728
{
  gboolean success = TRUE;
  GimpLayer *layer;
  gboolean show_mask;

  layer = gimp_value_get_layer (&args->values[0], gimp);
  show_mask = g_value_get_boolean (&args->values[1]);

  if (success)
    {
      if (layer->mask)
        gimp_layer_mask_set_show (layer->mask, show_mask, TRUE);
      else
        success = FALSE;
    }

  return gimp_procedure_get_return_values (procedure, success);
}

static GValueArray *
729 730 731 732 733 734
layer_get_edit_mask_invoker (GimpProcedure      *procedure,
                             Gimp               *gimp,
                             GimpContext        *context,
                             GimpProgress       *progress,
                             const GValueArray  *args,
                             GError            **error)
735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759
{
  gboolean success = TRUE;
  GValueArray *return_vals;
  GimpLayer *layer;
  gboolean edit_mask = FALSE;

  layer = gimp_value_get_layer (&args->values[0], gimp);

  if (success)
    {
      if (layer->mask)
        edit_mask = gimp_layer_mask_get_edit (layer->mask);
      else
        edit_mask = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success);

  if (success)
    g_value_set_boolean (&return_vals->values[1], edit_mask);

  return return_vals;
}

static GValueArray *
760 761 762 763 764 765
layer_set_edit_mask_invoker (GimpProcedure      *procedure,
                             Gimp               *gimp,
                             GimpContext        *context,
                             GimpProgress       *progress,
                             const GValueArray  *args,
                             GError            **error)
766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782
{
  gboolean success = TRUE;
  GimpLayer *layer;
  gboolean edit_mask;

  layer = gimp_value_get_layer (&args->values[0], gimp);
  edit_mask = g_value_get_boolean (&args->values[1]);

  if (success)
    {
      if (layer->mask)
        gimp_layer_mask_set_edit (layer->mask, edit_mask);
      else
        success = FALSE;
    }

  return gimp_procedure_get_return_values (procedure, success);
Elliot Lee's avatar
Elliot Lee committed
783 784
}

785
static GValueArray *
786 787 788 789 790 791
layer_get_opacity_invoker (GimpProcedure      *procedure,
                           Gimp               *gimp,
                           GimpContext        *context,
                           GimpProgress       *progress,
                           const GValueArray  *args,
                           GError            **error)
Elliot Lee's avatar
Elliot Lee committed
792
{
793
  gboolean success = TRUE;
794
  GValueArray *return_vals;
795
  GimpLayer *layer;
796
  gdouble opacity = 0.0;
Elliot Lee's avatar
Elliot Lee committed
797

798
  layer = gimp_value_get_layer (&args->values[0], gimp);
Elliot Lee's avatar
Elliot Lee committed
799

800 801
  if (success)
    {
802
      opacity = gimp_layer_get_opacity (layer) * 100.0;
803 804
    }

805
  return_vals = gimp_procedure_get_return_values (procedure, success);
Elliot Lee's avatar
Elliot Lee committed
806 807

  if (success)
808
    g_value_set_double (&return_vals->values[1], opacity);
Elliot Lee's avatar
Elliot Lee committed
809

810
  return return_vals;
Elliot Lee's avatar
Elliot Lee committed
811 812
}

813
static GValueArray *
814 815 816 817 818 819
layer_set_opacity_invoker (GimpProcedure      *procedure,
                           Gimp               *gimp,
                           GimpContext        *context,
                           GimpProgress       *progress,
                           const GValueArray  *args,
                           GError            **error)
Elliot Lee's avatar
Elliot Lee committed
820
{
821 822
  gboolean success = TRUE;
  GimpLayer *layer;
823
  gdouble opacity;
824

825
  layer = gimp_value_get_layer (&args->values[0], gimp);
826
  opacity = g_value_get_double (&args->values[1]);
Elliot Lee's avatar
Elliot Lee committed
827 828

  if (success)
829
    {
830
      gimp_layer_set_opacity (layer, opacity / 100.0, TRUE);
831
    }
Elliot Lee's avatar
Elliot Lee committed
832

833
  return gimp_procedure_get_return_values (procedure, success);
Elliot Lee's avatar
Elliot Lee committed
834 835
}

836
static GValueArray *
837 838 839 840 841 842
layer_get_mode_invoker (GimpProcedure      *procedure,
                        Gimp               *gimp,
                        GimpContext        *context,
                        GimpProgress       *progress,
                        const GValueArray  *args,
                        GError            **error)
843 844
{
  gboolean success = TRUE;
845
  GValueArray *return_vals;
846
  GimpLayer *layer;
847
  gint32 mode = 0;
848

849
  layer = gimp_value_get_layer (&args->values[0], gimp);
850

851 852
  if (success)
    {
853
      mode = gimp_layer_get_mode (layer);
854 855
    }

856
  return_vals = gimp_procedure_get_return_values (procedure, success);
857 858

  if (success)
859
    g_value_set_enum (&return_vals->values[1], mode);
860

861
  return return_vals;
862 863
}

864
static GValueArray *
865 866 867 868 869 870
layer_set_mode_invoker (GimpProcedure      *procedure,
                        Gimp               *gimp,
                        GimpContext        *context,
                        GimpProgress       *progress,
                        const GValueArray  *args,
                        GError            **error)
871 872 873
{
  gboolean success = TRUE;
  GimpLayer *layer;
874
  gint32 mode;
875

876
  layer = gimp_value_get_layer (&args->values[0], gimp);
877
  mode = g_value_get_enum (&args->values[1]);
878 879

  if (success)
880
    {
881
      gimp_layer_set_mode (layer, mode, TRUE);
882
    }
883

884
  return gimp_procedure_get_return_values (procedure, success);
885 886
}

887
void
888
register_layer_procs (GimpPDB *pdb)
889
{
890
  GimpProcedure *procedure;
891

892 893 894
  /*
   * gimp-layer-new
   */
895
  procedure = gimp_procedure_new (layer_new_invoker);
896 897
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-layer-new");
898 899 900
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-layer-new",
                                     "Create a new layer.",
901
                                     "This procedure creates a new layer with the specified width, height, and type. Name, opacity, and mode are also supplied parameters. The new layer still needs to be added to the image, as this is not automatic. Add the new layer with the 'gimp-image-add-layer' command. Other attributes such as layer mask modes, and offsets should be set with explicit procedure calls.",
902 903 904 905 906 907 908 909
                                     "Spencer Kimball & Peter Mattis",
                                     "Spencer Kimball & Peter Mattis",
                                     "1995-1996",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_image_id ("image",
                                                         "image",
                                                         "The image to which to add the layer",
910
                                                         pdb->gimp, FALSE,
911 912 913 914
                                                         GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_int32 ("width",
                                                      "width",
915
                                                      "The layer width",
916
                                                      1, GIMP_MAX_IMAGE_SIZE, 1,
917 918 919 920
                                                      GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_int32 ("height",
                                                      "height",
921
                                                      "The layer height",
922
                                                      1, GIMP_MAX_IMAGE_SIZE, 1,
923 924 925 926
                                                      GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_enum ("type",
                                                  "type",
927
                                                  "The layer type",
928 929 930 931 932 933 934
                                                  GIMP_TYPE_IMAGE_TYPE,
                                                  GIMP_RGB_IMAGE,
                                                  GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("name",
                                                       "name",
                                                       "The layer name",
935
                                                       FALSE, TRUE, FALSE,
936 937 938 939 940
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("opacity",
                                                    "opacity",
941
                                                    "The layer opacity",
942 943 944 945 946
                                                    0, 100, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_enum ("mode",
                                                  "mode",
947
                                                  "The layer combination mode",
948 949 950 951 952 953 954
                                                  GIMP_TYPE_LAYER_MODE_EFFECTS,
                                                  GIMP_NORMAL_MODE,
                                                  GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_layer_id ("layer",
                                                             "layer",
                                                             "The newly created layer",
955
                                                             pdb->gimp, FALSE,
956
                                                             GIMP_PARAM_READWRITE));
957
  gimp_pdb_register_procedure (pdb, procedure);
958
  g_object_unref (procedure);
959

960 961 962
  /*
   * gimp-layer-new-from-drawable
   */
963
  procedure = gimp_procedure_new (layer_new_from_drawable_invoker);
964 965
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-layer-new-from-drawable");
966 967 968
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-layer-new-from-drawable",
                                     "Create a new layer by copying an existing drawable.",
969
                                     "This procedure creates a new layer as a copy of the specified drawable. The new layer still needs to be added to the image, as this is not automatic. Add the new layer with the 'gimp-image-add-layer' command. Other attributes such as layer mask modes, and offsets should be set with explicit procedure calls.",
970 971 972 973 974 975 976 977
                                     "Spencer Kimball & Peter Mattis",
                                     "Spencer Kimball & Peter Mattis",
                                     "1995-1996",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_drawable_id ("drawable",
                                                            "drawable",
                                                            "The source drawable from where the new layer is copied",
978
                                                            pdb->gimp, FALSE,
979 980 981 982 983
                                                            GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_image_id ("dest-image",
                                                         "dest image",
                                                         "The destination image to which to add the layer",
984
                                                         pdb->gimp, FALSE,
985 986 987 988 989
                                                         GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_layer_id ("layer-copy",
                                                             "layer copy",
                                                             "The newly copied layer",
990
                                                             pdb->gimp, FALSE,
991
                                                             GIMP_PARAM_READWRITE));
992
  gimp_pdb_register_procedure (pdb, procedure);
993
  g_object_unref (procedure);
994 995 996 997

  /*
   * gimp-layer-copy
   */
998
  procedure = gimp_procedure_new (layer_copy_invoker);
999 1000
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-layer-copy");
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-layer-copy",
                                     "Copy a layer.",
                                     "This procedure copies the specified layer and returns the copy. The newly copied layer is for use within the original layer's image. It should not be subsequently added to any other image. The copied layer can optionally have an added alpha channel. This is useful if the background layer in an image is being copied and added to the same image.",
                                     "Spencer Kimball & Peter Mattis",
                                     "Spencer Kimball & Peter Mattis",
                                     "1995-1996",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_layer_id ("layer",
                                                         "layer",
                                                         "The layer to copy",
1013
                                                         pdb->gimp, FALSE,
1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024
                                                         GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_boolean ("add-alpha",
                                                     "add alpha",
                                                     "Add an alpha channel to the copied layer",
                                                     FALSE,
                                                     GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_layer_id ("layer-copy",
                                                             "layer copy",
                                                             "The newly copied layer",
1025
                                                             pdb->gimp, FALSE,
1026
                                                             GIMP_PARAM_READWRITE));
1027
  gimp_pdb_register_procedure (pdb, procedure);
1028
  g_object_unref (procedure);
1029 1030 1031 1032

  /*
   * gimp-layer-add-alpha
   */
1033
  procedure = gimp_procedure_new (layer_add_alpha_invoker);
1034 1035
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-layer-add-alpha");
1036 1037 1038
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-layer-add-alpha",
                                     "Add an alpha channel to the layer if it doesn't already have one.",
1039
                                     "This procedure adds an additional component to the specified layer if it does not already possess an alpha channel. An alpha channel makes it possible to clear and erase to transparency, instead of the background color. This transforms layers of type RGB to RGBA, GRAY to GRAYA, and INDEXED to INDEXEDA.",
1040 1041 1042 1043 1044 1045 1046 1047
                                     "Spencer Kimball & Peter Mattis",
                                     "Spencer Kimball & Peter Mattis",
                                     "1995-1996",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_layer_id ("layer",
                                                         "layer",
                                                         "The layer",
1048
                                                         pdb->gimp, FALSE,
1049
                                                         GIMP_PARAM_READWRITE));
1050
  gimp_pdb_register_procedure (pdb, procedure);
1051
  g_object_unref (procedure);
1052

1053 1054 1055 1056
  /*
   * gimp-layer-flatten
   */
  procedure = gimp_procedure_new (layer_flatten_invoker);
1057 1058
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-layer-flatten");
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-layer-flatten",
                                     "Remove the alpha channel from the layer if it has one.",
                                     "This procedure removes the alpha channel from a layer, blending all (partially) transparent pixels in the layer against the background color. This transforms layers of type RGBA to RGB, GRAYA to GRAY, and INDEXEDA to INDEXED.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2007",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_layer_id ("layer",
                                                         "layer",
                                                         "The layer",
                                                         pdb->gimp, FALSE,
                                                         GIMP_PARAM_READWRITE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

1076 1077 1078
  /*
   * gimp-layer-scale
   */
1079
  procedure = gimp_procedure_new (layer_scale_invoker);
1080 1081
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-layer-scale");
1082 1083 1084
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-layer-scale",
                                     "Scale the layer to the specified extents.",
1085
                                     "This procedure scales the layer so that its new width and height are equal to the supplied parameters. The 'local-origin' parameter specifies whether to scale from the center of the layer, or from the image origin. This operation only works if the layer has been added to an image.",
1086 1087 1088 1089 1090 1091 1092 1093
                                     "Spencer Kimball & Peter Mattis",
                                     "Spencer Kimball & Peter Mattis",
                                     "1995-1996",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_layer_id ("layer",
                                                         "layer",
                                                         "The layer",
1094
                                                         pdb->gimp, FALSE,
1095 1096 1097 1098
                                                         GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_int32 ("new-width",
                                                      "new width",
1099
                                                      "New layer width",
1100
                                                      1, GIMP_MAX_IMAGE_SIZE, 1,
1101 1102 1103 1104
                                                      GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_int32 ("new-height",
                                                      "new height",
1105
                                                      "New layer height",
1106
                                                      1, GIMP_MAX_IMAGE_SIZE, 1,
1107 1108 1109 1110 1111 1112 1113
                                                      GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_boolean ("local-origin",
                                                     "local origin",
                                                     "Use a local origin (as opposed to the image origin)",
                                                     FALSE,
                                                     GIMP_PARAM_READWRITE));
1114
  gimp_pdb_register_procedure (pdb, procedure);
1115
  g_object_unref (procedure);
1116 1117 1118 1119

  /*
   * gimp-layer-resize
   */
1120
  procedure = gimp_procedure_new (layer_resize_invoker);
1121 1122
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-layer-resize");
1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-layer-resize",
                                     "Resize the layer to the specified extents.",
                                     "This procedure resizes the layer so that its new width and height are equal to the supplied parameters. Offsets are also provided which describe the position of the previous layer's content. This operation only works if the layer has been added to an image.",
                                     "Spencer Kimball & Peter Mattis",
                                     "Spencer Kimball & Peter Mattis",
                                     "1995-1996",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_layer_id ("layer",
                                                         "layer",
                                                         "The layer",
1135
                                                         pdb->gimp, FALSE,
1136 1137 1138 1139
                                                         GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_int32 ("new-width",
                                                      "new width",
1140
                                                      "New layer width",
1141
                                                      1, GIMP_MAX_IMAGE_SIZE, 1,
1142 1143 1144 1145
                                                      GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_int32 ("new-height",
                                                      "new height",
1146
                                                      "New layer height",
1147
                                                      1, GIMP_MAX_IMAGE_SIZE, 1,
1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160
                                                      GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_int32 ("offx",
                                                      "offx",
                                                      "x offset between upper left corner of old and new layers: (old - new)",
                                                      G_MININT32, G_MAXINT32, 0,
                                                      GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_int32 ("offy",
                                                      "offy",
                                                      "y offset between upper left corner of old and new layers: (old - new)",
                                                      G_MININT32, G_MAXINT32, 0,
                                                      GIMP_PARAM_READWRITE));
1161
  gimp_pdb_register_procedure (pdb, procedure);
1162
  g_object_unref (procedure);
1163

1164 1165 1166
  /*
   * gimp-layer-resize-to-image-size
   */
1167
  procedure = gimp_procedure_new (layer_resize_to_image_size_invoker);
1168 1169
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-layer-resize-to-image-size");
1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-layer-resize-to-image-size",
                                     "Resize a layer to the image size.",
                                     "This procedure resizes the layer so that it's new width and height are equal to the width and height of its image container.",
                                     "Manish Singh",
                                     "Manish Singh",
                                     "2003",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_layer_id ("layer",
                                                         "layer",
                                                         "The layer to resize",
1182
                                                         pdb->gimp, FALSE,
1183
                                                         GIMP_PARAM_READWRITE));
1184
  gimp_pdb_register_procedure (pdb, procedure);
1185
  g_object_unref (procedure);
1186

1187 1188 1189
  /*
   * gimp-layer-translate
   */
1190
  procedure = gimp_procedure_new (layer_translate_invoker);
1191 1192
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-layer-translate");
1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-layer-translate",
                                     "Translate the layer by the specified offsets.",
                                     "This procedure translates the layer by the amounts specified in the x and y arguments. These can be negative, and are considered offsets from the current position. This command only works if the layer has been added to an image. All additional layers contained in the image which have the linked flag set to TRUE w ill also be translated by the specified offsets.",
                                     "Spencer Kimball & Peter Mattis",
                                     "Spencer Kimball & Peter Mattis",
                                     "1995-1996",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_layer_id ("layer",
                                                         "layer",
                                                         "The layer",
1205
                                                         pdb->gimp, FALSE,
1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218
                                                         GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_int32 ("offx",
                                                      "offx",
                                                      "Offset in x direction",
                                                      G_MININT32, G_MAXINT32, 0,
                                                      GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_int32 ("offy",
                                                      "offy",
                                                      "Offset in y direction",
                                                      G_MININT32, G_MAXINT32, 0,
                                                      GIMP_PARAM_READWRITE));
1219
  gimp_pdb_register_procedure (pdb, procedure);
1220
  g_object_unref (procedure);
1221

1222 1223 1224
  /*
   * gimp-layer-set-offsets
   */
1225
  procedure = gimp_procedure_new (layer_set_offsets_invoker);
1226 1227
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-layer-set-offsets");
1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-layer-set-offsets",
                                     "Set the layer offsets.",
                                     "This procedure sets the offsets for the specified layer. The offsets are relative to the image origin and can be any values. This operation is valid only on layers which have been added to an image.",
                                     "Spencer Kimball & Peter Mattis",
                                     "Spencer Kimball & Peter Mattis",
                                     "1995-1996",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_layer_id ("layer",
                                                         "layer",
                                                         "The layer",
1240
                                                         pdb->gimp, FALSE,
1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253
                                                         GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_int32 ("offx",
                                                      "offx",
                                                      "Offset in x direction",
                                                      G_MININT32, G_MAXINT32, 0,
                                                      GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_int32 ("offy",
                                                      "offy",
                                                      "Offset in y direction",
                                                      G_MININT32, G_MAXINT32, 0,
                                                      GIMP_PARAM_READWRITE));
1254
  gimp_pdb_register_procedure (pdb, procedure);
1255
  g_object_unref (procedure);
1256

1257 1258 1259
  /*
   * gimp-layer-create-mask
   */
1260
  procedure = gimp_procedure_new (layer_create_mask_invoker);
1261 1262
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-layer-create-mask");
1263 1264 1265
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-layer-create-mask",
                                     "Create a layer mask for the specified specified layer.",
1266
                                     "This procedure creates a layer mask for the specified layer. Layer masks serve as an additional alpha channel for a layer. A number of different types of masks are allowed for initialisation: completely white masks (which will leave the layer fully visible), completely black masks (which will give the layer complete transparency, the layer's already existing alpha channel (which will leave the layer fully visible, but which may be more useful than a white mask), the current selection or a grayscale copy of the layer. The layer mask still needs to be added to the layer. This can be done with a call to 'gimp-layer-add-mask'.",
1267 1268 1269 1270 1271 1272 1273 1274
                                     "Spencer Kimball & Peter Mattis",
                                     "Spencer Kimball & Peter Mattis",
                                     "1995-1996",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_layer_id ("layer",
                                                         "layer",
                                                         "The layer to which to add the mask",
1275
                                                         pdb->gimp, FALSE,
1276 1277 1278 1279
                                                         GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_enum ("mask-type",
                                                  "mask type",
1280
                                                  "The type of mask",
1281 1282 1283 1284 1285 1286 1287
                                                  GIMP_TYPE_ADD_MASK_TYPE,
                                                  GIMP_ADD_WHITE_MASK,
                                                  GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_layer_mask_id ("mask",
                                                                  "mask",
                                                                  "The newly created mask",
1288
                                                                  pdb->gimp, FALSE,
1289
                                                                  GIMP_PARAM_READWRITE));
1290
  gimp_pdb_register_procedure (pdb, procedure);
1291
  g_object_unref (procedure);
1292

1293 1294 1295
  /*
   * gimp-layer-get-mask
   */
1296
  procedure = gimp_procedure_new (layer_get_mask_invoker);
1297 1298
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-layer-get-mask");
1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-layer-get-mask",
                                     "Get the specified layer's mask if it exists.",
                                     "This procedure returns the specified layer's mask, or -1 if none exists.",
                                     "Spencer Kimball & Peter Mattis",
                                     "Spencer Kimball & Peter Mattis",
                                     "1995-1996",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_layer_id ("layer",
                                                         "layer",
                                                         "The layer",
1311
                                                         pdb->gimp, FALSE,
1312 1313 1314 1315 1316
                                                         GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_layer_mask_id ("mask",
                                                                  "mask",
                                                                  "The layer mask",
1317
                                                                  pdb->gimp, FALSE,
1318
                                                                  GIMP_PARAM_READWRITE));
1319
  gimp_pdb_register_procedure (pdb, procedure);