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

« back to all changes in this revision

Viewing changes to tools/pdbgen/pdb/channel.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
 
sub channel_arg () {{
21
 
    name => 'channel',
22
 
    type => 'channel',
23
 
    desc => 'The channel'
24
 
}}
25
 
 
26
 
sub operation_arg () {{
27
 
    name => 'operation',
28
 
    type => 'enum GimpChannelOps',
29
 
    desc => 'The selection operation: { %%desc%% }'
30
 
}}
31
 
 
32
 
sub channel_get_prop_proc {
33
 
    my ($prop, $type, $desc, $undo, $core_type, $core_var) = @_;
34
 
 
35
 
    $core_type = 'channel' unless $core_type;
36
 
    $core_var  = 'channel' unless $core_var;
37
 
 
38
 
    $blurb = "Get the $desc of the specified channel.";
39
 
 
40
 
    $help = "This procedure returns the specified channel's $desc. ";
41
 
 
42
 
    &std_pdb_misc;
43
 
 
44
 
    @inargs = ( &channel_arg );
45
 
 
46
 
    @outargs = (
47
 
        { name => $prop, type => $type,
48
 
          desc => "The channel $desc", no_declare => 1 }
49
 
    );
50
 
 
51
 
    my $alias = "gimp_${core_type}_get_$prop ($core_var)";
52
 
    $alias = "g_strdup ($alias)" if $type eq 'string';
53
 
    $outargs[0]->{alias} .= "$alias";
54
 
 
55
 
    if ($type eq 'color') {
56
 
        delete @{$outargs[0]}{qw(alias no_declare)};
57
 
        $invoke{code} = 'gimp_channel_get_color (channel, &color);';
58
 
    }
59
 
}
60
 
 
61
 
sub channel_set_prop_proc {
62
 
    my ($prop, $type, $desc, $undo, $core_type, $core_var) = @_;
63
 
 
64
 
    $core_type = 'channel' unless $core_type;
65
 
    $core_var  = 'channel' unless $core_var;
66
 
 
67
 
    $blurb = "Set the $desc of the specified channel.";
68
 
 
69
 
    $help = "This procedure sets the specified channel's $desc. ";
70
 
 
71
 
    &std_pdb_misc;
72
 
 
73
 
    @inargs = (
74
 
        &channel_arg,
75
 
        { name => $prop, type => $type,
76
 
          desc => "The new channel $desc" }
77
 
    );
78
 
 
79
 
    if ($type =~ /float/) {
80
 
        $inargs[1]->{desc} .= ' (%%desc%%)';
81
 
    }
82
 
 
83
 
    $invoke{code} = $undo ? "gimp_${core_type}_set_$prop ($core_var, $prop, TRUE);"
84
 
                          : "gimp_${core_type}_set_$prop ($core_var, $prop);";
85
 
 
86
 
    if ($type eq 'color') {
87
 
        $invoke{code} = <<'CODE'
88
 
{
89
 
  GimpRGB rgb_color = color;
90
 
 
91
 
  rgb_color.a = channel->color.a;
92
 
  gimp_channel_set_color (channel, &rgb_color, TRUE);
93
 
}
94
 
CODE
95
 
    }
96
 
}
97
 
 
98
 
