[gimp/wip/Jehan/classy-GIMP: 2/17] libgimp: support all GimpItem subclasses as argument and return values.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/Jehan/classy-GIMP: 2/17] libgimp: support all GimpItem subclasses as argument and return values.
- Date: Thu, 15 Aug 2019 22:31:57 +0000 (UTC)
commit ae4ce26e04c6d9a6036b9be7dda4006c75109e84
Author: Jehan <jehan girinstud io>
Date: Wed Aug 14 14:56:28 2019 +0200
libgimp: support all GimpItem subclasses as argument and return values.
libgimp/gimpgpparams-body.c | 82 ++++++++++++++++++++++++++++++++++++---------
libgimp/gimpgpparams.c | 2 ++
2 files changed, 68 insertions(+), 16 deletions(-)
---
diff --git a/libgimp/gimpgpparams-body.c b/libgimp/gimpgpparams-body.c
index 4af66964db..6476a2855c 100644
--- a/libgimp/gimpgpparams-body.c
+++ b/libgimp/gimpgpparams-body.c
@@ -183,26 +183,26 @@ _gimp_param_spec_to_gp_param_def (GParamSpec *pspec,
* included from app/ which won't know of the types.
*/
if (g_strcmp0 (g_type_name (pspec->value_type), "GimpImage") == 0)
- {
- param_def->type_name = "GimpParamImageID";
- param_def->param_def_type = GP_PARAM_DEF_TYPE_ID;
- param_def->meta.m_id.none_ok = TRUE;
- }
+ param_def->type_name = "GimpParamImageID";
+ if (g_strcmp0 (g_type_name (pspec->value_type), "GimpDisplay") == 0)
+ param_def->type_name = "GimpParamDisplayID";
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;
- }
+ param_def->type_name = "GimpParamItemID";
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;
- }
+ param_def->type_name = "GimpParamDrawableID";
else if (g_strcmp0 (g_type_name (pspec->value_type), "GimpLayer") == 0)
+ param_def->type_name = "GimpParamLayerID";
+ else if (g_strcmp0 (g_type_name (pspec->value_type), "GimpChannel") == 0)
+ param_def->type_name = "GimpParamChannelID";
+ else if (g_strcmp0 (g_type_name (pspec->value_type), "GimpLayerMask") == 0)
+ param_def->type_name = "GimpParamLayerMaskID";
+ else if (g_strcmp0 (g_type_name (pspec->value_type), "GimpSelection") == 0)
+ param_def->type_name = "GimpParamSelectionID";
+ else if (g_strcmp0 (g_type_name (pspec->value_type), "GimpVectors") == 0)
+ param_def->type_name = "GimpParamVectorsID";
+
+ if (G_PARAM_SPEC_TYPE_NAME (pspec) != param_def->type_name)
{
- param_def->type_name = "GimpParamLayerID";
param_def->param_def_type = GP_PARAM_DEF_TYPE_ID;
param_def->meta.m_id.none_ok = TRUE;
}
@@ -620,6 +620,56 @@ _gimp_value_to_gp_param (const GValue *value,
_gimp_param_spec_to_gp_param_def (g_value_get_param (value),
¶m->data.d_param_def);
}
+ else if (G_VALUE_HOLDS_OBJECT (value))
+ {
+#ifdef __LIBGIMP_GPPARAMS__
+ GObject *object = g_value_get_object (value);
+ const gchar *type_name = NULL;
+
+ if (full_copy)
+ g_clear_pointer (¶m->type_name, g_free);
+
+ if (GIMP_IS_IMAGE (object))
+ {
+ type_name = "GimpImageID";
+ param->param_type = GP_PARAM_TYPE_INT;
+ param->data.d_int = gimp_image_get_id (GIMP_IMAGE (object));
+ }
+ if (GIMP_IS_DISPLAY (object))
+ {
+ type_name = "GimpDisplayID";
+ param->param_type = GP_PARAM_TYPE_INT;
+ param->data.d_int = gimp_display_get_id (GIMP_DISPLAY (object));
+ }
+ else if (GIMP_IS_ITEM (object))
+ {
+ param->param_type = GP_PARAM_TYPE_INT;
+ param->data.d_int = gimp_item_get_id (GIMP_ITEM (object));
+
+ if (GIMP_IS_LAYER (object))
+ type_name = "GimpLayerID";
+ else if (GIMP_IS_LAYER_MASK (object))
+ type_name = "GimpLayerMaskID";
+ else if (GIMP_IS_SELECTION (object))
+ type_name = "GimpSelectionID";
+ else if (GIMP_IS_VECTORS (object))
+ type_name = "GimpVectorsID";
+ else if (GIMP_IS_CHANNEL (object))
+ type_name = "GimpChannelID";
+ else if (GIMP_IS_DRAWABLE (object))
+ type_name = "GimpDrawableID";
+ else
+ type_name = "GimpItemID";
+ }
+ if (type_name)
+ {
+ if (full_copy)
+ param->type_name = g_strdup (type_name);
+ else
+ param->type_name = (gchar *) type_name;
+ }
+#endif /* __LIBGIMP_GPPARAMS__ */
+ }
if (param->param_type == -1)
g_printerr ("%s: GValue contains unsupported type '%s'\n",
diff --git a/libgimp/gimpgpparams.c b/libgimp/gimpgpparams.c
index e740fce7fc..e94f4653e4 100644
--- a/libgimp/gimpgpparams.c
+++ b/libgimp/gimpgpparams.c
@@ -37,7 +37,9 @@
/* include the implementation, they are shared between app/ and
* libgimp/ but need different headers.
*/
+#define __LIBGIMP_GPPARAMS__
#include "gimpgpparams-body.c"
+#undef __LIBGIMP_GPPARAMS__
GParamSpec *
_gimp_gp_param_def_to_param_spec (gpointer gimp,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]