From 8249afe2fc217ba7b599caf84bceabf4cfa8f9c5 Mon Sep 17 00:00:00 2001 From: Jehan Date: Tue, 13 Aug 2019 18:00:25 +0200 Subject: [PATCH] libgimp: allow object GParamSpec for GimpItem and child classes. --- libgimp/gimpgpparams-body.c | 18 ++++++++++++++++++ libgimp/gimpprocedure.c | 18 +++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/libgimp/gimpgpparams-body.c b/libgimp/gimpgpparams-body.c index b20cd768f8..3134da66a0 100644 --- a/libgimp/gimpgpparams-body.c +++ b/libgimp/gimpgpparams-body.c @@ -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; + } } } diff --git a/libgimp/gimpprocedure.c b/libgimp/gimpprocedure.c index 645b952a10..0d7821a151 100644 --- a/libgimp/gimpprocedure.c +++ b/libgimp/gimpprocedure.c @@ -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)