[gimp/wip/Jehan/classy-GIMP: 44/45] plug-ins: port fractal-explorer to GimpImage|Drawable.



commit 538f74c72ca13411301cd6d1d16d35d7189ec5a9
Author: Jehan <jehan girinstud io>
Date:   Sat Aug 17 11:06:19 2019 +0200

    plug-ins: port fractal-explorer to GimpImage|Drawable.

 plug-ins/fractal-explorer/Makefile.am        |  1 -
 plug-ins/fractal-explorer/fractal-explorer.c | 50 ++++++++++++++--------------
 2 files changed, 25 insertions(+), 26 deletions(-)
---
diff --git a/plug-ins/fractal-explorer/Makefile.am b/plug-ins/fractal-explorer/Makefile.am
index d961e7bc92..2905f1f6e5 100644
--- a/plug-ins/fractal-explorer/Makefile.am
+++ b/plug-ins/fractal-explorer/Makefile.am
@@ -34,7 +34,6 @@ fractal_explorer_SOURCES = \
        fractal-explorer.h
 
 AM_CPPFLAGS = \
-       -DGIMP_DEPRECATED_REPLACE_NEW_API \
        -I$(top_srcdir) \
        $(GTK_CFLAGS)   \
        $(GEGL_CFLAGS) \
diff --git a/plug-ins/fractal-explorer/fractal-explorer.c b/plug-ins/fractal-explorer/fractal-explorer.c
index a19815d032..6a4fa04f0c 100644
--- a/plug-ins/fractal-explorer/fractal-explorer.c
+++ b/plug-ins/fractal-explorer/fractal-explorer.c
@@ -97,7 +97,7 @@ static GimpValueArray * explorer_run              (GimpProcedure        *procedu
                                                    const GimpValueArray *args,
                                                    gpointer              run_data);
 
-static void       explorer                         (gint32              drawable_id);
+static void       explorer                         (GimpDrawable       *drawable);
 
 static void       delete_dialog_callback           (GtkWidget          *widget,
                                                     gboolean            value,
@@ -157,7 +157,7 @@ gchar               *fractalexplorer_path = NULL;
 
 static gfloat        cx = -0.75;
 static gfloat        cy = -0.2;
-gint32               drawable_id;
+GimpDrawable        *drawable;
 static GList        *fractalexplorer_list = NULL;
 
 explorer_interface_t wint =
@@ -252,17 +252,17 @@ explorer_create_procedure (GimpPlugIn  *plug_in,
                                                       GIMP_RUN_NONINTERACTIVE,
                                                       G_PARAM_READWRITE));
       gimp_procedure_add_argument (procedure,
-                                   gimp_param_spec_image_id ("image",
-                                                             "Image",
-                                                             "The input image",
-                                                             FALSE,
-                                                             G_PARAM_READWRITE));
+                                   g_param_spec_object ("image",
+                                                        "Image",
+                                                        "The input image",
+                                                        GIMP_TYPE_IMAGE,
+                                                        G_PARAM_READWRITE));
       gimp_procedure_add_argument (procedure,
-                                   gimp_param_spec_drawable_id ("drawable",
-                                                                "Drawable",
-                                                                "The input drawable",
-                                                                FALSE,
-                                                                G_PARAM_READWRITE));
+                                   g_param_spec_object ("drawable",
+                                                        "Drawable",
+                                                        "The input drawable",
+                                                        GIMP_TYPE_DRAWABLE,
+                                                        G_PARAM_READWRITE));
       gimp_procedure_add_argument (procedure,
                                    g_param_spec_int ("fractal-type",
                                                      "Fractal type",
@@ -427,10 +427,10 @@ explorer_run (GimpProcedure        *procedure,
   INIT_I18N ();
   gegl_init (NULL, NULL);
 
-  run_mode    = g_value_get_enum           (gimp_value_array_index (args, 0));
-  drawable_id = gimp_value_get_drawable_id (gimp_value_array_index (args, 2));
+  run_mode = g_value_get_enum   (gimp_value_array_index (args, 0));
+  drawable = g_value_get_object (gimp_value_array_index (args, 2));
 
-  if (! gimp_drawable_mask_intersect (drawable_id,
+  if (! gimp_drawable_mask_intersect (drawable,
                                       &sel_x, &sel_y,
                                       &sel_width, &sel_height))
     {
@@ -510,7 +510,7 @@ explorer_run (GimpProcedure        *procedure,
     {
       gimp_progress_init (_("Rendering fractal"));
 
-      explorer (drawable_id);
+      explorer (drawable);
 
       if (run_mode != GIMP_RUN_NONINTERACTIVE)
         gimp_displays_flush ();
@@ -529,7 +529,7 @@ explorer_run (GimpProcedure        *procedure,
  *********************************************************************/
 
 static void
-explorer (gint32 drawable_id)
+explorer (GimpDrawable *drawable)
 {
   GeglBuffer *src_buffer;
   GeglBuffer *dest_buffer;
@@ -551,16 +551,16 @@ explorer (gint32 drawable_id)
    *  need to be done for correct operation. (It simply makes it go
    *  faster, since fewer pixels need to be operated on).
    */
-  if (! gimp_drawable_mask_intersect (drawable_id, &x, &y, &w, &h))
+  if (! gimp_drawable_mask_intersect (drawable, &x, &y, &w, &h))
     return;
 
   /* Get the size of the input image. (This will/must be the same
    *  as the size of the output image.
    */
-  width  = gimp_drawable_width  (drawable_id);
-  height = gimp_drawable_height (drawable_id);
+  width  = gimp_drawable_width  (drawable);
+  height = gimp_drawable_height (drawable);
 
-  if (gimp_drawable_has_alpha (drawable_id))
+  if (gimp_drawable_has_alpha (drawable))
     format = babl_format ("R'G'B'A u8");
   else
     format = babl_format ("R'G'B' u8");
@@ -571,8 +571,8 @@ explorer (gint32 drawable_id)
   src_row  = g_new (guchar, bpp * w);
   dest_row = g_new (guchar, bpp * w);
 
-  src_buffer  = gimp_drawable_get_buffer (drawable_id);
-  dest_buffer = gimp_drawable_get_shadow_buffer (drawable_id);
+  src_buffer  = gimp_drawable_get_buffer (drawable);
+  dest_buffer = gimp_drawable_get_shadow_buffer (drawable);
 
   xbild = width;
   ybild = height;
@@ -608,8 +608,8 @@ explorer (gint32 drawable_id)
   gimp_progress_update (1.0);
 
   /*  update the processed region  */
-  gimp_drawable_merge_shadow (drawable_id, TRUE);
-  gimp_drawable_update (drawable_id, x, y, w, h);
+  gimp_drawable_merge_shadow (drawable, TRUE);
+  gimp_drawable_update (drawable, x, y, w, h);
 }
 
 /**********************************************************************


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