From 0fc3b637ea6f6322d0f84f99a838cf9cc86a33d0 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Sat, 12 Jul 2008 08:20:14 +0000 Subject: [PATCH] added GIMP_TYPE_COLOR_ARRAY and GIMP_TYPE_PARAM_COLOR_ARRAY in preparation 2008-07-12 Sven Neumann * app/core/gimpparamspecs.[ch]: added GIMP_TYPE_COLOR_ARRAY and GIMP_TYPE_PARAM_COLOR_ARRAY in preparation for fixing bug #332206. svn path=/trunk/; revision=26150 --- ChangeLog | 5 ++ app/core/gimpparamspecs.c | 125 ++++++++++++++++++++++++++++++++++++++ app/core/gimpparamspecs.h | 45 ++++++++++++++ 3 files changed, 175 insertions(+) diff --git a/ChangeLog b/ChangeLog index 15fd86b0e5..2a40c1275f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-07-12 Sven Neumann + + * app/core/gimpparamspecs.[ch]: added GIMP_TYPE_COLOR_ARRAY and + GIMP_TYPE_PARAM_COLOR_ARRAY in preparation for fixing bug #332206. + 2008-07-12 Martin Nordholts * app/display/gimpdisplayshell-scale.c diff --git a/app/core/gimpparamspecs.c b/app/core/gimpparamspecs.c index 074ea3e9ca..09caaf193c 100644 --- a/app/core/gimpparamspecs.c +++ b/app/core/gimpparamspecs.c @@ -2805,3 +2805,128 @@ gimp_value_take_stringarray (GValue *value, g_value_take_boxed (value, array); } + + +/* + * GIMP_TYPE_COLOR_ARRAY + */ + +GType +gimp_color_array_get_type (void) +{ + static GType type = 0; + + if (! type) + type = g_boxed_type_register_static ("GimpColorArray", + (GBoxedCopyFunc) gimp_array_copy, + (GBoxedFreeFunc) gimp_array_free); + + return type; +} + + +/* + * GIMP_TYPE_PARAM_COLOR_ARRAY + */ + +static void gimp_param_color_array_class_init (GParamSpecClass *klass); +static void gimp_param_color_array_init (GParamSpec *pspec); + +GType +gimp_param_color_array_get_type (void) +{ + static GType type = 0; + + if (! type) + { + const GTypeInfo info = + { + sizeof (GParamSpecClass), + NULL, NULL, + (GClassInitFunc) gimp_param_color_array_class_init, + NULL, NULL, + sizeof (GimpParamSpecArray), + 0, + (GInstanceInitFunc) gimp_param_color_array_init + }; + + type = g_type_register_static (G_TYPE_PARAM_BOXED, + "GimpParamColorArray", &info, 0); + } + + return type; +} + +static void +gimp_param_color_array_class_init (GParamSpecClass *klass) +{ + klass->value_type = GIMP_TYPE_COLOR_ARRAY; +} + +static void +gimp_param_color_array_init (GParamSpec *pspec) +{ +} + +GParamSpec * +gimp_param_spec_color_array (const gchar *name, + const gchar *nick, + const gchar *blurb, + GParamFlags flags) +{ + GimpParamSpecColorArray *array_spec; + + array_spec = g_param_spec_internal (GIMP_TYPE_PARAM_COLOR_ARRAY, + name, nick, blurb, flags); + + return G_PARAM_SPEC (array_spec); +} + +const GimpRGB * +gimp_value_get_colorarray (const GValue *value) +{ + g_return_val_if_fail (GIMP_VALUE_HOLDS_COLOR_ARRAY (value), NULL); + + return (const GimpRGB *) gimp_value_get_array (value); +} + +GimpRGB * +gimp_value_dup_colorarray (const GValue *value) +{ + g_return_val_if_fail (GIMP_VALUE_HOLDS_COLOR_ARRAY (value), NULL); + + return (GimpRGB *) gimp_value_dup_array (value); +} + +void +gimp_value_set_colorarray (GValue *value, + const GimpRGB *data, + gsize length) +{ + g_return_if_fail (GIMP_VALUE_HOLDS_COLOR_ARRAY (value)); + + gimp_value_set_array (value, (const guint8 *) data, + length * sizeof (GimpRGB)); +} + +void +gimp_value_set_static_colorarray (GValue *value, + const GimpRGB *data, + gsize length) +{ + g_return_if_fail (GIMP_VALUE_HOLDS_COLOR_ARRAY (value)); + + gimp_value_set_static_array (value, (const guint8 *) data, + length * sizeof (GimpRGB)); +} + +void +gimp_value_take_colorarray (GValue *value, + GimpRGB *data, + gsize length) +{ + g_return_if_fail (GIMP_VALUE_HOLDS_COLOR_ARRAY (value)); + + gimp_value_take_array (value, (guint8 *) data, + length * sizeof (GimpRGB)); +} diff --git a/app/core/gimpparamspecs.h b/app/core/gimpparamspecs.h index ca8918e0ef..29c9140016 100644 --- a/app/core/gimpparamspecs.h +++ b/app/core/gimpparamspecs.h @@ -859,4 +859,49 @@ void gimp_value_take_stringarray (GValue *value, gsize length); +/* + * GIMP_TYPE_COLOR_ARRAY + */ + +#define GIMP_TYPE_COLOR_ARRAY (gimp_color_array_get_type ()) +#define GIMP_VALUE_HOLDS_COLOR_ARRAY(value) (G_TYPE_CHECK_VALUE_TYPE ((value), GIMP_TYPE_COLOR_ARRAY)) + +GType gimp_color_array_get_type (void) G_GNUC_CONST; + + +/* + * GIMP_TYPE_PARAM_COLOR_ARRAY + */ + +#define GIMP_TYPE_PARAM_COLOR_ARRAY (gimp_param_color_array_get_type ()) +#define GIMP_PARAM_SPEC_COLOR_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), GIMP_TYPE_PARAM_COLOR_ARRAY, GimpParamSpecColorArray)) +#define GIMP_IS_PARAM_SPEC_COLOR_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), GIMP_TYPE_PARAM_COLOR_ARRAY)) + +typedef struct _GimpParamSpecColorArray GimpParamSpecColorArray; + +struct _GimpParamSpecColorArray +{ + GParamSpecBoxed parent_instance; +}; + +GType gimp_param_color_array_get_type (void) G_GNUC_CONST; + +GParamSpec * gimp_param_spec_color_array (const gchar *name, + const gchar *nick, + const gchar *blurb, + GParamFlags flags); + +const GimpRGB * gimp_value_get_colorarray (const GValue *value); +GimpRGB * gimp_value_dup_colorarray (const GValue *value); +void gimp_value_set_colorarray (GValue *value, + const GimpRGB *array, + gsize length); +void gimp_value_set_static_colorarray (GValue *value, + const GimpRGB *array, + gsize length); +void gimp_value_take_colorarray (GValue *value, + GimpRGB *array, + gsize length); + + #endif /* __GIMP_PARAM_SPECS_H__ */