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

« back to all changes in this revision

Viewing changes to tools/pdbgen/pdb/fileops.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, 1996, 1997 Spencer Kimball and Peter Mattis
3
3
# Copyright (C) 1997 Josh MacDonald
4
4
 
18
18
 
19
19
# "Perlized" from C source by Manish Singh <yosh@gimp.org>
20
20
 
21
 
sub pdb_misc {
22
 
    $author = $copyright = 'Josh MacDonald';
23
 
    $date = '1997';
24
 
}
25
 
 
26
 
sub list_arg {
27
 
    my ($type, $name, $desc, $example) = @_;
28
 
    push @inargs, { name => $name, type => 'string', no_success => 1,
29
 
                    desc => qq/comma separated list of $desc this handler
30
 
                               can $type (i.e. "$example")/ }
31
 
}
32
 
 
33
 
sub handler_args {
34
 
    my $type = shift;
35
 
 
36
 
    my $action = $type;
37
 
    $action =~ s/e$//;
38
 
    $action .= 'ing';
39
 
 
40
 
    push @inargs, { name => 'procedure_name', type => 'string',
41
 
                    desc => "The name of the procedure to be used for $action",
42
 
                    alias => 'name' };
43
 
 
44
 
    foreach ([ 'extensions', 'jpg,jpeg' ], [ 'prefixes', 'http:,ftp:' ]) {
45
 
        &list_arg($type, $_->[0], @$_);
46
 
    }
47
 
}
48
 
 
49
 
