~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/pdb/selection_cmds.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
16
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
17
 */
18
18
 
19
 
/* NOTE: This file is autogenerated by pdbgen.pl. */
 
19
/* NOTE: This file is auto-generated by pdbgen.pl. */
20
20
 
21
21
#include "config.h"
22
22
 
24
24
#include <glib-object.h>
25
25
 
26
26
#include "pdb-types.h"
27
 
#include "procedural_db.h"
 
27
#include "gimppdb.h"
 
28
#include "gimpprocedure.h"
 
29
#include "core/gimpparamspecs.h"
28
30
 
29
31
#include "core/gimpchannel-select.h"
30
32
#include "core/gimpchannel.h"
31
33
#include "core/gimpdrawable.h"
32
34
#include "core/gimpimage.h"
33
35
#include "core/gimplayer.h"
 
36
#include "core/gimppickable.h"
34
37
#include "core/gimpselection.h"
35
38
#include "gimp-intl.h"
36
39
 
37
 
static ProcRecord selection_bounds_proc;
38
 
static ProcRecord selection_value_proc;
39
 
static ProcRecord selection_is_empty_proc;
40
 
static ProcRecord selection_translate_proc;
41
 
static ProcRecord selection_float_proc;
42
 
static ProcRecord selection_invert_proc;
43
 
static ProcRecord selection_sharpen_proc;
44
 
static ProcRecord selection_all_proc;
45
 
static ProcRecord selection_none_proc;
46
 
static ProcRecord selection_feather_proc;
47
 
static ProcRecord selection_border_proc;
48
 
static ProcRecord selection_grow_proc;
49
 
static ProcRecord selection_shrink_proc;
50
 
static ProcRecord selection_layer_alpha_proc;
51
 
static ProcRecord selection_load_proc;
52
 
static ProcRecord selection_save_proc;
53
 
static ProcRecord selection_combine_proc;
54
 
 
55
 
void
56
 
register_selection_procs (Gimp *gimp)
57
 
{
58
 
  procedural_db_register (gimp, &selection_bounds_proc);
59
 
  procedural_db_register (gimp, &selection_value_proc);
60
 
  procedural_db_register (gimp, &selection_is_empty_proc);
61
 
  procedural_db_register (gimp, &selection_translate_proc);
62
 
  procedural_db_register (gimp, &selection_float_proc);
63
 
  procedural_db_register (gimp, &selection_invert_proc);
64
 
  procedural_db_register (gimp, &selection_sharpen_proc);
65
 
  procedural_db_register (gimp, &selection_all_proc);
66
 
  procedural_db_register (gimp, &selection_none_proc);
67
 
  procedural_db_register (gimp, &selection_feather_proc);
68
 
  procedural_db_register (gimp, &selection_border_proc);
69
 
  procedural_db_register (gimp, &selection_grow_proc);
70
 
  procedural_db_register (gimp, &selection_shrink_proc);
71
 
  procedural_db_register (gimp, &selection_layer_alpha_proc);
72
 
  procedural_db_register (gimp, &selection_load_proc);
73
 
  procedural_db_register (gimp, &selection_save_proc);
74
 
  procedural_db_register (gimp, &selection_combine_proc);
75
 
}
76
 
 
77
 
static Argument *
78
 
selection_bounds_invoker (Gimp         *gimp,
79
 
                          GimpContext  *context,
80
 
                          GimpProgress *progress,
81
 
                          Argument     *args)
 
40
#include "internal_procs.h"
 
41
 
 
42
 
 
43
static GValueArray *
 
44
selection_bounds_invoker (GimpProcedure     *procedure,
 
45
                          Gimp              *gimp,
 
46
                          GimpContext       *context,
 
47
                          GimpProgress      *progress,
 
48
                          const GValueArray *args)
82
49
{
83
50
  gboolean success = TRUE;
84
 
  Argument *return_args;
85
 
  GimpImage *gimage;
 
51
  GValueArray *return_vals;
 
52
  GimpImage *image;
86
53
  gboolean non_empty = FALSE;
87
 
  gint32 x1;
88
 
  gint32 y1;
89
 
  gint32 x2;
90
 
  gint32 y2;
91
 
 
92
 
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
93
 
  if (! GIMP_IS_IMAGE (gimage))
94
 
    success = FALSE;
95
 
 
96
 
  if (success)
97
 
    non_empty = gimp_channel_bounds (gimp_image_get_mask (gimage), &x1, &y1, &x2, &y2);
98
 
 
99
 
  return_args = procedural_db_return_args (&selection_bounds_proc, success);
100
 
 
101
 
  if (success)
102
 
    {
103
 
      return_args[1].value.pdb_int = non_empty;
104
 
      return_args[2].value.pdb_int = x1;
105
 
      return_args[3].value.pdb_int = y1;
106
 
      return_args[4].value.pdb_int = x2;
107
 
      return_args[5].value.pdb_int = y2;
108
 
    }
109
 
 
110
 
  return return_args;
 
54
  gint32 x1 = 0;
 
55
  gint32 y1 = 0;
 
56
  gint32 x2 = 0;
 
57
  gint32 y2 = 0;
 
58
 
 
59
  image = gimp_value_get_image (&args->values[0], gimp);
 
60
 
 
61
  if (success)
 
62
    {
 
63
      non_empty = gimp_channel_bounds (gimp_image_get_mask (image),
 
64
                                       &x1, &y1, &x2, &y2);
 
65
    }
 
66
 
 
67
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
68
 
 
69
  if (success)
 
70
    {
 
71
      g_value_set_boolean (&return_vals->values[1], non_empty);
 
72
      g_value_set_int (&return_vals->values[2], x1);
 
73
      g_value_set_int (&return_vals->values[3], y1);
 
74
      g_value_set_int (&return_vals->values[4], x2);
 
75
      g_value_set_int (&return_vals->values[5], y2);
 
76
    }
 
77
 
 
78
  return return_vals;
111
79
}
112
80
 
113
 
static ProcArg selection_bounds_inargs[] =
114
 
{
115
 
  {
116
 
    GIMP_PDB_IMAGE,
117
 
    "image",
118
 
    "The image"
119
 
  }
120
 
};
121
 
 
122
 
static ProcArg selection_bounds_outargs[] =
123
 
{
124
 
  {
125
 
    GIMP_PDB_INT32,
126
 
    "non_empty",
127
 
    "True if there is a selection"
128
 
  },
129
 
  {
130
 
    GIMP_PDB_INT32,
131
 
    "x1",
132
 
    "x coordinate of upper left corner of selection bounds"
133
 
  },
134
 
  {
135
 
    GIMP_PDB_INT32,
136
 
    "y1",
137
 
    "y coordinate of upper left corner of selection bounds"
138
 
  },
139
 
  {
140
 
    GIMP_PDB_INT32,
141
 
    "x2",
142
 
    "x coordinate of lower right corner of selection bounds"
143
 
  },
144
 
  {
145
 
    GIMP_PDB_INT32,
146
 
    "y2",
147
 
    "y coordinate of lower right corner of selection bounds"
148
 
  }
149
 
};
150
 
 
151
 
static ProcRecord selection_bounds_proc =
152
 
{
153
 
  "gimp_selection_bounds",
154
 
  "Find the bounding box of the current selection.",
155
 
  "This procedure returns whether there is a selection for the specified image. If there is one, the upper left and lower right corners of the bounding box are returned. These coordinates are relative to the image. Please note that the pixel specified by the lower righthand coordinate of the bounding box is not part of the selection. The selection ends at the upper left corner of this pixel. This means the width of the selection can be calculated as (x2 - x1), its height as (y2 - y1).",
156
 
  "Spencer Kimball & Peter Mattis",
157
 
  "Spencer Kimball & Peter Mattis",
158
 
  "1995-1996",
159
 
  NULL,
160
 
  GIMP_INTERNAL,
161
 
  1,
162
 
  selection_bounds_inargs,
163
 
  5,
164
 
  selection_bounds_outargs,
165
 
  { { selection_bounds_invoker } }
166
 
};
167
 
 
168
 
static Argument *
169
 
selection_value_invoker (Gimp         *gimp,
170
 
                         GimpContext  *context,
171
 
                         GimpProgress *progress,
172
 
                         Argument     *args)
 
81
static GValueArray *
 
82
selection_value_invoker (GimpProcedure     *procedure,
 
83
                         Gimp              *gimp,
 
84
                         GimpContext       *context,
 
85
                         GimpProgress      *progress,
 
86
                         const GValueArray *args)
173
87
{
174
88
  gboolean success = TRUE;
175
 
  Argument *return_args;
176
 
  GimpImage *gimage;
 
89
  GValueArray *return_vals;
 
90
  GimpImage *image;
177
91
  gint32 x;
178
92
  gint32 y;
179
 
 
180
 
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
181
 
  if (! GIMP_IS_IMAGE (gimage))
182
 
    success = FALSE;
183
 
 
184
 
  x = args[1].value.pdb_int;
185
 
 
186
 
  y = args[2].value.pdb_int;
187
 
 
188
 
  return_args = procedural_db_return_args (&selection_value_proc, success);
189
 
 
190
 
  if (success)
191
 
    return_args[1].value.pdb_int = gimp_channel_value (gimp_image_get_mask (gimage), x, y);
192
 
 
193
 
  return return_args;
194
 
}
195
 
 
196
 
static ProcArg selection_value_inargs[] =
197
 
{
198
 
  {
199
 
    GIMP_PDB_IMAGE,
200
 
    "image",
201
 
    "The image"
202
 
  },
203
 
  {
204
 
    GIMP_PDB_INT32,
205
 
    "x",
206
 
    "x coordinate of value"
207
 
  },
208
 
  {
209
 
    GIMP_PDB_INT32,
210
 
    "y",
211
 
    "y coordinate of value"
212
 
  }
213
 
};
214
 
 
215
 
static ProcArg selection_value_outargs[] =
216
 
