Commit dfabfb96 authored by Michael Natterer's avatar Michael Natterer 😴

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.
parent d93d2e71
......@@ -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:
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment