libgimp*, plug-ins: filter ID are now usable in script-fu.

Marshalled PDB procedures into script-fu can now convert a filter ID
into the proper object. For instance, here would be the code to append a
new gaussian blur filter to the drawable with ID 2 (with specific
settings), then making invisible:

```script-fu
(define filter (gimp-drawable-append-new-filter 2 "gegl:gaussian-blur" "hello" LAYER-MODE-COLOR-ERASE 1.0 "std-dev-x" 20 "abyss-policy" "none"))
(gimp-drawable-filter-set-visible filter FALSE)
(gimp-drawable-update 2 0 0 -1 -1)
```
This commit is contained in:
Jehan 2024-12-14 14:42:37 +01:00
parent 39df978c2c
commit e5134e67aa
3 changed files with 53 additions and 12 deletions

View File

@ -290,6 +290,11 @@ _gimp_gp_param_def_to_param_spec (const GPParamDef *param_def)
return gimp_param_spec_path (name, nick, blurb,
param_def->meta.m_id.none_ok,
flags);
if (! strcmp (param_def->type_name, "GimpParamDrawableFilter"))
return gimp_param_spec_drawable_filter (name, nick, blurb,
param_def->meta.m_id.none_ok,
flags);
break;
case GP_PARAM_DEF_TYPE_ID_ARRAY:
@ -585,6 +590,14 @@ _gimp_param_spec_to_gp_param_def (GParamSpec *pspec,
param_def->meta.m_id.none_ok = ispec->none_ok;
}
else if (GIMP_IS_PARAM_SPEC_DRAWABLE_FILTER (pspec))
{
GimpParamSpecDrawableFilter *fspec = GIMP_PARAM_SPEC_DRAWABLE_FILTER (pspec);
param_def->param_def_type = GP_PARAM_DEF_TYPE_ID;
param_def->meta.m_id.none_ok = fspec->none_ok;
}
else if (pspec_type == GIMP_TYPE_PARAM_DISPLAY)
{
GimpParamSpecDisplay *ispec = GIMP_PARAM_SPEC_DISPLAY (pspec);

View File

@ -324,7 +324,8 @@ gimp_config_param_spec_duplicate (GParamSpec *pspec)
g_strcmp0 (type_name, "GimpItem") == 0 ||
g_strcmp0 (type_name, "GimpLayerMask") == 0 ||
g_strcmp0 (type_name, "GimpSelection") == 0 ||
g_strcmp0 (type_name, "GimpPath") == 0)
g_strcmp0 (type_name, "GimpPath") == 0 ||
g_strcmp0 (type_name, "GimpDrawableFilter") == 0)
{
copy = g_param_spec_object (name, nick, blurb,
value_type,

View File

@ -1024,6 +1024,33 @@ script_fu_marshal_arg_to_value (scheme *sc,
}
}
}
else if (GIMP_VALUE_HOLDS_DRAWABLE_FILTER (value))
{
if (! sc->vptr->is_number (arg_val))
{
return script_type_error (sc, "numeric", arg_index, proc_name);
}
else
{
gint id;
id = sc->vptr->ivalue (arg_val);
if (gimp_drawable_filter_id_is_valid (id))
{
GimpDrawableFilter *filter = gimp_drawable_filter_get_by_id (id);
g_value_set_object (value, filter);
}
else
{
/* Filter ID is invalid.
* Usually 0 or -1, passed for a nullable arg.
*/
g_value_set_object (value, NULL);
}
}
}
else if (GIMP_VALUE_HOLDS_INT32_ARRAY (value))
{
vector = arg_val;