{
217
 
  {
218
 
    GIMP_PDB_INT32,
219
 
    "value",
220
 
    "Value of the selection: (0 <= value <= 255)"
221
 
  }
222
 
};
223
 
 
224
 
static ProcRecord selection_value_proc =
225
 
{
226
 
  "gimp_selection_value",
227
 
  "Find the value of the selection at the specified coordinates.",
228
 
  "This procedure returns the value of the selection at the specified coordinates. If the coordinates lie out of bounds, 0 is returned.",
229
 
  "Spencer Kimball & Peter Mattis",
230
 
  "Spencer Kimball & Peter Mattis",
231
 
  "1995-1996",
232
 
  NULL,
233
 
  GIMP_INTERNAL,
234
 
  3,
235
 
  selection_value_inargs,
236
 
  1,
237
 
  selection_value_outargs,
238
 
  { { selection_value_invoker } }
239
 
};
240
 
 
241
 
static Argument *
242
 
selection_is_empty_invoker (Gimp         *gimp,
243
 
                            GimpContext  *context,
244
 
                            GimpProgress *progress,
245
 
                            Argument     *args)
246
 
{
247
 
  gboolean success = TRUE;
248
 
  Argument *return_args;
249
 
  GimpImage *gimage;
250
 
 
251
 
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
252
 
  if (! GIMP_IS_IMAGE (gimage))
253
 
    success = FALSE;
254
 
 
255
 
  return_args = procedural_db_return_args (&selection_is_empty_proc, success);
256
 
 
257
 
  if (success)
258
 
    return_args[1].value.pdb_int = gimp_channel_is_empty (gimp_image_get_mask (gimage));
259
 
 
260
 
  return return_args;
261
 
}
262
 
 
263
 
static ProcArg selection_is_empty_inargs[] =
264
 
{
265
 
  {
266
 
    GIMP_PDB_IMAGE,
267
 
    "image",
268
 
    "The image"
269
 
  }
270
 
};
271
 
 
272
 
static ProcArg selection_is_empty_outargs[] =
273
 
{
274
 
  {
275
 
    GIMP_PDB_INT32,
276
 
    "is_empty",
277
 
    "Is the selection empty?"
278
 
  }
279
 
};
280
 
 
281
 
static ProcRecord selection_is_empty_proc =
282
 
{
283
 
  "gimp_selection_is_empty",
284
 
  "Determine whether the selection is empty.",
285
 
  "This procedure returns non-zero if the selection for the specified image is not empty.",
286
 
  "Spencer Kimball & Peter Mattis",
287
 
  "Spencer Kimball & Peter Mattis",
288
 
  "1995-1996",
289
 
  NULL,
290
 
  GIMP_INTERNAL,
291
 
  1,
292
 
  selection_is_empty_inargs,
293
 
  1,
294
 
  selection_is_empty_outargs,
295
 
  { { selection_is_empty_invoker } }
296
 
};
297
 
 
298
 
static Argument *
299
 
selection_translate_invoker (Gimp         *gimp,
300
 
                             GimpContext  *context,
301
 
                             GimpProgress *progress,
302
 
                             Argument     *args)
303
 
{
304
 
  gboolean success = TRUE;
305
 
  GimpImage *gimage;
 
93
  gint32 value = 0;
 
94
 
 
95
  image = gimp_value_get_image (&args->values[0], gimp);
 
96
  x = g_value_get_int (&args->values[1]);
 
97
  y = g_value_get_int (&args->values[2]);
 
98
 
 
99
  if (success)
 
100
    {
 
101
      value = gimp_pickable_get_opacity_at (GIMP_PICKABLE (gimp_image_get_mask (image)), x, y);
 
102
    }
 
103
 
 
104
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
105
 
 
106
  if (success)
 
107
    g_value_set_int (&return_vals->values[1], value);
 
108
 
 
109
  return return_vals;
 
110
}
 
111
 
 
112
static GValueArray *
 
113
selection_is_empty_invoker (GimpProcedure     *procedure,
 
114
                            Gimp              *gimp,
 
115
                            GimpContext       *context,
 
116
                            GimpProgress      *progress,
 
117
                            const GValueArray *args)
 
118
{
 
119
  gboolean success = TRUE;
 
120
  GValueArray *return_vals;
 
121
  GimpImage *image;
 
122
  gboolean is_empty = FALSE;
 
123
 
 
124
  image = gimp_value_get_image (&args->values[0], gimp);
 
125
 
 
126
  if (success)
 
127
    {
 
128
      is_empty = gimp_channel_is_empty (gimp_image_get_mask (image));
 
129
    }
 
130
 
 
131
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
132
 
 
133
  if (success)
 
134
    g_value_set_boolean (&return_vals->values[1], is_empty);
 
135
 
 
136
  return return_vals;
 
137
}
 
138
 
 
139
static GValueArray *
 
140
selection_translate_invoker (GimpProcedure     *procedure,
 
141
                             Gimp              *gimp,
 
142
                             GimpContext       *context,
 
143
                             GimpProgress      *progress,
 
144
                             const GValueArray *args)
 
145
{
 
146
  gboolean success = TRUE;
 
147
  GimpImage *image;
306
148
  gint32 offx;
307
149
  gint32 offy;
308
150
 
309
 
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
310
 
  if (! GIMP_IS_IMAGE (gimage))
311
 
    success = FALSE;
312
 
 
313
 
  offx = args[1].value.pdb_int;
314
 
 
315
 
  offy = args[2].value.pdb_int;
 
151
  image = gimp_value_get_image (&args->values[0], gimp);
 
152
  offx = g_value_get_int (&args->values[1]);
 
153
  offy = g_value_get_int (&args->values[2]);
316
154
 
317
155
  if (success)
318
 
    gimp_item_translate (GIMP_ITEM (gimp_image_get_mask (gimage)), offx, offy, TRUE);
 
156
    {
 
157
      gimp_item_translate (GIMP_ITEM (gimp_image_get_mask (image)),
 
158
                           offx, offy, TRUE);
 
159
    }
319
160
 
320
 
  return procedural_db_return_args (&selection_translate_proc, success);
 
161
  return gimp_procedure_get_return_values (procedure, success);
321
162
}
322
163
 
323
 
static ProcArg selection_translate_inargs[] =
324
 
{
325
 
  {
326
 
    GIMP_PDB_IMAGE,
327
 
    "image",
328
 
    "The image"
329
 
  },
330
 
  {
331
 
    GIMP_PDB_INT32,
332
 
    "offx",
333
 
    "x offset for translation"
334
 
  },
335
 
  {
336
 
    GIMP_PDB_INT32,
337
 
    "offy",
338
 
    "y offset for translation"
339
 
  }
340
 
};
341
 
 
342
 
static ProcRecord selection_translate_proc =
343
 
{
344
 
  "gimp_selection_translate",
345
 
  "Translate the selection by the specified offsets.",
346
 
  "This procedure actually translates the selection for the specified image by the specified offsets. Regions that are translated from beyond the bounds of the image are set to empty. Valid regions of the selection which are translated beyond the bounds of the image because of this call are lost.",
347
 
  "Spencer Kimball & Peter Mattis",
348
 
  "Spencer Kimball & Peter Mattis",
349
 
  "1995-1996",
350
 
  NULL,
351
 
  GIMP_INTERNAL,
352
 
  3,
353
 
  selection_translate_inargs,
354
 
  0,
355
 
  NULL,
356
 
  { { selection_translate_invoker } }
357
 
};
358
 
 
359
 
static Argument *
360
 
selection_float_invoker (Gimp         *gimp,
361
 
                         GimpContext  *context,
362
 
                         GimpProgress *progress,
363
 
                         Argument     *args)
 
164
static GValueArray *
 
165
selection_float_invoker (GimpProcedure     *procedure,
 
166
                         Gimp              *gimp,
 
167
                         GimpContext       *context,
 
168
                         GimpProgress      *progress,
 
169
                         const GValueArray *args)
364
170
{
365
171
  gboolean success = TRUE;
366
 
  Argument *return_args;
 
172
  GValueArray *return_vals;
367
173
  GimpDrawable *drawable;
368
174
  gint32 offx;
369
175
  gint32 offy;
370
176
  GimpLayer *layer = NULL;
371
177
 
372
 
  drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
373
 
  if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
374
 
    success = FALSE;
375
 
 
376
 
  offx = args[1].value.pdb_int;
377
 
 
378
 
  offy = args[2].value.pdb_int;
 
178
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
 
179
  offx = g_value_get_int (&args->values[1]);
 
180
  offy = g_value_get_int (&args->values[2]);
379
181
 
380
182
  if (success)
381
183
    {
382
 
      success = gimp_item_is_attached (GIMP_ITEM (drawable));
383
 
 
384
 
      if (success)
 
184
      if (gimp_item_is_attached (GIMP_ITEM (drawable)))
385
185
        {
386
 
          GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
 
186
          GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
387
187
 
388
 
          layer = gimp_selection_float (gimp_image_get_mask (gimage),
 
188
          layer = gimp_selection_float (gimp_image_get_mask (image),
389
189
                                        drawable, context, TRUE, offx, offy);
390
190
          if (! layer)
391
191
            success = FALSE;
392
192
        }
393
 
    }
394
 
 
395
 
  return_args = procedural_db_return_args (&selection_float_proc, success);
396
 
 
397
 
  if (success)
398
 
    return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (layer));
399
 
 
400
 
  return return_args;
401
 
}
402
 
 
403
 
static ProcArg selection_float_inargs[] =
404
 
{
405
 
  {
406
 
    GIMP_PDB_DRAWABLE,
407
 
    "drawable",
408
 
    "The drawable from which to float selection"
409
 
  },
410
 
  {
411
 
    GIMP_PDB_INT32,
412
 
    "offx",
413
 
    "x offset for translation"
414
 
  },
415
 
  {
416
 
    GIMP_PDB_INT32,
417
 
    "offy",
418
 
    "y offset for translation"
419
 
  }
420
 
};
421
 
 
422
 