# The defs
50
 
 
51
21
sub file_load {
52
 
    $blurb = 'Loads a file by invoking the right load handler.';
 
22
    $blurb = 'Loads an image file by invoking the right load handler.';
53
23
 
54
24
    $help = <<'HELP';
55
25
This procedure invokes the correct file load handler using magic if possible,
60
30
and the full pathname will not look like a URL."
61
31
HELP
62
32
 
63
 
    &pdb_misc;
 
33
    &josh_pdb_misc('1997');
64
34
 
65
35
    @inargs = (
66
 
        { name => 'run_mode',
67
 
          type => 'enum GimpRunMode (no GIMP_RUN_WITH_LAST_VALS)',
68
 
          desc => 'The run mode: %%desc%%' },
69
 
        { name => 'filename', type => 'string', no_validate => 1,
70
 
          desc => 'The name of the file to load' },
71
 
        { name => 'raw_filename', type => 'string', no_validate => 1,
72
 
          desc => 'The name as entered by the user' }
 
36
        { name => 'run_mode',
 
37
          type => 'enum GimpRunMode (no GIMP_RUN_WITH_LAST_VALS)',
 
38
          desc => 'The run mode' },
 
39
        { name => 'filename', type => 'string', no_validate => 1,
 
40
          desc => 'The name of the file to load' },
 
41
        { name => 'raw_filename', type => 'string', no_validate => 1,
 
42
          desc => 'The name as entered by the user' }
73
43
    );
74
44
 
75
 
    @outargs = ( &std_image_arg );
76
 
    $outargs[0]->{desc} = 'The output image';
 
45
    @outargs = (
 
46
        { name => 'image', type => 'image',
 
47
          desc => 'The output image' }
 
48
    );
77
49
 
78
50
    %invoke = (
79
 
        proc => [ 'proc->name', 'new_args' ],
80
 
        args => [ 'new_args', 'return_vals' ],
81
 
        vars => [ 'PlugInProcDef *file_proc', 'const ProcRecord *proc',
82
 
                  'gchar *uri', 'gint i' ],
83
 
        code => <<'CODE'
 
51
        no_marshalling => 1,
 
52
        code => <<'CODE'
84
53
{
85
 
  uri = file_utils_filename_to_uri (gimp->load_procs, %%filename%%, NULL);
 
54
  GValueArray         *new_args;
 
55
  GValueArray         *return_vals;
 
56
  GimpPlugInProcedure *file_proc;
 
57
  GimpProcedure       *proc;
 
58
  gchar               *uri;
 
59
  gint                 i;
 
60
 
 
61
  uri = file_utils_filename_to_uri (gimp,
 
62
                                    g_value_get_string (&args->values[1]),
 
63
                                    NULL);
86
64
 
87
65
  if (! uri)
88
 
    return %%fail%%;
 
66
    return gimp_procedure_get_return_values (procedure, FALSE);
89
67
 
90
 
  file_proc = file_utils_find_proc (gimp->load_procs, uri);
 
68
  file_proc =
 
69
    file_utils_find_proc (gimp->plug_in_manager->load_procs, uri, NULL);
91
70
 
92
71
  g_free (uri);
93
72
 
94
73
  if (! file_proc)
95
 
    return %%fail%%;
96
 
 
97
 
  proc = plug_in_proc_def_get_proc (file_proc);
98
 
 
99
 
  new_args = g_new0 (%%argtype%%, proc->num_args);
100
 
  memcpy (new_args, args, sizeof (%%argtype%%) * 3);
 
74
    return gimp_procedure_get_return_values (procedure, FALSE);
 
75
 
 
76
  proc = GIMP_PROCEDURE (file_proc);
 
77
 
 
78
  new_args = gimp_procedure_get_arguments (proc);
 
79
 
 
80
  for (i = 0; i < 3; i++)
 
81
    g_value_transform (&args->values[i], &new_args->values[i]);
101
82
 
102
83
  for (i = 3; i < proc->num_args; i++)
103
 
    {
104
 
      new_args[i].arg_type = proc->args[i].arg_type;
105
 
      if (proc->args[i].arg_type == GIMP_PDB_STRING)
106
 
        new_args[i].value.pdb_pointer = g_strdup ("");
107
 
    }
108
 
 
109
 
  return_vals = %%exec%%;
110
 
  g_free (new_args);
 
84
    if (G_IS_PARAM_SPEC_STRING (proc->args[i]))
 
85
      g_value_set_static_string (&new_args->values[i], "");
 
86
 
 
87
  return_vals =
 
88
    gimp_pdb_execute_procedure_by_name_args (gimp->pdb,
 
89
                                             context, progress,
 
90
                                             GIMP_OBJECT (proc)->name,
 
91
                                             new_args);
 
92
 
 
93
  g_value_array_free (new_args);
111
94
 
112
95
  return return_vals;
113
96
}
115
98
    );
116
99
}
117
100
 
 
101
sub file_load_layer {
 
102
    $blurb = 'Loads an image file as a layer for an existing image.';
 
103
 
 
104
    $help = <<'HELP';
 
105
This procedure behaves like the file-load procedure but opens the specified
 
106
image as a layer for an existing image. The returned layer needs to be
 
107
added to the existing image with gimp_image_add_layer().
 
108
HELP
 
109
 
 
110
    &neo_pdb_misc('2005', '2.4');
 
111
 
 
112
    @inargs = (
 
113
        { name => 'run_mode',
 
114
          type => 'enum GimpRunMode (no GIMP_RUN_WITH_LAST_VALS)',
 
115
          desc => 'The run mode' },
 
116
        { name => 'image', type => 'image',
 
117
          desc => 'Destination image' },
 
118
        { name => 'filename', type => 'string', no_validate => 1,
 
119
          desc => 'The name of the file to load' }
 
120
    );
 
121
 
 
122
    @outargs = (
 
123
        { name => 'layer', type => 'layer',
 
124
          desc => 'The layer created when loading the image file' }
 
125
    );
 
126
 
 
127
    %invoke = (
 
128
        code => <<'CODE'
 
129
{
 
130
  gchar *uri = file_utils_filename_to_uri (gimp, filename, NULL);
 
131
 
 
132
  if (uri)
 
133
    {
 
134
      GList             *layers;
 
135
      GimpPDBStatusType  status;
 
136
 
 
137
      layers = file_open_layers (gimp, context, progress,
 
138
                                 image, FALSE,
 
139
                                 uri, run_mode, NULL, &status, NULL);
 
140
 
 
141
      if (layers)
 
142
        {
 
143
          layer = layers->data;
 
144
          g_list_free (layers);
 
145
        }
 
146
      else
 
147
        success = FALSE;
 
148
    }
 
149
  else
 
150
    success = FALSE;
 
151
}
 
152
CODE
 
153
    );
 
154
}
 
