ScriptFu: fix #11001
At script create time, create a GimpRGB i.e. pixel from the declared name of default color. At plugin procedure registration time, convert that pixel to GeglColor, and use that color to declare the color arg using GeglParamSpecColor(default=color) Fixes a faulty fix a few commits back where we lost the declared color name. The proper dataflow is name->color->paramspec-with-default-color.
This commit is contained in:
@ -292,20 +292,12 @@ script_fu_arg_get_param_spec (SFArg *arg,
|
||||
break;
|
||||
|
||||
case SF_COLOR:
|
||||
/* FIXME by name is wrong, but that is a separate issue from refactor. */
|
||||
/* Set the default by name. */
|
||||
/* G_PARAM_READWRITE vs GIMP_PARAM_READWRITE, they are not equal. */
|
||||
pspec = gegl_param_spec_color_from_string (name, nick, arg->label,
|
||||
sf_color_arg_get_name_of_default (arg),
|
||||
G_PARAM_READWRITE);
|
||||
/* FIXME instead use this
|
||||
{
|
||||
GeglColor *color = sf_color_arg_get_color_of_default (arg);
|
||||
GeglColor *color = sf_color_arg_get_default_color (arg);
|
||||
|
||||
pspec = gegl_param_spec_color (name, nick, arg->label, color, G_PARAM_READWRITE);
|
||||
g_object_unref (color);
|
||||
}
|
||||
*/
|
||||
break;
|
||||
|
||||
case SF_TOGGLE:
|
||||
|
@ -61,29 +61,7 @@ sf_color_get_repr (SFColorType *arg_value)
|
||||
return g_strdup_printf ("'(%d %d %d)", (gint) r, (gint) g, (gint) b);
|
||||
}
|
||||
|
||||
/* FIXME sf_color_arg_get_name_of_default goes away after the refactor.
|
||||
* when we create a param spec by color, not by name.
|
||||
*/
|
||||
|
||||
/* Get the name of the default.
|
||||
*
|
||||
* Returns null when the default has no name,
|
||||
* when script author alternatively declared the color by a list of integers,
|
||||
* and that color doesn't represent a nameable color.
|
||||
*
|
||||
* Returned string is owned by instance/self.
|
||||
*/
|
||||
gchar*
|
||||
sf_color_arg_get_name_of_default (SFArg *arg)
|
||||
{
|
||||
/* FIXME get the default name declared at registration time.
|
||||
* or if not declared by name (optionally by list), return NULL.
|
||||
*/
|
||||
return "black";
|
||||
}
|
||||
|
||||
/* Get GeglColor
|
||||
* Knows that SFColorType is GimpRGB and format is quad of double.
|
||||
/* Returns GeglColor from SFColorType: GimpRGB w format quad of double.
|
||||
*
|
||||
* Returned GeglColor is owned by caller.
|
||||
*/
|
||||
|
@ -115,7 +115,5 @@ gboolean sf_color_arg_set_default_by_name (SFArg *arg,
|
||||
void sf_color_arg_set_default_by_color (SFArg *arg,
|
||||
GeglColor *color);
|
||||
GeglColor* sf_color_arg_get_default_color (SFArg *arg);
|
||||
/* FIXME this should go away. */
|
||||
gchar* sf_color_arg_get_name_of_default (SFArg *arg);
|
||||
|
||||
#endif /* __SCRIPT_FU_TYPES__ */
|
||||
|
Reference in New Issue
Block a user