static ProcArg selection_float_outargs[] =
423
 
{
424
 
  {
425
 
    GIMP_PDB_LAYER,
426
 
    "layer",
427
 
    "The floated layer"
428
 
  }
429
 
};
430
 
 
431
 
static ProcRecord selection_float_proc =
432
 
{
433
 
  "gimp_selection_float",
434
 
  "Float the selection from the specified drawable with initial offsets as specified.",
435
 
  "This procedure determines the region of the specified drawable that lies beneath the current selection. The region is then cut from the drawable and the resulting data is made into a new layer which is instantiated as a floating selection. The offsets allow initial positioning of the new floating selection.",
436
 
  "Spencer Kimball & Peter Mattis",
437
 
  "Spencer Kimball & Peter Mattis",
438
 
  "1995-1996",
439
 
  NULL,
440
 
  GIMP_INTERNAL,
441
 
  3,
442
 
  selection_float_inargs,
443
 
  1,
444
 
  selection_float_outargs,
445
 
  { { selection_float_invoker } }
446
 
};
447
 
 
448
 
static Argument *
449
 
selection_invert_invoker (Gimp         *gimp,
450
 
                          GimpContext  *context,
451
 
                          GimpProgress *progress,
452
 
                          Argument     *args)
453
 
{
454
 
  gboolean success = TRUE;
455
 
  GimpImage *gimage;
456
 
 
457
 
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
458
 
  if (! GIMP_IS_IMAGE (gimage))
459
 
    success = FALSE;
460
 
 
461
 
  if (success)
462
 
    gimp_channel_invert (gimp_image_get_mask (gimage), TRUE);
463
 
 
464
 
  return procedural_db_return_args (&selection_invert_proc, success);
465
 
}
466
 
 
467
 
static ProcArg selection_invert_inargs[] =
468
 
{
469
 
  {
470
 
    GIMP_PDB_IMAGE,
471
 
    "image",
472
 
    "The image"
473
 
  }
474
 
};
475
 
 
476
 
static ProcRecord selection_invert_proc =
477
 
{
478
 
  "gimp_selection_invert",
479
 
  "Invert the selection mask.",
480
 
  "This procedure inverts the selection mask. For every pixel in the selection channel, its new value is calculated as (255 - old_value).",
481
 
  "Spencer Kimball & Peter Mattis",
482
 
  "Spencer Kimball & Peter Mattis",
483
 
  "1995-1996",
484
 
  NULL,
485
 
  GIMP_INTERNAL,
486
 
  1,
487
 
  selection_invert_inargs,
488
 
  0,
489
 
  NULL,
490
 
  { { selection_invert_invoker } }
491
 
};
492
 
 
493
 
static Argument *
494
 
selection_sharpen_invoker (Gimp         *gimp,
495
 
                           GimpContext  *context,
496
 
                           GimpProgress *progress,
497
 
                           Argument     *args)
498
 
{
499
 
  gboolean success = TRUE;
500
 
  GimpImage *gimage;
501
 
 
502
 
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
503
 
  if (! GIMP_IS_IMAGE (gimage))
504
 
    success = FALSE;
505
 
 
506
 
  if (success)
507
 
    gimp_channel_sharpen (gimp_image_get_mask (gimage), TRUE);
508
 
 
509
 
  return procedural_db_return_args (&selection_sharpen_proc, success);
510
 
}
511
 
 
512
 
static ProcArg selection_sharpen_inargs[] =
513
 
{
514
 
  {
515
 
    GIMP_PDB_IMAGE,
516
 
    "image",
517
 
    "The image"
518
 
  }
519
 
};
520
 
 
521
 
static ProcRecord selection_sharpen_proc =
522
 
{
523
 
  "gimp_selection_sharpen",
524
 
  "Sharpen the selection mask.",
525
 
  "This procedure sharpens the selection mask. For every pixel in the selection channel, if the value is > 0, the new pixel is assigned a value of 255. This removes any \"anti-aliasing\" that might exist in the selection mask's boundary.",
526
 
  "Spencer Kimball & Peter Mattis",
527
 
  "Spencer Kimball & Peter Mattis",
528
 
  "1995-1996",
529
 
  NULL,
530
 
  GIMP_INTERNAL,
531
 
  1,
532
 
  selection_sharpen_inargs,
533
 
  0,
534
 
  NULL,
535
 
  { { selection_sharpen_invoker } }
536
 
};
537
 
 
538
 
static Argument *
539
 
selection_all_invoker (Gimp         *gimp,
540
 
                       GimpContext  *context,
541
 
                       GimpProgress *progress,
542
 
                       Argument     *args)
543
 
{
544
 
  gboolean success = TRUE;
545
 
  GimpImage *gimage;
546
 
 
547
 
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
548
 
  if (! GIMP_IS_IMAGE (gimage))
549
 
    success = FALSE;
550
 
 
551
 
  if (success)
552
 
    gimp_channel_all (gimp_image_get_mask (gimage), TRUE);
553
 
 
554
 
  return procedural_db_return_args (&selection_all_proc, success);
555
 
}
556
 
 
557
 
static ProcArg selection_all_inargs[] =
558
 
{
559
 
  {
560
 
    GIMP_PDB_IMAGE,
561
 
    "image",
562
 
    "The image"
563
 
  }
564
 
};
565
 
 
566
 
static ProcRecord selection_all_proc =
567
 
{
568
 
  "gimp_selection_all",
569
 
  "Select all of the image.",
570
 
  "This procedure sets the selection mask to completely encompass the image. Every pixel in the selection channel is set to 255.",
571
 
  "Spencer Kimball & Peter Mattis",
572
 
  "Spencer Kimball & Peter Mattis",
573
 
  "1995-1996",
574
 
  NULL,
575
 
  GIMP_INTERNAL,
576
 
  1,
577
 
  selection_all_inargs,
578
 
  0,
579
 
  NULL,
580
 
  { { selection_all_invoker } }
581
 
};
582
 
 
583
 
static Argument *
584
 
selection_none_invoker (Gimp         *gimp,
585
 
                        GimpContext  *context,
586
 
                        GimpProgress *progress,
587
 
                        Argument     *args)
588
 
{
589
 
  gboolean success = TRUE;
590
 
  GimpImage *gimage;
591
 
 
592
 
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
593
 
  if (! GIMP_IS_IMAGE (gimage))
594
 
    success = FALSE;
595
 
 
596
 
  if (success)
597
 
    gimp_channel_clear (gimp_image_get_mask (gimage), NULL, TRUE);
598
 
 
599
 
  return procedural_db_return_args (&selection_none_proc, success);
600
 
}
601
 
 
602
 
static ProcArg selection_none_inargs[] =
603
 
{
604
 
  {
605
 
    GIMP_PDB_IMAGE,
606
 
    "image",
607
 
    "The image"
608
 
  }
609
 
};
610
 
 
611
 
static ProcRecord selection_none_proc =
612
 
{
613
 
  "gimp_selection_none",
614
 
  "Deselect the entire image.",
615
 
  "This procedure deselects the entire image. Every pixel in the selection channel is set to 0.",
616
 
  "Spencer Kimball & Peter Mattis",
617
 
  "Spencer Kimball & Peter Mattis",
618
 
  "1995-1996",
619
 
  NULL,
620
 
  GIMP_INTERNAL,
621
 
  1,
622
 
  selection_none_inargs,
623
 
  0,
624
 
  NULL,
625
 
  { { selection_none_invoker } }
626
 
};
627
 
 
628
 
static Argument *
629
 
selection_feather_invoker (Gimp         *gimp,
630
 
                           GimpContext  *context,
631
 
                           GimpProgress *progress,
632
 
                           Argument     *args)
633
 
{
634
 
  gboolean success = TRUE;
635
 
  GimpImage *gimage;
 
193
      else
 
194
        success = FALSE;
 
195
    }
 
196
 
 
197
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
198
 
 
199
  if (success)
 
200
    gimp_value_set_layer (&return_vals->values[1], layer);
 
201
 
 
202
  return return_vals;
 
203
}
 
204
 
 
205
static GValueArray *
 
206
selection_invert_invoker (GimpProcedure     *procedure,
 
207
                          Gimp              *gimp,
 
208
                          GimpContext       *context,
 
209
                          GimpProgress      *progress,
 
210
                          const GValueArray *args)
 
211
{
 
212
  gboolean success = TRUE;
 
213
  GimpImage *image;
 
214
 
 
215
  image = gimp_value_get_image (&args->values[0], gimp);
 
216
 
 
217
  if (success)
 
218
    {
 
219
      gimp_channel_invert (gimp_image_get_mask (image), TRUE);
 
220
    }
 
221
 
 
222
  return gimp_procedure_get_return_values (procedure, success);
 
223
}
 
224
 
 
225
static GValueArray *
 
226
selection_sharpen_invoker (GimpProcedure     *procedure,
 
227
                           Gimp              *gimp,
 
228
                           GimpContext       *context,
 
229
                           GimpProgress      *progress,
 
230
                           const GValueArray *args)
 
231
{
 
232
  gboolean success = TRUE;
 
233
  GimpImage *image;
 
234
 
 
235
  image = gimp_value_get_image (&args->values[0], gimp);
 
236
 
 
237
  if (success)
 
238
    {
 
239
      gimp_channel_sharpen (gimp_image_get_mask (image), TRUE);
 
240
    }
 
241
 
 
242
  return gimp_procedure_get_return_values (procedure, success);
 
243
}
 
244
 
 
245
static GValueArray *
 
246
selection_all_invoker (GimpProcedure     *procedure,
 
247
                       Gimp              *gimp,
 
248
                       GimpContext       *context,
 
249
                       GimpProgress      *progress,
 
250
                       const GValueArray *args)
 