155
 
 
156
sub file_load_layers {
 
157
    $blurb = 'Loads an image file as layers for an existing image.';
 
158
 
 
159
    $help = <<'HELP';
 
160
This procedure behaves like the file-load procedure but opens the specified
 
161
image as layers for an existing image. The returned layers needs to be
 
162
added to the existing image with gimp_image_add_layer().
 
163
HELP
 
164
 
 
165
    &mitch_pdb_misc('2006', '2.4');
 
166
 
 
167
    @inargs = (
 
168
        { name => 'run_mode',
 
169
          type => 'enum GimpRunMode (no GIMP_RUN_WITH_LAST_VALS)',
 
170
          desc => 'The run mode' },
 
171
        { name => 'image', type => 'image',
 
172
          desc => 'Destination image' },
 
173
        { name => 'filename', type => 'string', no_validate => 1,
 
174
          desc => 'The name of the file to load' }
 
175
    );
 
176
 
 
177
    @outargs = (
 
178
        { name => 'layer_ids', type => 'int32array',
 
179
          desc => 'The list of loaded layers',
 
180
          array => { name => 'num_layers',
 
181
                     desc => 'The number of loaded layers' } }
 
182
    );
 
183
 
 
184
    %invoke = (
 
185
        code => <<'CODE'
 
186
{
 
187
  gchar *uri = file_utils_filename_to_uri (gimp, filename, NULL);
 
188
 
 
189
  if (uri)
 
190
    {
 
191
      GList             *layers;
 
192
      GimpPDBStatusType  status;
 
193
 
 
194
      layers = file_open_layers (gimp, context, progress,
 
195
                                 image, FALSE,
 
196
                                 uri, run_mode, NULL, &status, NULL);
 
197
 
 
198
      if (layers)
 
199
        {
 
200
          GList *list;
 
201
          gint i;
 
202
 
 
203
          num_layers = g_list_length (layers);
 
204
 
 
205
          layer_ids = g_new (gint32, num_layers);
 
206
 
 
207
          for (i = 0, list = layers;
 
208
               i < num_layers;
 
209
               i++, list = g_list_next (list))
 
210
            layer_ids[i] = gimp_item_get_ID (GIMP_ITEM (list->data));
 
211
 
 
212
          g_list_free (layers);
 
213
        }
 
214
      else
 
215
        success = FALSE;
 
216
    }
 
217
  else
 
218
    success = FALSE;
 
219
}
 
220
CODE
 
221
    );
 
222
}
 
223
 
