~ubuntu-branches/ubuntu/gutsy/gimp/gutsy-backports

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
/* GIMP - The GNU Image Manipulation Program
 * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

/* NOTE: This file is auto-generated by pdbgen.pl. */

#include "config.h"

#include <string.h>

#include <glib-object.h>

#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"

#include "pdb-types.h"
#include "gimppdb.h"
#include "gimpprocedure.h"
#include "core/gimpparamspecs.h"

#include "core/gimp-utils.h"
#include "core/gimp.h"
#include "core/gimpimage.h"
#include "core/gimplayer.h"
#include "file/file-open.h"
#include "file/file-procedure.h"
#include "file/file-save.h"
#include "file/file-utils.h"
#include "plug-in/gimppluginmanager-file.h"
#include "plug-in/gimppluginmanager.h"

#include "internal_procs.h"


static GValueArray *
file_load_invoker (GimpProcedure     *procedure,
                   Gimp              *gimp,
                   GimpContext       *context,
                   GimpProgress      *progress,
                   const GValueArray *args)
{
  GValueArray         *new_args;
  GValueArray         *return_vals;
  GimpPlugInProcedure *file_proc;
  GimpProcedure       *proc;
  gchar               *uri;
  gint                 i;

  uri = file_utils_filename_to_uri (gimp,
                                    g_value_get_string (&args->values[1]),
                                    NULL);

  if (! uri)
    return gimp_procedure_get_return_values (procedure, FALSE);

  file_proc =
    file_procedure_find (gimp->plug_in_manager->load_procs, uri, NULL);

  g_free (uri);

  if (! file_proc)
    return gimp_procedure_get_return_values (procedure, FALSE);

  proc = GIMP_PROCEDURE (file_proc);

  new_args = gimp_procedure_get_arguments (proc);

  for (i = 0; i < 3; i++)
    g_value_transform (&args->values[i], &new_args->values[i]);

  for (i = 3; i < proc->num_args; i++)
    if (G_IS_PARAM_SPEC_STRING (proc->args[i]))
      g_value_set_static_string (&new_args->values[i], "");

  return_vals =
    gimp_pdb_execute_procedure_by_name_args (gimp->pdb,
                                             context, progress,
                                             GIMP_OBJECT (proc)->name,
                                             new_args);

  g_value_array_free (new_args);

  if (g_value_get_enum (return_vals->values) == GIMP_PDB_SUCCESS)
    {
      if (return_vals->n_values > 1 &&
          GIMP_VALUE_HOLDS_IMAGE_ID (return_vals->values + 1))
        {
          GimpImage *image = gimp_value_get_image (return_vals->values + 1,
                                                   gimp);
          gimp_image_set_load_proc (image, file_proc);
        }
    }

  return return_vals;
}

static GValueArray *
file_load_layer_invoker (GimpProcedure     *procedure,
                         Gimp              *gimp,
                         GimpContext       *context,
                         GimpProgress      *progress,
                         const GValueArray *args)
{
  gboolean success = TRUE;
  GValueArray *return_vals;
  gint32 run_mode;
  GimpImage *image;
  const gchar *filename;
  GimpLayer *layer = NULL;

  run_mode = g_value_get_enum (&args->values[0]);
  image = gimp_value_get_image (&args->values[1], gimp);
  filename = g_value_get_string (&args->values[2]);

  if (success)
    {
      gchar *uri = file_utils_filename_to_uri (gimp, filename, NULL);

      if (uri)
        {
          GList             *layers;
          GimpPDBStatusType  status;

          layers = file_open_layers (gimp, context, progress,
                                     image, FALSE,
                                     uri, run_mode, NULL, &status, NULL);

          if (layers)
            {
              layer = layers->data;
              g_list_free (layers);
            }
          else
            success = FALSE;
        }
      else
        success = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success);

  if (success)
    gimp_value_set_layer (&return_vals->values[1], layer);

  return return_vals;
}