251
{
 
252
  gboolean success = TRUE;
 
253
  GimpImage *image;
 
254
 
 
255
  image = gimp_value_get_image (&args->values[0], gimp);
 
256
 
 
257
  if (success)
 
258
    {
 
259
      gimp_channel_all (gimp_image_get_mask (image), TRUE);
 
260
    }
 
261
 
 
262
  return gimp_procedure_get_return_values (procedure, success);
 
263
}
 
264
 
 
265
static GValueArray *
 
266
selection_none_invoker (GimpProcedure     *procedure,
 
267
                        Gimp              *gimp,
 
268
                        GimpContext       *context,
 
269
                        GimpProgress      *progress,
 
270
                        const GValueArray *args)
 
271
{
 
272
  gboolean success = TRUE;
 
273
  GimpImage *image;
 
274
 
 
275
  image = gimp_value_get_image (&args->values[0], gimp);
 
276
 
 
277
  if (success)
 
278
    {
 
279
      gimp_channel_clear (gimp_image_get_mask (image), NULL, TRUE);
 
280
    }
 
281
 
 
282
  return gimp_procedure_get_return_values (procedure, success);
 
283
}
 
284
 
 
285
static GValueArray *
 
286
selection_feather_invoker (GimpProcedure     *procedure,
 
287
                           Gimp              *gimp,
 
288
                           GimpContext       *context,
 
289
                           GimpProgress      *progress,
 
290
                           const GValueArray *args)
 
291
{
 
292
  gboolean success = TRUE;
 
293
  GimpImage *image;
636
294
  gdouble radius;
637
295
 
638
 
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
639
 
  if (! GIMP_IS_IMAGE (gimage))
640
 
    success = FALSE;
641
 
 
642
 
  radius = args[1].value.pdb_float;
643
 
  if (radius < 0.0)
644
 
    success = FALSE;
645
 
 
646
 
  if (success)
647
 
    gimp_channel_feather (gimp_image_get_mask (gimage), radius, radius, TRUE);
648
 
 
649
 
  return procedural_db_return_args (&selection_feather_proc, success);
650
 
}
651
 
 
652
 
static ProcArg selection_feather_inargs[] =
653
 
{
654
 
  {
655
 
    GIMP_PDB_IMAGE,
656
 
    "image",
657
 
    "The image"
658
 
  },
659
 
  {
660
 
    GIMP_PDB_FLOAT,
661
 
    "radius",
662
 
    "Radius of feather (in pixels)"
663
 
  }
664
 
};
665
 
 
666
 
static ProcRecord selection_feather_proc =
667
 
{
668
 
  "gimp_selection_feather",
669
 
  "Feather the image's selection",
670
 
  "This procedure feathers the selection. Feathering is implemented using a gaussian blur.",
671
 
  "Spencer Kimball & Peter Mattis",
672
 
  "Spencer Kimball & Peter Mattis",
673
 
  "1995-1996",
674
 
  NULL,
675
 
  GIMP_INTERNAL,
676
 
  2,
677
 
  selection_feather_inargs,
678
 
  0,
679
 
  NULL,
680
 
  { { selection_feather_invoker } }
681
 
};
682
 
 
683
 
static Argument *
684
 
selection_border_invoker (Gimp         *gimp,
685
 
                          GimpContext  *context,
686
 
                          GimpProgress *progress,
687
 
                          Argument     *args)
688
 
{
689
 
  gboolean success = TRUE;
690
 
  GimpImage *gimage;
691
 
  gint32 radius;
692
 
 
693
 
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
694
 
  if (! GIMP_IS_IMAGE (gimage))
695
 
    success = FALSE;
696
 
 
697
 
  radius = args[1].value.pdb_int;
698
 
  if (radius < 0)
699
 
    success = FALSE;
700
 
 
701
 
  if (success)
702
 
    gimp_channel_border (gimp_image_get_mask (gimage), radius, radius, TRUE);
703
 
 
704
 
  return procedural_db_return_args (&selection_border_proc, success);
705
 
}
706
 
 
707
 
static ProcArg selection_border_inargs[] =
708
 
{
709
 
  {
710
 
    GIMP_PDB_IMAGE,
711
 
    "image",
712
 
    "The image"
713
 
  },
714
 
  {
715
 
    GIMP_PDB_INT32,
716
 
    "radius",
717
 
    "Radius of border (in pixels)"
718
 
  }
719
 
};
720
 
 
721
 
static ProcRecord selection_border_proc =
722
 
{
723
 
  "gimp_selection_border",
724
 
  "Border the image's selection",
725
 
  "This procedure borders the selection. Bordering creates a new selection which is defined along the boundary of the previous selection at every point within the specified radius.",
726
 
  "Spencer Kimball & Peter Mattis",
727
 
  "Spencer Kimball & Peter Mattis",
728
 
  "1995-1996",
729
 
  NULL,
730
 
  GIMP_INTERNAL,
731
 
  2,
732
 
  selection_border_inargs,
733
 
  0,
734
 
  NULL,
735
 
  { { selection_border_invoker } }
736
 
};
737
 
 
738
 
static Argument *
739
 
selection_grow_invoker (Gimp         *gimp,
740
 
                        GimpContext  *context,
741
 
                        GimpProgress *progress,
742
 
                        Argument     *args)
743
 
{
744
 
  gboolean success = TRUE;
745
 
  GimpImage *gimage;
746
 
  gint32 steps;
747
 
 
748
 
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
749
 
  if (! GIMP_IS_IMAGE (gimage))
750
 
    success = FALSE;
751
 
 
752
 
  steps = args[1].value.pdb_int;
753
 
  if (steps < 0)
754
 
    success = FALSE;
755
 
 
756
 
  if (success)
757
 
    gimp_channel_grow (gimp_image_get_mask (gimage), steps, steps, TRUE);
758
 
 
759
 
  return procedural_db_return_args (&selection_grow_proc, success);
760
 
}
761
 
 
762
 
static ProcArg selection_grow_inargs[] =
763
 
{
764
 
  {
765
 
    GIMP_PDB_IMAGE,
766
 
    "image",
767
 
    "The image"
768
 
  },
769
 
  {
770
 
    GIMP_PDB_INT32,
771
 
    "steps",
772
 
    "Steps of grow (in pixels)"
773
 
  }
774
 
};
775
 
 
776
 
static ProcRecord selection_grow_proc =
777
 
{
778
 
  "gimp_selection_grow",
779
 
  "Grow the image's selection",
780
 
  "This procedure grows the selection. Growing involves expanding the boundary in all directions by the specified pixel amount.",
781
 
  "Spencer Kimball & Peter Mattis",
782
 
  "Spencer Kimball & Peter Mattis",
783
 
  "1995-1996",
784
 
  NULL,
785
 
  GIMP_INTERNAL,
786
 
  2,
787
 
  selection_grow_inargs,
788
 
  0,
789
 
  NULL,
790
 
  { { selection_grow_invoker } }
791
 
};
792
 
 
793
 
static Argument *
794
 
selection_shrink_invoker (Gimp         *gimp,
795
 
                          GimpContext  *context,
796
 
                          GimpProgress *progress,
797
 
                          Argument     *args)
798
 
{
799
 
  gboolean success = TRUE;
800
 
  GimpImage *gimage;
801
 
  gint32 radius;
802
 
 
803
 
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
804
 
  if (! GIMP_IS_IMAGE (gimage))
805
 
    success = FALSE;
806
 
 
807
 
  radius = args[1].value.pdb_int;
808
 
  if (radius < 0)
809
 
    success = FALSE;
810
 
 
811
 
  if (success)
812
 
    gimp_channel_shrink (gimp_image_get_mask (gimage), radius, radius, FALSE, TRUE);
813
 
 
814
 
  return procedural_db_return_args (&selection_shrink_proc, success);
815
 
}
816
 
 
817
 
static ProcArg selection_shrink_inargs[] =
818
 
{
819
 
  {
820
 
    GIMP_PDB_IMAGE,
821
 
    "image",
822
 
    "The image"
823
 
  },
824
 
  {
825
 
    GIMP_PDB_INT32,
826
 
    "radius",
827
 
    "Radius of shrink (in pixels)"
828
 
  }
829
 
};
830
 
 
831
 
static ProcRecord selection_shrink_proc =
832
 
{
833
 
  "gimp_selection_shrink",
834
 
  "Shrink the image's selection",
835
 
  "This procedure shrinks the selection. Shrinking invovles trimming the existing selection boundary on all sides by the specified number of pixels.",
836
 
  "Spencer Kimball & Peter Mattis",
837
 
  "Spencer Kimball & Peter Mattis",
838
 
  "1995-1996",
839
 
  NULL,
840
 
  GIMP_INTERNAL,
841
 
  2,
842
 
  selection_shrink_inargs,
843
 
  0,
844
 
  NULL,
845
 
  { { selection_shrink_invoker } }
846
 
};
847
 
 
848
 
static Argument *
849
 
selection_layer_alpha_invoker (Gimp         *gimp,
850
 
                               GimpContext  *context,
851
 
                               GimpProgress *progress,
852
 
                               Argument     *args)
 
296
  image = gimp_value_get_image (&args->values[0], gimp);
 
297
  radius = g_value_get_double (&args->values[1]);
 
298
 
 
299
  if (success)
 
300
    {
 
301
      gimp_channel_feather (gimp_image_get_mask (image),
 
302
                            radius, radius, TRUE);
 
303
    }
 
304
 
 
305
  return gimp_procedure_get_return_values (procedure, success);
 
306
}
 
307
 
 
308
static GValueArray *
 
309
selection_border_invoker (GimpProcedure     *procedure,
 
310
                          Gimp              *gimp,
 
311
                          GimpContext       *context,
 
312
                          GimpProgress      *progress,
 
313
                          const GValueArray *args)
 
314
{
 
315
  gboolean success = TRUE;
 
316
  GimpImage *image;
 
317
  gint32 radius;
 
318
 
 
319
  image = gimp_value_get_image (&args->values[0], gimp);
 
320
  radius = g_value_get_int (&args->values[1]);
 
321
 
 
322
  if (success)
 
323
    {
 
324
      /* FIXME: "feather" and "edge-lock" hardcoded to TRUE */
 
325
      gimp_channel_border (gimp_image_get_mask (image),
 
326
                           radius, radius, TRUE, TRUE, TRUE);
 
327
    }
 
328
 
 
329
  return gimp_procedure_get_return_values (procedure, success);
 
330
}
 