sub channel_accessors {
99
 
    my ($prop, $type, $desc, $undo, $extra, $core_type, $core_var) = @_;
100
 
 
101
 
    $core_type = 'channel' unless $core_type;
102
 
    $core_var  = 'channel' unless $core_var;
103
 
 
104
 
    my (@extra, %extra); my $once = 0;
105
 
 
106
 
    ref($extra) ? (@extra = @$extra) : (@extra = ($extra, $extra));
107
 
    %extra = map { $once++ ? 'set' : 'get', $_ ? $_ : "" } @extra;
108
 
 
109
 
    foreach (sort keys %extra) {
110
 
        my $proc = "channel_${_}_$prop";
111
 
 
112
 
        push @procs, $proc;
113
 
 
114
 
        eval <<SUB;
115
 
sub @{[ scalar caller ]}::$proc {
116
 
    \&channel_${_}_prop_proc('$prop', '$type', '$desc', $undo,
117
 
                             '$core_type', '$core_var');
118
 
    $extra{$_}
119
 
}
120
 
SUB
121
 
    }
122
 
}
123
 
 
124
20
sub channel_new {
125
21
    $blurb = 'Create a new channel.';
126
22
 
128
24
This procedure creates a new channel with the specified width and height. Name,
129
25
opacity, and color are also supplied parameters. The new channel still needs to
130
26
be added to the image, as this is not automatic. Add the new channel with the
131
 
'gimp_image_add_channel' command. Other attributes such as channel show masked,
 
27
gimp_image_add_channel() command. Other attributes such as channel show masked,
132
28
should be set with explicit procedure calls. The channel's contents are
133
29
undefined initially.
134
30
HELP
136
32
    &std_pdb_misc;
137
33
 
138
34
    @inargs = (
139
 
        &std_image_arg,
140
 
        { name => 'width', type => '0 < int32',
141
 
          desc => 'The channel width: (%%desc%%)' },
142
 
        { name => 'height', type => '0 < int32',
143
 
          desc => 'The channel height: (%%desc%%)' },
 
35
        { name => 'image', type => 'image',
 
36
          desc => 'The image to which to add the channel' },
 
37
        { name => 'width', type => '1 <= int32',
 
38
          desc => 'The channel width' },
 
39
        { name => 'height', type => '1 <= int32',
 
40
          desc => 'The channel height' },
144
41
        { name => 'name', type => 'string',
145
42
          desc => 'The channel name' },
146
43
        { name => 'opacity', type => '0 <= float <= 100',
147
 
          desc => 'The channel opacity: (%%desc%%)' },
 
44
          desc => 'The channel opacity' },
148
45
        { name => 'color', type => 'color',
149
46
          desc => 'The channel compositing color'
150
47
        }
151
48
    );
152
 
    $inargs[0]->{desc} .= ' to which to add the channel';
153
49
 
154
50
    @outargs = (
155
51
        { name => 'channel', type => 'channel', wrap => 1,
156
 
          desc => 'The newly created channel', init => 1 }
 
52
          desc => 'The newly created channel' }
157
53
    );
158
54
 
159
55
    %invoke = (
162
58
  GimpRGB rgb_color = color;
163
59
 
164
60
  rgb_color.a = opacity / 100.0;
165
 
  channel = gimp_channel_new (gimage, width, height, name, &rgb_color);
166
 
  success = channel != NULL;
 
61
  channel = gimp_channel_new (image, width, height, name, &rgb_color);
 
62
 
 
63
  if (! channel)
 
64
    success = FALSE;
167
65
}
168
66
CODE
169
67
    );
178
76
 
179
77
    &std_pdb_misc;
180
78
 
181
 
    @inargs = ( &channel_arg );
182
 
    $inargs[0]->{desc} .= ' to copy';
 
79
    @inargs = (
 
80
        { name => 'channel', type => 'channel',
 
81
          desc => 'The channel to copy' }
 
82
    );
183
83
 
184
84
    @outargs = (
185
 
        { name => 'channel_copy', type => 'channel', init => 1,
 
85
        { name => 'channel_copy', type => 'channel',
186
86
          desc => 'The newly copied channel' }
187
87
    );
188
88
 
191
91
{
192
92
  channel_copy = GIMP_CHANNEL (gimp_item_duplicate (GIMP_ITEM (channel),
193
93
                               G_TYPE_FROM_INSTANCE (channel), FALSE));
194
 
  success = (channel_copy != NULL);
 
94
 
 
95
  if (! channel_copy)
 
96
    success = FALSE;
195
97
}
196
98
CODE
197
99
    );
207
109
 
208
110
    &std_pdb_misc;
209
111
 
210
 
    @inargs = ( &channel_arg, &channel_arg, &operation_arg );
211
 
               
212
 
    foreach my $i (0,1) {
213
 
        foreach my $unused (qw(name desc)) {
214
 
          $inargs[$i]{$unused} .= $i + 1;
215
 
        }
216
 
    }