static GValueArray *
file_load_layers_invoker (GimpProcedure     *procedure,
                          Gimp              *gimp,
                          GimpContext       *context,
                          GimpProgress      *progress,
                          const GValueArray *args)
{
  gboolean success = TRUE;
  GValueArray *return_vals;
  gint32 run_mode;
  GimpImage *image;
  const gchar *filename;
  gint32 num_layers = 0;
  gint32 *layer_ids = NULL;

  run_mode = g_value_get_enum (&args->values[0]);
  image = gimp_value_get_image (&args->values[1], gimp);
  filename = g_value_get_string (&args->values[2]);

  if (success)
    {
      gchar *uri = file_utils_filename_to_uri (gimp, filename, NULL);

      if (uri)
        {
          GList             *layers;
          GimpPDBStatusType  status;

          layers = file_open_layers (gimp, context, progress,
                                     image, FALSE,
                                     uri, run_mode, NULL, &status, NULL);

          if (layers)
            {
              GList *list;
              gint i;

              num_layers = g_list_length (layers);

              layer_ids = g_new (gint32, num_layers);

              for (i = 0, list = layers;
                   i < num_layers;
                   i++, list = g_list_next (list))
                layer_ids[i] = gimp_item_get_ID (GIMP_ITEM (list->data));

              g_list_free (layers);
            }
          else
            success = FALSE;
        }
      else
        success = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success);

  if (success)
    {
      g_value_set_int (&return_vals->values[1], num_layers);
      gimp_value_take_int32array (&return_vals->values[2], layer_ids, num_layers);
    }

  return return_vals;
}

static GValueArray *
file_save_invoker (GimpProcedure     *procedure,
                   Gimp              *gimp,
                   GimpContext       *context,
                   GimpProgress      *progress,
                   const GValueArray *args)
{
  GValueArray         *new_args;
  GValueArray         *return_vals;
  GimpPlugInProcedure *file_proc;
  GimpProcedure       *proc;
  gchar               *uri;
  gint                 i;

  uri = file_utils_filename_to_uri (gimp,
                                    g_value_get_string (&args->values[3]),
                                    NULL);

  if (! uri)
    return gimp_procedure_get_return_values (procedure, FALSE);

  file_proc =
    file_procedure_find (gimp->plug_in_manager->save_procs, uri, NULL);

  g_free (uri);

  if (! file_proc)
    return gimp_procedure_get_return_values (procedure, FALSE);

  proc = GIMP_PROCEDURE (file_proc);

  new_args = gimp_procedure_get_arguments (proc);

  for (i = 0; i < 5; i++)
    g_value_transform (&args->values[i], &new_args->values[i]);

  for (i = 5; i < proc->num_args; i++)
    if (G_IS_PARAM_SPEC_STRING (proc->args[i]))
      g_value_set_static_string (&new_args->values[i], "");

  return_vals = gimp_pdb_execute_procedure_by_name_args (gimp->pdb,
                                                         context, progress,
                                                         GIMP_OBJECT (proc)->name,
                                                         new_args);

  g_value_array_free (new_args);

  return return_vals;
}

static GValueArray *
file_load_thumbnail_invoker (GimpProcedure     *procedure,
                             Gimp              *gimp,
                             GimpContext       *context,
                             GimpProgress      *progress,
                             const GValueArray *args)
{
  gboolean success = TRUE;
  GValueArray *return_vals;
  const gchar *filename;
  gint32 width = 0;
  gint32 height = 0;
  gint32 thumb_data_count = 0;
  guint8 *thumb_data = NULL;

  filename = g_value_get_string (&args->values[0]);

  if (success)
    {
      GdkPixbuf *pixbuf = file_utils_load_thumbnail (filename);

      if (pixbuf)
        {
          width            = gdk_pixbuf_get_width (pixbuf);
          height           = gdk_pixbuf_get_height (pixbuf);
          thumb_data_count = 3 * width * height;
          thumb_data       = g_memdup (gdk_pixbuf_get_pixels (pixbuf),
                                       thumb_data_count);

          g_object_unref (pixbuf);
        }
      else
        success = FALSE;
    }

  return_vals = gimp_procedure_get_return_values (procedure, success);

  if (success)
    {
      g_value_set_int (&return_vals->values[1], width);
      g_value_set_int (&return_vals->values[2], height);
      g_value_set_int (&return_vals->values[3], thumb_data_count);
      gimp_value_take_int8array (&return_vals->values[4], thumb_data, thumb_data_count);
    }

  return return_vals;
}

