mirror of https://github.com/GNOME/gimp.git
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:
parent
0a0d66bda7
commit
8d6f281a72
|
@ -450,6 +450,11 @@ ifs_create_procedure (GimpPlugIn *plug_in,
|
||||||
"Owen Taylor",
|
"Owen Taylor",
|
||||||
"Owen Taylor",
|
"Owen Taylor",
|
||||||
"1997");
|
"1997");
|
||||||
|
|
||||||
|
GIMP_PROC_AUX_ARG_STRING (procedure, "fractal-str",
|
||||||
|
"The fractal description serialized as string",
|
||||||
|
NULL, NULL,
|
||||||
|
GIMP_PARAM_READWRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return procedure;
|
return procedure;
|
||||||
|
@ -518,16 +523,12 @@ ifs_run (GimpProcedure *procedure,
|
||||||
|
|
||||||
if (! found_parasite)
|
if (! found_parasite)
|
||||||
{
|
{
|
||||||
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);
|
ifsvals_parse_string (data, &ifsvals, &elements);
|
||||||
|
g_free (data);
|
||||||
gimp_get_data (PLUG_IN_PROC, data);
|
|
||||||
ifsvals_parse_string (data, &ifsvals, &elements);
|
|
||||||
g_free (data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* after ifsvals_parse_string, need to set up naming */
|
/* after ifsvals_parse_string, need to set up naming */
|
||||||
|
@ -553,22 +554,28 @@ ifs_run (GimpProcedure *procedure,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GIMP_RUN_WITH_LAST_VALS:
|
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);
|
{
|
||||||
|
ifsvals_parse_string (data, &ifsvals, &elements);
|
||||||
|
}
|
||||||
|
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 ();
|
||||||
|
}
|
||||||
|
|
||||||
gimp_get_data (PLUG_IN_PROC, data);
|
g_free (data);
|
||||||
ifsvals_parse_string (data, &ifsvals, &elements);
|
}
|
||||||
g_free (data);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ifs_compose_set_defaults ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -589,8 +596,7 @@ ifs_run (GimpProcedure *procedure,
|
||||||
* as a parasite on this layer
|
* as a parasite on this layer
|
||||||
*/
|
*/
|
||||||
str = ifsvals_stringify (&ifsvals, elements);
|
str = ifsvals_stringify (&ifsvals, elements);
|
||||||
|
g_object_set (config, "fractal-str", str, NULL);
|
||||||
gimp_set_data (PLUG_IN_PROC, str, strlen (str) + 1);
|
|
||||||
|
|
||||||
parasite = gimp_parasite_new (PLUG_IN_PARASITE,
|
parasite = gimp_parasite_new (PLUG_IN_PARASITE,
|
||||||
GIMP_PARASITE_PERSISTENT |
|
GIMP_PARASITE_PERSISTENT |
|
||||||
|
|
Loading…
Reference in New Issue