libgimp*: GimpParamSpecValueArray struct also hidden away!

New libgimpbase function: gimp_param_spec_value_array_get_element_spec()
This commit is contained in:
Jehan 2025-01-25 00:37:55 +01:00
parent f09d97b9a5
commit 080b09bb96
4 changed files with 54 additions and 35 deletions

View file

@ -158,6 +158,7 @@ EXPORTS
gimp_param_spec_unit_percent_allowed
gimp_param_spec_unit_pixel_allowed
gimp_param_spec_value_array
gimp_param_spec_value_array_get_element_spec
gimp_param_unit_get_type
gimp_param_value_array_get_type
gimp_parasite_compare

View file

@ -590,6 +590,26 @@ gimp_value_array_truncate (GimpValueArray *value_array,
* GIMP_TYPE_PARAM_VALUE_ARRAY
*/
#define GIMP_PARAM_SPEC_VALUE_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), GIMP_TYPE_PARAM_VALUE_ARRAY, GimpParamSpecValueArray))
typedef struct _GimpParamSpecValueArray GimpParamSpecValueArray;
/**
* GimpParamSpecValueArray:
* @parent_instance: private #GParamSpec portion
* @element_spec: the #GParamSpec of the array elements
* @fixed_n_elements: default length of the array
*
* A #GParamSpec derived structure that contains the meta data for
* value array properties.
**/
struct _GimpParamSpecValueArray
{
GParamSpec parent_instance;
GParamSpec *element_spec;
gint fixed_n_elements;
};
static void gimp_param_value_array_class_init (GParamSpecClass *klass);
static void gimp_param_value_array_init (GParamSpec *pspec);
static void gimp_param_value_array_finalize (GParamSpec *pspec);
@ -849,3 +869,19 @@ gimp_param_spec_value_array (const gchar *name,
return G_PARAM_SPEC (aspec);
}
/**
* gimp_param_spec_value_array_get_element_spec:
* @pspec: a #GParamSpec to hold a #GimpParamSpecValueArray value.
*
* Returns: (transfer none): param spec for elements of the value array.
*
* Since: 3.0
**/
GParamSpec *
gimp_param_spec_value_array_get_element_spec (GParamSpec *pspec)
{
g_return_val_if_fail (GIMP_IS_PARAM_SPEC_VALUE_ARRAY (pspec), NULL);
return GIMP_PARAM_SPEC_VALUE_ARRAY (pspec)->element_spec;
}

View file

@ -85,25 +85,7 @@ void gimp_value_array_truncate (GimpValueArray *
#define GIMP_TYPE_PARAM_VALUE_ARRAY (gimp_param_value_array_get_type ())
#define GIMP_IS_PARAM_SPEC_VALUE_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), GIMP_TYPE_PARAM_VALUE_ARRAY))
#define GIMP_PARAM_SPEC_VALUE_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), GIMP_TYPE_PARAM_VALUE_ARRAY, GimpParamSpecValueArray))
typedef struct _GimpParamSpecValueArray GimpParamSpecValueArray;
/**
* GimpParamSpecValueArray:
* @parent_instance: private #GParamSpec portion
* @element_spec: the #GParamSpec of the array elements
* @fixed_n_elements: default length of the array
*
* A #GParamSpec derived structure that contains the meta data for
* value array properties.
**/
struct _GimpParamSpecValueArray
{
GParamSpec parent_instance;
GParamSpec *element_spec;
gint fixed_n_elements;
};
GType gimp_param_value_array_get_type (void) G_GNUC_CONST;
@ -113,6 +95,8 @@ GParamSpec * gimp_param_spec_value_array (const gchar *name,
GParamSpec *element_spec,
GParamFlags flags);
GParamSpec * gimp_param_spec_value_array_get_element_spec (GParamSpec *pspec);
G_END_DECLS

View file

@ -824,14 +824,14 @@ gimp_config_deserialize_value_array (GValue *value,
GParamSpec *prop_spec,
GScanner *scanner)
{
GimpParamSpecValueArray *array_spec;
GParamSpec *element_spec;
GimpValueArray *array;
GValue array_value = G_VALUE_INIT;
gint n_values;
GTokenType token;
gint i;
array_spec = GIMP_PARAM_SPEC_VALUE_ARRAY (prop_spec);
element_spec = gimp_param_spec_value_array_get_element_spec (prop_spec);
if (! gimp_scanner_parse_int (scanner, &n_values))
return G_TOKEN_INT;
@ -840,12 +840,10 @@ gimp_config_deserialize_value_array (GValue *value,
for (i = 0; i < n_values; i++)
{
g_value_init (&array_value, array_spec->element_spec->value_type);
g_value_init (&array_value, element_spec->value_type);
token = gimp_config_deserialize_value (&array_value,
config,
array_spec->element_spec,
scanner);
token = gimp_config_deserialize_value (&array_value, config,
element_spec, scanner);
if (token == G_TOKEN_RIGHT_PAREN)
gimp_value_array_append (array, &array_value);