static GValueArray *
file_save_thumbnail_invoker (GimpProcedure     *procedure,
                             Gimp              *gimp,
                             GimpContext       *context,
                             GimpProgress      *progress,
                             const GValueArray *args)
{
  gboolean success = TRUE;
  GimpImage *image;
  const gchar *filename;

  image = gimp_value_get_image (&args->values[0], gimp);
  filename = g_value_get_string (&args->values[1]);

  if (success)
    {
      success = file_utils_save_thumbnail (image, filename);
    }

  return gimp_procedure_get_return_values (procedure, success);
}

static GValueArray *
temp_name_invoker (GimpProcedure     *procedure,
                   Gimp              *gimp,
                   GimpContext       *context,
                   GimpProgress      *progress,
                   const GValueArray *args)
{
  gboolean success = TRUE;
  GValueArray *return_vals;
  const gchar *extension;
  gchar *name = NULL;

  extension = g_value_get_string (&args->values[0]);

  if (success)
    {
      name = gimp_get_temp_filename (gimp, extension);
    }

  return_vals = gimp_procedure_get_return_values (procedure, success);

  if (success)
    g_value_take_string (&return_vals->values[1], name);

  return return_vals;
}

static GValueArray *
register_magic_load_handler_invoker (GimpProcedure     *procedure,
                                     Gimp              *gimp,
                                     GimpContext       *context,
                                     GimpProgress      *progress,
                                     const GValueArray *args)
{
  gboolean success = TRUE;
  const gchar *procedure_name;
  const gchar *extensions;
  const gchar *prefixes;
  const gchar *magics;

  procedure_name = g_value_get_string (&args->values[0]);
  extensions = g_value_get_string (&args->values[1]);
  prefixes = g_value_get_string (&args->values[2]);
  magics = g_value_get_string (&args->values[3]);

  if (success)
    {
      gchar *canonical = gimp_canonicalize_identifier (procedure_name);

      success = gimp_plug_in_manager_register_load_handler (gimp->plug_in_manager,
                                                            canonical,
                                                            extensions, prefixes, magics);

      g_free (canonical);
    }

  return gimp_procedure_get_return_values (procedure, success);
}

static GValueArray *
register_load_handler_invoker (GimpProcedure     *procedure,
                               Gimp              *gimp,
                               GimpContext       *context,
                               GimpProgress      *progress,
                               const GValueArray *args)
{
  gboolean success = TRUE;
  const gchar *procedure_name;
  const gchar *extensions;
  const gchar *prefixes;

  procedure_name = g_value_get_string (&args->values[0]);
  extensions = g_value_get_string (&args->values[1]);
  prefixes = g_value_get_string (&args->values[2]);

  if (success)
    {
      gchar *canonical = gimp_canonicalize_identifier (procedure_name);

      success = gimp_plug_in_manager_register_load_handler (gimp->plug_in_manager,
                                                            canonical,
                                                            extensions, prefixes, NULL);

      g_free (canonical);
    }

  return gimp_procedure_get_return_values (procedure, success);
}

static GValueArray *
register_save_handler_invoker (GimpProcedure     *procedure,
                               Gimp              *gimp,
                               GimpContext       *context,
                               GimpProgress      *progress,
                               const GValueArray *args)
{
  gboolean success = TRUE;
  const gchar *procedure_name;
  const gchar *extensions;
  const gchar *prefixes;

  procedure_name = g_value_get_string (&args->values[0]);
  extensions = g_value_get_string (&args->values[1]);
  prefixes = g_value_get_string (&args->values[2]);

  if (success)
    {
      gchar *canonical = gimp_canonicalize_identifier (procedure_name);

      success = gimp_plug_in_manager_register_save_handler (gimp->plug_in_manager,
                                                            canonical,
                                                            extensions, prefixes);

      g_free (canonical);
    }

  return gimp_procedure_get_return_values (procedure, success);
}

static GValueArray *
register_file_handler_mime_invoker (GimpProcedure     *procedure,
                                    Gimp              *gimp,
                                    GimpContext       *context,
                                    GimpProgress      *progress,
                                    const GValueArray *args)
{
  gboolean success = TRUE;
  const gchar *procedure_name;
  const gchar *mime_type;

  procedure_name = g_value_get_string (&args->values[0]);
  mime_type = g_value_get_string (&args->values[1]);

  if (success)
    {
      gchar *canonical = gimp_canonicalize_identifier (procedure_name);

      success = gimp_plug_in_manager_register_mime_type (gimp->plug_in_manager,
                                                         canonical, mime_type);

      g_free (canonical);
    }

  return gimp_procedure_get_return_values (procedure, success);
}

static GValueArray *
register_thumbnail_loader_invoker (GimpProcedure     *procedure,
                                   Gimp              *gimp,
                                   GimpContext       *context,
                                   GimpProgress      *progress,
                                   const GValueArray *args)
{
  gboolean success = TRUE;
  const gchar *load_proc;
  const gchar *thumb_proc;

  load_proc = g_value_get_string (&args->values[0]);
  thumb_proc = g_value_get_string (&args->values[1]);

  if (success)
    {
      gchar *canonical   = gimp_canonicalize_identifier (load_proc);
      gchar *canon_thumb = gimp_canonicalize_identifier (thumb_proc);

      success = gimp_plug_in_manager_register_thumb_loader (gimp->plug_in_manager,
                                                            canonical, canon_thumb);

      g_free (canonical);
      g_free (canon_thumb);
    }

  return gimp_procedure_get_return_values (procedure, success);
}