331
 
 
332
static GValueArray *
 
333
selection_grow_invoker (GimpProcedure     *procedure,
 
334
                        Gimp              *gimp,
 
335
                        GimpContext       *context,
 
336
                        GimpProgress      *progress,
 
337
                        const GValueArray *args)
 
338
{
 
339
  gboolean success = TRUE;
 
340
  GimpImage *image;
 
341
  gint32 steps;
 
342
 
 
343
  image = gimp_value_get_image (&args->values[0], gimp);
 
344
  steps = g_value_get_int (&args->values[1]);
 
345
 
 
346
  if (success)
 
347
    {
 
348
      gimp_channel_grow (gimp_image_get_mask (image),
 
349
                         steps, steps, TRUE);
 
350
    }
 
351
 
 
352
  return gimp_procedure_get_return_values (procedure, success);
 
353
}
 
354
 
 
355
static GValueArray *
 
356
selection_shrink_invoker (GimpProcedure     *procedure,
 
357
                          Gimp              *gimp,
 
358
                          GimpContext       *context,
 
359
                          GimpProgress      *progress,
 
360
                          const GValueArray *args)
 
361
{
 
362
  gboolean success = TRUE;
 
363
  GimpImage *image;
 
364
  gint32 steps;
 
365
 
 
366
  image = gimp_value_get_image (&args->values[0], gimp);
 
367
  steps = g_value_get_int (&args->values[1]);
 
368
 
 
369
  if (success)
 
370
    {
 
371
      gimp_channel_shrink (gimp_image_get_mask (image),
 
372
                           steps, steps, FALSE, TRUE);
 
373
    }
 
374
 
 
375
  return gimp_procedure_get_return_values (procedure, success);
 
376
}
 
377
 
 
378
static GValueArray *
 
379
selection_layer_alpha_invoker (GimpProcedure     *procedure,
 
380
                               Gimp              *gimp,
 
381
                               GimpContext       *context,
 
382
                               GimpProgress      *progress,
 
383
                               const GValueArray *args)
853
384
{
854
385
  gboolean success = TRUE;
855
386
  GimpLayer *layer;
856
 
  GimpImage *gimage;
857
387
 
858
 
  layer = (GimpLayer *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
859
 
  if (! (GIMP_IS_LAYER (layer) && ! gimp_item_is_removed (GIMP_ITEM (layer))))
860
 
    success = FALSE;
 
388
  layer = gimp_value_get_layer (&args->values[0], gimp);
861
389
 
862
390
  if (success)
863
391
    {
864
 
      gimage = gimp_item_get_image (GIMP_ITEM (layer));
865
 
      gimp_channel_select_alpha (gimp_image_get_mask (gimage),
 
392
      GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer));
 
393
 
 
394
      gimp_channel_select_alpha (gimp_image_get_mask (image),
866
395
                                 GIMP_DRAWABLE (layer),
867
396
                                 GIMP_CHANNEL_OP_REPLACE, FALSE, 0.0, 0.0);
868
397
    }
869
398
 
870
 
  return procedural_db_return_args (&selection_layer_alpha_proc, success);
 
399
  return gimp_procedure_get_return_values (procedure, success);
871
400
}
872
401
 
873
 
static ProcArg selection_layer_alpha_inargs[] =
874
 
{
875
 
  {
876
 
    GIMP_PDB_LAYER,
877
 
    "layer",
878
 
    "Layer with alpha"
879
 
  }
880
 
};
881
 
 
882
 
static ProcRecord selection_layer_alpha_proc =
883
 
{
884
 
  "gimp_selection_layer_alpha",
885
 
  "Transfer the specified layer's alpha channel to the selection mask.",
886
 
  "This procedure requires a layer with an alpha channel. The alpha channel information is used to create a selection mask such that for any pixel in the image defined in the specified layer, that layer pixel's alpha value is transferred to the selection mask. If the layer is undefined at a particular image pixel, the associated selection mask value is set to 0.",
887
 
  "Spencer Kimball & Peter Mattis",
888
 
  "Spencer Kimball & Peter Mattis",
889
 
  "1995-1996",
890
 
  NULL,
891
 
  GIMP_INTERNAL,
892
 
  1,
893
 
  selection_layer_alpha_inargs,
894
 
  0,
895
 
  NULL,
896
 
  { { selection_layer_alpha_invoker } }
897
 
};
898
 
 
899
 
static Argument *
900
 
selection_load_invoker (Gimp         *gimp,
901
 
                        GimpContext  *context,
902
 
                        GimpProgress *progress,
903
 
                        Argument     *args)
 
402
static GValueArray *
 
403
selection_load_invoker (GimpProcedure     *procedure,
 
404
                        Gimp              *gimp,
 
405
                        GimpContext       *context,
 
406
                        GimpProgress      *progress,
 
407
                        const GValueArray *args)
