plug-ins: replace gimp_[sg]et_data() with an aux str argument in ifs-compose.

The argument is the serialized description of the generated fractal. Actually it
may even be useful as a non-aux argument. A GFile argument could eventually be
interesting too, though one arg per setting would be better of course (it allows
more easily to generate animated frames for instance). In such a case, the GFile
would be used in priority, otherwise the other args.

Notes:

* I didn't port to GimpProcedureDialog though it looks like it would not be too
  hard (most of the GUI would still be custom GTK code, yet we could have the
  generic "reset to initial|factory values" buttons and load/save).
* The custom "Reset" button (identical to what "reset to factory values" would
  do) works fine anyway.
* The "run with last vals" works fine where there were indeed previous runs
  (which may be in previous sessions), but crashes when it's actually the first
  run ever. Some of the base structure data were not initialized. It should not
  be too hard yet would require a bit of code reorganization to fix this.
This commit is contained in:
Jehan 2023-10-25 17:40:02 +02:00
parent 0a0d66bda7
commit 8d6f281a72
1 changed files with 31 additions and 25 deletions

View File

@ -450,6 +450,11 @@ ifs_create_procedure (GimpPlugIn *plug_in,
"Owen Taylor",
"Owen Taylor",
"1997");
GIMP_PROC_AUX_ARG_STRING (procedure, "fractal-str",
"The fractal description serialized as string",
NULL, NULL,
GIMP_PARAM_READWRITE);
}
return procedure;
@ -518,17 +523,13 @@ ifs_run (GimpProcedure *procedure,
if (! found_parasite)
{
gint length = gimp_get_data_size (PLUG_IN_PROC);
gchar *data = NULL;
if (length > 0)
{
gchar *data = g_new (gchar, length);
gimp_get_data (PLUG_IN_PROC, data);
g_object_get (config, "fractal-str", &data, NULL);
if (data != NULL && strlen (data) > 0)
ifsvals_parse_string (data, &ifsvals, &elements);
g_free (data);
}
}
/* after ifsvals_parse_string, need to set up naming */
count_for_naming = ifsvals.num_elements;
@ -554,20 +555,26 @@ ifs_run (GimpProcedure *procedure,
case GIMP_RUN_WITH_LAST_VALS:
{
gint length = gimp_get_data_size (PLUG_IN_PROC);
gchar *data = NULL;
if (length > 0)
g_object_get (config, "fractal-str", &data, NULL);
if (data != NULL && strlen (data) > 0)
{
gchar *data = g_new (gchar, length);
gimp_get_data (PLUG_IN_PROC, data);
ifsvals_parse_string (data, &ifsvals, &elements);
g_free (data);
}
else
{
/* FIXME: there is a known crash in this code path, because some
* base structures (which are visibly created as part of the
* dialog or with ifsvals_parse_string() on a valid serialized
* fractal) don't exist. This should be fixed so that we can run
* with last vals even when no last vals exist (which should use
* defaults).
*/
ifs_compose_set_defaults ();
}
g_free (data);
}
break;
@ -589,8 +596,7 @@ ifs_run (GimpProcedure *procedure,
* as a parasite on this layer
*/
str = ifsvals_stringify (&ifsvals, elements);
gimp_set_data (PLUG_IN_PROC, str, strlen (str) + 1);
g_object_set (config, "fractal-str", str, NULL);
parasite = gimp_parasite_new (PLUG_IN_PARASITE,
GIMP_PARASITE_PERSISTENT |