void
register_fileops_procs (GimpPDB *pdb)
{
  GimpProcedure *procedure;

  /*
   * gimp-file-load
   */
  procedure = gimp_procedure_new (file_load_invoker);
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-file-load");
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-file-load",
                                     "Loads an image file by invoking the right load handler.",
                                     "This procedure invokes the correct file load handler using magic if possible, and falling back on the file's extension and/or prefix if not. The name of the file to load is typically a full pathname, and the name entered is what the user actually typed before prepending a directory path. The reason for this is that if the user types http://www.xcf/~gimp/ he wants to fetch a URL, and the full pathname will not look like a URL.\"",
                                     "Josh MacDonald",
                                     "Josh MacDonald",
                                     "1997",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_enum ("run-mode",
                                                     "run mode",
                                                     "The run mode",
                                                     GIMP_TYPE_RUN_MODE,
                                                     GIMP_RUN_INTERACTIVE,
                                                     GIMP_PARAM_READWRITE));
  gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->args[0]),
                                      GIMP_RUN_WITH_LAST_VALS);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("filename",
                                                       "filename",
                                                       "The name of the file to load",
                                                       TRUE, FALSE, FALSE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("raw-filename",
                                                       "raw filename",
                                                       "The name as entered by the user",
                                                       TRUE, FALSE, FALSE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_image_id ("image",
                                                             "image",
                                                             "The output image",
                                                             pdb->gimp, FALSE,
                                                             GIMP_PARAM_READWRITE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * gimp-file-load-layer
   */
  procedure = gimp_procedure_new (file_load_layer_invoker);
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-file-load-layer");
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-file-load-layer",
                                     "Loads an image file as a layer for an existing image.",
                                     "This procedure behaves like the file-load procedure but opens the specified image as a layer for an existing image. The returned layer needs to be added to the existing image with 'gimp-image-add-layer'.",
                                     "Sven Neumann <sven@gimp.org>",
                                     "Sven Neumann",
                                     "2005",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_enum ("run-mode",
                                                     "run mode",
                                                     "The run mode",
                                                     GIMP_TYPE_RUN_MODE,
                                                     GIMP_RUN_INTERACTIVE,
                                                     GIMP_PARAM_READWRITE));
  gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->args[0]),
                                      GIMP_RUN_WITH_LAST_VALS);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_image_id ("image",
                                                         "image",
                                                         "Destination image",
                                                         pdb->gimp, FALSE,
                                                         GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("filename",
                                                       "filename",
                                                       "The name of the file to load",
                                                       TRUE, FALSE, FALSE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_layer_id ("layer",
                                                             "layer",
                                                             "The layer created when loading the image file",
                                                             pdb->gimp, FALSE,
                                                             GIMP_PARAM_READWRITE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * gimp-file-load-layers
   */
  procedure = gimp_procedure_new (file_load_layers_invoker);
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-file-load-layers");
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-file-load-layers",
                                     "Loads an image file as layers for an existing image.",
                                     "This procedure behaves like the file-load procedure but opens the specified image as layers for an existing image. The returned layers needs to be added to the existing image with 'gimp-image-add-layer'.",
                                     "Michael Natterer <mitch@gimp.org>",
                                     "Michael Natterer",
                                     "2006",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_enum ("run-mode",
                                                     "run mode",
                                                     "The run mode",
                                                     GIMP_TYPE_RUN_MODE,
                                                     GIMP_RUN_INTERACTIVE,
                                                     GIMP_PARAM_READWRITE));
  gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->args[0]),
                                      GIMP_RUN_WITH_LAST_VALS);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_image_id ("image",
                                                         "image",
                                                         "Destination image",
                                                         pdb->gimp, FALSE,
                                                         GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("filename",
                                                       "filename",
                                                       "The name of the file to load",
                                                       TRUE, FALSE, FALSE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_int32 ("num-layers",
                                                          "num layers",
                                                          "The number of loaded layers",
                                                          0, G_MAXINT32, 0,
                                                          GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_int32_array ("layer-ids",
                                                                "layer ids",
                                                                "The list of loaded layers",
                                                                GIMP_PARAM_READWRITE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * gimp-file-save
   */
  procedure = gimp_procedure_new (file_save_invoker);
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-file-save");
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-file-save",
                                     "Saves a file by extension.",
                                     "This procedure invokes the correct file save handler according to the file's extension and/or prefix. The name of the file to save is typically a full pathname, and the name entered is what the user actually typed before prepending a directory path. The reason for this is that if the user types http://www.xcf/~gimp/ she wants to fetch a URL, and the full pathname will not look like a URL.",
                                     "Josh MacDonald",
                                     "Josh MacDonald",
                                     "1997",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               g_param_spec_enum ("run-mode",
                                                  "run mode",
                                                  "The run mode",
                                                  GIMP_TYPE_RUN_MODE,
                                                  GIMP_RUN_INTERACTIVE,
                                                  GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_image_id ("image",
                                                         "image",
                                                         "Input image",
                                                         pdb->gimp, FALSE,
                                                         GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_drawable_id ("drawable",
                                                            "drawable",
                                                            "Drawable to save",
                                                            pdb->gimp, FALSE,
                                                            GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("filename",
                                                       "filename",
                                                       "The name of the file to save the image in",
                                                       TRUE, FALSE, FALSE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("raw-filename",
                                                       "raw filename",
                                                       "The name as entered by the user",
                                                       TRUE, FALSE, FALSE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * gimp-file-load-thumbnail
   */
  procedure = gimp_procedure_new (file_load_thumbnail_invoker);
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-file-load-thumbnail");
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-file-load-thumbnail",
                                     "Loads the thumbnail for a file.",
                                     "This procedure tries to load a thumbnail that belongs to the file with the given filename. This name is a full pathname. The returned data is an array of colordepth 3 (RGB), regardless of the image type. Width and height of the thumbnail are also returned. Don't use this function if you need a thumbnail of an already opened image, use 'gimp-image-thumbnail' instead.",
                                     "Adam D. Moss, Sven Neumann",
                                     "Adam D. Moss, Sven Neumann",
                                     "1999-2003",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("filename",
                                                       "filename",
                                                       "The name of the file that owns the thumbnail to load",
                                                       TRUE, FALSE, FALSE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_int32 ("width",
                                                          "width",
                                                          "The width of the thumbnail",
                                                          G_MININT32, G_MAXINT32, 0,
                                                          GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_int32 ("height",
                                                          "height",
                                                          "The height of the thumbnail",
                                                          G_MININT32, G_MAXINT32, 0,
                                                          GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_int32 ("thumb-data-count",
                                                          "thumb data count",
                                                          "The number of bytes in thumbnail data",
                                                          0, G_MAXINT32, 0,
                                                          GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_int8_array ("thumb-data",
                                                               "thumb data",
                                                               "The thumbnail data",
                                                               GIMP_PARAM_READWRITE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * gimp-file-save-thumbnail
   */
  procedure = gimp_procedure_new (file_save_thumbnail_invoker);
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-file-save-thumbnail");
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-file-save-thumbnail",
                                     "Saves a thumbnail for the given image",
                                     "This procedure saves a thumbnail for the given image according to the Free Desktop Thumbnail Managing Standard. The thumbnail is saved so that it belongs to the file with the given filename. This means you have to save the image under this name first, otherwise this procedure will fail. This procedure may become useful if you want to explicitely save a thumbnail with a file.",
                                     "Josh MacDonald",
                                     "Josh MacDonald",
                                     "1997",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_image_id ("image",
                                                         "image",
                                                         "The image",
                                                         pdb->gimp, FALSE,
                                                         GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("filename",
                                                       "filename",
                                                       "The name of the file the thumbnail belongs to",
                                                       TRUE, FALSE, FALSE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * gimp-temp-name
   */
  procedure = gimp_procedure_new (temp_name_invoker);
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-temp-name");
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-temp-name",
                                     "Generates a unique filename.",
                                     "Generates a unique filename using the temp path supplied in the user's gimprc.",
                                     "Josh MacDonald",
                                     "Josh MacDonald",
                                     "1997",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("extension",
                                                       "extension",
                                                       "The extension the file will have",
                                                       TRUE, TRUE, FALSE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_string ("name",
                                                           "name",
                                                           "The new temp filename",
                                                           FALSE, FALSE, FALSE,
                                                           NULL,
                                                           GIMP_PARAM_READWRITE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * gimp-register-magic-load-handler
   */
  procedure = gimp_procedure_new (register_magic_load_handler_invoker);
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-register-magic-load-handler");
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-register-magic-load-handler",
                                     "Registers a file load handler procedure.",
                                     "Registers a procedural database procedure to be called to load files of a particular file format using magic file information.",
                                     "Spencer Kimball & Peter Mattis",
                                     "Spencer Kimball & Peter Mattis",
                                     "1995-1996",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("procedure-name",
                                                       "procedure name",
                                                       "The name of the procedure to be used for loading",
                                                       FALSE, FALSE, TRUE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("extensions",
                                                       "extensions",
                                                       "comma separated list of extensions this handler can load (i.e. \"jpg,jpeg\")",
                                                       FALSE, FALSE, FALSE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("prefixes",
                                                       "prefixes",
                                                       "comma separated list of prefixes this handler can load (i.e. \"http:,ftp:\")",
                                                       FALSE, FALSE, FALSE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("magics",
                                                       "magics",
                                                       "comma separated list of magic file information this handler can load (i.e. \"0,string,GIF\")",
                                                       FALSE, FALSE, FALSE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * gimp-register-load-handler
   */
  procedure = gimp_procedure_new (register_load_handler_invoker);
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-register-load-handler");
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-register-load-handler",
                                     "Registers a file load handler procedure.",
                                     "Registers a procedural database procedure to be called to load files of a particular file format.",
                                     "Spencer Kimball & Peter Mattis",
                                     "Spencer Kimball & Peter Mattis",
                                     "1995-1996",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("procedure-name",
                                                       "procedure name",
                                                       "The name of the procedure to be used for loading",
                                                       FALSE, FALSE, TRUE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("extensions",
                                                       "extensions",
                                                       "comma separated list of extensions this handler can load (i.e. \"jpg,jpeg\")",
                                                       FALSE, FALSE, FALSE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("prefixes",
                                                       "prefixes",
                                                       "comma separated list of prefixes this handler can load (i.e. \"http:,ftp:\")",
                                                       FALSE, FALSE, FALSE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * gimp-register-save-handler
   */
  procedure = gimp_procedure_new (register_save_handler_invoker);
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-register-save-handler");
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-register-save-handler",
                                     "Registers a file save handler procedure.",
                                     "Registers a procedural database procedure to be called to save files in a particular file format.",
                                     "Spencer Kimball & Peter Mattis",
                                     "Spencer Kimball & Peter Mattis",
                                     "1995-1996",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("procedure-name",
                                                       "procedure name",
                                                       "The name of the procedure to be used for saving",
                                                       FALSE, FALSE, TRUE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("extensions",
                                                       "extensions",
                                                       "comma separated list of extensions this handler can save (i.e. \"jpg,jpeg\")",
                                                       FALSE, FALSE, FALSE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("prefixes",
                                                       "prefixes",
                                                       "comma separated list of prefixes this handler can save (i.e. \"http:,ftp:\")",
                                                       FALSE, FALSE, FALSE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE | GIMP_PARAM_NO_VALIDATE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * gimp-register-file-handler-mime
   */
  procedure = gimp_procedure_new (register_file_handler_mime_invoker);
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-register-file-handler-mime");
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-register-file-handler-mime",
                                     "Associates a MIME type with a file handler procedure.",
                                     "Registers a MIME type for a file handler procedure. This allows GIMP to determine the MIME type of the file opened or saved using this procedure.",
                                     "Sven Neumann <sven@gimp.org>",
                                     "Sven Neumann",
                                     "2004",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("procedure-name",
                                                       "procedure name",
                                                       "The name of the procedure to associate a MIME type with.",
                                                       FALSE, FALSE, TRUE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("mime-type",
                                                       "mime type",
                                                       "A single MIME type, like for example \"image/jpeg\".",
                                                       FALSE, FALSE, FALSE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * gimp-register-thumbnail-loader
   */
  procedure = gimp_procedure_new (register_thumbnail_loader_invoker);
  gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-register-thumbnail-loader");
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-register-thumbnail-loader",
                                     "Associates a thumbnail loader with a file load procedure.",
                                     "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.",
                                     "Sven Neumann <sven@gimp.org>",
                                     "Sven Neumann",
                                     "2004",
                                     NULL);
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("load-proc",
                                                       "load proc",
                                                       "The name of the procedure the thumbnail loader with.",
                                                       FALSE, FALSE, TRUE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_string ("thumb-proc",
                                                       "thumb proc",
                                                       "The name of the thumbnail load procedure.",
                                                       FALSE, FALSE, TRUE,
                                                       NULL,
                                                       GIMP_PARAM_READWRITE));
  gimp_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);
}