mirror of https://github.com/GNOME/gimp.git
libgimp: allow object GParamSpec for GimpItem and child classes.
This commit is contained in:
parent
433fcd4334
commit
8249afe2fc
|
@ -178,6 +178,24 @@ _gimp_param_spec_to_gp_param_def (GParamSpec *pspec,
|
|||
param_def->param_def_type = GP_PARAM_DEF_TYPE_ID;
|
||||
param_def->meta.m_id.none_ok = TRUE;
|
||||
}
|
||||
else if (g_strcmp0 (g_type_name (pspec->value_type), "GimpItem") == 0)
|
||||
{
|
||||
param_def->type_name = "GimpParamItemID";
|
||||
param_def->param_def_type = GP_PARAM_DEF_TYPE_ID;
|
||||
param_def->meta.m_id.none_ok = TRUE;
|
||||
}
|
||||
else if (g_strcmp0 (g_type_name (pspec->value_type), "GimpDrawable") == 0)
|
||||
{
|
||||
param_def->type_name = "GimpParamDrawableID";
|
||||
param_def->param_def_type = GP_PARAM_DEF_TYPE_ID;
|
||||
param_def->meta.m_id.none_ok = TRUE;
|
||||
}
|
||||
else if (g_strcmp0 (g_type_name (pspec->value_type), "GimpLayer") == 0)
|
||||
{
|
||||
param_def->type_name = "GimpParamLayerID";
|
||||
param_def->param_def_type = GP_PARAM_DEF_TYPE_ID;
|
||||
param_def->meta.m_id.none_ok = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1425,7 +1425,7 @@ gimp_procedure_validate_args (GimpProcedure *procedure,
|
|||
GType arg_type = G_VALUE_TYPE (arg);
|
||||
GType spec_type = G_PARAM_SPEC_VALUE_TYPE (pspec);
|
||||
|
||||
/* As a special case, validation can transform IDs into their
|
||||
/* As special cases, validation can transform IDs into their
|
||||
* respective object.
|
||||
*/
|
||||
if (arg_type == GIMP_TYPE_IMAGE_ID &&
|
||||
|
@ -1440,6 +1440,22 @@ gimp_procedure_validate_args (GimpProcedure *procedure,
|
|||
gimp_value_array_insert (args, i, &value);
|
||||
g_value_unset (&value);
|
||||
}
|
||||
else if ((arg_type == GIMP_TYPE_ITEM_ID &&
|
||||
spec_type == GIMP_TYPE_ITEM) ||
|
||||
(arg_type == GIMP_TYPE_DRAWABLE_ID &&
|
||||
spec_type == GIMP_TYPE_DRAWABLE) ||
|
||||
(arg_type == GIMP_TYPE_LAYER_ID &&
|
||||
spec_type == GIMP_TYPE_LAYER))
|
||||
{
|
||||
GValue value = G_VALUE_INIT;
|
||||
GimpItem *item = gimp_item_new_by_id (g_value_get_int (arg));
|
||||
|
||||
g_value_init (&value, spec_type);
|
||||
g_value_take_object (&value, item);
|
||||
gimp_value_array_remove (args, i);
|
||||
gimp_value_array_insert (args, i, &value);
|
||||
g_value_unset (&value);
|
||||
}
|
||||
else if (arg_type != spec_type)
|
||||
{
|
||||
if (return_vals)
|
||||
|
|
Loading…
Reference in New Issue