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

« back to all changes in this revision

Viewing changes to tools/pdbgen/pdb/edit.pdb

  • 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 Spencer Kimball and Peter Mattis
3
3
 
4
4
# This program is free software; you can redistribute it and/or modify
17
17
 
18
18
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
19
19
 
20
 
# Common arguments
21
 
sub inargs {
22
 
    @inargs = (
23
 
        { name => 'drawable', type => 'drawable',
24
 
          desc => "The drawable to @{[shift]}" }
25
 
    );
26
 
}
27
 
 
28
 
sub outargs {
29
 
    @outargs = (
30
 
        { name => 'non_empty', type => 'boolean', init => 1,
31
 
          desc => "TRUE if the @{[shift]} was successful, FALSE if the selection contained only transparent pixels" }
32
 
    );
33
 
}
34
 
 
35
 
sub drawable_arg () {{
36
 
    name => 'drawable',
37
 
    type => 'drawable',
38
 
    desc => 'The affected drawable',
39
 
}}
40
 
 
41
 
sub sample_merged_arg () {{
42
 
    name => 'sample_merged',
43
 
    type => 'boolean',
44
 
    desc => 'Use the composite image, not the drawable'
45
 
}}
46
 
 
47
 
# Common invoker for checking for image/drawable consistency
48
 
sub invoke {
49
 
    %invoke = (
50
 
        code => <<CODE
51
 
{
52
 
  success = gimp_item_is_attached (GIMP_ITEM (drawable));
53
 
 
54
 
  if (success)
55
 
    {
56
 
      GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
57
 
 
58
 
      @{[shift]};
59
 
    }
60
 
}
61
 
CODE
62
 
    );
63
 
}
64
 
 
65
 
