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

« back to all changes in this revision

Viewing changes to tools/pdbgen/pdb/guides.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 pdb_misc {
21
 
    $author = $copyright = 'Adam D. Moss';
22
 
    $date = '1998';
23
 
}
24
 
 
25
 
sub image_add_guide {
26
 
    my ($desc, $type, $max, $pos) = @_;
27
 
 
28
 
    $blurb = "Add a $desc guide to an image.";
29
 
 
30
 
    $help = <<HELP;
31
 
This procedure adds a $desc guide to an image. It takes the input image and the
32
 
$type-position of the new guide as parameters. It returns the guide ID of the
33
 
new guide.
34
 
HELP
35
 
 
36
 
    &pdb_misc;
37
 
 
38
 
    @inargs = (
39
 
        &std_image_arg,
40
 
        { name => "${type}position", type => '0 <= int32',
41
 
          desc => "The guide's ${type}-offset from $pos of image",
42
 
          alias => 'offset' }
43
 
    );
44
 
 
45
 
    @outargs = (
46
 
        { name => 'guide', type => 'guide', init => 1, alias => 'guide_ID',
47
 
          desc => 'The new guide' }
48
 
    );
49
 
 
50
 
    my $func = substr($desc, 0, 1);
51
 
    %invoke = (
52
 
        vars => [ 'GimpGuide *guide' ],
53
 
        code => <<CODE
54
 
{
55
 
  if (offset <= gimage->$max)
56
 
    {
57
 
      guide = gimp_image_add_${func}guide (gimage, offset, TRUE);
58
 
      guide_ID = guide->guide_ID;
59
 
    }
60
 
  else
61
 
    success = FALSE;
62
 
}
63
 
CODE
64
 
    );
65
 
}
66
 
 
67
 
# The defs
68
 
 
69
20
sub image_add_hguide {
70
 
    &image_add_guide('horizontal', 'y', 'height', 'top');
 
21
    $blurb = 'Add a horizontal guide to an image.';
 
22
 
 
23
    $help = <<HELP;
 
24
This procedure adds a horizontal guide to an image. It takes the input
 
25
image and the y-position of the new guide as parameters. It returns
 
26
the guide ID of the new guide.
 
27
HELP
 
28
 
 
29
    &adam_pdb_misc('1998');
 
30
 
 
31
    @inargs = (
 
32
        { name => 'image', type => 'image',
 
33
          desc => 'The image' },
 
34
        { name => 'yposition', type => '0 <= int32',
 
35
          desc => "The guide's y-offset from top of image" }
 
36
    );
 
37
 
 
38
    @outargs = (
 
39
        { name => 'guide', type => 'guide',
 
40
          desc => 'The new guide' }
 
41
    );
 
42
 
 
43
    %invoke = (
 
44
        code => <<'CODE'
 
45
{
 
46
  if (yposition <= image->height)
 
47
    {
 
48
      GimpGuide *g;
 
49
 
 
50
      g = gimp_image_add_hguide (image, yposition, TRUE);
 
51
      guide = gimp_guide_get_ID (g);
 
52
    }
 
53
  else
 
54
    success = FALSE;
 
55
}
 
56
CODE
 
57
    );
71
58
}
72
59
 
73
60
sub image_add_vguide {
74
 
    &image_add_guide('vertical', 'x', 'width', 'left');
 
61
    $blurb = 'Add a vertical guide to an image.';
 
62
 
 
63
    $help = <<HELP;
 
64
This procedure adds a vertical guide to an image. It takes the input
 
65
image and the x-position of the new guide as parameters. It returns
 
66
the guide ID of the new guide.
 
67
HELP
 
68
 
 
69
    &adam_pdb_misc('1998');
 
70
 
 
71
    @inargs = (
 
72
        { name => 'image', type => 'image',
 
73
          desc => 'The image' },
 
74
        { name => 'xposition', type => '0 <= int32',
 
75
          desc => "The guide's x-offset from left of image" }
 
76
    );
 
77
 
 
78
    @outargs = (
 
79
        { name => 'guide', type => 'guide',
 
80
          desc => 'The new guide' }
 
81
    );
 
82
 
 
83
    %invoke = (
 
84
        code => <<'CODE'
 
85
{
 
86
  if (xposition <= image->width)
 
87
    {
 
88
      GimpGuide *g;
 
89
 
 
90
      g = gimp_image_add_vguide (image, xposition, TRUE);
 
91
      guide = gimp_guide_get_ID (g);
 
92
    }
 
93
  else
 
94
    success = FALSE;
 
95
}
 
96
CODE
 
97
    );
75
98
}
76
99
 
