[gimp] plug-ins: change all ported thumbnail loaders to GimpThumbnailProcedure



commit 1253faaab3d0be726089627aa630d3a80e581ebd
Author: Michael Natterer <mitch gimp org>
Date:   Mon Aug 19 14:04:00 2019 +0200

    plug-ins: change all ported thumbnail loaders to GimpThumbnailProcedure

 plug-ins/common/file-gif-load.c      | 43 +++++---------------------
 plug-ins/common/file-ps.c            | 34 +++++----------------
 plug-ins/common/file-svg.c           | 47 +++++++----------------------
 plug-ins/file-ico/ico.c              | 49 ++++++++----------------------
 plug-ins/file-psd/psd.c              | 46 +++++++---------------------
 plug-ins/file-raw/file-darktable.c   | 58 +++++++-----------------------------
 plug-ins/file-raw/file-rawtherapee.c | 49 ++++++++----------------------
 7 files changed, 73 insertions(+), 253 deletions(-)
---
diff --git a/plug-ins/common/file-gif-load.c b/plug-ins/common/file-gif-load.c
index 33097d9750..4d5e092202 100644
--- a/plug-ins/common/file-gif-load.c
+++ b/plug-ins/common/file-gif-load.c
@@ -112,6 +112,8 @@ static GimpValueArray * gif_load             (GimpProcedure        *procedure,
                                               const GimpValueArray *args,
                                               gpointer              run_data);
 static GimpValueArray * gif_load_thumb       (GimpProcedure        *procedure,
+                                              GFile                *file,
+                                              gint                  size,
                                               const GimpValueArray *args,
                                               gpointer              run_data);
 
@@ -194,8 +196,8 @@ gif_create_procedure (GimpPlugIn  *plug_in,
     }
   else if (! strcmp (name, LOAD_THUMB_PROC))
     {
-      procedure = gimp_procedure_new (plug_in, name, GIMP_PLUGIN,
-                                      gif_load_thumb, NULL, NULL);
+      procedure = gimp_thumbnail_procedure_new (plug_in, name, GIMP_PLUGIN,
+                                                gif_load_thumb, NULL, NULL);
 
       gimp_procedure_set_documentation (procedure,
                                         "Loads only the first frame of a "
@@ -207,36 +209,6 @@ gif_create_procedure (GimpPlugIn  *plug_in,
                                       "Sven Neumann",
                                       "Sven Neumann",
                                       "2006");
-
-      GIMP_PROC_ARG_STRING (procedure, "uri",
-                            "URI",
-                            "URI of the file to load",
-                            NULL,
-                            GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_ARG_INT (procedure, "thumb-size",
-                         "Thumb Size",
-                         "Preferred thumbnail size",
-                         16, 2014, 256,
-                         GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_VAL_IMAGE (procedure, "image",
-                           "Image",
-                           "Thumbnail image",
-                           FALSE,
-                           GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_VAL_INT (procedure, "image-width",
-                         "Image width",
-                         "Width of the full-sized image",
-                         1, GIMP_MAX_IMAGE_SIZE, 1,
-                         GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_VAL_INT (procedure, "image-height",
-                         "Image height",
-                         "Height of the full-sized image",
-                         1, GIMP_MAX_IMAGE_SIZE, 1,
-                         GIMP_PARAM_READWRITE);
     }
 
   return procedure;
@@ -299,19 +271,18 @@ gif_load (GimpProcedure        *procedure,
 
 static GimpValueArray *
 gif_load_thumb (GimpProcedure        *procedure,
+                GFile                *file,
+                gint                  size,
                 const GimpValueArray *args,
                 gpointer              run_data)
 {
   GimpValueArray *return_vals;
-  GFile          *file;
   gint32          image_id;
   GError         *error = NULL;
 
   INIT_I18N ();
   gegl_init (NULL, NULL);
 
-  file = g_file_new_for_uri (g_value_get_string (gimp_value_array_index (args, 0)));
-
   image_id = load_image (g_file_get_path (file), TRUE, &error);
 
   if (image_id < 1)
@@ -333,6 +304,8 @@ gif_load_thumb (GimpProcedure        *procedure,
   g_value_set_int         (gimp_value_array_index (return_vals, 3),
                            gimp_image_height (image_id));
 
+  gimp_value_array_truncate (return_vals, 4);
+
   return return_vals;
 }
 
diff --git a/plug-ins/common/file-ps.c b/plug-ins/common/file-ps.c
index c41c02cdfd..fdc5bae65e 100644
--- a/plug-ins/common/file-ps.c
+++ b/plug-ins/common/file-ps.c
@@ -162,6 +162,8 @@ static GimpValueArray * ps_load             (GimpProcedure        *procedure,
                                              const GimpValueArray *args,
                                              gpointer              run_data);
 static GimpValueArray * ps_load_thumb       (GimpProcedure        *procedure,
+                                             GFile                *file,
+                                             gint                  size,
                                              const GimpValueArray *args,
                                              gpointer              run_data);
 static GimpValueArray * ps_save             (GimpProcedure        *procedure,
@@ -460,8 +462,8 @@ ps_create_procedure (GimpPlugIn  *plug_in,
     }
   else if (! strcmp (name, LOAD_PS_THUMB_PROC))
     {
-      procedure = gimp_procedure_new (plug_in, name, GIMP_PLUGIN,
-                                      ps_load_thumb, NULL, NULL);
+      procedure = gimp_thumbnail_procedure_new (plug_in, name, GIMP_PLUGIN,
+                                                ps_load_thumb, NULL, NULL);
 
       gimp_procedure_set_documentation (procedure,
                                         "Loads a small preview from a "
@@ -472,24 +474,6 @@ ps_create_procedure (GimpPlugIn  *plug_in,
                                       "Peter Kirchgessner <peter kirchgessner net>",
                                       "Peter Kirchgessner",
                                       dversion);
-
-      GIMP_PROC_ARG_STRING (procedure, "uri",
-                            "URI",
-                            "URI of the file to load",
-                            NULL,
-                            GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_ARG_INT (procedure, "thumb-size",
-                         "Thumb Size",
-                         "Preferred thumbnail size",
-                         16, 2014, 256,
-                         GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_VAL_IMAGE (procedure, "image",
-                           "Image",
-                           "Thumbnail image",
-                           FALSE,
-                           GIMP_PARAM_READWRITE);
     }
   else if (! strcmp (name, SAVE_PS_PROC) ||
            ! strcmp (name, SAVE_EPS_PROC))
@@ -687,22 +671,18 @@ ps_load (GimpProcedure        *procedure,
 
 static GimpValueArray *
 ps_load_thumb (GimpProcedure        *procedure,
+               GFile                *file,
+               gint                  size,
                const GimpValueArray *args,
                gpointer              run_data)
 {
   GimpValueArray *return_vals;
-  GFile          *file;
-  gint            size;
   gint32          image_id;
   GError         *error = NULL;
 
   INIT_I18N ();
   gegl_init (NULL, NULL);
 
-  file = g_file_new_for_uri (g_value_get_string (gimp_value_array_index (args, 0)));
-
-  size = g_value_get_int (gimp_value_array_index (args, 1));
-
   /*  We should look for an embedded preview but for now we
    *  just load the document at a small resolution and the
    *  first page only.
@@ -727,6 +707,8 @@ ps_load_thumb (GimpProcedure        *procedure,
 
   gimp_value_set_image_id (gimp_value_array_index (return_vals, 1), image_id);
 
+  gimp_value_array_truncate (return_vals, 2);
+
   return return_vals;
 }
 
diff --git a/plug-ins/common/file-svg.c b/plug-ins/common/file-svg.c
index ccccda04e8..a7c372ca31 100644
--- a/plug-ins/common/file-svg.c
+++ b/plug-ins/common/file-svg.c
@@ -83,6 +83,8 @@ static GimpValueArray * svg_load             (GimpProcedure        *procedure,
                                               const GimpValueArray *args,
                                               gpointer              run_data);
 static GimpValueArray * svg_load_thumb       (GimpProcedure        *procedure,
+                                              GFile                *file,
+                                              gint                  size,
                                               const GimpValueArray *args,
                                               gpointer              run_data);
 
@@ -203,8 +205,8 @@ svg_create_procedure (GimpPlugIn  *plug_in,
     }
   else if (! strcmp (name, LOAD_THUMB_PROC))
     {
-      procedure = gimp_procedure_new (plug_in, name, GIMP_PLUGIN,
-                                      svg_load_thumb, NULL, NULL);
+      procedure = gimp_thumbnail_procedure_new (plug_in, name, GIMP_PLUGIN,
+                                                svg_load_thumb, NULL, NULL);
 
       gimp_procedure_set_documentation (procedure,
                                         "Generates a thumbnail of an SVG image",
@@ -215,36 +217,6 @@ svg_create_procedure (GimpPlugIn  *plug_in,
                                       "Dom Lachowicz, Sven Neumann",
                                       "Dom Lachowicz <cinamod hotmail com>",
                                       SVG_VERSION);
-
-      GIMP_PROC_ARG_STRING (procedure, "uri",
-                            "URI",
-                            "URI of the file to load",
-                            NULL,
-                            GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_ARG_INT (procedure, "thumb-size",
-                         "Thumb Size",
-                         "Preferred thumbnail size",
-                         16, 2014, 256,
-                         GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_VAL_IMAGE (procedure, "image",
-                           "Image",
-                           "Thumbnail image",
-                           FALSE,
-                           GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_VAL_INT (procedure, "image-width",
-                         "Image width",
-                         "Width of the full-sized image",
-                         1, GIMP_MAX_IMAGE_SIZE, 1,
-                         GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_VAL_INT (procedure, "image-height",
-                         "Image height",
-                         "Height of the full-sized image",
-                         1, GIMP_MAX_IMAGE_SIZE, 1,
-                         GIMP_PARAM_READWRITE);
     }
 
   return procedure;
@@ -325,11 +297,12 @@ svg_load (GimpProcedure        *procedure,
 
 static GimpValueArray *
 svg_load_thumb (GimpProcedure        *procedure,
+                GFile                *file,
+                gint                  size,
                 const GimpValueArray *args,
                 gpointer              run_data)
 {
   GimpValueArray *return_vals;
-  GFile          *file;
   gint            width  = 0;
   gint            height = 0;
   gint32          image_id;
@@ -338,8 +311,6 @@ svg_load_thumb (GimpProcedure        *procedure,
   INIT_I18N ();
   gegl_init (NULL, NULL);
 
-  file = g_file_new_for_uri (g_value_get_string (gimp_value_array_index (args, 0)));
-
   if (load_rsvg_size (g_file_get_path (file),
                       &load_vals, NULL))
     {
@@ -348,8 +319,8 @@ svg_load_thumb (GimpProcedure        *procedure,
     }
 
   load_vals.resolution = SVG_DEFAULT_RESOLUTION;
-  load_vals.width      = - g_value_get_int (gimp_value_array_index (args, 1));
-  load_vals.height     = - g_value_get_int (gimp_value_array_index (args, 1));
+  load_vals.width      = - size;
+  load_vals.height     = - size;
 
   image_id = load_image (g_file_get_path (file),
                          &error);
@@ -367,6 +338,8 @@ svg_load_thumb (GimpProcedure        *procedure,
   g_value_set_int         (gimp_value_array_index (return_vals, 2), width);
   g_value_set_int         (gimp_value_array_index (return_vals, 3), height);
 
+  gimp_value_array_truncate (return_vals, 4);
+
   return return_vals;
 }
 
diff --git a/plug-ins/file-ico/ico.c b/plug-ins/file-ico/ico.c
index d25ce4bec4..9fbe337df9 100644
--- a/plug-ins/file-ico/ico.c
+++ b/plug-ins/file-ico/ico.c
@@ -67,6 +67,8 @@ static GimpValueArray * ico_load             (GimpProcedure        *procedure,
                                               const GimpValueArray *args,
                                               gpointer              run_data);
 static GimpValueArray * ico_load_thumb       (GimpProcedure        *procedure,
+                                              GFile                *file,
+                                              gint                  size,
                                               const GimpValueArray *args,
                                               gpointer              run_data);
 static GimpValueArray * ico_save             (GimpProcedure        *procedure,
@@ -144,8 +146,8 @@ ico_create_procedure (GimpPlugIn  *plug_in,
     }
   else if (! strcmp (name, LOAD_THUMB_PROC))
     {
-      procedure = gimp_procedure_new (plug_in, name, GIMP_PLUGIN,
-                                      ico_load_thumb, NULL, NULL);
+      procedure = gimp_thumbnail_procedure_new (plug_in, name, GIMP_PLUGIN,
+                                                ico_load_thumb, NULL, NULL);
 
       gimp_procedure_set_documentation (procedure,
                                         "Loads a preview from an Windows ICO file",
@@ -155,36 +157,6 @@ ico_create_procedure (GimpPlugIn  *plug_in,
                                       "Dom Lachowicz, Sven Neumann",
                                       "Sven Neumann <sven gimp org>",
                                       "2005");
-
-      GIMP_PROC_ARG_STRING (procedure, "uri",
-                            "URI",
-                            "URI of the file to load",
-                            NULL,
-                            GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_ARG_INT (procedure, "thumb-size",
-                         "Thumb Size",
-                         "Preferred thumbnail size",
-                         16, 2014, 256,
-                         GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_VAL_IMAGE (procedure, "image",
-                           "Image",
-                           "Thumbnail image",
-                           FALSE,
-                           GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_VAL_INT (procedure, "image-width",
-                         "Image width",
-                         "Width of the full-sized image",
-                         1, GIMP_MAX_IMAGE_SIZE, 1,
-                         GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_VAL_INT (procedure, "image-height",
-                         "Image height",
-                         "Height of the full-sized image",
-                         1, GIMP_MAX_IMAGE_SIZE, 1,
-                         GIMP_PARAM_READWRITE);
     }
   else if (! strcmp (name, SAVE_PROC))
     {
@@ -252,21 +224,24 @@ ico_load (GimpProcedure        *procedure,
 
 static GimpValueArray *
 ico_load_thumb (GimpProcedure        *procedure,
+                GFile                *file,
+                gint                  size,
                 const GimpValueArray *args,
                 gpointer              run_data)
 {
   GimpValueArray *return_vals;
-  const gchar    *filename;
+  gchar          *filename;
   gint            width;
   gint            height;
   gint32          image_id;
   GError         *error = NULL;
+
   INIT_I18N ();
   gegl_init (NULL, NULL);
 
-  filename = g_value_get_string (gimp_value_array_index (args, 0));
-  width    = g_value_get_int    (gimp_value_array_index (args, 1));
-  height   = width;
+  filename = g_file_get_path (file);
+  width    = size;
+  height   = size;
 
   image_id = ico_load_thumbnail_image (filename,
                                        &width, &height, &error);
@@ -284,6 +259,8 @@ ico_load_thumb (GimpProcedure        *procedure,
   g_value_set_int         (gimp_value_array_index (return_vals, 2), width);
   g_value_set_int         (gimp_value_array_index (return_vals, 3), height);
 
+  gimp_value_array_truncate (return_vals, 4);
+
   return return_vals;
 }
 
diff --git a/plug-ins/file-psd/psd.c b/plug-ins/file-psd/psd.c
index 82f7c2c90c..4fe230acd7 100644
--- a/plug-ins/file-psd/psd.c
+++ b/plug-ins/file-psd/psd.c
@@ -62,6 +62,8 @@ static GimpValueArray * psd_load             (GimpProcedure        *procedure,
                                               const GimpValueArray *args,
                                               gpointer              run_data);
 static GimpValueArray * psd_load_thumb       (GimpProcedure        *procedure,
+                                              GFile                *file,
+                                              gint                  size,
                                               const GimpValueArray *args,
                                               gpointer              run_data);
 static GimpValueArray * psd_save             (GimpProcedure        *procedure,
@@ -171,8 +173,8 @@ psd_create_procedure (GimpPlugIn  *plug_in,
     }
   else if (! strcmp (name, LOAD_THUMB_PROC))
     {
-      procedure = gimp_procedure_new (plug_in, name, GIMP_PLUGIN,
-                                      psd_load_thumb, NULL, NULL);
+      procedure = gimp_thumbnail_procedure_new (plug_in, name, GIMP_PLUGIN,
+                                                psd_load_thumb, NULL, NULL);
 
       gimp_procedure_set_documentation (procedure,
                                         "Loads thumbnails from the "
@@ -185,36 +187,6 @@ psd_create_procedure (GimpPlugIn  *plug_in,
                                       "John Marshall",
                                       "John Marshall",
                                       "2007");
-
-      GIMP_PROC_ARG_STRING (procedure, "uri",
-                            "URI",
-                            "URI of the file to load",
-                            NULL,
-                            GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_ARG_INT (procedure, "thumb-size",
-                         "Thumb Size",
-                         "Preferred thumbnail size",
-                         16, 2014, 256,
-                         GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_VAL_IMAGE (procedure, "image",
-                           "Image",
-                           "Thumbnail image",
-                           FALSE,
-                           GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_VAL_INT (procedure, "image-width",
-                         "Image width",
-                         "Width of the full-sized image",
-                         1, GIMP_MAX_IMAGE_SIZE, 1,
-                         GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_VAL_INT (procedure, "image-height",
-                         "Image height",
-                         "Height of the full-sized image",
-                         1, GIMP_MAX_IMAGE_SIZE, 1,
-                         GIMP_PARAM_READWRITE);
     }
   else if (! strcmp (name, SAVE_PROC))
     {
@@ -322,11 +294,13 @@ psd_load (GimpProcedure        *procedure,
 
 static GimpValueArray *
 psd_load_thumb (GimpProcedure        *procedure,
+                GFile                *file,
+                gint                  size,
                 const GimpValueArray *args,
                 gpointer              run_data)
 {
   GimpValueArray *return_vals;
-  const gchar    *filename;
+  gchar          *filename;
   gint            width  = 0;
   gint            height = 0;
   gint32          image_id;
@@ -335,9 +309,9 @@ psd_load_thumb (GimpProcedure        *procedure,
   INIT_I18N ();
   gegl_init (NULL, NULL);
 
-  filename = g_value_get_string (gimp_value_array_index (args, 0));
+  filename = g_file_get_path (file);
 
-  image_id = load_thumbnail_image (filename,&width, &height, &error);
+  image_id = load_thumbnail_image (filename, &width, &height, &error);
 
   if (image_id < 1)
     return gimp_procedure_new_return_values (procedure,
@@ -352,6 +326,8 @@ psd_load_thumb (GimpProcedure        *procedure,
   g_value_set_int         (gimp_value_array_index (return_vals, 2), width);
   g_value_set_int         (gimp_value_array_index (return_vals, 3), height);
 
+  gimp_value_array_truncate (return_vals, 4);
+
   return return_vals;
 }
 
diff --git a/plug-ins/file-raw/file-darktable.c b/plug-ins/file-raw/file-darktable.c
index 33b9696765..7a741043e5 100644
--- a/plug-ins/file-raw/file-darktable.c
+++ b/plug-ins/file-raw/file-darktable.c
@@ -64,6 +64,8 @@ static GimpValueArray * darktable_load             (GimpProcedure        *proced
                                                     const GimpValueArray *args,
                                                     gpointer              run_data);
 static GimpValueArray * darktable_load_thumb       (GimpProcedure        *procedure,
+                                                    GFile                *file,
+                                                    gint                  size,
                                                     const GimpValueArray *args,
                                                     gpointer              run_data);
 
@@ -224,8 +226,8 @@ darktable_create_procedure (GimpPlugIn  *plug_in,
 
   if (! strcmp (name, LOAD_THUMB_PROC))
     {
-      procedure = gimp_procedure_new (plug_in, name, GIMP_PLUGIN,
-                                      darktable_load_thumb, NULL, NULL);
+      procedure = gimp_thumbnail_procedure_new (plug_in, name, GIMP_PLUGIN,
+                                                darktable_load_thumb, NULL, NULL);
 
       gimp_procedure_set_documentation (procedure,
                                         "Load thumbnail from a raw image "
@@ -238,36 +240,6 @@ darktable_create_procedure (GimpPlugIn  *plug_in,
                                       "Tobias Ellinghaus",
                                       "Tobias Ellinghaus",
                                       "2016");
-
-      GIMP_PROC_ARG_STRING (procedure, "uri",
-                            "URI",
-                            "URI of the file to load",
-                            NULL,
-                            GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_ARG_INT (procedure, "thumb-size",
-                         "Thumb Size",
-                         "Preferred thumbnail size",
-                         16, 2014, 256,
-                         GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_VAL_IMAGE (procedure, "image",
-                           "Image",
-                           "Thumbnail image",
-                           FALSE,
-                           GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_VAL_INT (procedure, "image-width",
-                         "Image width",
-                         "Width of the full-sized image",
-                         1, GIMP_MAX_IMAGE_SIZE, 1,
-                         GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_VAL_INT (procedure, "image-height",
-                         "Image height",
-                         "Height of the full-sized image",
-                         1, GIMP_MAX_IMAGE_SIZE, 1,
-                         GIMP_PARAM_READWRITE);
     }
   else
     {
@@ -362,23 +334,21 @@ darktable_load (GimpProcedure        *procedure,
 
 static GimpValueArray *
 darktable_load_thumb (GimpProcedure        *procedure,
+                      GFile                *file,
+                      gint                  size,
                       const GimpValueArray *args,
                       gpointer              run_data)
 {
   GimpValueArray *return_vals;
-  GFile          *file;
   gint            width;
   gint            height;
   gint32          image_id;
-  GValue          value = G_VALUE_INIT;
   GError         *error = NULL;
 
   INIT_I18N ();
 
-  file = g_file_new_for_uri (g_value_get_string (gimp_value_array_index (args, 0)));
-
-  width  = g_value_get_int    (gimp_value_array_index (args, 1));
-  height = width;
+  width  = size;
+  height = size;
 
   image_id = load_thumbnail_image (g_file_get_path (file),
                                    width, &width, &height, &error);
@@ -395,16 +365,10 @@ darktable_load_thumb (GimpProcedure        *procedure,
   gimp_value_set_image_id (gimp_value_array_index (return_vals, 1), image_id);
   g_value_set_int         (gimp_value_array_index (return_vals, 2), width);
   g_value_set_int         (gimp_value_array_index (return_vals, 3), height);
+  g_value_set_enum        (gimp_value_array_index (return_vals, 4), GIMP_RGB_IMAGE);
+  g_value_set_int         (gimp_value_array_index (return_vals, 5), 1);
 
-  g_value_init (&value, GIMP_TYPE_IMAGE_TYPE);
-  g_value_set_enum (&value, GIMP_RGB_IMAGE);
-  gimp_value_array_append (return_vals, &value);
-  g_value_unset (&value);
-
-  g_value_init (&value, G_TYPE_INT);
-  g_value_set_int (&value, 1);
-  gimp_value_array_append (return_vals, &value);
-  g_value_unset (&value);
+  gimp_value_array_truncate (return_vals, 6);
 
   return return_vals;
 }
diff --git a/plug-ins/file-raw/file-rawtherapee.c b/plug-ins/file-raw/file-rawtherapee.c
index 547cb76737..8006fa6eb4 100644
--- a/plug-ins/file-raw/file-rawtherapee.c
+++ b/plug-ins/file-raw/file-rawtherapee.c
@@ -32,7 +32,7 @@
 #include "file-raw-utils.h"
 
 
-#define LOAD_THUMB_PROC "file-rawtherapee-load-thumb"
+#define LOAD_THUMB_PROC   "file-rawtherapee-load-thumb"
 #define REGISTRY_KEY_BASE "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\rawtherapee"
 
 
@@ -65,6 +65,8 @@ static GimpValueArray * rawtherapee_load             (GimpProcedure        *proc
                                                       const GimpValueArray *args,
                                                       gpointer              run_data);
 static GimpValueArray * rawtherapee_load_thumb       (GimpProcedure        *procedure,
+                                                      GFile                *file,
+                                                      gint                  size,
                                                       const GimpValueArray *args,
                                                       gpointer              run_data);
 
@@ -175,8 +177,8 @@ rawtherapee_create_procedure (GimpPlugIn  *plug_in,
 
   if (! strcmp (name, LOAD_THUMB_PROC))
     {
-      procedure = gimp_procedure_new (plug_in, name, GIMP_PLUGIN,
-                                      rawtherapee_load_thumb, NULL, NULL);
+      procedure = gimp_thumbnail_procedure_new (plug_in, name, GIMP_PLUGIN,
+                                                rawtherapee_load_thumb, NULL, NULL);
 
       gimp_procedure_set_documentation (procedure,
                                         "Load thumbnail from a raw image "
@@ -189,24 +191,6 @@ rawtherapee_create_procedure (GimpPlugIn  *plug_in,
                                       "Alberto Griggio",
                                       "Alberto Griggio",
                                       "2017");
-
-      GIMP_PROC_ARG_STRING (procedure, "uri",
-                            "URI",
-                            "URI of the file to load",
-                            NULL,
-                            GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_ARG_INT (procedure, "thumb-size",
-                         "Thumb Size",
-                         "Preferred thumbnail size",
-                         16, 2014, 256,
-                         GIMP_PARAM_READWRITE);
-
-      GIMP_PROC_VAL_IMAGE (procedure, "image",
-                           "Image",
-                           "Thumbnail image",
-                           FALSE,
-                           GIMP_PARAM_READWRITE);
     }
   else
     {
@@ -301,22 +285,17 @@ rawtherapee_load (GimpProcedure        *procedure,
 
 static GimpValueArray *
 rawtherapee_load_thumb (GimpProcedure        *procedure,
+                        GFile                *file,
+                        gint                  size,
                         const GimpValueArray *args,
                         gpointer              run_data)
 {
   GimpValueArray *return_vals;
-  GFile          *file;
-  gint            size;
   gint32          image_id;
-  GValue          value = G_VALUE_INIT;
   GError         *error = NULL;
 
   INIT_I18N ();
 
-  file = g_file_new_for_uri (g_value_get_string (gimp_value_array_index (args, 0)));
-
-  size = g_value_get_int (gimp_value_array_index (args, 1));
-
   image_id = load_thumbnail_image (g_file_get_path (file),
                                    size, &error);
 
@@ -330,16 +309,12 @@ rawtherapee_load_thumb (GimpProcedure        *procedure,
                                                   NULL);
 
   gimp_value_set_image_id (gimp_value_array_index (return_vals, 1), image_id);
+  g_value_set_int         (gimp_value_array_index (return_vals, 2), 0);
+  g_value_set_int         (gimp_value_array_index (return_vals, 3), 0);
+  g_value_set_enum        (gimp_value_array_index (return_vals, 4), GIMP_RGB_IMAGE);
+  g_value_set_int         (gimp_value_array_index (return_vals, 5), 1);
 
-  g_value_init (&value, GIMP_TYPE_IMAGE_TYPE);
-  g_value_set_enum (&value, GIMP_RGB_IMAGE);
-  gimp_value_array_append (return_vals, &value);
-  g_value_unset (&value);
-
-  g_value_init (&value, G_TYPE_INT);
-  g_value_set_int (&value, 1);
-  gimp_value_array_append (return_vals, &value);
-  g_value_unset (&value);
+  gimp_value_array_truncate (return_vals, 6);
 
   return return_vals;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]