# The defs
66
 
 
67
20
sub edit_cut {
68
21
    $blurb = 'Cut from the specified drawable.';
69
22
 
70
23
    $help = <<'HELP';
71
 
If there is a selection in the image, then the area specified by the selection
72
 
is cut from the specified drawable and placed in an internal GIMP edit buffer.
73
 
It can subsequently be retrieved using the 'gimp-edit-paste' command. If there
74
 
is no selection, then the specified drawable will be removed and its contents
75
 
stored in the internal GIMP edit buffer.
 
24
If there is a selection in the image, then the area specified by the
 
25
selection is cut from the specified drawable and placed in an internal
 
26
GIMP edit buffer.  It can subsequently be retrieved using the
 
27
gimp_edit_paste() command. If there is no selection, then the
 
28
specified drawable will be removed and its contents stored in the
 
29
internal GIMP edit buffer.
76
30
HELP
77
31
 
78
32
    &std_pdb_misc;
79
 
    &inargs('cut from');
80
 
    &outargs('cut');
81
 
    &invoke('non_empty = gimp_edit_cut (gimage, drawable, context) != NULL');
 
33
 
 
34
    @inargs = (
 
35
        { name => 'drawable', type => 'drawable',
 
36
          desc => 'The drawable to cut from' }
 
37
    );
 
38
 
 
39
    @outargs = (
 
40
        { name => 'non_empty', type => 'boolean',
 
41
          desc => 'TRUE if the cut was successful, FALSE if the
 
42
                   selection contained only transparent pixels' }
 
43
    );
 
44
 
 
45
    %invoke = (
 
46
        code => <<CODE
 
47
{
 
48
  if (gimp_item_is_attached (GIMP_ITEM (drawable)))
 
49
    {
 
50
      GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
 
51
 
 
52
      non_empty = gimp_edit_cut (image, drawable, context) != NULL;
 
53
    }
 
54
  else
 
55
    success = FALSE;
 
56
}
 
57
CODE
 
58
    );
82
59
}
83
60
 
84
61
sub edit_copy {
85
62
    $blurb = 'Copy from the specified drawable.';
86
63
 
87
64
    $help = <<'HELP';
88
 
If there is a selection in the image, then the area specified by the selection
89
 
is copied from the specified drawable and placed in an internal GIMP edit
90
 
buffer. It can subsequently be retrieved using the 'gimp-edit-paste' command.
91
 
If there is no selection, then the specified drawable's contents will be stored
92
 
in the internal GIMP edit buffer.
 
65
If there is a selection in the image, then the area specified by the
 
66
selection is copied from the specified drawable and placed in an
 
67
internal GIMP edit buffer. It can subsequently be retrieved using the
 
68
gimp_edit_paste() command.  If there is no selection, then the
 
69
specified drawable's contents will be stored in the internal GIMP edit
 
70
buffer.
93
71
HELP
94
72
 
95
73
    &std_pdb_misc;
96
 
    &inargs('copy from');
97
 
    &outargs('copy');
98
 
    &invoke('non_empty = gimp_edit_copy (gimage, drawable, context) != NULL');
 
74
 
 
75
    @inargs = (
 
76
        { name => 'drawable', type => 'drawable',
 
77
          desc => 'The drawable to copy from' }
 
78
    );
 
79
 
 
80
    @outargs = (
 
81
        { name => 'non_empty', type => 'boolean',
 
82
          desc => 'TRUE if the copy was successful, FALSE if the
 
83
                   selection contained only transparent pixels' }
 
84
    );
 
85
 
 
86
    %invoke = (
 
87
        code => <<CODE
 
88
{
 
89
  if (gimp_item_is_attached (GIMP_ITEM (drawable)))
 
90
    {
 
91
      GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
 
92
 
 
93
      non_empty = gimp_edit_copy (image, drawable, context) != NULL;
 
94
    }
 
95
  else
 
96
    success = FALSE;
 
97
}
 
98
CODE
 
99
    );
99
100
}
100
101
 
101
102
sub edit_copy_visible {
105
106
If there is a selection in the image, then the area specified by the
106
107
selection is copied from the projection and placed in an internal GIMP
107
108
edit buffer. It can subsequently be retrieved using the
108
 
'gimp-edit-paste' command.  If there is no selection, then the
 
109
gimp_edit_paste() command. If there is no selection, then the
109
110
projection's contents will be stored in the internal GIMP edit buffer.
110
111
HELP
111
112
 
112
 
    $author = $copyright = 'Michael Natterer <mitch@gimp.org>';
113
 
    $date   = '2004';
114
 
    $since  = '2.2';
 
113
    &mitch_pdb_misc('2004', '2.2');
115
114
 
116
115
    @inargs = (
117
116
        { name => 'image', type => 'image',
118
117
          desc => "The image to copy from" }
119
118
    );
120
 
    &outargs('copy');
 
119
 
 
120
    @outargs = (
 
121
        { name => 'non_empty', type => 'boolean',
 
122
          desc => 'TRUE if the copy was successful, FALSE if the
 
123
                   selection contained only transparent pixels' }
 
124
    );
121
125
 
122
126
    %invoke = (
123
127
        code => <<CODE
132
136
    $blurb = 'Paste buffer to the specified drawable.';
133
137
 
134
138
    $help = <<'HELP';
135
 
This procedure pastes a copy of the internal GIMP edit buffer to the specified
136
 
drawable. The GIMP edit buffer will be empty unless a call was previously made
137
 
to either 'gimp-edit-cut' or 'gimp-edit-copy'. The "paste_into" option
138
 
specifies whether to clear the current image selection, or to paste the buffer
139
 
"behind" the selection. This allows the selection to act as a mask for the
140
 
pasted buffer. Anywhere that the selection mask is non-zero, the pasted buffer
141
 
will show through. The pasted buffer will be a new layer in the image which is
142
 
designated as the image floating selection. If the image has a floating
143
 
selection at the time of pasting, the old floating selection will be anchored
144
 
to it's drawable before the new floating selection is added. This procedure
145
 
returns the new floating layer. The resulting floating selection will already
146
 
be attached to the specified drawable, and a subsequent call to
147
 
floating_sel_attach is not needed.
 
139
This procedure pastes a copy of the internal GIMP edit buffer to the
 
140
specified drawable. The GIMP edit buffer will be empty unless a call
 
141
was previously made to either gimp_edit_cut() or gimp_edit_copy(). The
 
142
"paste_into" option specifies whether to clear the current image
 
143
selection, or to paste the buffer "behind" the selection. This allows
 
144
the selection to act as a mask for the pasted buffer. Anywhere that
 
145
the selection mask is non-zero, the pasted buffer will show
 
146
through. The pasted buffer will be a new layer in the image which is
 
147
designated as the image floating selection. If the image has a
 
148
floating selection at the time of pasting, the old floating selection
 
149
will be anchored to it's drawable before the new floating selection is
 
150
added. This procedure returns the new floating layer. The resulting
 
151
floating selection will already be attached to the specified drawable,
 
152
and a subsequent call to floating_sel_attach is not needed.
148
153
HELP
149
154
 
150
155
    &std_pdb_misc;
151
156
 
152
 
    &inargs('paste to');
153
 
    push @inargs, { name => 'paste_into', type => 'boolean',
154
 
                    desc => 'Clear selection, or paste behind it?' };
155
 
 
156
 
    @outargs = (
157
 
        { name  => 'floating_sel', type  => 'layer',
158
 
          desc  => 'The new floating selection', alias => 'layer', init => 1 }
159
 
    );
160
 
 
161
 
    %invoke = (
162
 
        code => <<CODE
163
 
{
164
 
  success = (gimp_item_is_attached (GIMP_ITEM (drawable)) &&
165
 
             gimp->global_buffer != NULL);
166
 
 
167
 
  if (success)
168
 
    {
169
 
      layer = gimp_edit_paste (gimp_item_get_image (GIMP_ITEM (drawable)),
170
 
                               drawable, gimp->global_buffer,
171
 
                               paste_into, -1, -1, -1, -1);
172
 
      if (! layer)
173
 
        success = FALSE;
174
 
    }
 
157
    @inargs = (
 
158
        { name => 'drawable', type => 'drawable',
 
159
          desc => 'The drawable to paste to' },
 
160
        { name => 'paste_into', type => 'boolean',
 
161
          desc => 'Clear selection, or paste behind it?' }
 
162
    );
 
163
 
 
164
    @outargs = (
 
165
        { name  => 'floating_sel', type  => 'layer',
 
166
          desc  => 'The new floating selection' }
 
167
    );
 
168
 
 
169
    %invoke = (
 
170
        code => <<CODE
 
171
{
 
172
  if (gimp->global_buffer && gimp_item_is_attached (GIMP_ITEM (drawable)))
 
173
    {
 
174
      floating_sel = gimp_edit_paste (gimp_item_get_image (GIMP_ITEM (drawable)),
 
175
                                      drawable, gimp->global_buffer,
 
176
                                      paste_into, -1, -1, -1, -1);
 
177
 
 
178
      if (! floating_sel)
 
179
        success = FALSE;
 
180
    }
 
181
  else
 
182
    success = FALSE;
 
183
}
 
184
CODE
 
185
    );
 
186
}
 
187
 
 
188
sub edit_paste_as_new {
 
189
    $blurb = 'Paste buffer to a new image.';
 
190
 
 
191
    $help = <<'HELP';
 
192
This procedure pastes a copy of the internal GIMP edit buffer to a new
 
193
image.  The GIMP edit buffer will be empty unless a call was
 
194
previously made to either gimp_edit_cut() or gimp_edit_copy(). This
 
195
procedure returns the new image.
 
196
HELP
 
197
 
 
198
    &mitch_pdb_misc('2005', '2.4');
 
199
 
 
200
    @outargs = (
 
201
        { name => 'image', type => 'image',
 
202
          desc => 'The new image' }
 
203
    );
 
204
    %invoke = (
 
205
        code => <<CODE
 
206
{
 
207
  if (gimp->global_buffer)
 
208
    {
 
209
      image = gimp_edit_paste_as_new (gimp, NULL, gimp->global_buffer);
 
210
 
 
211
      if (! image)
 
212
        success = FALSE;
 
213
    }
 
214
  else
 
215
    success = FALSE;
 
216
}
 
217
CODE
 
218
    );
 
219
}
 
220
 
 
221
sub edit_named_cut {
 
222
    $blurb = 'Cut into a named buffer.';
 
223
 
 
224
    $help = <<'HELP';
 
225
This procedure works like gimp_edit_cut(), but additionally stores the
 
226
cut buffer into a named buffer that will stay available for later
 
227
pasting, regardless of any intermediate copy or cut operations.
 
228
HELP
 
229
 
 
230
    &mitch_pdb_misc('2005', '2.4');
 
231
 
 
232
    @inargs = (
 
233
        { name => 'drawable', type => 'drawable',
 
234
          desc => "The drawable to cut from" },
 
235
        { name => 'buffer_name', type => 'string',
 
236
          desc => 'The name of the buffer to create' }
 
237
    );
 
238
    @outargs = (
 
239
        { name => 'real_name', type => 'string',
 
240
          desc => 'The real name given to the buffer, or NULL if the
 
241
                   selection contained only transparent pixels' }
 
242
    );
 
243
 
 
244
    %invoke = (
 
245
        code => <<CODE
 
246
{
 
247
  if (strlen (buffer_name) && gimp_item_is_attached (GIMP_ITEM (drawable)))
 
248
    {
 
249
       GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
 
250
 
 
251
       real_name = (gchar *) gimp_edit_named_cut (image, buffer_name,
 
252
                                                  drawable, context);
 
253
 
 
254
       if (real_name)
 
255
         real_name = g_strdup (real_name);
 
256
       else
 
257
         success = FALSE;
 
258
    }
 
259
  else
 
260
    success = FALSE;
 
261
}
 
262
CODE
 
263
    );
 
264
}
 
265
 
 
266
sub edit_named_copy {
 
267
    $blurb = 'Copy into a named buffer.';
 
268
 
 
269
    $help = <<'HELP';
 
270
This procedure works like gimp_edit_copy(), but additionally stores the
 
271
copied buffer into a named buffer that will stay available for later
 
272
pasting, regardless of any intermediate copy or cut operations.
 
273
HELP
 
274
 
 
275
    &mitch_pdb_misc('2005', '2.4');
 
276
 
 
277
    @inargs = (
 
278
        { name => 'drawable', type => 'drawable',
 
279
          desc => "The drawable to copy from" },
 
280
        { name => 'buffer_name', type => 'string',
 
281
          desc => 'The name of the buffer to create' }
 
282
    );
 
283
    @outargs = (
 
284
        { name => 'real_name', type => 'string',
 
285
          desc => 'The real name given to the buffer, or NULL if the
 
286
                   selection contained only transparent pixels' }
 
287
    );
 
288
 
 
289
    %invoke = (
 
290
        code => <<CODE
 
291
{
 
292
  if (strlen (buffer_name) && gimp_item_is_attached (GIMP_ITEM (drawable)))
 
293
    {
 
294
       GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
 
295
 
 
296
       real_name = (gchar *) gimp_edit_named_copy (image, buffer_name,
 
297
                                                   drawable, context);
 
298
 
 
299
       if (real_name)
 
300
         real_name = g_strdup (real_name);
 
301
       else
 
302
         success = FALSE;
 
303
    }
 
304
  else
 
305
    success = FALSE;
 
306
}
 
307
CODE
 
308
    );
 
309
}
 
310
 
 
311
sub edit_named_copy_visible {
 
312
    $blurb = 'Copy from the projection into a named buffer.';
 
313
 
 
314
    $help = <<'HELP';
 
315
This procedure works like gimp_edit_copy_visible(), but additionally
 
316
stores the copied buffer into a named buffer that will stay available
 
317
for later pasting, regardless of any intermediate copy or cut
 
318
operations.
 
319
HELP
 
320
 
 
321
    &mitch_pdb_misc('2005', '2.4');
 
322
 
 
323
    @inargs = (
 
324
        { name => 'image', type => 'image',
 
325
          desc => "The image to copy from" },
 
326
        { name => 'buffer_name', type => 'string',
 
327
          desc => 'The name of the buffer to create' }
 
328
    );
 
329
 
 
330
    @outargs = (
 
331
        { name => 'real_name', type => 'string',
 
332
          desc => 'The real name given to the buffer' }
 
333
    );
 
334
 
 
335
    %invoke = (
 
336
        code => <<CODE
 
337
{
 
338
  if (strlen (buffer_name))
 
339
    {
 
340
      real_name = (gchar *) gimp_edit_named_copy_visible (image, buffer_name,
 
341
                                                          context);
 
342
 
 
343
      if (real_name)
 
344
        real_name = g_strdup (real_name);
 
345
      else
 
346
        success = FALSE;
 
347
    }
 
348
  else
 
349
    success = FALSE;
 
350
}
 
351
CODE
 
352
    );
 
353
}
 
354
 
 
355
sub edit_named_paste {
 
356
    $blurb = 'Paste named buffer to the specified drawable.';
 
357
 
 
358
    $help = <<'HELP';
 
359
This procedure works like gimp_edit_paste() but pastes a named buffer
 
360
instead of the global buffer.
 
361
HELP
 
362
 
 
363
    &mitch_pdb_misc('2005', '2.4');
 
364
 
 
365
    @inargs = (
 
366
        { name => 'drawable', type => 'drawable',
 
367
          desc => 'The drawable to paste to' },
 
368
        { name => 'buffer_name', type => 'string',
 
369
          desc => 'The name of the buffer to paste' },
 
370
        { name => 'paste_into', type => 'boolean',
 
371
          desc => 'Clear selection, or paste behind it?' }
 
372
    );
 
373
 
 
374
    @outargs = (
 
375
        { name  => 'floating_sel', type  => 'layer',
 
376
          desc  => 'The new floating selection' }
 
377
    );
 
378
 
 
379
    %invoke = (
 
380
        code => <<CODE
 
381
{
 
382
  GimpBuffer *buffer = (GimpBuffer *)
 
383
    gimp_container_get_child_by_name (gimp->named_buffers, buffer_name);
 
384
 
 
385
  if (buffer && gimp_item_is_attached (GIMP_ITEM (drawable)))
 
386
    {
 
387
      floating_sel = gimp_edit_paste (gimp_item_get_image (GIMP_ITEM (drawable)),
 
388
                                      drawable, buffer,
 
389
                                      paste_into, -1, -1, -1, -1);
 
390
      if (! floating_sel)
 
391
        success = FALSE;
 
392
    }
 
393
  else
 
394
    success = FALSE;
175
395
}
176
396
CODE
177
397
    )
178
398
}
179
399
 
 
400
sub edit_named_paste_as_new {
 
401
    $blurb = 'Paste named buffer to a new image.';
 
402
 
 
403
    $help = <<'HELP';
 
404
This procedure works like gimp_edit_paste_as_new() but pastes a named buffer
 
405
instead of the global buffer.
 
406
HELP
 
407
 
 
408
    &mitch_pdb_misc('2005', '2.4');
 
409
 
 
410
    @inargs = (
 
411
        { name => 'buffer_name', type => 'string',
 
412
          desc => 'The name of the buffer to paste' }
 
413
    );
 
414
 
 
415
    @outargs = (
 
416
        { name => 'image', type => 'image',
 
417
          desc => 'The new image' }
 
418
    );
 
419
 
 
420
    %invoke = (
 
421
        code => <<CODE
 
422
{
 
423
  GimpBuffer *buffer = (GimpBuffer *)
 
424
    gimp_container_get_child_by_name (gimp->named_buffers, buffer_name);
 
425
 
 
426
  if (buffer)
 
427
    {
 
428
      image = gimp_edit_paste_as_new (gimp, NULL, buffer);
 
429
 
 
430
      if (! image)
 
431
        success = FALSE;
 
432
    }
 
433
  else
 
434
    success = FALSE;
 
435
}
 
436
CODE
 
437
    );
 
438
}
 
439
 
180
440
sub edit_clear {
181
441
    $blurb = 'Clear selected area of drawable.';
182
442
 
183
443
    $help = <<'HELP';
184
 
This procedure clears the specified drawable. If the drawable has an alpha
185
 
channel, the cleared pixels will become transparent. If the drawable does not
186
 
have an alpha channel, cleared pixels will be set to the background color. This
187
 
procedure only affects regions within a selection if there is a selection
188
 
active.
 
444
This procedure clears the specified drawable. If the drawable has an
 
445
alpha channel, the cleared pixels will become transparent. If the
 
446
drawable does not have an alpha channel, cleared pixels will be set to
 
447
the background color. This procedure only affects regions within a
 
448
selection if there is a selection active.
189
449
HELP
190
450
 
191
451
    &std_pdb_misc;
192
 
    &inargs('clear from');
193
 
    &invoke('success = gimp_edit_clear (gimage, drawable, context)');
 
452
 
 
453
    @inargs = (
 
454
        { name => 'drawable', type => 'drawable',
 
455
          desc => 'The drawable to clear from' }
 
456
    );
 
457
 
 
458
    %invoke = (
 
459
        code => <<CODE
 
460
{
 
461
  if (gimp_item_is_attached (GIMP_ITEM (drawable)))
 
462
    {
 
463
      GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
 
464
 
 
465
      success = gimp_edit_clear (image, drawable, context);
 
466
    }
 
467
  else
 
468
    success = FALSE;
 
469
}
 
470
CODE
 
471
    );
194
472
}
195
473
 
196
474
sub edit_fill {
197
475
    $blurb = 'Fill selected area of drawable.';
198
476
 
199
477
    $help = <<'HELP';
200
 
This procedure fills the specified drawable with the fill mode. If the fill
201
 
mode is foreground, the current foreground color is used. If the fill mode is
202
 
background, the current background color is used. Other fill modes should not
203
 
be used. This procedure only affects regions within a selection if there is a
204
 
selection active. If you want to fill the whole drawable, regardless of the
205
 
selection, use gimp_drawable_fill().
 
478
This procedure fills the specified drawable with the fill mode. If the
 
479
fill mode is foreground, the current foreground color is used. If the
 
480
fill mode is background, the current background color is used. Other
 
481
fill modes should not be used. This procedure only affects regions
 
482
within a selection if there is a selection active. If you want to fill
 
483
the whole drawable, regardless of the selection, use
 
484
gimp_drawable_fill().
206
485
HELP
207
486
 
208
487
    &std_pdb_misc;
209
488
    $author .= ' & Raphael Quinet';
210
489
    $date = '1995-2000';
 
490
 
211
491
    @inargs = (
212
492
        { name => 'drawable', type => 'drawable',
213
493
          desc => "The drawable to fill to" },
214
494
        { name => 'fill_type', type => 'enum GimpFillType',
215
 
          desc => 'The type of fill: %%desc%%' }
216
 
    );
217
 
    &invoke('success = gimp_edit_fill (gimage, drawable, context, (GimpFillType) fill_type)');
 
495
          desc => 'The type of fill' }
 
496
    );
 
497
 
 
498
    %invoke = (
 
499
        code => <<CODE
 
500
{
 
501
  if (gimp_item_is_attached (GIMP_ITEM (drawable)))
 
502
    {
 
503
      GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
 
504
 
 
505
      success = gimp_edit_fill (image, drawable, context,
 
506
                                (GimpFillType) fill_type);
 
507
    }
 
508
  else
 
509
    success = FALSE;
 
510
}
 
511
CODE
 
512
    );
218
513
}
219
514
 
220
515
sub edit_bucket_fill {
230
525
executed at the specified coordinates and extends outward in keeping
231
526
with the threshold parameter. If there is a selection in the target
232
527
image, the threshold, sample merged, x, and y arguments are unused. If
233
 
the sample_merged parameter is non-zero, the data of the composite
 
528
the sample_merged parameter is TRUE, the data of the composite
234
529
image will be used instead of that for the specified drawable.  This
235
530
is equivalent to sampling for colors after merging all visible
236
531
layers. In the case of merged sampling, the x and y coordinates are
240
535
 
241
536
    &std_pdb_misc;
242
537
 
243
 
    my $validity = 'This parameter is only valid when there is no selection in
244
 
                    the specified image.';
245
 
 
246
538
    @inargs = (
247
 
        &drawable_arg,
 
539
        { name => 'drawable', type => 'drawable',
 
540
          desc => 'The affected drawable' },
248
541
        { name => 'fill_mode', type => 'enum GimpBucketFillMode',
249
 
          desc => 'The type of fill: { %%desc%% }' },
 
542
          desc => 'The type of fill' },
250
543
        { name => paint_mode, type => 'enum GimpLayerModeEffects',
251
 
          desc => 'The paint application mode: { %%desc%% }' },
 
544
          desc => 'The paint application mode' },
252
545
        { name => 'opacity', type => '0 <= float <= 100',
253
 
          desc => 'The opacity of the final bucket fill (%%desc%%)' },
 
546
          desc => 'The opacity of the final bucket fill' },
254
547
        { name => 'threshold', type => '0 <= float <= 255',
255
548
          desc => "The threshold determines how extensive the seed fill will
256
 
                   be. It's value is specified in terms of intensity levels
257
 
                   (%%desc%%). $validity" },
258
 
        &sample_merged_arg
 
549
                   be. It's value is specified in terms of intensity levels.
 
550
                   This parameter is only valid when there is no selection in
 
551
                   the specified image." },
 
552
        { name => 'sample_merged', type => 'boolean',
 
553
          desc => 'Use the composite image, not the drawable' },
 
554
        { name => 'x', type => 'float',
 
555
          desc => "The x coordinate of this bucket fill's application.
 
556
                   This parameter is only valid when there is no selection
 
557
                   in the specified image." },
 
558
        { name => 'y', type => 'float',
 
559
          desc => "The y coordinate of this bucket fill's application.
 
560
                   This parameter is only valid when there is no selection
 
561
                   in the specified image." }
259
562
    );
260
563
 
261
 
    foreach (qw(x y)) {
262
 
        push @inargs, { name => $_, type => 'float',
263
 
                        desc => "The $_ coordinate of this bucket fill's
264
 
                                 application. $validity" }
265
 
    }
266
 
 
267
564
    %invoke = (
268
565
        headers => [ qw ("core/gimpdrawable-bucket-fill.h"
269
566
                         "core/gimpchannel.h") ],
270
567
        code => <<'CODE'
271
568
{
272
 
  success = gimp_item_is_attached (GIMP_ITEM (drawable));
273
 
 
274
 
  if (success)
 
569
  if (gimp_item_is_attached (GIMP_ITEM (drawable)))
275
570
    {
276
 
      GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
 
571
      GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
277
572
      gboolean   do_seed_fill;
278
573
 
279
 
      do_seed_fill = gimp_channel_is_empty (gimp_image_get_mask (gimage));
 
574
      do_seed_fill = gimp_channel_is_empty (gimp_image_get_mask (image));
280
575
 
281
576
      gimp_drawable_bucket_fill (drawable, context, fill_mode,
282
577
                                 paint_mode, opacity / 100.0,
283
578
                                 do_seed_fill,
284
579
                                 FALSE /* don't fill transparent */,
285
 
                                 threshold, sample_merged, x, y);
286
 
    }
287
 
}
288
 
CODE
289
 
    );
290
 
}
 
580
                                 GIMP_SELECT_CRITERION_COMPOSITE,
 
581
                                 threshold, sample_merged, x, y);
 
582
    }
 
583
  else
 
584
    success = FALSE;
 
585
}
 
586
CODE
 
587
    );
 
588
}
 
589
 
 
590
sub edit_bucket_fill_full {
 
591
    $blurb = <<'BLURB';
 
592
Fill the area specified either by the current selection if there is one, or by
 
593
a seed fill starting at the specified coordinates.
 
594
BLURB
 
595
 
 
596
    $help = <<'HELP';
 
597
This tool requires information on the paint application mode, and the
 
598
fill mode, which can either be in the foreground color, or in the
 
599
currently active pattern. If there is no selection, a seed fill is
 
600
executed at the specified coordinates and extends outward in keeping
 
601
with the threshold parameter. If there is a selection in the target
 
602
image, the threshold, sample merged, x, and y arguments are unused. If
 
603
the sample_merged parameter is TRUE, the data of the composite
 
604
image will be used instead of that for the specified drawable.  This
 
605
is equivalent to sampling for colors after merging all visible
 
606
layers. In the case of merged sampling, the x and y coordinates are
 
607
relative to the image's origin; otherwise, they are relative to the
 
608
drawable's origin.
 
609
HELP
 
610
 
 
611
    &david_pdb_misc('2006', '2.4');
 
612
 
 
613
    @inargs = (
 
614
        { name => 'drawable', type => 'drawable',
 
615
          desc => 'The affected drawable' },
 
616
        { name => 'fill_mode', type => 'enum GimpBucketFillMode',
 
617
          desc => 'The type of fill' },
 
618
        { name => paint_mode, type => 'enum GimpLayerModeEffects',
 
619
          desc => 'The paint application mode' },
 
620
        { name => 'opacity', type => '0 <= float <= 100',
 
621
          desc => 'The opacity of the final bucket fill' },
 
622
        { name => 'threshold', type => '0 <= float <= 255',
 
623
          desc => "The threshold determines how extensive the seed fill will
 
624
                   be. It's value is specified in terms of intensity levels.
 
625
                   This parameter is only valid when there is no selection in
 
626
                   the specified image." },
 
627
        { name => 'sample_merged', type => 'boolean',
 
628
          desc => 'Use the composite image, not the drawable' },
 
629
        { name => 'fill_transparent', type => 'boolean',
 
630
          desc => "Whether to consider transparent pixels for filling.
 
631
                   If TRUE, transparency is considered as a unique fillable
 
632
                   color." },
 
633
        { name => 'select_criterion', type => 'enum GimpSelectCriterion',
 
634
          desc => "The criterion used to determine color similarity.
 
635
                   SELECT_CRITERION_COMPOSITE is the standard choice.
 
636
                   " },
 
637
        { name => 'x', type => 'float',
 
638
          desc => "The x coordinate of this bucket fill's application.
 
639
                   This parameter is only valid when there is no selection
 
640
                   in the specified image." },
 
641
        { name => 'y', type => 'float',
 
642
          desc => "The y coordinate of this bucket fill's application.
 
643
                   This parameter is only valid when there is no selection
 
644
                   in the specified image." }
 
645
    );
 
646
 
 
647
    %invoke = (
 
648
        headers => [ qw ("core/gimpdrawable-bucket-fill.h"
 
649
                         "core/gimpchannel.h") ],
 
650
        code => <<'CODE'
 
651
{
 
652
  if (gimp_item_is_attached (GIMP_ITEM (drawable)))
 
653
    {
 
654
      GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
 
655
      gboolean   do_seed_fill;
 
656
 
 
657
      do_seed_fill = gimp_channel_is_empty (gimp_image_get_mask (image));
 
658
 
 
659
      gimp_drawable_bucket_fill (drawable, context, fill_mode,
 
660
                                 paint_mode, opacity / 100.0,
 
661
                                 do_seed_fill,
 
662
                                 fill_transparent,
 
663
                                 select_criterion,
 
664
                                 threshold, sample_merged, x, y);
 
665
    }
 
666
  else
 
667
    success = FALSE;
 
668
}
 
669
CODE
 
670
    );
 
671
}
 
672
 
 
673
 
 
674
 
 
675
 
291
676
 
292
677
sub edit_blend {
293
678
    $blurb = <<'BLURB';
294
 
Blend between the starting and ending coordinates with the specified blend mode
295
 
and gradient type.
 
679
Blend between the starting and ending coordinates with the specified
 
680
blend mode and gradient type.
296
681
BLURB
297
682
 
298
683
    $help = <<'HELP';
299
 
This tool requires information on the paint application mode, the blend mode,
300
 
and the gradient type. It creates the specified variety of blend using the
301
 
starting and ending coordinates as defined for each gradient type.
 
684
This tool requires information on the paint application mode, the
 
685
blend mode, and the gradient type. It creates the specified variety of
 
686
blend using the starting and ending coordinates as defined for each
 
687
gradient type.
302
688
HELP
303
689
 
304
690
    &std_pdb_misc;
305
691
 
306
692
    @inargs = (
307
 
        &drawable_arg,
 
693
        { name => 'drawable', type => 'drawable',
 
694
          desc => 'The affected drawable' },
308
695
        { name => 'blend_mode', type => 'enum GimpBlendMode',
309
 
          desc => 'The type of blend: { %%desc%% }' },
 
696
          desc => 'The type of blend' },
310
697
        { name => 'paint_mode', type => 'enum GimpLayerModeEffects',
311
 
          desc => 'The paint application mode: { %%desc%% }' },
 
698
          desc => 'The paint application mode' },
312
699
        { name => 'gradient_type',  type => 'enum GimpGradientType',
313
 
          desc => 'The type of gradient: { %%desc%% }' },
 
700
          desc => 'The type of gradient' },
314
701
        { name => 'opacity', type => '0 <= float <= 100',
315
 
          desc => 'The opacity of the final blend (%%desc%%)' },
 
702
          desc => 'The opacity of the final blend' },
316
703
        { name => 'offset', type => '0 <= float',
317
704
          desc => 'Offset relates to the starting and ending coordinates
318
 
                   specified for the blend. This parameter is mode dependent
319
 
                   (%%desc%%)' },
 
705
                   specified for the blend. This parameter is mode dependent.' },
320
706
        { name => 'repeat', type => 'enum GimpRepeatMode',
321
 
          desc => 'Repeat mode: { %%desc%% }' },
 
707
          desc => 'Repeat mode' },
322
708
        { name => 'reverse', type => 'boolean',
323
 
          desc => 'Use the reverse gradient (%%desc%%)' },
 
709
          desc => 'Use the reverse gradient' },
324
710
        { name => 'supersample', type => 'boolean',
325
 
          desc => 'Do adaptive supersampling (%%desc%%)' },
326
 
        { name => 'max_depth', type => '1 <= int32 <= 9',
327
 
          desc => 'Maximum recursion levels for supersampling',
328
 
          cond => [ 'supersample' ] },
329
 
        { name => 'threshold', type => '0 <= float <= 4',
330
 
          desc => 'Supersampling threshold',
331
 
          cond => [ 'supersample' ] },
 
711
          desc => 'Do adaptive supersampling' },
 
712
        { name => 'max_depth', type => '1 <= int32 <= 9', no_success => 1,
 
713
          desc => 'Maximum recursion levels for supersampling' },
 
714
        { name => 'threshold', type => '0 <= float <= 4', no_success => 1,
 
715
          desc => 'Supersampling threshold' },
332
716
        { name => 'dither', type => 'boolean',
333
 
          desc => 'Use dithering to reduce banding (%%desc%%)' },
 
717
          desc => 'Use dithering to reduce banding' },
334
718
        { name => 'x1', type => 'float',
335
719
          desc => "The x coordinate of this blend's starting point" },
336
720
        { name => 'y1', type => 'float',
347
731
{
348
732
  success = gimp_item_is_attached (GIMP_ITEM (drawable));
349
733
 
 
734
  if (success && supersample)
 
735
    {
 
736
      if (max_depth < 1 || max_depth > 9)
 
737
        success = FALSE;
 
738
 
 
739
      if (threshold < 0.0 || threshold > 4.0)
 
740
        success = FALSE;
 
741
    }
 
742
 
350
743
  if (success)
351
744
    {
352
745
      if (progress)
353
 
        gimp_progress_start (progress, _("Blending..."), FALSE);
 
746
        gimp_progress_start (progress, _("Blending"), FALSE);
354
747
 
355
748
      gimp_drawable_blend (drawable,
356
749
                           context,
382
775
HELP
383
776
 
384
777
    &std_pdb_misc;
385
 
    &inargs('stroke to');
386
 
 
387
 
    %invoke = (
388
 
        headers => [ qw("core/gimpstrokedesc.h") ],
389
 
        code => <<'CODE'
390
 
{
391
 
  success = gimp_item_is_attached (GIMP_ITEM (drawable));
392
 
 
393
 
  if (success)
394
 
    {
395
 
      GimpImage      *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
396
 
      GimpStrokeDesc *desc   = gimp_stroke_desc_new (gimp, context);
397
 
 
398
 
      g_object_set (desc, "method", GIMP_STROKE_METHOD_PAINT_CORE, NULL);
399
 
 
400
 
      success = gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (gimage)),
401
 
                                  drawable, context, desc, TRUE);
402
 
 
403
 
      g_object_unref (desc);
404
 
    }
405
 
}
406
 
CODE
407
 
    );
408
 
}
409
 
 
410
 
@headers = qw("core/gimp.h" "core/gimp-edit.h" "core/gimpimage.h"
 
778
 
 
779
    @inargs = (
 
780
        { name => 'drawable', type => 'drawable',
 
781
          desc => 'The drawable to stroke to' }
 
782
    );
 
783
 
 
784
    %invoke = (
 
785
        headers => [ qw("core/gimpstrokedesc.h") ],
 
786
        code => <<'CODE'
 
787
{
 
788
  if (gimp_item_is_attached (GIMP_ITEM (drawable)))
 
789
    {
 
790
      GimpImage      *image = gimp_item_get_image (GIMP_ITEM (drawable));
 
791
      GimpStrokeDesc *desc  = gimp_stroke_desc_new (gimp, context);
 
792
 
 
793
      g_object_set (desc, "method", GIMP_STROKE_METHOD_PAINT_CORE, NULL);
 
794
 
 
795
      success = gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (image)),
 
796
                                  drawable, context, desc, TRUE);
 
797
 
 
798
      g_object_unref (desc);
 
799
    }
 
800
  else
 
801
    success = FALSE;
 
802
}
 
803
CODE
 
804
    );
 
805
}
 
806
 
 
807
sub edit_stroke_vectors {
 
808
    $blurb = 'Stroke the specified vectors object';
 
809
 
 
810
    $help = <<'HELP';
 
811
This procedure strokes the specified vectors object, painting along the
 
812
path with the active brush and foreground color.
 
813
HELP
 
814
 
 
815
    &simon_pdb_misc('2006', '2.4');
 
816
 
 
817
    @inargs = (
 
818
        { name => 'drawable', type => 'drawable',
 
819
          desc => 'The drawable to stroke to' },
 
820
        { name => 'vectors', type => 'vectors',
 
821
          desc => 'The vectors object' }
 
822
    );
 
823
 
 
824
    %invoke = (
 
825
        headers => [ qw("core/gimpstrokedesc.h") ],
 
826
        code => <<'CODE'
 
827
{
 
828
  if (gimp_item_is_attached (GIMP_ITEM (drawable)))
 
829
    {
 
830
      GimpStrokeDesc *desc  = gimp_stroke_desc_new (gimp, context);
 
831
 
 
832
      g_object_set (desc, "method", GIMP_STROKE_METHOD_PAINT_CORE, NULL);
 
833
 
 
834
      success = gimp_item_stroke (GIMP_ITEM (vectors),
 
835
                                  drawable, context, desc, TRUE);
 
836
 
 
837
      g_object_unref (desc);
 
838
    }
 
839
  else
 
840
    success = FALSE;
 
841
}
 
842
CODE
 
843
    );
 
844
}
 
845
 
 
846
 
 
847
@headers = qw(<string.h>
 
848
              "core/gimp.h"
 
849
              "core/gimp-edit.h"
 
850
              "core/gimpcontainer.h"
 
851
              "core/gimpimage.h"
411
852
              "core/gimpprogress.h"
412
853
              "gimp-intl.h");
413
854
 
414
 
@procs = qw(edit_cut edit_copy edit_copy_visible edit_paste edit_clear
415
 
            edit_fill edit_bucket_fill edit_blend edit_stroke);
 
855
@procs = qw(edit_cut edit_copy edit_copy_visible
 
856
            edit_paste edit_paste_as_new
 
857
            edit_named_cut edit_named_copy edit_named_copy_visible
 
858
            edit_named_paste edit_named_paste_as_new
 
859
            edit_clear edit_fill edit_bucket_fill edit_bucket_fill_full
 
860
            edit_blend edit_stroke edit_stroke_vectors);
 
861
 
416
862
%exports = (app => [@procs], lib => [@procs]);
417
863
 
418
864
$desc = 'Edit procedures';