77
100
sub image_delete_guide {
82
105
guide from the specified image.
83
106
HELP
84
107
 
85
 
    &pdb_misc;
 
108
    &adam_pdb_misc('1998');
86
109
 
87
110
    @inargs = (
88
 
        &std_image_arg,
 
111
        { name => 'image', type => 'image',
 
112
          desc => 'The image' },
89
113
        { name => 'guide', type => 'guide',
90
114
          desc => 'The ID of the guide to be removed' }
91
115
    );
92
116
 
93
117
    %invoke = (
94
 
        vars => [ 'GList *guides' ],
95
118
        code => <<'CODE'
96
119
{
97
 
  success = FALSE;
98
 
 
99
 
  for (guides = gimage->guides; guides; guides = g_list_next (guides))
100
 
    {
101
 
      GimpGuide *g = (GimpGuide *) guides->data;
102
 
 
103
 
      if ((g->guide_ID == guide) && (g->position >= 0))
104
 
        {
105
 
          gimp_image_remove_guide (gimage, g, TRUE);
106
 
          success = TRUE;
107
 
          break;
108
 
        }
109
 
    }
 
120
  GimpGuide *g = gimp_image_get_guide (image, guide);
 
121
 
 
122
  if (g)
 
123
    gimp_image_remove_guide (image, g, TRUE);
 
124
  else
 
125
    success = FALSE;
110
126
}
111
127
CODE
112
128
    );
122
138
return 0 if given the final guide ID as an argument or the image has no guides.
123
139
HELP
124
140
 
125
 
    &pdb_misc;
 
141
    &adam_pdb_misc('1998');
126
142
 
127
143
    @inargs = (
128
 
        &std_image_arg,
129
 
        { name => 'guide', type => 'guide',
 
144
        { name => 'image', type => 'image',
 
145
          desc => 'The image' },
 
146
        { name => 'guide', type => 'guide', no_success => 1,
130
147
          desc => 'The ID of the current guide (0 if first invocation)' }
131
148
    );
132
149
 
133
150
    @outargs = (
134
 
        { name => 'next_guide', type => 'guide', init => 1,
 
151
        { name => 'next_guide', type => 'guide',
135
152
          desc => "The next guide's ID" }
136
153
    );
137
154
 
138
155
    %invoke = (
139
 
        vars => [ 'GList *guides', 'gboolean guide_found' ],
140
156
        code => <<'CODE'
141
157
{
142
 
  if (gimage->guides != NULL)
143
 
    {
144
 
      success     = FALSE;
145
 
      guide_found = FALSE;
146
 
 
147
 
      for (guides = gimage->guides; guides; guides = g_list_next (guides))
148
 
        {
149
 
          GimpGuide *g = (GimpGuide *) guides->data;
150
 
 
151
 
          if (g->position < 0)
152
 
            continue;
153
 
 
154
 
          if (guide == 0)  /* init - Return first guide ID in list */
155
 
            {
156
 
              next_guide = g->guide_ID;
157
 
 
158
 
              guide_found = TRUE;
159
 
              break;
160
 
            }
161
 
 
162
 
          if (! guide_found)
163
 
            {
164
 
              if (g->guide_ID == guide)
165
 
                guide_found = TRUE;
166
 
            }
167
 
          else
168
 
            {
169
 
              next_guide = g->guide_ID;
170
 
              break;
171
 
            }
172
 
        }
173
 
 
174
 
      if (guide_found)
175
 
        success = TRUE;
176
 
    }
 
158
  GimpGuide *g = gimp_image_get_next_guide (image, guide, &success);
 
159
 
 
160
  if (g)
 
161
    next_guide = gimp_guide_get_ID (g);
177
162
}
178
163
CODE
179
164
    );
187
172
orientations of the guide.
188
173
HELP
189
174
 
190
 
    &pdb_misc;
191
 
    
 
175
    &adam_pdb_misc('1998');
 
176
 
192
177
    @inargs = (
193
 
        &std_image_arg,
 
178
        { name => 'image', type => 'image',
 
179
          desc => 'The image' },
194
180
        { name => 'guide', type => 'guide',
195
181
          desc => 'The guide' }
196
182
    );
197
183
 
198
184
    @outargs = (
199
 
        { name => 'orientation', type => &std_orientation_enum, init => 1,
200
 
          desc => "The guide's orientation: { %%desc%% }",
 
185
        { name => 'orientation',
 
186
          type => 'enum GimpOrientationType (no GIMP_ORIENTATION_UNKNOWN)',
 
187
          desc => "The guide's orientation",
201
188
          libdef => 'GIMP_ORIENTATION_UNKNOWN' }
202
189
    );
203
190
 
204
191
    %invoke = (
205
 
        vars => [ 'GList *guides' ],
206
192
        code => <<'CODE'
207
193
{
208
 
  success = FALSE;
209
 
 
210
 
  for (guides = gimage->guides; guides; guides = g_list_next (guides))
211
 
    {
212
 
      GimpGuide *g = (GimpGuide *) guides->data;
213
 
 
214
 
      if ((g->guide_ID == guide) && (g->position >= 0))
215
 
        {
216
 
          orientation = g->orientation;
217
 
 
218
 
          success = TRUE;
219
 
          break;
220
 
        }
221
 
    }
 
194
  GimpGuide *g = gimp_image_get_guide (image, guide);
 
195
 
 
196
  if (g)
 
197
    orientation = gimp_guide_get_orientation (g);
 
198
  else
 
199
    success = FALSE;
222
200
}
223
201
CODE
224
202
    );
232
210
of the guide relative to the top or left of the image.
233
211
HELP
234
212
 
235
 
    &pdb_misc;
 
213
    &adam_pdb_misc('1998');
236
214
 
237
215
    @inargs = (
238
 
        &std_image_arg,
 
216
        { name => 'image', type => 'image',
 
217
          desc => 'The image' },
239
218
        { name => 'guide', type => 'guide',
240
219
          desc => 'The guide' }
241
220
    );
242
221
 
243
222
    @outargs = (
244
 
        { name => 'position', type => 'int32', init => 1, libdef => '-1',
 
223
        { name => 'position', type => 'int32', libdef => '-1',
245
224
          desc => "The guide's position relative to top or left of image" }
246
225
    );
247
226
 
248
227
    %invoke = (
249
 
        vars => [ 'GList *guides' ],
250
228
        code => <<'CODE'
251
229
{
252
 
  success = FALSE;
253
 
 
254
 
  for (guides = gimage->guides; guides; guides = g_list_next (guides))
255
 
    {
256
 
      GimpGuide *g = (GimpGuide *) guides->data;
257
 
 
258
 
      if ((g->guide_ID == guide) && (g->position >= 0))
259
 
        {
260
 
          position = g->position;
261
 
 
262
 
          success = TRUE;
263
 
          break;
264
 
        }
265
 
    } 
 
230
  GimpGuide *g = gimp_image_get_guide (image, guide);
 
231
 
 
232
  if (g)
 
233
    position = gimp_guide_get_position (g);
 
234
  else
 
235
    success = FALSE;
266
236
}
267
237
CODE
268
238
    );
269
239
}
270
240
 
271
 
@headers = qw("core/gimpimage-guides.h" "core/gimpimage-undo-push.h");
 
241
 
 
242
@headers = qw("core/gimpguide.h" "core/gimpimage-guides.h" "core/gimpimage-undo-push.h");
272
243
 
273
244
@procs = qw(image_add_hguide image_add_vguide image_delete_guide
274
245
            image_find_next_guide image_get_guide_orientation
275
246
            image_get_guide_position);
 
247
 
276
248
%exports = (app => [@procs], lib => [@procs]);
277
249
 
278
250
$desc = 'Guide procedures';