[gimp/wip/Jehan/classy-GIMP: 28/57] libgimp: allow object GParamSpec for GimpItem and child classes.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/Jehan/classy-GIMP: 28/57] libgimp: allow object GParamSpec for GimpItem and child classes.
- Date: Sat, 17 Aug 2019 08:56:50 +0000 (UTC)
commit a9828625473ef3d70c495e9110ae3ea8f4c3247d
Author: Jehan <jehan girinstud io>
Date: Tue Aug 13 18:00:25 2019 +0200
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 457b1ecca2..4af66964db 100644
--- a/libgimp/gimpgpparams-body.c
+++ b/libgimp/gimpgpparams-body.c
@@ -188,6 +188,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 9e2063aef5..7591d0775a 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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]