[gimp/wip/Jehan/classy-GIMP: 35/60] plug-ins: port file-pat to GimpImage/GimpDrawable.



commit dfbbdaca46a3595bf23a51e387d872757dedc4c4
Author: Jehan <jehan girinstud io>
Date:   Wed Aug 14 15:41:47 2019 +0200

    plug-ins: port file-pat to GimpImage/GimpDrawable.

 plug-ins/common/Makefile.am    |  2 --
 plug-ins/common/file-pat.c     | 27 +++++++++++++--------------
 plug-ins/common/plugin-defs.pl |  2 +-
 3 files changed, 14 insertions(+), 17 deletions(-)
---
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index f2ca34a103..45b4a2a0f9 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -896,8 +896,6 @@ file_mng_LDADD = \
        $(INTLLIBS)             \
        $(file_mng_RC)
 
-file_pat_CPPFLAGS = $(AM_CPPFLAGS) -DGIMP_DEPRECATED_REPLACE_NEW_API
-
 file_pat_SOURCES = \
        file-pat.c
 
diff --git a/plug-ins/common/file-pat.c b/plug-ins/common/file-pat.c
index 97caf64194..4d15936f59 100644
--- a/plug-ins/common/file-pat.c
+++ b/plug-ins/common/file-pat.c
@@ -57,8 +57,8 @@ static GimpProcedure  * pat_create_procedure (GimpPlugIn           *plug_in,
 
 static GimpValueArray * pat_save             (GimpProcedure        *procedure,
                                               GimpRunMode           run_mode,
-                                              gint32                image_id,
-                                              gint32                drawable_id,
+                                              GimpImage            *image,
+                                              GimpDrawable         *drawable,
                                               GFile                *file,
                                               const GimpValueArray *args,
                                               gpointer              run_data);
@@ -140,8 +140,8 @@ pat_create_procedure (GimpPlugIn  *plug_in,
 static GimpValueArray *
 pat_save (GimpProcedure        *procedure,
           GimpRunMode           run_mode,
-          gint32                image_id,
-          gint32                drawable_id,
+          GimpImage            *image,
+          GimpDrawable         *drawable,
           GFile                *file,
           const GimpValueArray *args,
           gpointer              run_data)
@@ -149,12 +149,12 @@ pat_save (GimpProcedure        *procedure,
   GimpPDBStatusType  status = GIMP_PDB_SUCCESS;
   GimpExportReturn   export = GIMP_EXPORT_CANCEL;
   GimpParasite      *parasite;
-  gint32             orig_image_id;
+  GimpImage         *orig_image;
   GError            *error  = NULL;
 
   INIT_I18N ();
 
-  orig_image_id = image_id;
+  orig_image = image;
 
   switch (run_mode)
     {
@@ -162,7 +162,7 @@ pat_save (GimpProcedure        *procedure,
     case GIMP_RUN_WITH_LAST_VALS:
       gimp_ui_init (PLUG_IN_BINARY, FALSE);
 
-      export = gimp_export_image (&image_id, &drawable_id, "PAT",
+      export = gimp_export_image (&image, &drawable, "PAT",
                                   GIMP_EXPORT_CAN_HANDLE_GRAY    |
                                   GIMP_EXPORT_CAN_HANDLE_RGB     |
                                   GIMP_EXPORT_CAN_HANDLE_INDEXED |
@@ -175,8 +175,7 @@ pat_save (GimpProcedure        *procedure,
       /*  Possibly retrieve data  */
       gimp_get_data (SAVE_PROC, description);
 
-      parasite = gimp_image_get_parasite (orig_image_id,
-                                          "gimp-pattern-name");
+      parasite = gimp_image_get_parasite (orig_image, "gimp-pattern-name");
       if (parasite)
         {
           g_strlcpy (description,
@@ -233,8 +232,8 @@ pat_save (GimpProcedure        *procedure,
         gimp_pdb_run_procedure (gimp_get_pdb (),
                                 "file-pat-save-internal",
                                 GIMP_TYPE_RUN_MODE,    GIMP_RUN_NONINTERACTIVE,
-                                GIMP_TYPE_IMAGE_ID,    image_id,
-                                GIMP_TYPE_DRAWABLE_ID, drawable_id,
+                                GIMP_TYPE_IMAGE_ID,    gimp_image_get_id (image),
+                                GIMP_TYPE_DRAWABLE_ID, gimp_item_get_id (GIMP_ITEM (drawable)),
                                 G_TYPE_STRING,         uri,
                                 G_TYPE_STRING,         uri,
                                 G_TYPE_STRING,         description,
@@ -268,17 +267,17 @@ pat_save (GimpProcedure        *procedure,
                                     GIMP_PARASITE_PERSISTENT,
                                     strlen (description) + 1,
                                     description);
-      gimp_image_attach_parasite (orig_image_id, parasite);
+      gimp_image_attach_parasite (orig_image, parasite);
       gimp_parasite_free (parasite);
     }
   else
     {
-      gimp_image_detach_parasite (orig_image_id, "gimp-pattern-name");
+      gimp_image_detach_parasite (orig_image, "gimp-pattern-name");
     }
 
  out:
   if (export == GIMP_EXPORT_EXPORT)
-    gimp_image_delete (image_id);
+    gimp_image_delete (image);
 
   return gimp_procedure_new_return_values (procedure, status, error);
 }
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index 7954a637b8..3ea1f3abe2 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -33,7 +33,7 @@
     'file-html-table' => { ui => 1, gegl => 1, old_api => 1 },
     'file-jp2-load' => { ui => 1, optional => 1, gegl => 1, libs => 'OPENJPEG_LIBS', cflags => 
'OPENJPEG_CFLAGS', old_api => 1 },
     'file-mng' => { ui => 1, gegl => 1, optional => 1, libs => 'MNG_LIBS', cflags => 'MNG_CFLAGS', old_api 
=> 1 },
-    'file-pat' => { ui => 1, gegl => 1, old_api => 1 },
+    'file-pat' => { ui => 1, gegl => 1 },
     'file-pcx' => { ui => 1, gegl => 1, old_api => 1 },
     'file-pix' => { ui => 1, gegl => 1, old_api => 1 },
     'file-png' => { ui => 1, gegl => 1, libs => 'PNG_LIBS', cflags => 'PNG_CFLAGS', old_api => 1 },


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