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



commit 951610a6ce124c5317a06436175c5499763b4535
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 6e0ba7c55b..8f47057c59 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 223648e45a..defa96f460 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);
@@ -146,8 +146,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)
@@ -155,12 +155,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)
     {
@@ -168,7 +168,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 |
@@ -181,8 +181,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)
         {
           strncpy (description,
@@ -244,8 +243,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,
@@ -279,17 +278,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 3290012cf6..d85762d47e 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]