gimp r25703 - in trunk: . app/gegl libgimpconfig
- From: mitch svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r25703 - in trunk: . app/gegl libgimpconfig
- Date: Sun, 18 May 2008 19:13:28 +0000 (UTC)
Author: mitch
Date: Sun May 18 19:13:28 2008
New Revision: 25703
URL: http://svn.gnome.org/viewvc/gimp?rev=25703&view=rev
Log:
2008-05-18 Michael Natterer <mitch gimp org>
* libgimpconfig/gimpconfig-serialize.[ch]
* libgimpconfig/gimpconfig.def: add
gimp_config_serialize_property_by_name().
* app/gegl/gimpcolorbalanceconfig.c
* app/gegl/gimpcurvesconfig.c
* app/gegl/gimphuesaturationconfig.c
* app/gegl/gimplevelsconfig.c: implement serialize() and
deserialize() and make sure the properties which change when the
channel/range property changes are handled correctly. Not too
ugly but it's still a hack...
Modified:
trunk/ChangeLog
trunk/app/gegl/gimpcolorbalanceconfig.c
trunk/app/gegl/gimpcurvesconfig.c
trunk/app/gegl/gimphuesaturationconfig.c
trunk/app/gegl/gimplevelsconfig.c
trunk/libgimpconfig/gimpconfig-serialize.c
trunk/libgimpconfig/gimpconfig-serialize.h
trunk/libgimpconfig/gimpconfig.def
Modified: trunk/app/gegl/gimpcolorbalanceconfig.c
==============================================================================
--- trunk/app/gegl/gimpcolorbalanceconfig.c (original)
+++ trunk/app/gegl/gimpcolorbalanceconfig.c Sun May 18 19:13:28 2008
@@ -48,21 +48,28 @@
static void gimp_color_balance_config_iface_init (GimpConfigInterface *iface);
-static void gimp_color_balance_config_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void gimp_color_balance_config_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-
-static gboolean gimp_color_balance_config_equal (GimpConfig *a,
- GimpConfig *b);
-static void gimp_color_balance_config_reset (GimpConfig *config);
-static gboolean gimp_color_balance_config_copy (GimpConfig *src,
- GimpConfig *dest,
- GParamFlags flags);
+static void gimp_color_balance_config_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_color_balance_config_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+static gboolean gimp_color_balance_config_serialize (GimpConfig *config,
+ GimpConfigWriter *writer,
+ gpointer data);
+static gboolean gimp_color_balance_config_deserialize (GimpConfig *config,
+ GScanner *scanner,
+ gint nest_level,
+ gpointer data);
+static gboolean gimp_color_balance_config_equal (GimpConfig *a,
+ GimpConfig *b);
+static void gimp_color_balance_config_reset (GimpConfig *config);
+static gboolean gimp_color_balance_config_copy (GimpConfig *src,
+ GimpConfig *dest,
+ GParamFlags flags);
G_DEFINE_TYPE_WITH_CODE (GimpColorBalanceConfig, gimp_color_balance_config,
@@ -114,9 +121,11 @@
static void
gimp_color_balance_config_iface_init (GimpConfigInterface *iface)
{
- iface->equal = gimp_color_balance_config_equal;
- iface->reset = gimp_color_balance_config_reset;
- iface->copy = gimp_color_balance_config_copy;
+ iface->serialize = gimp_color_balance_config_serialize;
+ iface->deserialize = gimp_color_balance_config_deserialize;
+ iface->equal = gimp_color_balance_config_equal;
+ iface->reset = gimp_color_balance_config_reset;
+ iface->copy = gimp_color_balance_config_copy;
}
static void
@@ -201,6 +210,68 @@
}
static gboolean
+gimp_color_balance_config_serialize (GimpConfig *config,
+ GimpConfigWriter *writer,
+ gpointer data)
+{
+ GimpColorBalanceConfig *bc_config = GIMP_COLOR_BALANCE_CONFIG (config);
+ GimpTransferMode range;
+ GimpTransferMode old_range;
+ gboolean success = TRUE;
+
+ old_range = bc_config->range;
+
+ for (range = GIMP_SHADOWS; range <= GIMP_HIGHLIGHTS; range++)
+ {
+ bc_config->range = range;
+
+ success = (gimp_config_serialize_property_by_name (config,
+ "range",
+ writer) &&
+ gimp_config_serialize_property_by_name (config,
+ "cyan-red",
+ writer) &&
+ gimp_config_serialize_property_by_name (config,
+ "magenta-green",
+ writer) &&
+ gimp_config_serialize_property_by_name (config,
+ "yellow-blue",
+ writer));
+
+ if (! success)
+ break;
+ }
+
+ if (success)
+ success = gimp_config_serialize_property_by_name (config,
+ "preserve-luminosity",
+ writer);
+
+ bc_config->range = old_range;
+
+ return success;
+}
+
+static gboolean
+gimp_color_balance_config_deserialize (GimpConfig *config,
+ GScanner *scanner,
+ gint nest_level,
+ gpointer data)
+{
+ GimpColorBalanceConfig *cb_config = GIMP_COLOR_BALANCE_CONFIG (config);
+ GimpTransferMode old_range;
+ gboolean success = TRUE;
+
+ old_range = cb_config->range;
+
+ success = gimp_config_deserialize_properties (config, scanner, nest_level);
+
+ g_object_set (config, "range", old_range, NULL);
+
+ return success;
+}
+
+static gboolean
gimp_color_balance_config_equal (GimpConfig *a,
GimpConfig *b)
{
Modified: trunk/app/gegl/gimpcurvesconfig.c
==============================================================================
--- trunk/app/gegl/gimpcurvesconfig.c (original)
+++ trunk/app/gegl/gimpcurvesconfig.c Sun May 18 19:13:28 2008
@@ -64,6 +64,13 @@
const GValue *value,
GParamSpec *pspec);
+static gboolean gimp_curves_config_serialize (GimpConfig *config,
+ GimpConfigWriter *writer,
+ gpointer data);
+static gboolean gimp_curves_config_deserialize (GimpConfig *config,
+ GScanner *scanner,
+ gint nest_level,
+ gpointer data);
static gboolean gimp_curves_config_equal (GimpConfig *a,
GimpConfig *b);
static void gimp_curves_config_reset (GimpConfig *config);
@@ -111,9 +118,11 @@
static void
gimp_curves_config_iface_init (GimpConfigInterface *iface)
{
- iface->equal = gimp_curves_config_equal;
- iface->reset = gimp_curves_config_reset;
- iface->copy = gimp_curves_config_copy;
+ iface->serialize = gimp_curves_config_serialize;
+ iface->deserialize = gimp_curves_config_deserialize;
+ iface->equal = gimp_curves_config_equal;
+ iface->reset = gimp_curves_config_reset;
+ iface->copy = gimp_curves_config_copy;
}
static void
@@ -217,6 +226,54 @@
}
static gboolean
+gimp_curves_config_serialize (GimpConfig *config,
+ GimpConfigWriter *writer,
+ gpointer data)
+{
+ GimpCurvesConfig *c_config = GIMP_CURVES_CONFIG (config);
+ GimpHistogramChannel channel;
+ GimpHistogramChannel old_channel;
+ gboolean success = TRUE;
+
+ old_channel = c_config->channel;
+
+ for (channel = GIMP_HISTOGRAM_VALUE;
+ channel <= GIMP_HISTOGRAM_ALPHA;
+ channel++)
+ {
+ c_config->channel = channel;
+
+ success = gimp_config_serialize_properties (config, writer);
+
+ if (! success)
+ break;
+ }
+
+ c_config->channel = old_channel;
+
+ return success;
+}
+
+static gboolean
+gimp_curves_config_deserialize (GimpConfig *config,
+ GScanner *scanner,
+ gint nest_level,
+ gpointer data)
+{
+ GimpCurvesConfig *c_config = GIMP_CURVES_CONFIG (config);
+ GimpHistogramChannel old_channel;
+ gboolean success = TRUE;
+
+ old_channel = c_config->channel;
+
+ success = gimp_config_deserialize_properties (config, scanner, nest_level);
+
+ g_object_set (config, "channel", old_channel, NULL);
+
+ return success;
+}
+
+static gboolean
gimp_curves_config_equal (GimpConfig *a,
GimpConfig *b)
{
Modified: trunk/app/gegl/gimphuesaturationconfig.c
==============================================================================
--- trunk/app/gegl/gimphuesaturationconfig.c (original)
+++ trunk/app/gegl/gimphuesaturationconfig.c Sun May 18 19:13:28 2008
@@ -46,21 +46,28 @@
static void gimp_hue_saturation_config_iface_init (GimpConfigInterface *iface);
-static void gimp_hue_saturation_config_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void gimp_hue_saturation_config_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-
-static gboolean gimp_hue_saturation_config_equal (GimpConfig *a,
- GimpConfig *b);
-static void gimp_hue_saturation_config_reset (GimpConfig *config);
-static gboolean gimp_hue_saturation_config_copy (GimpConfig *src,
- GimpConfig *dest,
- GParamFlags flags);
+static void gimp_hue_saturation_config_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_hue_saturation_config_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+static gboolean gimp_hue_saturation_config_serialize (GimpConfig *config,
+ GimpConfigWriter *writer,
+ gpointer data);
+static gboolean gimp_hue_saturation_config_deserialize (GimpConfig *config,
+ GScanner *scanner,
+ gint nest_level,
+ gpointer data);
+static gboolean gimp_hue_saturation_config_equal (GimpConfig *a,
+ GimpConfig *b);
+static void gimp_hue_saturation_config_reset (GimpConfig *config);
+static gboolean gimp_hue_saturation_config_copy (GimpConfig *src,
+ GimpConfig *dest,
+ GParamFlags flags);
G_DEFINE_TYPE_WITH_CODE (GimpHueSaturationConfig, gimp_hue_saturation_config,
@@ -112,9 +119,11 @@
static void
gimp_hue_saturation_config_iface_init (GimpConfigInterface *iface)
{
- iface->equal = gimp_hue_saturation_config_equal;
- iface->reset = gimp_hue_saturation_config_reset;
- iface->copy = gimp_hue_saturation_config_copy;
+ iface->serialize = gimp_hue_saturation_config_serialize;
+ iface->deserialize = gimp_hue_saturation_config_deserialize;
+ iface->equal = gimp_hue_saturation_config_equal;
+ iface->reset = gimp_hue_saturation_config_reset;
+ iface->copy = gimp_hue_saturation_config_copy;
}
static void
@@ -199,6 +208,63 @@
}
static gboolean
+gimp_hue_saturation_config_serialize (GimpConfig *config,
+ GimpConfigWriter *writer,
+ gpointer data)
+{
+ GimpHueSaturationConfig *hs_config = GIMP_HUE_SATURATION_CONFIG (config);
+ GimpHueRange range;
+ GimpHueRange old_range;
+ gboolean success = TRUE;
+
+ old_range = hs_config->range;
+
+ for (range = GIMP_ALL_HUES; range <= GIMP_MAGENTA_HUES; range++)
+ {
+ hs_config->range = range;
+
+ success = (gimp_config_serialize_property_by_name (config, "range",
+ writer) &&
+ gimp_config_serialize_property_by_name (config, "hue",
+ writer) &&
+ gimp_config_serialize_property_by_name (config, "saturation",
+ writer) &&
+ gimp_config_serialize_property_by_name (config, "lightness",
+ writer));
+
+ if (! success)
+ break;
+ }
+
+ if (success)
+ success = gimp_config_serialize_property_by_name (config, "overlap",
+ writer);
+
+ hs_config->range = old_range;
+
+ return success;
+}
+
+static gboolean
+gimp_hue_saturation_config_deserialize (GimpConfig *config,
+ GScanner *scanner,
+ gint nest_level,
+ gpointer data)
+{
+ GimpHueSaturationConfig *hs_config = GIMP_HUE_SATURATION_CONFIG (config);
+ GimpHueRange old_range;
+ gboolean success = TRUE;
+
+ old_range = hs_config->range;
+
+ success = gimp_config_deserialize_properties (config, scanner, nest_level);
+
+ g_object_set (config, "range", old_range, NULL);
+
+ return success;
+}
+
+static gboolean
gimp_hue_saturation_config_equal (GimpConfig *a,
GimpConfig *b)
{
Modified: trunk/app/gegl/gimplevelsconfig.c
==============================================================================
--- trunk/app/gegl/gimplevelsconfig.c (original)
+++ trunk/app/gegl/gimplevelsconfig.c Sun May 18 19:13:28 2008
@@ -60,21 +60,28 @@
static void gimp_levels_config_iface_init (GimpConfigInterface *iface);
-static void gimp_levels_config_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void gimp_levels_config_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-
-static gboolean gimp_levels_config_equal (GimpConfig *a,
- GimpConfig *b);
-static void gimp_levels_config_reset (GimpConfig *config);
-static gboolean gimp_levels_config_copy (GimpConfig *src,
- GimpConfig *dest,
- GParamFlags flags);
+static void gimp_levels_config_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_levels_config_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+static gboolean gimp_levels_config_serialize (GimpConfig *config,
+ GimpConfigWriter *writer,
+ gpointer data);
+static gboolean gimp_levels_config_deserialize (GimpConfig *config,
+ GScanner *scanner,
+ gint nest_level,
+ gpointer data);
+static gboolean gimp_levels_config_equal (GimpConfig *a,
+ GimpConfig *b);
+static void gimp_levels_config_reset (GimpConfig *config);
+static gboolean gimp_levels_config_copy (GimpConfig *src,
+ GimpConfig *dest,
+ GParamFlags flags);
G_DEFINE_TYPE_WITH_CODE (GimpLevelsConfig, gimp_levels_config,
@@ -131,9 +138,11 @@
static void
gimp_levels_config_iface_init (GimpConfigInterface *iface)
{
- iface->equal = gimp_levels_config_equal;
- iface->reset = gimp_levels_config_reset;
- iface->copy = gimp_levels_config_copy;
+ iface->serialize = gimp_levels_config_serialize;
+ iface->deserialize = gimp_levels_config_deserialize;
+ iface->equal = gimp_levels_config_equal;
+ iface->reset = gimp_levels_config_reset;
+ iface->copy = gimp_levels_config_copy;
}
static void
@@ -228,6 +237,54 @@
}
static gboolean
+gimp_levels_config_serialize (GimpConfig *config,
+ GimpConfigWriter *writer,
+ gpointer data)
+{
+ GimpLevelsConfig *l_config = GIMP_LEVELS_CONFIG (config);
+ GimpHistogramChannel channel;
+ GimpHistogramChannel old_channel;
+ gboolean success = TRUE;
+
+ old_channel = l_config->channel;
+
+ for (channel = GIMP_HISTOGRAM_VALUE;
+ channel <= GIMP_HISTOGRAM_ALPHA;
+ channel++)
+ {
+ l_config->channel = channel;
+
+ success = gimp_config_serialize_properties (config, writer);
+
+ if (! success)
+ break;
+ }
+
+ l_config->channel = old_channel;
+
+ return success;
+}
+
+static gboolean
+gimp_levels_config_deserialize (GimpConfig *config,
+ GScanner *scanner,
+ gint nest_level,
+ gpointer data)
+{
+ GimpLevelsConfig *l_config = GIMP_LEVELS_CONFIG (config);
+ GimpHistogramChannel old_channel;
+ gboolean success = TRUE;
+
+ old_channel = l_config->channel;
+
+ success = gimp_config_deserialize_properties (config, scanner, nest_level);
+
+ g_object_set (config, "channel", old_channel, NULL);
+
+ return success;
+}
+
+static gboolean
gimp_levels_config_equal (GimpConfig *a,
GimpConfig *b)
{
Modified: trunk/libgimpconfig/gimpconfig-serialize.c
==============================================================================
--- trunk/libgimpconfig/gimpconfig-serialize.c (original)
+++ trunk/libgimpconfig/gimpconfig-serialize.c Sun May 18 19:13:28 2008
@@ -309,6 +309,34 @@
}
/**
+ * gimp_config_serialize_property_by_name:
+ * @config: a #GimpConfig.
+ * @prop_name: the property's name.
+ * @writer: a #GimpConfigWriter.
+ *
+ * This function serializes a single object property to the @writer.
+ *
+ * Returns: %TRUE if serialization succeeded, %FALSE otherwise
+ *
+ * Since: GIMP 2.6
+ **/
+gboolean
+gimp_config_serialize_property_by_name (GimpConfig *config,
+ const gchar *prop_name,
+ GimpConfigWriter *writer)
+{
+ GParamSpec *pspec;
+
+ pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (config),
+ prop_name);
+
+ if (! pspec)
+ return FALSE;
+
+ return gimp_config_serialize_property (config, pspec, writer);
+}
+
+/**
* gimp_config_serialize_value:
* @value: a #GValue.
* @str: a #Gstring.
Modified: trunk/libgimpconfig/gimpconfig-serialize.h
==============================================================================
--- trunk/libgimpconfig/gimpconfig-serialize.h (original)
+++ trunk/libgimpconfig/gimpconfig-serialize.h Sun May 18 19:13:28 2008
@@ -36,6 +36,9 @@
gboolean gimp_config_serialize_property (GimpConfig *config,
GParamSpec *param_spec,
GimpConfigWriter *writer);
+gboolean gimp_config_serialize_property_by_name (GimpConfig *config,
+ const gchar *prop_name,
+ GimpConfigWriter *writer);
gboolean gimp_config_serialize_value (const GValue *value,
GString *str,
gboolean escaped);
Modified: trunk/libgimpconfig/gimpconfig.def
==============================================================================
--- trunk/libgimpconfig/gimpconfig.def (original)
+++ trunk/libgimpconfig/gimpconfig.def Sun May 18 19:13:28 2008
@@ -24,6 +24,7 @@
gimp_config_serialize_changed_properties
gimp_config_serialize_properties
gimp_config_serialize_property
+ gimp_config_serialize_property_by_name
gimp_config_serialize_to_fd
gimp_config_serialize_to_file
gimp_config_serialize_to_string
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]