[gimp] Bug 572997 - gih description alter when re-saving



commit dfabfb96642e38deef871cd8c8c109421b7e64cc
Author: Michael Natterer <mitch gimp org>
Date:   Sat Jan 19 20:52:27 2013 +0100

    Bug 572997 - gih description alter when re-saving
    
    Undeprecate, clean up and apply patch from Eric Lamarque which adds a
    "gimp-brush-pipe-name" parasite to remember the description.

 devel-docs/parasites.txt   |    6 ++++++
 plug-ins/common/file-gih.c |   41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/devel-docs/parasites.txt b/devel-docs/parasites.txt
index b782975..1aac78b 100644
--- a/devel-docs/parasites.txt
+++ b/devel-docs/parasites.txt
@@ -69,6 +69,12 @@ Global data follows no strict rules.
         saving .gbr files. A trailing \0 might be included and is not
         part of the name.
 
+"gimp-brush-pipe-name" (IMAGE, PERSISTENT)
+        A string in UTF-8 encoding specifying the name of a GIMP brush
+        pipe. Currently, the gih plug-in uses this parasite when loading and
+        saving .gih files. A trailing \0 might be included and is not
+        part of the name.
+
 "gimp-brush-pipe-parameters" (IMAGE, PERSISTENT)
 	This is all very preliminary:
 
diff --git a/plug-ins/common/file-gih.c b/plug-ins/common/file-gih.c
index 49b3097..4790091 100644
--- a/plug-ins/common/file-gih.c
+++ b/plug-ins/common/file-gih.c
@@ -234,6 +234,7 @@ run (const gchar      *name,
   static GimpParam   values[2];
   GimpRunMode        run_mode;
   GimpPDBStatusType  status = GIMP_PDB_SUCCESS;
+  GimpParasite      *name_parasite;
   GimpParasite      *pipe_parasite;
   gint32             image_ID;
   gint32             orig_image_ID;
@@ -319,6 +320,17 @@ run (const gchar      *name,
                 gimp_image_height (image_ID) / gihparams.rows;
             }
 
+          name_parasite =
+            gimp_image_get_parasite (orig_image_ID,
+                                     "gimp-brush-pipe-name");
+          if (name_parasite)
+            {
+              strncpy (info.description,
+                       gimp_parasite_data (name_parasite),
+                       MIN (MAXDESCLEN, gimp_parasite_data_size (name_parasite)));
+              info.description[MAXDESCLEN] = 0;
+            }
+
           pipe_parasite =
             gimp_image_get_parasite (orig_image_ID,
                                      "gimp-brush-pipe-parameters");
@@ -368,6 +380,18 @@ run (const gchar      *name,
 
         case GIMP_RUN_WITH_LAST_VALS:
           gimp_get_data (SAVE_PROC, &info);
+
+         name_parasite =
+           gimp_image_get_parasite (orig_image_ID,
+                                    "gimp-brush-pipe-name");
+         if (name_parasite)
+           {
+             strncpy (info.description,
+                      gimp_parasite_data (name_parasite),
+                      MIN (MAXDESCLEN, gimp_parasite_data_size (name_parasite)));
+             info.description[MAXDESCLEN] = 0;
+           }
+
           pipe_parasite =
             gimp_image_get_parasite (orig_image_ID,
                                      "gimp-brush-pipe-parameters");
@@ -561,6 +585,7 @@ gih_load_image (GFile   *file,
   gchar        *name = NULL;
   gint          num_of_brushes = 0;
   gchar        *paramstring;
+  GimpParasite *name_parasite;
   GimpParasite *pipe_parasite;
   gsize         bytes_read;
 
@@ -640,6 +665,14 @@ gih_load_image (GFile   *file,
 
   g_object_unref (input);
 
+  /*  Attaching name as a parasite */
+  name_parasite = gimp_parasite_new ("gimp-brush-pipe-name",
+                                     GIMP_PARASITE_PERSISTENT,
+                                     strlen (name) + 1,
+                                     name);
+  gimp_image_attach_parasite (image_ID, name_parasite);
+  gimp_parasite_free (name_parasite);
+
   while (*paramstring && g_ascii_isspace (*paramstring))
     paramstring++;
 
@@ -1162,6 +1195,7 @@ gih_save_image (GFile    *file,
                 GError  **error)
 {
   GOutputStream *output;
+  GimpParasite  *name_parasite;
   GimpParasite  *pipe_parasite;
   gchar         *header;
   gchar         *parstring;
@@ -1203,6 +1237,13 @@ gih_save_image (GFile    *file,
 
   g_free (header);
 
+  name_parasite = gimp_parasite_new ("gimp-brush-pipe-name",
+                                     GIMP_PARASITE_PERSISTENT,
+                                     strlen (info.description) + 1,
+                                     info.description);
+  gimp_image_attach_parasite (orig_image_ID, name_parasite);
+  gimp_parasite_free (name_parasite);
+
   pipe_parasite = gimp_parasite_new ("gimp-brush-pipe-parameters",
                                      GIMP_PARASITE_PERSISTENT,
                                      strlen (parstring) + 1, parstring);



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