gimp r25704 - in trunk: . app/core
- From: mitch svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r25704 - in trunk: . app/core
- Date: Sun, 18 May 2008 20:07:08 +0000 (UTC)
Author: mitch
Date: Sun May 18 20:07:07 2008
New Revision: 25704
URL: http://svn.gnome.org/viewvc/gimp?rev=25704&view=rev
Log:
2008-05-18 Michael Natterer <mitch gimp org>
* app/core/gimpcurve.c: implement (de)serializing of the points
and samples arrays using GValueArray. Set "identity" to FALSE
after deserializing.
Modified:
trunk/ChangeLog
trunk/app/core/gimpcurve.c
Modified: trunk/app/core/gimpcurve.c
==============================================================================
--- trunk/app/core/gimpcurve.c (original)
+++ trunk/app/core/gimpcurve.c Sun May 18 20:07:07 2008
@@ -127,6 +127,7 @@
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
GimpDataClass *data_class = GIMP_DATA_CLASS (klass);
+ GParamSpec *array_spec;
object_class->finalize = gimp_curve_finalize;
object_class->set_property = gimp_curve_set_property;
@@ -156,22 +157,28 @@
"The number of points",
17, 17, 17, 0);
+ array_spec = g_param_spec_double ("point", NULL, NULL,
+ -1.0, 1.0, 0.0, GIMP_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_POINTS,
- g_param_spec_boolean ("points", NULL, NULL,
- FALSE,
- GIMP_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
+ g_param_spec_value_array ("points",
+ NULL, NULL,
+ array_spec,
+ GIMP_PARAM_STATIC_STRINGS |
+ GIMP_CONFIG_PARAM_FLAGS));
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_N_SAMPLES,
"n-samples",
"The number of samples",
256, 256, 256, 0);
+ array_spec = g_param_spec_double ("sample", NULL, NULL,
+ 0.0, 1.0, 0.0, GIMP_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_SAMPLES,
- g_param_spec_boolean ("samples", NULL, NULL,
- FALSE,
- GIMP_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
+ g_param_spec_value_array ("samples",
+ NULL, NULL,
+ array_spec,
+ GIMP_PARAM_STATIC_STRINGS |
+ GIMP_CONFIG_PARAM_FLAGS));
}
static void
@@ -233,6 +240,22 @@
break;
case PROP_POINTS:
+ {
+ GValueArray *array = g_value_get_boxed (value);
+ gint i;
+
+ if (! array)
+ break;
+
+ for (i = 0; i < curve->n_points && i * 2 < array->n_values; i++)
+ {
+ GValue *x = g_value_array_get_nth (array, i * 2);
+ GValue *y = g_value_array_get_nth (array, i * 2 + 1);
+
+ curve->points[i].x = g_value_get_double (x);
+ curve->points[i].y = g_value_get_double (y);
+ }
+ }
break;
case PROP_N_SAMPLES:
@@ -240,6 +263,20 @@
break;
case PROP_SAMPLES:
+ {
+ GValueArray *array = g_value_get_boxed (value);
+ gint i;
+
+ if (! array)
+ break;
+
+ for (i = 0; i < curve->n_samples && i < array->n_values; i++)
+ {
+ GValue *v = g_value_array_get_nth (array, i);
+
+ curve->samples[i] = g_value_get_double (v);
+ }
+ }
break;
default:
@@ -267,6 +304,26 @@
break;
case PROP_POINTS:
+ {
+ GValueArray *array = g_value_array_new (curve->n_points * 2);
+ GValue v = { 0, };
+ gint i;
+
+ g_value_init (&v, G_TYPE_DOUBLE);
+
+ for (i = 0; i < curve->n_points; i++)
+ {
+ g_value_set_double (&v, curve->points[i].x);
+ g_value_array_append (array, &v);
+
+ g_value_set_double (&v, curve->points[i].y);
+ g_value_array_append (array, &v);
+ }
+
+ g_value_unset (&v);
+
+ g_value_take_boxed (value, array);
+ }
break;
case PROP_N_SAMPLES:
@@ -274,6 +331,23 @@
break;
case PROP_SAMPLES:
+ {
+ GValueArray *array = g_value_array_new (curve->n_samples);
+ GValue v = { 0, };
+ gint i;
+
+ g_value_init (&v, G_TYPE_DOUBLE);
+
+ for (i = 0; i < curve->n_samples; i++)
+ {
+ g_value_set_double (&v, curve->samples[i]);
+ g_value_array_append (array, &v);
+ }
+
+ g_value_unset (&v);
+
+ g_value_take_boxed (value, array);
+ }
break;
default:
@@ -385,7 +459,13 @@
gint nest_level,
gpointer data)
{
- return gimp_config_deserialize_properties (config, scanner, nest_level);
+ gboolean success;
+
+ success = gimp_config_deserialize_properties (config, scanner, nest_level);
+
+ GIMP_CURVE (config)->identity = FALSE;
+
+ return success;
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]