217
 
 
218
 
    foreach (qw(x y)) {
219
 
        push @inargs, { name => "off$_", type => 'int32',
220
 
                        desc => "$_ offset between upper left corner of
221
 
                                 channels: (second - first)" }
222
 
    }
 
112
    @inargs = (
 
113
        { name => 'channel1', type => 'channel',
 
114
          desc => 'The channel1' },
 
115
        { name => 'channel2', type => 'channel',
 
116
          desc => 'The channel2' },
 
117
        { name => 'operation', type => 'enum GimpChannelOps',
 
118
          desc => 'The selection operation' },
 
119
        { name => 'offx', type => 'int32',
 
120
          desc => 'x offset between upper left corner of
 
121
                   channels: (second - first)' },
 
122
        { name => 'offy', type => 'int32',
 
123
          desc => 'y offset between upper left corner of
 
124
                   channels: (second - first)' }
 
125
    );
223
126
 
224
127
    %invoke = (
225
 
        headers => [ qw("core/gimpchannel-combine.h") ],
 
128
        headers => [ qw("core/gimpchannel-combine.h" "gimp-intl.h") ],
226
129
        code => <<'CODE'
227
130
{
 
131
  gimp_channel_push_undo (channel1, _("Combine Masks"));
228
132
  gimp_channel_combine_mask (channel1, channel2, operation, offx, offy);
229
133
}
230
134
CODE
231
135
    );
232
136
}
233
137
 
234
 
&channel_accessors('show_masked', 'boolean', 'composite method', 0,
235
 
                   <<'CODE');
236
 
    $help .= <<'HELP'
237
 
If it is non-zero, then the channel is composited with the image so that masked
238
 
regions are shown. Otherwise, selected regions are shown.
239
 
HELP
240
 
CODE
241
 
 
242
 
&channel_accessors('opacity', '0 <= float <= 100', 'opacity', 1,
243
 
                 [ '$outargs[0]->{alias} =
244
 
                        "gimp_channel_get_opacity (channel) * 100.0"',
245
 
                   '$invoke{code} =~
246
 
                        s%opacity, %opacity / 100.0, %' ]);
247
 
 
248
 
&channel_accessors('color', 'color', 'compositing color', 0,
249
 
                   [ '$outargs[0]->{void_ret} = 1', '' ]);
250
 
 
251
 
unshift @procs, qw(channel_new channel_copy channel_combine_masks);
 
138
sub channel_new_from_component {
 
139
    $blurb = 'Create a new channel from a color component';
 
140
 
 
141
    $help = <<'HELP';
 
142
This procedure creates a new channel from a color component.
 
143
HELP
 
144
 
 
145
    &shlomi_pdb_misc('2005', '2.4');
 
146
 
 
147
    @inargs = (
 
148
        { name => 'image', type => 'image',
 
149
          desc => 'The image to which to add the channel' },
 
150
        { name => 'component', type => 'enum GimpChannelType',
 
151
          desc => 'The image component' },
 
152
        { name => 'name', type => 'string',
 
153
          desc => 'The channel name' },
 
154
    );
 
155
 
 
156
    @outargs = (
 
157
        { name => 'channel', type => 'channel',
 
158
          desc => 'The newly created channel' }
 
159
    );
 
160
 
 
161
    %invoke = (
 
162
        code => <<'CODE'
 
163
{
 
164
  if (gimp_image_get_component_index (image, component) != -1)
 
165
    channel = gimp_channel_new_from_component (image,
 
166
                                               component, name, NULL);
 
167
 
 
168
  if (channel)
 
169
    gimp_item_set_visible (GIMP_ITEM (channel), FALSE, FALSE);
 
170
  else
 
171
    success = FALSE;
 
172
}
 
173
CODE
 
174
    );
 
175
}
 
176
 
 
177
sub channel_get_show_masked {
 
178
    $blurb = "Get the composite method of the specified channel.";
 
179
 
 
180
    $help = <<'HELP';
 
181
This procedure returns the specified channel's composite method. If
 
182
it is TRUE, then the channel is composited with the image so that
 
183
masked regions are shown. Otherwise, selected regions are shown.
 
184
HELP
 
185
 
 
186
    &std_pdb_misc;
 
187
 
 
188
    @inargs = (
 
189
        { name => 'channel', type => 'channel',
 
190
          desc => 'The channel' }
 
191
    );
 
192
 
 
193
    @outargs = (
 
194
        { name => 'show_masked', type => 'boolean',
 
195
          desc => 'The channel composite method' }
 
196
    );
 
197
 
 
198
    %invoke = (
 
199
        code => <<'CODE'
 
200
{
 
201
  show_masked = gimp_channel_get_show_masked (channel);
 
202
}
 
203
CODE
 
204
    );
 
205
}
 
206
 
 
207
sub channel_set_show_masked {
 
208
    $blurb = "Set the composite method of the specified channel.";
 
209
 
 
210
    $help = <<'HELP';
 
211
This procedure sets the specified channel's composite method. If
 
212
it is TRUE, then the channel is composited with the image so that
 
213
masked regions are shown. Otherwise, selected regions are shown.
 
214
HELP
 
215
 
 
216
    &std_pdb_misc;
 
217
 
 
218
    @inargs = (
 
219
        { name => 'channel', type => 'channel',
 
220
          desc => 'The channel' },
 
221
        { name => 'show_masked', type => 'boolean',
 
222
          desc => 'The new channel composite method' }
 
223
    );
 
224
 
 
225
    %invoke = (
 
226
        code => <<'CODE'
 
227
{
 
228
  gimp_channel_set_show_masked (channel, show_masked);
 
229
}
 
230
CODE
 
231
    );
 
232
}
 
233
 
 
234
sub channel_get_opacity {
 
235
    $blurb = "Get the opacity of the specified channel.";
 
236
 
 
237
    $help = <<'HELP';
 
238
This procedure returns the specified channel's opacity.
 
239
HELP
 
240
 
 
241
    &std_pdb_misc;
 
242
 
 
243
    @inargs = (
 
244
        { name => 'channel', type => 'channel',
 
245
          desc => 'The channel' }
 
246
    );
 
247
 
 
248
    @outargs = (
 
249
        { name => 'opacity', type => '0 <= float <= 100',
 
250
          desc => 'The channel opacity' }
 
251
    );
 
252
 
 
253
    %invoke = (
 
254
        code => <<'CODE'
 
255
{
 
256
  opacity = gimp_channel_get_opacity (channel) * 100;
 
257
}
 
258
CODE
 
259
    );
 
260
}
 
261
 
 
262
sub channel_set_opacity {
 
263
    $blurb = "Set the opacity of the specified channel.";
 
264
 
 
265
    $help = <<'HELP';
 
266
This procedure sets the specified channel's opacity.
 
267
HELP
 
268
 
 
269
    &std_pdb_misc;
 
270
 
 
271
    @inargs = (
 
272
        { name => 'channel', type => 'channel',
 
273
          desc => 'The channel' },
 
274
        { name => 'opacity', type => '0 <= float <= 100',
 
275
          desc => 'The new channel opacity' }
 
276
    );
 
277
 
 
278
    %invoke = (
 
279
        code => <<'CODE'
 
280
{
 
281
  gimp_channel_set_opacity (channel, opacity / 100.0, TRUE);
 
282
}
 
283
CODE
 
284
    );
 
285
}
 
286
 
 
287
sub channel_get_color {
 
288
    $blurb = "Get the compositing color of the specified channel.";
 
289
 
 
290
    $help = <<'HELP';
 
291
This procedure returns the specified channel's compositing color.
 
292
HELP
 
293
 
 
294
    &std_pdb_misc;
 
295
 
 
296
    @inargs = (
 
297
        { name => 'channel', type => 'channel',
 
298
          desc => 'The channel' }
 
299
    );
 
300
 
 
301
    @outargs = (
 
302
        { name => 'color', type => 'color', void_ret => 1,
 
303
          desc => 'The channel compositing color' }
 
304
    );
 
305
 
 
306
    %invoke = (
 
307
        code => <<'CODE'
 
308
{
 
309
  gimp_channel_get_color (channel, &color);
 
310
  gimp_rgb_set_alpha (&color, 1.0);
 
311
}
 
312
CODE
 
313
    );
 
314
}
 
315
 
 
316
sub channel_set_color {
 
317
    $blurb = "Set the compositing color of the specified channel.";
 
318
 
 
319
    $help = <<'HELP';
 
320
This procedure sets the specified channel's compositing color.
 
321
HELP
 
322
 
 
323
    &std_pdb_misc;
 
324
 
 
325
    @inargs = (
 
326
        { name => 'channel', type => 'channel',
 
327
          desc => 'The channel' },
 
328
        { name => 'color', type => 'color',
 
329
          desc => 'The new channel compositing color' }
 
330
    );
 
331
 
 
332
    %invoke = (
 
333
        code => <<'CODE'
 
334
{
 
335
  GimpRGB rgb_color = color;
 
336
 
 
337
  rgb_color.a = channel->color.a;
 
338
  gimp_channel_set_color (channel, &rgb_color, TRUE);
 
339
}
 
340
CODE
 
341
    );
 
342
}
 
343
 
 
344
 
 
345
@procs = qw(channel_new channel_new_from_component channel_copy
 
346
            channel_combine_masks
 
347
            channel_get_show_masked channel_set_show_masked
 
348
            channel_get_opacity channel_set_opacity
 
349
            channel_get_color channel_set_color);
 
350
 
252
351
%exports = (app => [@procs], lib => [@procs]);
253
352
 
254
353
$desc = 'Channel';