904
408
{
905
409
  gboolean success = TRUE;
906
410
  GimpChannel *channel;
907
411
 
908
 
  channel = (GimpChannel *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
909
 
  if (! (GIMP_IS_CHANNEL (channel) && ! gimp_item_is_removed (GIMP_ITEM (channel))))
910
 
    success = FALSE;
 
412
  channel = gimp_value_get_channel (&args->values[0], gimp);
911
413
 
912
414
  if (success)
913
415
    {
914
 
      GimpImage *gimage;
 
416
      GimpImage *image;
915
417
      gint       off_x, off_y;
916
418
 
917
 
      gimage = gimp_item_get_image (GIMP_ITEM (channel));
 
419
      image = gimp_item_get_image (GIMP_ITEM (channel));
918
420
      gimp_item_offsets (GIMP_ITEM (channel), &off_x, &off_y);
919
421
 
920
 
      gimp_channel_select_channel (gimp_image_get_mask (gimage),
 
422
      gimp_channel_select_channel (gimp_image_get_mask (image),
921
423
                                   _("Channel to Selection"),
922
 
                                   channel, 
 
424
                                   channel,
923
425
                                   off_x, off_y,
924
426
                                   GIMP_CHANNEL_OP_REPLACE,
925
427
                                   FALSE, 0.0, 0.0);
926
428
    }
927
429
 
928
 
  return procedural_db_return_args (&selection_load_proc, success);
 
430
  return gimp_procedure_get_return_values (procedure, success);
929
431
}
930
432
 
931
 
static ProcArg selection_load_inargs[] =
932
 
{
933
 
  {
934
 
    GIMP_PDB_CHANNEL,
935
 
    "channel",
936
 
    "The channel"
937
 
  }
938
 
};
939
 
 
940
 
static ProcRecord selection_load_proc =
941
 
{
942
 
  "gimp_selection_load",
943
 
  "Transfer the specified channel to the selection mask.",
944
 
  "This procedure loads the specified channel into the selection mask.",
945
 
  "Spencer Kimball & Peter Mattis",
946
 
  "Spencer Kimball & Peter Mattis",
947
 
  "1995-1996",
948
 
  NULL,
949
 
  GIMP_INTERNAL,
950
 
  1,
951
 
  selection_load_inargs,
952
 
  0,
953
 
  NULL,
954
 
  { { selection_load_invoker } }
955
 
};
956
 
 
957
 
static Argument *
958
 
selection_save_invoker (Gimp         *gimp,
959
 
                        GimpContext  *context,
960
 
                        GimpProgress *progress,
961
 
                        Argument     *args)
 
433
static GValueArray *
 
434
selection_save_invoker (GimpProcedure     *procedure,
 
435
                        Gimp              *gimp,
 
436
                        GimpContext       *context,
 
437
                        GimpProgress      *progress,
 
438
                        const GValueArray *args)
962
439
{
963
440
  gboolean success = TRUE;
964
 
  Argument *return_args;
965
 
  GimpImage *gimage;
 
441
  GValueArray *return_vals;
 
442
  GimpImage *image;
966
443
  GimpChannel *channel = NULL;
967
444
 
968
 
  gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
969
 
  if (! GIMP_IS_IMAGE (gimage))
970
 
    success = FALSE;
971
 
 
972
 
  if (success)
973
 
    success = (channel = gimp_selection_save (gimp_image_get_mask (gimage))) != NULL;
974
 
 
975
 
  return_args = procedural_db_return_args (&selection_save_proc, success);
976
 
 
977
 
  if (success)
978
 
    return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (channel));
979
 
 
980
 
  return return_args;
 
445
  image = gimp_value_get_image (&args->values[0], gimp);
 
446
 
 
447
  if (success)
 
448
    {
 
449
      channel = gimp_selection_save (gimp_image_get_mask (image));
 
450
 
 
451
      if (! channel)
 
452
        success = FALSE;
 
453
    }
 
454
 
 
455
  return_vals = gimp_procedure_get_return_values (procedure, success);
 
456
 
 
457
  if (success)
 
458
    gimp_value_set_channel (&return_vals->values[1], channel);
 
459
 
 
460
  return return_vals;
981
461
}
982
462
 
983
 
static ProcArg selection_save_inargs[] =
984
 
{
985
 
  {
986
 
    GIMP_PDB_IMAGE,
987
 
    "image",
988
 
    "The image"
989
 
  }
990
 
};
991
 
 
992
 
static ProcArg selection_save_outargs[] =
993
 
{
994
 
  {
995
 
    GIMP_PDB_CHANNEL,
996
 
    "channel",
997
 
    "The new channel"
998
 
  }
999
 
};
1000
 
 
1001
 
static ProcRecord selection_save_proc =
1002
 
{
1003
 
  "gimp_selection_save",
1004
 
  "Copy the selection mask to a new channel.",
1005
 
  "This procedure copies the selection mask and stores the content in a new channel. The new channel is automatically inserted into the image's list of channels.",
1006
 
  "Spencer Kimball & Peter Mattis",
1007
 
  "Spencer Kimball & Peter Mattis",
1008
 
  "1995-1996",
1009
 
  NULL,
1010
 
  GIMP_INTERNAL,
1011
 
  1,
1012
 
  selection_save_inargs,
1013
 
  1,
1014
 
  selection_save_outargs,
1015
 
  { { selection_save_invoker } }
1016
 
};
1017
 
 
1018
 
static Argument *
1019
 
selection_combine_invoker (Gimp         *gimp,
1020
 
                           GimpContext  *context,
1021
 
                           GimpProgress *progress,
1022
 
                           Argument     *args)
 
463
static GValueArray *
 
464
selection_combine_invoker (GimpProcedure     *procedure,
 
465
                           Gimp              *gimp,
 
466
                           GimpContext       *context,
 
467
                           GimpProgress      *progress,
 
468
                           const GValueArray *args)
1023
469
{
1024
470
  gboolean success = TRUE;
1025
471
  GimpChannel *channel;
1026
472
  gint32 operation;
1027
473
 
1028
 
  channel = (GimpChannel *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
1029
 
  if (! (GIMP_IS_CHANNEL (channel) && ! gimp_item_is_removed (GIMP_ITEM (channel))))
1030
 
    success = FALSE;
1031
 
 
1032
 
  operation = args[1].value.pdb_int;
1033
 
  if (operation < GIMP_CHANNEL_OP_ADD || operation > GIMP_CHANNEL_OP_INTERSECT)
1034
 
    success = FALSE;
 
474
  channel = gimp_value_get_channel (&args->values[0], gimp);
 
475
  operation = g_value_get_enum (&args->values[1]);
1035
476
 
1036
477
  if (success)
1037
478
    {
1038
 
      GimpImage *gimage;
 
479
      GimpImage *image;
1039
480
      gint       off_x, off_y;
1040
481
 
1041
 
      gimage = gimp_item_get_image (GIMP_ITEM (channel));
 
482
      image = gimp_item_get_image (GIMP_ITEM (channel));
1042
483
      gimp_item_offsets (GIMP_ITEM (channel), &off_x, &off_y);
1043
484
 
1044
 
      gimp_channel_select_channel (gimp_image_get_mask (gimage),
 
485
      gimp_channel_select_channel (gimp_image_get_mask (image),
1045
486
                                   _("Channel to Selection"),
1046
 
                                   channel, 
 
487
                                   channel,
1047
488
                                   off_x, off_y,
1048
489
                                   operation,
1049
490
                                   FALSE, 0.0, 0.0);
1050
491
    }
1051
492
 
1052
 
  return procedural_db_return_args (&selection_combine_proc, success);
1053
 
}
1054
 
 
1055
 
static ProcArg selection_combine_inargs[] =
1056
 
{
1057
 
  {
1058
 
    GIMP_PDB_CHANNEL,
1059
 
    "channel",
1060
 
    "The channel"
1061
 
  },
1062
 
  {
1063
 
    GIMP_PDB_INT32,
1064
 
    "operation",
1065
 
    "The selection operation: { GIMP_CHANNEL_OP_ADD (0), GIMP_CHANNEL_OP_SUBTRACT (1), GIMP_CHANNEL_OP_REPLACE (2), GIMP_CHANNEL_OP_INTERSECT (3) }"
1066
 
  }
1067
 
};
1068
 
 
1069
 
static ProcRecord selection_combine_proc =
1070
 
{
1071
 
  "gimp_selection_combine",
1072
 
  "Combines the specified channel with the selection mask.",
1073
 
  "This procedure combines the specified channel into the selection mask.",
1074
 
  "Spencer Kimball & Peter Mattis",
1075
 
  "Spencer Kimball & Peter Mattis",
1076
 
  "1995-1996",
1077
 
  NULL,
1078
 
  GIMP_INTERNAL,
1079
 
  2,
1080
 
  selection_combine_inargs,
1081
 
  0,
1082
 
  NULL,
1083
 
  { { selection_combine_invoker } }
1084
 
};
 
493
  return gimp_procedure_get_return_values (procedure, success);
 
494
}
 
495
 
 
496
void
 
497
register_selection_procs (GimpPDB *pdb)
 
498
{
 
499
  GimpProcedure *procedure;
 
500
 
 
501
  /*
 
502
   * gimp-selection-bounds
 
503
   */
 
504
  procedure = gimp_procedure_new (selection_bounds_invoker);
 
505
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-bounds");
 
506
  gimp_procedure_set_static_strings (procedure,
 
507
                                     "gimp-selection-bounds",
 
508
                                     "Find the bounding box of the current selection.",
 
509
                                     "This procedure returns whether there is a selection for the specified image. If there is one, the upper left and lower right corners of the bounding box are returned. These coordinates are relative to the image. Please note that the pixel specified by the lower righthand coordinate of the bounding box is not part of the selection. The selection ends at the upper left corner of this pixel. This means the width of the selection can be calculated as (x2 - x1), its height as (y2 - y1).",
 
510
                                     "Spencer Kimball & Peter Mattis",
 
511
                                     "Spencer Kimball & Peter Mattis",
 
512
                                     "1995-1996",
 
513
                                     NULL);
 
514
  gimp_procedure_add_argument (procedure,
 
515
                               gimp_param_spec_image_id ("image",
 
516
                                                         "image",
 
517
                                                         "The image",
 
518
                                                         pdb->gimp, FALSE,
 
519
                                                         GIMP_PARAM_READWRITE));
 
520
  gimp_procedure_add_return_value (procedure,
 
521
                                   g_param_spec_boolean ("non-empty",
 
522
                                                         "non empty",
 
523
                                                         "TRUE if there is a selection",
 
524
                                                         FALSE,
 
525
                                                         GIMP_PARAM_READWRITE));
 
526
  gimp_procedure_add_return_value (procedure,
 
527
                                   gimp_param_spec_int32 ("x1",
 
528
                                                          "x1",
 
529
                                                          "x coordinate of upper left corner of selection bounds",
 
530
                                                          G_MININT32, G_MAXINT32, 0,
 
531
                                                          GIMP_PARAM_READWRITE));
 
532
  gimp_procedure_add_return_value (procedure,
 
533
                                   gimp_param_spec_int32 ("y1",
 
534
                                                          "y1",
 
535
                                                          "y coordinate of upper left corner of selection bounds",
 
536
                                                          G_MININT32, G_MAXINT32, 0,
 
537
                                                          GIMP_PARAM_READWRITE));
 
538
  gimp_procedure_add_return_value (procedure,
 
539
                                   gimp_param_spec_int32 ("x2",
 
540
                                                          "x2",
 
541
                                                          "x coordinate of lower right corner of selection bounds",
 
542
                                                          G_MININT32, G_MAXINT32, 0,
 
543
                                                          GIMP_PARAM_READWRITE));
 
544
  gimp_procedure_add_return_value (procedure,
 
545
                                   gimp_param_spec_int32 ("y2",
 
546
                                                          "y2",
 
547
                                                          "y coordinate of lower right corner of selection bounds",
 
548
                                                          G_MININT32, G_MAXINT32, 0,
 
549
                                                          GIMP_PARAM_READWRITE));
 
550
  gimp_pdb_register_procedure (pdb, procedure);
 
551
  g_object_unref (procedure);
 
552
 
 
553
  /*
 
554
   * gimp-selection-value
 
555
   */
 
556
  procedure = gimp_procedure_new (selection_value_invoker);
 
557
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-value");
 
558
  gimp_procedure_set_static_strings (procedure,
 
559
                                     "gimp-selection-value",
 
560
                                     "Find the value of the selection at the specified coordinates.",
 
561
                                     "This procedure returns the value of the selection at the specified coordinates. If the coordinates lie out of bounds, 0 is returned.",
 
562
                                     "Spencer Kimball & Peter Mattis",
 
563
                                     "Spencer Kimball & Peter Mattis",
 
564
                                     "1995-1996",
 
565
                                     NULL);
 
566
  gimp_procedure_add_argument (procedure,
 
567
                               gimp_param_spec_image_id ("image",
 
568
                                                         "image",
 
569
                                                         "The image",
 
570
                                                         pdb->gimp, FALSE,
 
571
                                                         GIMP_PARAM_READWRITE));
 
572
  gimp_procedure_add_argument (procedure,
 
573
                               gimp_param_spec_int32 ("x",
 
574
                                                      "x",
 
575
                                                      "x coordinate of value",
 
576
                                                      G_MININT32, G_MAXINT32, 0,
 
577
                                                      GIMP_PARAM_READWRITE));
 
578
  gimp_procedure_add_argument (procedure,
 
579
                               gimp_param_spec_int32 ("y",
 
580
                                                      "y",
 
581
                                                      "y coordinate of value",
 
582
                                                      G_MININT32, G_MAXINT32, 0,
 
583
                                                      GIMP_PARAM_READWRITE));
 
584
  gimp_procedure_add_return_value (procedure,
 
585
                                   gimp_param_spec_int32 ("value",
 
586
                                                          "value",
 
587
                                                          "Value of the selection",
 
588
                                                          0, 255, 0,
 
589
                                                          GIMP_PARAM_READWRITE));
 
590
  gimp_pdb_register_procedure (pdb, procedure);
 
591
  g_object_unref (procedure);
 
592
 
 
593
  /*
 
594
   * gimp-selection-is-empty
 
595
   */
 
596
  procedure = gimp_procedure_new (selection_is_empty_invoker);
 
597
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-is-empty");
 
598
  gimp_procedure_set_static_strings (procedure,
 
599
                                     "gimp-selection-is-empty",
 
600
                                     "Determine whether the selection is empty.",
 
601
                                     "This procedure returns TRUE if the selection for the specified image is not empty.",
 
602
                                     "Spencer Kimball & Peter Mattis",
 
603
                                     "Spencer Kimball & Peter Mattis",
 
604
                                     "1995-1996",
 
605
                                     NULL);
 
606
  gimp_procedure_add_argument (procedure,
 
607
                               gimp_param_spec_image_id ("image",
 
608
                                                         "image",
 
609
                                                         "The image",
 
610
                                                         pdb->gimp, FALSE,
 
611
                                                         GIMP_PARAM_READWRITE));
 
612
  gimp_procedure_add_return_value (procedure,
 
613
                                   g_param_spec_boolean ("is-empty",
 
614
                                                         "is empty",
 
615
                                                         "Is the selection empty?",
 
616
                                                         FALSE,
 
617
                                                         GIMP_PARAM_READWRITE));
 
618
  gimp_pdb_register_procedure (pdb, procedure);
 
619
  g_object_unref (procedure);
 
620
 
 
621
  /*
 
622
   * gimp-selection-translate
 
623
   */
 
624
  procedure = gimp_procedure_new (selection_translate_invoker);
 
625
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-translate");
 
626
  gimp_procedure_set_static_strings (procedure,
 
627
                                     "gimp-selection-translate",
 
628
                                     "Translate the selection by the specified offsets.",
 
629
                                     "This procedure actually translates the selection for the specified image by the specified offsets. Regions that are translated from beyond the bounds of the image are set to empty. Valid regions of the selection which are translated beyond the bounds of the image because of this call are lost.",
 
630
                                     "Spencer Kimball & Peter Mattis",
 
631
                                     "Spencer Kimball & Peter Mattis",
 
632
                                     "1995-1996",
 
633
                                     NULL);
 
634
  gimp_procedure_add_argument (procedure,
 
635
                               gimp_param_spec_image_id ("image",
 
636
                                                         "image",
 
637
                                                         "The image",
 
638
                                                         pdb->gimp, FALSE,
 
639
                                                         GIMP_PARAM_READWRITE));
 
640
  gimp_procedure_add_argument (procedure,
 
641
                               gimp_param_spec_int32 ("offx",
 
642
                                                      "offx",
 
643
                                                      "x offset for translation",
 
644
                                                      G_MININT32, G_MAXINT32, 0,
 
645
                                                      GIMP_PARAM_READWRITE));
 
646
  gimp_procedure_add_argument (procedure,
 
647
                               gimp_param_spec_int32 ("offy",
 
648
                                                      "offy",
 
649
                                                      "y offset for translation",
 
650
                                                      G_MININT32, G_MAXINT32, 0,
 
651
                                                      GIMP_PARAM_READWRITE));
 
652
  gimp_pdb_register_procedure (pdb, procedure);
 
653
  g_object_unref (procedure);
 
654
 
 
655
  /*
 
656
   * gimp-selection-float
 
657
   */
 
658
  procedure = gimp_procedure_new (selection_float_invoker);
 
659
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-float");
 
660
  gimp_procedure_set_static_strings (procedure,
 
661
                                     "gimp-selection-float",
 
662
                                     "Float the selection from the specified drawable with initial offsets as specified.",
 
663
                                     "This procedure determines the region of the specified drawable that lies beneath the current selection. The region is then cut from the drawable and the resulting data is made into a new layer which is instantiated as a floating selection. The offsets allow initial positioning of the new floating selection.",
 
664
                                     "Spencer Kimball & Peter Mattis",
 
665
                                     "Spencer Kimball & Peter Mattis",
 
666
                                     "1995-1996",
 
667
                                     NULL);
 
668
  gimp_procedure_add_argument (procedure,
 
669
                               gimp_param_spec_drawable_id ("drawable",
 
670
                                                            "drawable",
 
671
                                                            "The drawable from which to float selection",
 
672
                                                            pdb->gimp, FALSE,
 
673
                                                            GIMP_PARAM_READWRITE));
 
674
  gimp_procedure_add_argument (procedure,
 
675
                               gimp_param_spec_int32 ("offx",
 
676
                                                      "offx",
 
677
                                                      "x offset for translation",
 
678
                                                      G_MININT32, G_MAXINT32, 0,
 
679
                                                      GIMP_PARAM_READWRITE));
 
680
  gimp_procedure_add_argument (procedure,
 
681
                               gimp_param_spec_int32 ("offy",
 
682
                                                      "offy",
 
683
                                                      "y offset for translation",
 
684
                                                      G_MININT32, G_MAXINT32, 0,
 
685
                                                      GIMP_PARAM_READWRITE));
 
686
  gimp_procedure_add_return_value (procedure,
 
687
                                   gimp_param_spec_layer_id ("layer",
 
688
                                                             "layer",
 
689
                                                             "The floated layer",
 
690
                                                             pdb->gimp, FALSE,
 
691
                                                             GIMP_PARAM_READWRITE));
 
692
  gimp_pdb_register_procedure (pdb, procedure);
 
693
  g_object_unref (procedure);
 
694
 
 
695
  /*
 
696
   * gimp-selection-invert
 
697
   */
 
698
  procedure = gimp_procedure_new (selection_invert_invoker);
 
699
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-invert");
 
700
  gimp_procedure_set_static_strings (procedure,
 
701
                                     "gimp-selection-invert",
 
702
                                     "Invert the selection mask.",
 
703
                                     "This procedure inverts the selection mask. For every pixel in the selection channel, its new value is calculated as (255 - old-value).",
 
704
                                     "Spencer Kimball & Peter Mattis",
 
705
                                     "Spencer Kimball & Peter Mattis",
 
706
                                     "1995-1996",
 
707
                                     NULL);
 
708
  gimp_procedure_add_argument (procedure,
 
709
                               gimp_param_spec_image_id ("image",
 
710
                                                         "image",
 
711
                                                         "The image",
 
712
                                                         pdb->gimp, FALSE,
 
713
                                                         GIMP_PARAM_READWRITE));
 
714
  gimp_pdb_register_procedure (pdb, procedure);
 
715
  g_object_unref (procedure);
 
716
 
 
717
  /*
 
718
   * gimp-selection-sharpen
 
719
   */
 
720
  procedure = gimp_procedure_new (selection_sharpen_invoker);
 
721
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-sharpen");
 
722
  gimp_procedure_set_static_strings (procedure,
 
723
                                     "gimp-selection-sharpen",
 
724
                                     "Sharpen the selection mask.",
 
725
                                     "This procedure sharpens the selection mask. For every pixel in the selection channel, if the value is > 127, the new pixel is assigned a value of 255. This removes any \"anti-aliasing\" that might exist in the selection mask's boundary.",
 
726
                                     "Spencer Kimball & Peter Mattis",
 
727
                                     "Spencer Kimball & Peter Mattis",
 
728
                                     "1995-1996",
 
729
                                     NULL);
 
730
  gimp_procedure_add_argument (procedure,
 
731
                               gimp_param_spec_image_id ("image",
 
732
                                                         "image",
 
733
                                                         "The image",
 
734
                                                         pdb->gimp, FALSE,
 
735
                                                         GIMP_PARAM_READWRITE));
 
736
  gimp_pdb_register_procedure (pdb, procedure);
 
737
  g_object_unref (procedure);
 
738
 
 
739
  /*
 
740
   * gimp-selection-all
 
741
   */
 
742
  procedure = gimp_procedure_new (selection_all_invoker);
 
743
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-all");
 
744
  gimp_procedure_set_static_strings (procedure,
 
745
                                     "gimp-selection-all",
 
746
                                     "Select all of the image.",
 
747
                                     "This procedure sets the selection mask to completely encompass the image. Every pixel in the selection channel is set to 255.",
 
748
                                     "Spencer Kimball & Peter Mattis",
 
749
                                     "Spencer Kimball & Peter Mattis",
 
750
                                     "1995-1996",
 
751
                                     NULL);
 
752
  gimp_procedure_add_argument (procedure,
 
753
                               gimp_param_spec_image_id ("image",
 
754
                                                         "image",
 
755
                                                         "The image",
 
756
                                                         pdb->gimp, FALSE,
 
757
                                                         GIMP_PARAM_READWRITE));
 
758
  gimp_pdb_register_procedure (pdb, procedure);
 
759
  g_object_unref (procedure);
 
760
 
 
761
  /*
 
762
   * gimp-selection-none
 
763
   */
 
764
  procedure = gimp_procedure_new (selection_none_invoker);
 
765
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-none");
 
766
  gimp_procedure_set_static_strings (procedure,
 
767
                                     "gimp-selection-none",
 
768
                                     "Deselect the entire image.",
 
769
                                     "This procedure deselects the entire image. Every pixel in the selection channel is set to 0.",
 
770
                                     "Spencer Kimball & Peter Mattis",
 
771
                                     "Spencer Kimball & Peter Mattis",
 
772
                                     "1995-1996",
 
773
                                     NULL);
 
774
  gimp_procedure_add_argument (procedure,
 
775
                               gimp_param_spec_image_id ("image",
 
776
                                                         "image",
 
777
                                                         "The image",
 
778
                                                         pdb->gimp, FALSE,
 
779
                                                         GIMP_PARAM_READWRITE));
 
780
  gimp_pdb_register_procedure (pdb, procedure);
 
781
  g_object_unref (procedure);
 
782
 
 
783
  /*
 
784
   * gimp-selection-feather
 
785
   */
 
786
  procedure = gimp_procedure_new (selection_feather_invoker);
 
787
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-feather");
 
788
  gimp_procedure_set_static_strings (procedure,
 
789
                                     "gimp-selection-feather",
 
790
                                     "Feather the image's selection",
 
791
                                     "This procedure feathers the selection. Feathering is implemented using a gaussian blur.",
 
792
                                     "Spencer Kimball & Peter Mattis",
 
793
                                     "Spencer Kimball & Peter Mattis",
 
794
                                     "1995-1996",
 
795
                                     NULL);
 
796
  gimp_procedure_add_argument (procedure,
 
797
                               gimp_param_spec_image_id ("image",
 
798
                                                         "image",
 
799
                                                         "The image",
 
800
                                                         pdb->gimp, FALSE,
 
801
                                                         GIMP_PARAM_READWRITE));
 
802
  gimp_procedure_add_argument (procedure,
 
803
                               g_param_spec_double ("radius",
 
804
                                                    "radius",
 
805
                                                    "Radius of feather (in pixels)",
 
806
                                                    0, G_MAXDOUBLE, 0,
 
807
                                                    GIMP_PARAM_READWRITE));
 
808
  gimp_pdb_register_procedure (pdb, procedure);
 
809
  g_object_unref (procedure);
 
810
 
 
811
  /*
 
812
   * gimp-selection-border
 
813
   */
 
814
  procedure = gimp_procedure_new (selection_border_invoker);
 
815
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-border");
 
816
  gimp_procedure_set_static_strings (procedure,
 
817
                                     "gimp-selection-border",
 
818
                                     "Border the image's selection",
 
819
                                     "This procedure borders the selection. Bordering creates a new selection which is defined along the boundary of the previous selection at every point within the specified radius.",
 
820
                                     "Spencer Kimball & Peter Mattis",
 
821
                                     "Spencer Kimball & Peter Mattis",
 
822
                                     "1995-1996",
 
823
                                     NULL);
 
824
  gimp_procedure_add_argument (procedure,
 
825
                               gimp_param_spec_image_id ("image",
 
826
                                                         "image",
 
827
                                                         "The image",
 
828
                                                         pdb->gimp, FALSE,
 
829
                                                         GIMP_PARAM_READWRITE));
 
830
  gimp_procedure_add_argument (procedure,
 
831
                               gimp_param_spec_int32 ("radius",
 
832
                                                      "radius",
 
833
                                                      "Radius of border (in pixels)",
 
834
                                                      0, G_MAXINT32, 0,
 
835
                                                      GIMP_PARAM_READWRITE));
 
836
  gimp_pdb_register_procedure (pdb, procedure);
 
837
  g_object_unref (procedure);
 
838
 
 
839
  /*
 
840
   * gimp-selection-grow
 
841
   */
 
842
  procedure = gimp_procedure_new (selection_grow_invoker);
 
843
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-grow");
 
844
  gimp_procedure_set_static_strings (procedure,
 
845
                                     "gimp-selection-grow",
 
846
                                     "Grow the image's selection",
 
847
                                     "This procedure grows the selection. Growing involves expanding the boundary in all directions by the specified pixel amount.",
 
848
                                     "Spencer Kimball & Peter Mattis",
 
849
                                     "Spencer Kimball & Peter Mattis",
 
850
                                     "1995-1996",
 
851
                                     NULL);
 
852
  gimp_procedure_add_argument (procedure,
 
853
                               gimp_param_spec_image_id ("image",
 
854
                                                         "image",
 
855
                                                         "The image",
 
856
                                                         pdb->gimp, FALSE,
 
857
                                                         GIMP_PARAM_READWRITE));
 
858
  gimp_procedure_add_argument (procedure,
 
859
                               gimp_param_spec_int32 ("steps",
 
860
                                                      "steps",
 
861
                                                      "Steps of grow (in pixels)",
 
862
                                                      0, G_MAXINT32, 0,
 
863
                                                      GIMP_PARAM_READWRITE));
 
864
  gimp_pdb_register_procedure (pdb, procedure);
 
865
  g_object_unref (procedure);
 
866
 
 
867
  /*
 
868
   * gimp-selection-shrink
 
869
   */
 
870
  procedure = gimp_procedure_new (selection_shrink_invoker);
 
871
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-shrink");
 
872
  gimp_procedure_set_static_strings (procedure,
 
873
                                     "gimp-selection-shrink",
 
874
                                     "Shrink the image's selection",
 
875
                                     "This procedure shrinks the selection. Shrinking invovles trimming the existing selection boundary on all sides by the specified number of pixels.",
 
876
                                     "Spencer Kimball & Peter Mattis",
 
877
                                     "Spencer Kimball & Peter Mattis",
 
878
                                     "1995-1996",
 
879
                                     NULL);
 
880
  gimp_procedure_add_argument (procedure,
 
881
                               gimp_param_spec_image_id ("image",
 
882
                                                         "image",
 
883
                                                         "The image",
 
884
                                                         pdb->gimp, FALSE,
 
885
                                                         GIMP_PARAM_READWRITE));
 
886
  gimp_procedure_add_argument (procedure,
 
887
                               gimp_param_spec_int32 ("steps",
 
888
                                                      "steps",
 
889
                                                      "Steps of shrink (in pixels)",
 
890
                                                      0, G_MAXINT32, 0,
 
891
                                                      GIMP_PARAM_READWRITE));
 
892
  gimp_pdb_register_procedure (pdb, procedure);
 
893
  g_object_unref (procedure);
 
894
 
 
895
  /*
 
896
   * gimp-selection-layer-alpha
 
897
   */
 
898
  procedure = gimp_procedure_new (selection_layer_alpha_invoker);
 
899
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-layer-alpha");
 
900
  gimp_procedure_set_static_strings (procedure,
 
901
                                     "gimp-selection-layer-alpha",
 
902
                                     "Transfer the specified layer's alpha channel to the selection mask.",
 
903
                                     "This procedure requires a layer with an alpha channel. The alpha channel information is used to create a selection mask such that for any pixel in the image defined in the specified layer, that layer pixel's alpha value is transferred to the selection mask. If the layer is undefined at a particular image pixel, the associated selection mask value is set to 0.",
 
904
                                     "Spencer Kimball & Peter Mattis",
 
905
                                     "Spencer Kimball & Peter Mattis",
 
906
                                     "1995-1996",
 
907
                                     NULL);
 
908
  gimp_procedure_add_argument (procedure,
 
909
                               gimp_param_spec_layer_id ("layer",
 
910
                                                         "layer",
 
911
                                                         "Layer with alpha",
 
912
                                                         pdb->gimp, FALSE,
 
913
                                                         GIMP_PARAM_READWRITE));
 
914
  gimp_pdb_register_procedure (pdb, procedure);
 
915
  g_object_unref (procedure);
 
916
 
 
917
  /*
 
918
   * gimp-selection-load
 
919
   */
 
920
  procedure = gimp_procedure_new (selection_load_invoker);
 
921
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-load");
 
922
  gimp_procedure_set_static_strings (procedure,
 
923
                                     "gimp-selection-load",
 
924
                                     "Transfer the specified channel to the selection mask.",
 
925
                                     "This procedure loads the specified channel into the selection mask.",
 
926
                                     "Spencer Kimball & Peter Mattis",
 
927
                                     "Spencer Kimball & Peter Mattis",
 
928
                                     "1995-1996",
 
929
                                     NULL);
 
930
  gimp_procedure_add_argument (procedure,
 
931
                               gimp_param_spec_channel_id ("channel",
 
932
                                                           "channel",
 
933
                                                           "The channel",
 
934
                                                           pdb->gimp, FALSE,
 
935
                                                           GIMP_PARAM_READWRITE));
 
936
  gimp_pdb_register_procedure (pdb, procedure);
 
937
  g_object_unref (procedure);
 
938
 
 
939
  /*
 
940
   * gimp-selection-save
 
941
   */
 
942
  procedure = gimp_procedure_new (selection_save_invoker);
 
943
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-save");
 
944
  gimp_procedure_set_static_strings (procedure,
 
945
                                     "gimp-selection-save",
 
946
                                     "Copy the selection mask to a new channel.",
 
947
                                     "This procedure copies the selection mask and stores the content in a new channel. The new channel is automatically inserted into the image's list of channels.",
 
948
                                     "Spencer Kimball & Peter Mattis",
 
949
                                     "Spencer Kimball & Peter Mattis",
 
950
                                     "1995-1996",
 
951
                                     NULL);
 
952
  gimp_procedure_add_argument (procedure,
 
953
                               gimp_param_spec_image_id ("image",
 
954
                                                         "image",
 
955
                                                         "The image",
 
956
                                                         pdb->gimp, FALSE,
 
957
                                                         GIMP_PARAM_READWRITE));
 
958
  gimp_procedure_add_return_value (procedure,
 
959
                                   gimp_param_spec_channel_id ("channel",
 
960
                                                               "channel",
 
961
                                                               "The new channel",
 
962
                                                               pdb->gimp, FALSE,
 
963
                                                               GIMP_PARAM_READWRITE));
 
964
  gimp_pdb_register_procedure (pdb, procedure);
 
965
  g_object_unref (procedure);
 
966
 
 
967
  /*
 
968
   * gimp-selection-combine
 
969
   */
 
970
  procedure = gimp_procedure_new (selection_combine_invoker);
 
971
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-selection-combine");
 
972
  gimp_procedure_set_static_strings (procedure,
 
973
                                     "gimp-selection-combine",
 
974
                                     "Combines the specified channel with the selection mask.",
 
975
                                     "This procedure combines the specified channel into the selection mask.",
 
976
                                     "Spencer Kimball & Peter Mattis",
 
977
                                     "Spencer Kimball & Peter Mattis",
 
978
                                     "1995-1996",
 
979
                                     NULL);
 
980
  gimp_procedure_add_argument (procedure,
 
981
                               gimp_param_spec_channel_id ("channel",
 
982
                                                           "channel",
 
983
                                                           "The channel",
 
984
                                                           pdb->gimp, FALSE,
 
985
                                                           GIMP_PARAM_READWRITE));
 
986
  gimp_procedure_add_argument (procedure,
 
987
                               g_param_spec_enum ("operation",
 
988
                                                  "operation",
 
989
                                                  "The selection operation",
 
990
                                                  GIMP_TYPE_CHANNEL_OPS,
 
991
                                                  GIMP_CHANNEL_OP_ADD,
 
992
                                                  GIMP_PARAM_READWRITE));
 
993
  gimp_pdb_register_procedure (pdb, procedure);
 
994
  g_object_unref (procedure);
 
995
}