118
224
sub file_save {
119
225
    $blurb = 'Saves a file by extension.';
120
226
 
127
233
look like a URL.
128
234
HELP
129
235
 
130
 
    &pdb_misc;
 
236
    &josh_pdb_misc('1997');
131
237
 
132
238
    @inargs = (
133
 
        { name => 'run_mode',
134
 
          type => 'enum GimpRunMode (no GIMP_RUN_WITH_LAST_VALS)',
135
 
          desc => 'The run mode: %%desc%%' },
136
 
        { name => 'image', type => 'image',
137
 
          desc => 'Input image' },
138
 
        { name => 'drawable', type => 'drawable',
139
 
          desc => 'Drawable to save' },
140
 
        { name => 'filename', type => 'string', no_validate => 1,
141
 
          desc => 'The name of the file to save the image in' },
142
 
        { name => 'raw_filename', type => 'string', no_validate => 1,
143
 
          desc => 'The name as entered by the user' }
 
239
        { name => 'run_mode', type => 'enum GimpRunMode',
 
240
          desc => 'The run mode' },
 
241
        { name => 'image', type => 'image',
 
242
          desc => 'Input image' },
 
243
        { name => 'drawable', type => 'drawable',
 
244
          desc => 'Drawable to save' },
 
245
        { name => 'filename', type => 'string', no_validate => 1,
 
246
          desc => 'The name of the file to save the image in' },
 
247
        { name => 'raw_filename', type => 'string', no_validate => 1,
 
248
          desc => 'The name as entered by the user' }
144
249
    );
145
250
 
146
 
 
147
251
    %invoke = (
148
 
        headers => [ qw(<string.h>) ],
149
 
        proc => [ 'proc->name', 'new_args' ],
150
 
        args => [ 'new_args', 'return_vals' ],
151
 
        vars => [ 'PlugInProcDef *file_proc', 'const ProcRecord *proc',
152
 
                  'gchar *uri', 'gint i' ],
153
 
        code => <<'CODE'
 
252
        headers => [ qw(<string.h>) ],
 
253
        no_marshalling => 1,
 
254
        code => <<'CODE'
154
255
{
155
 
  uri = file_utils_filename_to_uri (gimp->load_procs, %%filename%%, NULL);
 
256
  GValueArray         *new_args;
 
257
  GValueArray         *return_vals;
 
258
  GimpPlugInProcedure *file_proc;
 
259
  GimpProcedure       *proc;
 
260
  gchar               *uri;
 
261
  gint                 i;
 
262
 
 
263
  uri = file_utils_filename_to_uri (gimp,
 
264
                                    g_value_get_string (&args->values[3]),
 
265
                                    NULL);
156
266
 
157
267
  if (! uri)
158
 
    return %%fail%%;
 
268
    return gimp_procedure_get_return_values (procedure, FALSE);
159
269
 
160
 
  file_proc = file_utils_find_proc (gimp->save_procs, uri);
 
270
  file_proc =
 
271
    file_utils_find_proc (gimp->plug_in_manager->save_procs, uri, NULL);
161
272
 
162
273
  g_free (uri);
163
274
 
164
 
  if (! file_proc) 
165
 
    return %%fail%%;
166
 
 
167
 
  proc = plug_in_proc_def_get_proc (file_proc);
168
 
 
169
 
  new_args = g_new0 (%%argtype%%, proc->num_args);
170
 
  memcpy (new_args, args, sizeof (%%argtype%%) * 5);
 
275
  if (! file_proc)
 
276
    return gimp_procedure_get_return_values (procedure, FALSE);
 
277
 
 
278
  proc = GIMP_PROCEDURE (file_proc);
 
279
 
 
280
  new_args = gimp_procedure_get_arguments (proc);
 
281
 
 
282
  for (i = 0; i < 5; i++)
 
283
    g_value_transform (&args->values[i], &new_args->values[i]);
171
284
 
172
285
  for (i = 5; i < proc->num_args; i++)
173
 
    {
174
 
      new_args[i].arg_type = proc->args[i].arg_type;
175
 
      if (proc->args[i].arg_type == GIMP_PDB_STRING)
176
 
        new_args[i].value.pdb_pointer = g_strdup ("");
177
 
    }
178
 
 
179
 
  return_vals = %%exec%%;
180
 
  g_free (new_args);
 
286
    if (G_IS_PARAM_SPEC_STRING (proc->args[i]))
 
287
      g_value_set_static_string (&new_args->values[i], "");
 
288
 
 
289
  return_vals = gimp_pdb_execute_procedure_by_name_args (gimp->pdb,
 
290
                                                         context, progress,
 
291
                                                         GIMP_OBJECT (proc)->name,
 
292
                                                         new_args);
 
293
 
 
294
  g_value_array_free (new_args);
181
295
 
182
296
  return return_vals;
183
297
}
193
307
the given filename. This name is a full pathname. The returned data is 
194
308
an array of colordepth 3 (RGB), regardless of the image type. Width and 
195
309
height of the thumbnail are also returned. Don't use this function if 
196
 
you need a thumbnail of an already opened image, use gimp_image_thumbnail 
 
310
you need a thumbnail of an already opened image, use gimp_image_thumbnail()
197
311
instead.
198
312
HELP
199
313
 
201
315
    $date = '1999-2003';
202
316
 
203
317
    @inargs = (
204
 
        { name => 'filename', type => 'string', no_validate => 1,
205
 
          desc => 'The name of the file that owns the thumbnail to load' },
 
318
        { name => 'filename', type => 'string', no_validate => 1,
 
319
          desc => 'The name of the file that owns the thumbnail to load' }
206
320
    );
207
321
 
208
 
    @outargs = ( 
209
 
        { name => 'width', type => 'int32', init => 1,
210
 
          desc => 'The width of the thumbnail' },
211
 
        { name => 'height', type => 'int32', init => 1, 
212
 
          desc => 'The height of the thumbnail' },
213
 
        { name => 'thumb_data', type => 'int8array', init => 1,
214
 
          desc => 'The thumbnail data', 
215
 
          array =>  { name => 'thumbnail_data_count',
216
 
                      desc => 'The number of bytes in thumbnail data',
217
 
                      alias => 'num_bytes', init => 1 } },
 
322
    @outargs = (
 
323
        { name => 'width', type => 'int32',
 
324
          desc => 'The width of the thumbnail' },
 
325
        { name => 'height', type => 'int32',
 
326
          desc => 'The height of the thumbnail' },
 
327
        { name => 'thumb_data', type => 'int8array',
 
328
          desc => 'The thumbnail data',
 
329
          array =>  { name => 'thumb_data_count',
 
330
                      desc => 'The number of bytes in thumbnail data' } }
218
331
    );
219
332
 
220
333
    %invoke = (
221
 
        vars    => [ 'gchar *uri',
222
 
                     'GimpThumbnail *thumbnail = NULL',
223
 
                     'GdkPixbuf *pixbuf = NULL' ],
224
 
        code    => <<'CODE'
 
334
        code => <<'CODE'
225
335
{
226
 
  uri = g_filename_to_uri (filename, NULL, NULL);
227
 
 
228
 
  if (uri)
229
 
    {
230
 
      thumbnail = gimp_thumbnail_new ();
231
 
      gimp_thumbnail_set_uri (thumbnail, uri);
232
 
 
233
 
      pixbuf = gimp_thumbnail_load_thumb (thumbnail,
234
 
                                          GIMP_THUMBNAIL_SIZE_NORMAL,
235
 
                                          NULL);
236
 
    }
 
336
  GdkPixbuf *pixbuf = file_utils_load_thumbnail (filename);
237
337
 
238
338
  if (pixbuf)
239
339
    {
240
 
      width  = gdk_pixbuf_get_width (pixbuf);
241
 
      height = gdk_pixbuf_get_height (pixbuf);
242
 
 
243
 
      if (gdk_pixbuf_get_n_channels (pixbuf) != 3)
244
 
        {
245
 
          GdkPixbuf *tmp = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8,
246
 
                                           width, height);
247
 
 
248
 
          gdk_pixbuf_composite_color (pixbuf, tmp,
249
 
                                      0, 0, width, height, 0, 0, 1.0, 1.0,
250
 
                                      GDK_INTERP_NEAREST, 255,
251
 
                                      0, 0, GIMP_CHECK_SIZE_SM,
252
 
                                      0x66666666, 0x99999999);
253
 
 
254
 
          g_object_unref (pixbuf);
255
 
          pixbuf = tmp;
256
 
        }
257
 
 
258
 
      num_bytes  = 3 * width * height;
259
 
      thumb_data = g_memdup (gdk_pixbuf_get_pixels (pixbuf), num_bytes);
 
340
      width            = gdk_pixbuf_get_width (pixbuf);
 
341
      height           = gdk_pixbuf_get_height (pixbuf);
 
342
      thumb_data_count = 3 * width * height;
 
343
      thumb_data       = g_memdup (gdk_pixbuf_get_pixels (pixbuf),
 
344
                                   thumb_data_count);
260
345
 
261
346
      g_object_unref (pixbuf);
262
 
 
263
 
      success = TRUE;
264
347
    }
265
348
  else
266
 
    {
267
 
      success = FALSE;
268
 
    }
269
 
 
270
 
    g_free (uri);
 
349
    success = FALSE;
271
350
}
272
351
CODE
273
352
    );
285
364
explicitely save a thumbnail with a file.
286
365
HELP
287
366
 
288
 
    &pdb_misc;
 
367
    &josh_pdb_misc('1997');
289
368
 
290
369
    @inargs = (
291
 
        &std_image_arg,
292
 
        { name => 'filename', type => 'string', no_validate => 1,
293
 
          desc => 'The name of the file the thumbnail belongs to' },
 
370
        { name => 'image', type => 'image',
 
371
          desc => 'The image' },
 
372
        { name => 'filename', type => 'string', no_validate => 1,
 
373
          desc => 'The name of the file the thumbnail belongs to' },
294
374
    );
295
375
 
296
376
    %invoke = (
297
 
        vars => [ 'GimpImagefile *imagefile', 'gchar *uri',
298
 
                  'const gchar *image_uri' ],
299
 
        code => <<'CODE'
 
377
        code => <<'CODE'
300
378
{
301
 
  image_uri = gimp_object_get_name (GIMP_OBJECT (gimage));
302
 
  if (! image_uri)
303
 
    success = FALSE;
304
 
 
305
 
  if (success)
306
 
    {
307
 
      uri = g_filename_to_uri (filename, NULL, NULL);
308
 
      if (! uri)
309
 
        success = FALSE;
310
 
 
311
 
      if (success)
312
 
        {
313
 
          if (strcmp (uri, image_uri))
314
 
            success = FALSE;
315
 
 
316
 
          if (success)
317
 
            {
318
 
              imagefile = gimp_imagefile_new (gimp, uri);
319
 
              success = gimp_imagefile_save_thumbnail (imagefile, NULL, gimage);
320
 
              g_object_unref (imagefile);
321
 
            }
322
 
 
323
 
          g_free (uri);
324
 
        }
325
 
    }
 
379
  success = file_utils_save_thumbnail (image, filename);
326
380
}
327
381
CODE
328
382
    );
335
389
Generates a unique filename using the temp path supplied in the user's gimprc.
336
390
HELP
337
391
 
338
 
    &pdb_misc;
 
392
    &josh_pdb_misc('1997');
339
393
 
340
394
    @inargs = (
341
 
        { name => 'extension', type => 'string', no_validate => 1,
342
 
          desc => 'The extension the file will have' }
 
395
        { name => 'extension', type => 'string', no_validate => 1,
 
396
          desc => 'The extension the file will have' }
343
397
    );
344
398
 
345
399
    @outargs = (
346
 
        { name => 'name', type => 'string', init => 1,
347
 
          desc => 'The new temp filename' }
 
400
        { name => 'name', type => 'string',
 
401
          desc => 'The new temp filename' }
348
402
    );
349
403
 
350
404
    %invoke = (
351
 
        headers => [ qw(<process.h>
352
 
                        "config/gimpbaseconfig.h"
353
 
                        "config/gimpconfig-path.h") ],
354
 
        vars => [ 'static gint id = 0', 'static gint pid',
355
 
                  'gchar *filename', 'gchar *path' ],
356
 
        code => <<'CODE'
 
405
        code => <<'CODE'
357
406
{
358
 
  if (id == 0)
359
 
    pid = getpid ();
360
 
 
361
 
  filename = g_strdup_printf ("gimp_temp_%d%d.%s",
362
 
                              pid, id++, extension);
363
 
 
364
 
  path = gimp_config_path_expand (GIMP_BASE_CONFIG (gimp->config)->temp_path,
365
 
                                  TRUE, NULL);
366
 
 
367
 
  name = g_build_filename (path, filename, NULL);
368
 
 
369
 
  g_free (path);
370
 
  g_free (filename);
 
407
  name = gimp_get_temp_filename (gimp, extension);
371
408
}
372
409
CODE
373
410
    );
383
420
 
384
421
    &std_pdb_misc;
385
422
 
386
 
    &handler_args('load');
387
 
    &list_arg('load', 'magics', 'magic file information', '0,string,GIF');
 
423
    @inargs = (
 
424
        { name => 'procedure_name', type => 'string',
 
425
          desc => 'The name of the procedure to be used for loading' },
 
426
        { name => 'extensions', type => 'string', no_success => 1,
 
427
          desc => 'comma separated list of extensions this handler
 
428
                   can load (i.e. "jpg,jpeg")' },
 
429
        { name => 'prefixes', type => 'string', no_success => 1,
 
430
          desc => 'comma separated list of prefixes this handler
 
431
                   can load (i.e. "http:,ftp:")' },
 
432
        { name => 'magics', type => 'string', no_success => 1,
 
433
          desc => 'comma separated list of magic file information
 
434
                   this handler can load (i.e. "0,string,GIF")' }
 
435
    );
388
436
 
389
437
    %invoke = (
390
 
        vars => [ 'ProcRecord *proc', 'PlugInProcDef *file_proc' ],
391
 
        code => <<'CODE'
 
438
        code => <<'CODE'
392
439
{
393
 
  success = FALSE;
394
 
 
395
 
  proc = procedural_db_lookup (gimp, name);
396
 
 
397
 
  if (proc && ((proc->num_args < 3) ||
398
 
               (proc->num_values < 1) ||
399
 
               (proc->args[0].arg_type != GIMP_PDB_INT32) ||
400
 
               (proc->args[1].arg_type != GIMP_PDB_STRING) ||
401
 
               (proc->args[2].arg_type != GIMP_PDB_STRING) ||
402
 
               (proc->values[0].arg_type != GIMP_PDB_IMAGE)))
403
 
    {
404
 
      g_message ("load handler \"%s\" does not take the standard load handler args",
405
 
                 name);
406
 
      goto done;
407
 
    }
408
 
 
409
 
  file_proc = plug_ins_file_register_magic (gimp, name,
410
 
                                            extensions, prefixes, magics);
411
 
 
412
 
  if (! file_proc)
413
 
    {
414
 
      g_message ("attempt to register non-existant load handler \"%s\"",
415
 
                 name);
416
 
      goto done;
417
 
    }
418
 
 
419
 
  if (! g_slist_find (gimp->load_procs, file_proc))
420
 
    gimp->load_procs = g_slist_prepend (gimp->load_procs, file_proc);
421
 
 
422
 
  success = TRUE;
423
 
 
424
 
done: ;
 
440
  gchar *canonical = gimp_canonicalize_identifier (procedure_name);
 
441
 
 
442
  success = gimp_plug_in_manager_register_load_handler (gimp->plug_in_manager,
 
443
                                                        canonical,
 
444
                                                        extensions, prefixes, magics);
 
445
 
 
446
  g_free (canonical);
425
447
}
426
448
CODE
427
449
    );
437
459
 
438
460
    &std_pdb_misc;
439
461
 
440
 
    &handler_args('load');
 
462
    @inargs = (
 
463
        { name => 'procedure_name', type => 'string',
 
464
          desc => 'The name of the procedure to be used for loading' },
 
465
        { name => 'extensions', type => 'string', no_success => 1,
 
466
          desc => 'comma separated list of extensions this handler
 
467
                   can load (i.e. "jpg,jpeg")' },
 
468
        { name => 'prefixes', type => 'string', no_success => 1,
 
469
          desc => 'comma separated list of prefixes this handler
 
470
                   can load (i.e. "http:,ftp:")' }
 
471
    );
 
472
 
441
473
 
442
474
    %invoke = (
443
 
        pass_through => 'register_magic_load_handler',
444
 
        pass_args => [ 0..2 ],
445
 
        make_args => [ { type => 'string', code => '%%arg%% = NULL;' } ]
 
475
        code => <<'CODE'
 
476
{
 
477
  gchar *canonical = gimp_canonicalize_identifier (procedure_name);
 
478
 
 
479
  success = gimp_plug_in_manager_register_load_handler (gimp->plug_in_manager,
 
480
                                                        canonical,
 
481
                                                        extensions, prefixes, NULL);
 
482
 
 
483
  g_free (canonical);
 
484
}
 
485
CODE
446
486
    );
447
487
}
448
488
 
456
496
 
457
497
    &std_pdb_misc;
458
498
 
459
 
    &handler_args('save');
 
499
    @inargs = (
 
500
        { name => 'procedure_name', type => 'string',
 
501
          desc => 'The name of the procedure to be used for saving' },
 
502
        { name => 'extensions', type => 'string', no_success => 1,
 
503
          desc => 'comma separated list of extensions this handler
 
504
                   can save (i.e. "jpg,jpeg")' },
 
505
        { name => 'prefixes', type => 'string', no_success => 1,
 
506
          desc => 'comma separated list of prefixes this handler
 
507
                   can save (i.e. "http:,ftp:")' }
 
508
    );
460
509
 
461
510
    %invoke = (
462
 
        vars => [ 'ProcRecord *proc', 'PlugInProcDef *file_proc' ],
463
 
        code => <<'CODE'
 
511
        code => <<'CODE'
464
512
{
465
 
  success = FALSE;
466
 
 
467
 
  proc = procedural_db_lookup (gimp, name);
468
 
 
469
 
  if (proc && ((proc->num_args < 5) ||
470
 
               (proc->args[0].arg_type != GIMP_PDB_INT32) ||
471
 
               (proc->args[1].arg_type != GIMP_PDB_IMAGE) ||
472
 
               (proc->args[2].arg_type != GIMP_PDB_DRAWABLE) ||
473
 
               (proc->args[3].arg_type != GIMP_PDB_STRING) ||
474
 
               (proc->args[4].arg_type != GIMP_PDB_STRING)))
475
 
    {
476
 
      g_message ("save handler \"%s\" does not take the standard save handler args",
477
 
                 name);
478
 
      goto done;
479
 
    }
480
 
 
481
 
  file_proc = plug_ins_file_register_magic (gimp, name,
482
 
                                            extensions, prefixes, NULL);
483
 
 
484
 
  if (! file_proc)
485
 
    {
486
 
      g_message ("attempt to register non-existant save handler \"%s\"",
487
 
                 name);
488
 
      goto done;
489
 
    }
490
 
 
491
 
  if (! g_slist_find (gimp->save_procs, file_proc))
492
 
    gimp->save_procs = g_slist_prepend (gimp->save_procs, file_proc);
493
 
 
494
 
  success = TRUE;
495
 
 
496
 
done: ;
 
513
  gchar *canonical = gimp_canonicalize_identifier (procedure_name);
 
514
 
 
515
  success = gimp_plug_in_manager_register_save_handler (gimp->plug_in_manager,
 
516
                                                        canonical,
 
517
                                                        extensions, prefixes);
 
518
 
 
519
  g_free (canonical);
497
520
}
498
521
CODE
499
522
    );
508
531
procedure.
509
532
HELP
510
533
 
511
 
    $author = $copyright = 'Sven Neumann';
512
 
    $date = '2004';
513
 
    $since = '2.2';
 
534
    &neo_pdb_misc('2004', '2.2');
514
535
 
515
536
    @inargs = (
516
 
        { name => 'procedure_name', type => 'string', alias => 'name',
517
 
          desc => "The name of the procedure to associate a MIME type with." },
518
 
        { name => 'mime_type',      type => 'string',
519
 
          desc => "A single MIME type, like for example \"image/jpeg\"."     }
 
537
        { name => 'procedure_name', type => 'string',
 
538
          desc => "The name of the procedure to associate a MIME type with." },
 
539
        { name => 'mime_type', type => 'string',
 
540
          desc => "A single MIME type, like for example \"image/jpeg\"."     }
520
541
    );
521
542
 
522
543
    %invoke = (
523
 
        code => <<'CODE'
 
544
        code => <<'CODE'
524
545
{
525
 
  success = (plug_ins_file_register_mime (gimp, name, mime_type) != NULL);
 
546
  gchar *canonical = gimp_canonicalize_identifier (procedure_name);
 
547
 
 
548
  success = gimp_plug_in_manager_register_mime_type (gimp->plug_in_manager,
 
549
                                                     canonical, mime_type);
 
550
 
 
551
  g_free (canonical);
526
552
}
527
553
CODE
528
554
    );
532
558
    $blurb = 'Associates a thumbnail loader with a file load procedure.';
533
559
 
534
560
    $help = <<'HELP';
535
 
Some file formats allow for embedded thumbnails, other file formats contain a scalable image or provide the image data in different resolutions. A file plug-in for such a format may register a special procedure that allows GIMP to load a thumbnail preview of the image. This procedure is then associated with the standard load procedure using this function.
 
561
Some file formats allow for embedded thumbnails, other file formats
 
562
contain a scalable image or provide the image data in different
 
563
resolutions. A file plug-in for such a format may register a special
 
564
procedure that allows GIMP to load a thumbnail preview of the
 
565
image. This procedure is then associated with the standard load
 
566
procedure using this function.
536
567
HELP
537
568
 
538
 
    $author = $copyright = 'Sven Neumann';
539
 
    $date = '2004';
540
 
    $since = '2.2';
 
569
    &neo_pdb_misc('2004', '2.2');
541
570
 
542
571
    @inargs = (
543
 
        { name => 'load_proc', type => 'string',
544
 
          desc => "The name of the procedure the thumbnail loader with." },
545
 
        { name => 'thumb_proc', type => 'string',
546
 
          desc => "The name of the thumbnail load procedure." }
 
572
        { name => 'load_proc', type => 'string',
 
573
          desc => "The name of the procedure the thumbnail loader with." },
 
574
        { name => 'thumb_proc', type => 'string',
 
575
          desc => "The name of the thumbnail load procedure." }
547
576
    );
548
577
    %invoke = (
549
 
        code => <<'CODE'
 
578
        code => <<'CODE'
550
579
{
551
 
  success = (plug_ins_file_register_thumb_loader (gimp,
552
 
                                                  load_proc,
553
 
                                                  thumb_proc) != NULL);
 
580
  gchar *canonical = gimp_canonicalize_identifier (load_proc);
 
581
 
 
582
  success = gimp_plug_in_manager_register_thumb_loader (gimp->plug_in_manager,
 
583
                                                        canonical, thumb_proc);
 
584
 
 
585
  g_free (canonical);
554
586
}
555
587
CODE
556
588
    );
557
589
}
558
590
 
559
 
@headers = qw(<sys/types.h> <unistd.h> <gdk-pixbuf/gdk-pixbuf.h>
560
 
              "libgimpbase/gimpbase.h" "libgimpthumb/gimpthumb.h"
561
 
              "core/gimp.h" "core/gimpimagefile.h"
562
 
              "plug-in/plug-in.h" "plug-in/plug-ins.h"
563
 
              "plug-in/plug-in-proc-def.h"
 
591
 
 
592
@headers = qw("libgimpbase/gimpbase.h"
 
593
              "libgimpconfig/gimpconfig.h"
 
594
              "core/gimp.h"
 
595
              "core/gimp-utils.h"
 
596
              "plug-in/gimppluginmanager.h"
 
597
              "plug-in/gimppluginmanager-file.h"
 
598
              "file/file-open.h"
 
599
              "file/file-save.h"
564
600
              "file/file-utils.h");
565
601
 
566
 
@procs = qw(file_load file_save file_load_thumbnail file_save_thumbnail
567
 
            temp_name register_magic_load_handler register_load_handler
568
 
            register_save_handler register_file_handler_mime
 
602
@procs = qw(file_load file_load_layer file_load_layers
 
603
            file_save
 
604
            file_load_thumbnail file_save_thumbnail
 
605
            temp_name
 
606
            register_magic_load_handler register_load_handler
 
607
            register_save_handler
 
608
            register_file_handler_mime
569
609
            register_thumbnail_loader);
570
 
%exports = (app => [@procs], lib => [@procs[0,1,4..9]]);
 
610
 
 
611
%exports = (app => [@procs], lib => [@procs[0..3,5..11]]);
571
612
 
572
613
$desc = 'File Operations';
573
614