From f09d97b9a51030ee5773d491d7ce869001803b85 Mon Sep 17 00:00:00 2001 From: Jehan Date: Sat, 25 Jan 2025 00:02:29 +0100 Subject: [PATCH] app, libgimp*: GimpParamSpecCoreObjectArray struct hidden too. New libgimpbase function: gimp_param_spec_core_object_array_get_object_type() --- app/plug-in/gimppluginprocedure.c | 6 ++---- libgimp/gimpgpparams-body.c | 4 ++-- libgimp/gimpprocedureconfig.c | 8 ++++---- libgimpbase/gimpbase.def | 1 + libgimpbase/gimpparamspecs.c | 27 +++++++++++++++++++++++++++ libgimpbase/gimpparamspecs.h | 22 +++++++--------------- libgimpconfig/gimpconfig-params.c | 4 +--- 7 files changed, 44 insertions(+), 28 deletions(-) diff --git a/app/plug-in/gimppluginprocedure.c b/app/plug-in/gimppluginprocedure.c index 67289824f9..91d135879a 100644 --- a/app/plug-in/gimppluginprocedure.c +++ b/app/plug-in/gimppluginprocedure.c @@ -672,8 +672,7 @@ gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure *proc, } else { - GimpParamSpecCoreObjectArray *spec = GIMP_PARAM_SPEC_CORE_OBJECT_ARRAY (procedure->args[2]); - const gchar *type_name = g_type_name (spec->object_type); + const gchar *type_name = g_type_name (gimp_param_spec_core_object_array_get_object_type (procedure->args[2])); if (g_strcmp0 (type_name, "GimpDrawable") != 0 && g_strcmp0 (type_name, "GimpLayer") != 0) @@ -695,8 +694,7 @@ gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure *proc, } else { - GimpParamSpecCoreObjectArray *spec = GIMP_PARAM_SPEC_CORE_OBJECT_ARRAY (procedure->args[2]); - const gchar *type_name = g_type_name (spec->object_type); + const gchar *type_name = g_type_name (gimp_param_spec_core_object_array_get_object_type (procedure->args[2])); if (g_strcmp0 (type_name, "GimpDrawable") != 0 && g_strcmp0 (type_name, "GimpChannel") != 0) diff --git a/libgimp/gimpgpparams-body.c b/libgimp/gimpgpparams-body.c index 2098169093..92d3e69475 100644 --- a/libgimp/gimpgpparams-body.c +++ b/libgimp/gimpgpparams-body.c @@ -685,7 +685,7 @@ _gimp_param_spec_to_gp_param_def (GParamSpec *pspec, param_def->param_def_type = GP_PARAM_DEF_TYPE_ID_ARRAY; param_def->meta.m_id_array.type_name = - (gchar *) g_type_name (GIMP_PARAM_SPEC_CORE_OBJECT_ARRAY (pspec)->object_type); + (gchar *) g_type_name (gimp_param_spec_core_object_array_get_object_type (pspec)); } else if (pspec_type == GIMP_TYPE_PARAM_EXPORT_OPTIONS) { @@ -1090,7 +1090,7 @@ gimp_gp_param_to_value (gpointer gimp, } else if (pspec != NULL) { - object_type = GIMP_PARAM_SPEC_CORE_OBJECT_ARRAY (pspec)->object_type; + object_type = gimp_param_spec_core_object_array_get_object_type (pspec); } if (param->data.d_id_array.size > 1 && ! g_type_is_a (object_type, G_TYPE_OBJECT)) diff --git a/libgimp/gimpprocedureconfig.c b/libgimp/gimpprocedureconfig.c index f157e19358..ee0cafee37 100644 --- a/libgimp/gimpprocedureconfig.c +++ b/libgimp/gimpprocedureconfig.c @@ -450,7 +450,7 @@ gimp_procedure_config_save_metadata (GimpProcedureConfig *config, /** * gimp_procedure_config_get_core_object_array: * @config: a #GimpProcedureConfig - * @property_name: the name of a [struct@ParamSpecCoreObjectArray] param spec. + * @property_name: the name of a #GimpParamSpecCoreObjectArray param spec. * * A function for bindings to get a [type@CoreObjectArray] property. Getting * these with [method@GObject.Object.get] or [method@GObject.Object.get_property] won't @@ -501,7 +501,7 @@ gimp_procedure_config_get_core_object_array (GimpProcedureConfig *config, /** * gimp_procedure_config_set_core_object_array: * @config: a #GimpProcedureConfig - * @property_name: the name of a [struct@ParamSpecCoreObjectArray] param spec. + * @property_name: the name of a #GimpParamSpecCoreObjectArray param spec. * @objects: (array length=n_objects) (transfer none): an array of #GObjects. * @n_objects: the numbers of @objects. * @@ -560,7 +560,7 @@ gimp_procedure_config_set_core_object_array (GimpProcedureConfig *config, /** * gimp_procedure_config_get_color_array: * @config: a #GimpProcedureConfig - * @property_name: the name of a [struct@ParamSpecCoreObjectArray] param spec. + * @property_name: the name of a #GParamSpecBoxed param spec with [type@ColorArray] value type. * * A function for bindings to get a [type@ColorArray] property. Getting * these with [method@GObject.Object.get] or [method@GObject.Object.get_property] won't @@ -612,7 +612,7 @@ gimp_procedure_config_get_color_array (GimpProcedureConfig *config, /** * gimp_procedure_config_set_color_array: * @config: a #GimpProcedureConfig - * @property_name: the name of a [struct@ParamSpecCoreObjectArray] param spec. + * @property_name: the name of a #GParamSpecBoxed param spec with [type@ColorArray] value type. * @colors: (array length=n_colors) (transfer none): an array of [class@Gegl.Color]. * @n_colors: the numbers of @colors. * diff --git a/libgimpbase/gimpbase.def b/libgimpbase/gimpbase.def index 3a93b6c728..a7bb794bdd 100644 --- a/libgimpbase/gimpbase.def +++ b/libgimpbase/gimpbase.def @@ -141,6 +141,7 @@ EXPORTS gimp_param_spec_array gimp_param_spec_choice gimp_param_spec_core_object_array + gimp_param_spec_core_object_array_get_object_type gimp_param_spec_double_array gimp_param_spec_export_options gimp_param_spec_file diff --git a/libgimpbase/gimpparamspecs.c b/libgimpbase/gimpparamspecs.c index a26d725c9f..75e9f88934 100644 --- a/libgimpbase/gimpparamspecs.c +++ b/libgimpbase/gimpparamspecs.c @@ -1323,6 +1323,17 @@ gimp_core_object_array_copy (GimpCoreObjectArray array) * GIMP_TYPE_PARAM_CORE_OBJECT_ARRAY */ +#define GIMP_PARAM_SPEC_CORE_OBJECT_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), GIMP_TYPE_PARAM_CORE_OBJECT_ARRAY, GimpParamSpecCoreObjectArray)) + +typedef struct _GimpParamSpecCoreObjectArray GimpParamSpecCoreObjectArray; + +struct _GimpParamSpecCoreObjectArray +{ + GParamSpecBoxed parent_instance; + + GType object_type; +}; + static void gimp_param_core_object_array_class_init (GParamSpecClass *klass); static void gimp_param_core_object_array_init (GParamSpec *pspec); static gboolean gimp_param_core_object_array_validate (GParamSpec *pspec, @@ -1463,3 +1474,19 @@ gimp_param_spec_core_object_array (const gchar *name, return G_PARAM_SPEC (array_spec); } + +/** + * gimp_param_spec_core_object_array_get_object_type: + * @pspec: a #GParamSpec to hold a #GimpParamSpecCoreObjectArray value. + * + * Returns: the type for objects in the object array. + * + * Since: 3.0 + **/ +GType +gimp_param_spec_core_object_array_get_object_type (GParamSpec *pspec) +{ + g_return_val_if_fail (GIMP_IS_PARAM_SPEC_CORE_OBJECT_ARRAY (pspec), G_TYPE_NONE); + + return GIMP_PARAM_SPEC_CORE_OBJECT_ARRAY (pspec)->object_type; +} diff --git a/libgimpbase/gimpparamspecs.h b/libgimpbase/gimpparamspecs.h index 9921fd3e61..05ce17079f 100644 --- a/libgimpbase/gimpparamspecs.h +++ b/libgimpbase/gimpparamspecs.h @@ -396,25 +396,17 @@ gsize gimp_core_object_array_get_length (GObject **array); */ #define GIMP_TYPE_PARAM_CORE_OBJECT_ARRAY (gimp_param_core_object_array_get_type ()) -#define GIMP_PARAM_SPEC_CORE_OBJECT_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), GIMP_TYPE_PARAM_CORE_OBJECT_ARRAY, GimpParamSpecCoreObjectArray)) #define GIMP_IS_PARAM_SPEC_CORE_OBJECT_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), GIMP_TYPE_PARAM_CORE_OBJECT_ARRAY)) -typedef struct _GimpParamSpecCoreObjectArray GimpParamSpecCoreObjectArray; +GType gimp_param_core_object_array_get_type (void) G_GNUC_CONST; -struct _GimpParamSpecCoreObjectArray -{ - GParamSpecBoxed parent_instance; +GParamSpec * gimp_param_spec_core_object_array (const gchar *name, + const gchar *nick, + const gchar *blurb, + GType object_type, + GParamFlags flags); - GType object_type; -}; - -GType gimp_param_core_object_array_get_type (void) G_GNUC_CONST; - -GParamSpec * gimp_param_spec_core_object_array (const gchar *name, - const gchar *nick, - const gchar *blurb, - GType object_type, - GParamFlags flags); +GType gimp_param_spec_core_object_array_get_object_type (GParamSpec *pspec); G_END_DECLS diff --git a/libgimpconfig/gimpconfig-params.c b/libgimpconfig/gimpconfig-params.c index 9902b95eab..d8fcfb2983 100644 --- a/libgimpconfig/gimpconfig-params.c +++ b/libgimpconfig/gimpconfig-params.c @@ -295,10 +295,8 @@ gimp_config_param_spec_duplicate (GParamSpec *pspec) } else if (GIMP_IS_PARAM_SPEC_CORE_OBJECT_ARRAY (pspec)) { - GimpParamSpecCoreObjectArray *spec = GIMP_PARAM_SPEC_CORE_OBJECT_ARRAY (pspec); - copy = gimp_param_spec_core_object_array (name, nick, blurb, - spec->object_type, + gimp_param_spec_core_object_array_get_object_type (pspec), flags); } else if (GIMP_IS_PARAM_SPEC_EXPORT_OPTIONS (pspec))