2001-11-27 11:52:11 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2001-12-14 04:19:41 +08:00
|
|
|
* Object properties serialization routines
|
2002-03-24 01:58:57 +08:00
|
|
|
* Copyright (C) 2001-2002 Sven Neumann <sven@gimp.org>
|
2001-11-27 11:52:11 +08:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <glib-object.h>
|
|
|
|
|
2002-05-22 01:33:04 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2003-07-08 00:22:45 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2002-05-21 23:01:57 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
|
2005-01-26 04:30:20 +08:00
|
|
|
#include "gimpconfigtypes.h"
|
|
|
|
|
2005-01-26 03:11:26 +08:00
|
|
|
#include "gimpconfigwriter.h"
|
|
|
|
#include "gimpconfig-iface.h"
|
2002-05-22 01:33:04 +08:00
|
|
|
#include "gimpconfig-params.h"
|
2001-11-27 11:52:11 +08:00
|
|
|
#include "gimpconfig-serialize.h"
|
2002-05-04 07:48:03 +08:00
|
|
|
#include "gimpconfig-utils.h"
|
2001-11-27 11:52:11 +08:00
|
|
|
|
|
|
|
|
2002-03-24 01:58:57 +08:00
|
|
|
/**
|
|
|
|
* gimp_config_serialize_properties:
|
2003-10-11 22:30:18 +08:00
|
|
|
* @config: a #GimpConfig.
|
2003-03-06 04:21:50 +08:00
|
|
|
* @writer: a #GimpConfigWriter.
|
2003-09-16 21:12:50 +08:00
|
|
|
*
|
2003-03-06 04:21:50 +08:00
|
|
|
* This function writes all object properties to the @writer.
|
2003-08-09 03:30:23 +08:00
|
|
|
*
|
|
|
|
* Returns: %TRUE if serialization succeeded, %FALSE otherwise
|
2002-03-24 01:58:57 +08:00
|
|
|
**/
|
2002-05-15 19:05:32 +08:00
|
|
|
gboolean
|
2003-10-11 22:30:18 +08:00
|
|
|
gimp_config_serialize_properties (GimpConfig *config,
|
2003-03-06 04:21:50 +08:00
|
|
|
GimpConfigWriter *writer)
|
2001-11-27 11:52:11 +08:00
|
|
|
{
|
2001-12-08 00:10:53 +08:00
|
|
|
GObjectClass *klass;
|
|
|
|
GParamSpec **property_specs;
|
|
|
|
guint n_property_specs;
|
|
|
|
guint i;
|
2001-12-13 09:55:37 +08:00
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
g_return_val_if_fail (G_IS_OBJECT (config), FALSE);
|
2003-09-16 21:12:50 +08:00
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
klass = G_OBJECT_GET_CLASS (config);
|
2001-11-27 11:52:11 +08:00
|
|
|
|
2001-12-08 00:10:53 +08:00
|
|
|
property_specs = g_object_class_list_properties (klass, &n_property_specs);
|
2001-11-27 11:52:11 +08:00
|
|
|
|
2002-05-15 19:05:32 +08:00
|
|
|
if (! property_specs)
|
|
|
|
return TRUE;
|
2001-12-13 09:55:37 +08:00
|
|
|
|
2001-11-27 11:52:11 +08:00
|
|
|
for (i = 0; i < n_property_specs; i++)
|
|
|
|
{
|
2002-12-02 06:31:36 +08:00
|
|
|
GParamSpec *prop_spec = property_specs[i];
|
2001-11-27 11:52:11 +08:00
|
|
|
|
2002-05-22 01:33:04 +08:00
|
|
|
if (! (prop_spec->flags & GIMP_PARAM_SERIALIZE))
|
2001-11-27 11:52:11 +08:00
|
|
|
continue;
|
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
if (! gimp_config_serialize_property (config, prop_spec, writer))
|
2003-03-01 01:01:13 +08:00
|
|
|
return FALSE;
|
2001-12-13 09:55:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (property_specs);
|
2002-05-15 19:05:32 +08:00
|
|
|
|
|
|
|
return TRUE;
|
2001-12-13 09:55:37 +08:00
|
|
|
}
|
|
|
|
|
2002-03-24 01:58:57 +08:00
|
|
|
/**
|
2003-02-28 21:58:19 +08:00
|
|
|
* gimp_config_serialize_changed_properties:
|
2003-10-11 22:30:18 +08:00
|
|
|
* @config: a #GimpConfig.
|
2003-03-06 04:21:50 +08:00
|
|
|
* @writer: a #GimpConfigWriter.
|
2003-09-16 21:12:50 +08:00
|
|
|
*
|
2003-02-28 21:58:19 +08:00
|
|
|
* This function writes all object properties that have been changed from
|
2003-03-06 04:21:50 +08:00
|
|
|
* their default values to the @writer.
|
2003-08-09 03:30:23 +08:00
|
|
|
*
|
|
|
|
* Returns: %TRUE if serialization succeeded, %FALSE otherwise
|
2002-03-24 01:58:57 +08:00
|
|
|
**/
|
2002-05-15 19:05:32 +08:00
|
|
|
gboolean
|
2003-10-11 22:30:18 +08:00
|
|
|
gimp_config_serialize_changed_properties (GimpConfig *config,
|
2003-03-06 04:21:50 +08:00
|
|
|
GimpConfigWriter *writer)
|
2003-02-28 21:58:19 +08:00
|
|
|
{
|
|
|
|
GObjectClass *klass;
|
|
|
|
GParamSpec **property_specs;
|
|
|
|
guint n_property_specs;
|
|
|
|
guint i;
|
|
|
|
GValue value = { 0, };
|
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
g_return_val_if_fail (G_IS_OBJECT (config), FALSE);
|
2003-02-28 21:58:19 +08:00
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
klass = G_OBJECT_GET_CLASS (config);
|
2003-02-28 21:58:19 +08:00
|
|
|
|
|
|
|
property_specs = g_object_class_list_properties (klass, &n_property_specs);
|
|
|
|
|
|
|
|
if (! property_specs)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
for (i = 0; i < n_property_specs; i++)
|
|
|
|
{
|
|
|
|
GParamSpec *prop_spec = property_specs[i];
|
|
|
|
|
|
|
|
if (! (prop_spec->flags & GIMP_PARAM_SERIALIZE))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
g_value_init (&value, prop_spec->value_type);
|
2003-10-11 22:30:18 +08:00
|
|
|
g_object_get_property (G_OBJECT (config), prop_spec->name, &value);
|
2003-02-28 21:58:19 +08:00
|
|
|
|
|
|
|
if (! g_param_value_defaults (prop_spec, &value))
|
|
|
|
{
|
2003-10-11 22:30:18 +08:00
|
|
|
if (! gimp_config_serialize_property (config, prop_spec, writer))
|
2003-03-01 01:01:13 +08:00
|
|
|
return FALSE;
|
2003-02-28 21:58:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
g_value_unset (&value);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (property_specs);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-12-02 06:31:36 +08:00
|
|
|
gboolean
|
2003-10-11 22:30:18 +08:00
|
|
|
gimp_config_serialize_property (GimpConfig *config,
|
2003-03-06 04:21:50 +08:00
|
|
|
GParamSpec *param_spec,
|
|
|
|
GimpConfigWriter *writer)
|
2002-12-02 06:31:36 +08:00
|
|
|
{
|
|
|
|
GTypeClass *owner_class;
|
|
|
|
GimpConfigInterface *config_iface;
|
2004-02-19 20:30:18 +08:00
|
|
|
GimpConfigInterface *parent_iface = NULL;
|
2003-03-01 01:01:13 +08:00
|
|
|
GValue value = { 0, };
|
2003-02-08 23:27:51 +08:00
|
|
|
gboolean success = FALSE;
|
2002-12-02 06:31:36 +08:00
|
|
|
|
|
|
|
if (! (param_spec->flags & GIMP_PARAM_SERIALIZE))
|
|
|
|
return FALSE;
|
|
|
|
|
2003-10-26 08:03:16 +08:00
|
|
|
if (param_spec->flags & GIMP_PARAM_IGNORE)
|
|
|
|
return TRUE;
|
|
|
|
|
2002-12-02 06:31:36 +08:00
|
|
|
g_value_init (&value, param_spec->value_type);
|
2003-10-11 22:30:18 +08:00
|
|
|
g_object_get_property (G_OBJECT (config), param_spec->name, &value);
|
2002-12-02 06:31:36 +08:00
|
|
|
|
2003-10-26 08:03:16 +08:00
|
|
|
if (param_spec->flags & GIMP_PARAM_DEFAULTS &&
|
|
|
|
g_param_value_defaults (param_spec, &value))
|
|
|
|
{
|
|
|
|
g_value_unset (&value);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-12-02 06:31:36 +08:00
|
|
|
owner_class = g_type_class_peek (param_spec->owner_type);
|
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
config_iface = g_type_interface_peek (owner_class, GIMP_TYPE_CONFIG);
|
2002-12-02 06:31:36 +08:00
|
|
|
|
2004-02-19 20:30:18 +08:00
|
|
|
/* We must call serialize_property() *only* if the *exact* class
|
|
|
|
* which implements it is param_spec->owner_type's class.
|
|
|
|
*
|
|
|
|
* Therefore, we ask param_spec->owner_type's immediate parent class
|
|
|
|
* for it's GimpConfigInterface and check if we get a different pointer.
|
|
|
|
*
|
|
|
|
* (if the pointers are the same, param_spec->owner_type's
|
|
|
|
* GimpConfigInterface is inherited from one of it's parent classes
|
|
|
|
* and thus not able to handle param_spec->owner_type's properties).
|
|
|
|
*/
|
|
|
|
if (config_iface)
|
|
|
|
{
|
|
|
|
GTypeClass *owner_parent_class;
|
|
|
|
|
|
|
|
owner_parent_class = g_type_class_peek_parent (owner_class),
|
|
|
|
|
|
|
|
parent_iface = g_type_interface_peek (owner_parent_class,
|
|
|
|
GIMP_TYPE_CONFIG);
|
|
|
|
}
|
|
|
|
|
2002-12-02 06:31:36 +08:00
|
|
|
if (config_iface &&
|
2004-02-19 20:30:18 +08:00
|
|
|
config_iface != parent_iface && /* see comment above */
|
2003-02-08 23:27:51 +08:00
|
|
|
config_iface->serialize_property &&
|
2003-10-11 22:30:18 +08:00
|
|
|
config_iface->serialize_property (config,
|
2003-02-08 23:27:51 +08:00
|
|
|
param_spec->param_id,
|
|
|
|
(const GValue *) &value,
|
|
|
|
param_spec,
|
2003-03-06 04:21:50 +08:00
|
|
|
writer))
|
2002-12-02 06:31:36 +08:00
|
|
|
{
|
2003-02-08 23:27:51 +08:00
|
|
|
success = TRUE;
|
2002-12-02 06:31:36 +08:00
|
|
|
}
|
2003-02-08 23:27:51 +08:00
|
|
|
|
|
|
|
/* If there is no serialize_property() method *or* if it returned
|
|
|
|
* FALSE, continue with the default implementation
|
|
|
|
*/
|
|
|
|
|
2003-03-01 01:01:13 +08:00
|
|
|
if (! success)
|
2002-12-02 06:31:36 +08:00
|
|
|
{
|
2004-06-17 02:14:44 +08:00
|
|
|
if (G_VALUE_HOLDS_OBJECT (&value))
|
2003-03-01 01:01:13 +08:00
|
|
|
{
|
2003-10-11 22:30:18 +08:00
|
|
|
GimpConfigInterface *config_iface = NULL;
|
|
|
|
GimpConfig *prop_object;
|
2003-03-01 01:01:13 +08:00
|
|
|
|
|
|
|
prop_object = g_value_get_object (&value);
|
|
|
|
|
|
|
|
if (prop_object)
|
2003-10-11 22:30:18 +08:00
|
|
|
config_iface = GIMP_CONFIG_GET_INTERFACE (prop_object);
|
2003-03-01 01:01:13 +08:00
|
|
|
else
|
|
|
|
success = TRUE;
|
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
if (config_iface)
|
2003-04-13 03:06:25 +08:00
|
|
|
{
|
|
|
|
gimp_config_writer_open (writer, param_spec->name);
|
|
|
|
|
2004-06-17 02:14:44 +08:00
|
|
|
/* if the object property is not GIMP_PARAM_AGGREGATE,
|
|
|
|
* deserializing will need to know the exact type
|
|
|
|
* in order to create the object
|
|
|
|
*/
|
|
|
|
if (! (param_spec->flags & GIMP_PARAM_AGGREGATE))
|
|
|
|
{
|
|
|
|
GType object_type = G_TYPE_FROM_INSTANCE (prop_object);
|
|
|
|
|
|
|
|
gimp_config_writer_string (writer, g_type_name (object_type));
|
|
|
|
}
|
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
success = config_iface->serialize (prop_object, writer, NULL);
|
2003-04-13 03:06:25 +08:00
|
|
|
|
|
|
|
if (success)
|
|
|
|
gimp_config_writer_close (writer);
|
|
|
|
else
|
|
|
|
gimp_config_writer_revert (writer);
|
|
|
|
}
|
2003-03-01 01:01:13 +08:00
|
|
|
}
|
2003-04-13 03:06:25 +08:00
|
|
|
else if (! G_VALUE_HOLDS_OBJECT (&value))
|
2003-03-01 01:01:13 +08:00
|
|
|
{
|
2003-03-06 04:21:50 +08:00
|
|
|
GString *str = g_string_new (NULL);
|
|
|
|
|
2003-03-01 01:01:13 +08:00
|
|
|
success = gimp_config_serialize_value (&value, str, TRUE);
|
2003-03-06 04:21:50 +08:00
|
|
|
|
|
|
|
if (success)
|
2003-04-13 03:06:25 +08:00
|
|
|
{
|
|
|
|
gimp_config_writer_open (writer, param_spec->name);
|
|
|
|
gimp_config_writer_print (writer, str->str, str->len);
|
|
|
|
gimp_config_writer_close (writer);
|
|
|
|
}
|
2003-03-06 04:21:50 +08:00
|
|
|
|
|
|
|
g_string_free (str, TRUE);
|
|
|
|
}
|
2003-03-01 01:01:13 +08:00
|
|
|
|
2003-04-13 03:06:25 +08:00
|
|
|
if (! success)
|
|
|
|
{
|
|
|
|
/* don't warn for empty string properties */
|
|
|
|
if (G_VALUE_HOLDS_STRING (&value))
|
|
|
|
{
|
|
|
|
success = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("couldn't serialize property %s::%s of type %s",
|
2003-10-11 22:30:18 +08:00
|
|
|
g_type_name (G_TYPE_FROM_INSTANCE (config)),
|
2003-09-16 21:12:50 +08:00
|
|
|
param_spec->name,
|
2003-04-13 03:06:25 +08:00
|
|
|
g_type_name (param_spec->value_type));
|
|
|
|
}
|
|
|
|
}
|
2002-12-02 06:31:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
g_value_unset (&value);
|
|
|
|
|
2003-02-08 23:27:51 +08:00
|
|
|
return success;
|
2002-12-02 06:31:36 +08:00
|
|
|
}
|
|
|
|
|
2002-03-24 01:58:57 +08:00
|
|
|
/**
|
|
|
|
* gimp_config_serialize_value:
|
|
|
|
* @value: a #GValue.
|
|
|
|
* @str: a #Gstring.
|
2002-05-06 19:04:39 +08:00
|
|
|
* @escaped: whether to escape string values.
|
2002-05-06 06:11:34 +08:00
|
|
|
*
|
2002-03-24 01:58:57 +08:00
|
|
|
* This utility function appends a string representation of #GValue to @str.
|
2003-09-16 21:12:50 +08:00
|
|
|
*
|
2002-03-24 01:58:57 +08:00
|
|
|
* Return value: %TRUE if serialization succeeded, %FALSE otherwise.
|
|
|
|
**/
|
2001-12-29 00:26:54 +08:00
|
|
|
gboolean
|
|
|
|
gimp_config_serialize_value (const GValue *value,
|
2002-05-06 19:04:39 +08:00
|
|
|
GString *str,
|
|
|
|
gboolean escaped)
|
2001-12-13 09:55:37 +08:00
|
|
|
{
|
|
|
|
if (G_VALUE_HOLDS_BOOLEAN (value))
|
|
|
|
{
|
|
|
|
gboolean bool;
|
2003-09-16 21:12:50 +08:00
|
|
|
|
2001-12-13 09:55:37 +08:00
|
|
|
bool = g_value_get_boolean (value);
|
2002-05-06 06:11:34 +08:00
|
|
|
g_string_append (str, bool ? "yes" : "no");
|
2001-12-13 09:55:37 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
2003-09-16 21:12:50 +08:00
|
|
|
|
2001-12-13 09:55:37 +08:00
|
|
|
if (G_VALUE_HOLDS_ENUM (value))
|
|
|
|
{
|
2004-07-08 08:09:41 +08:00
|
|
|
GEnumClass *enum_class = g_type_class_peek (G_VALUE_TYPE (value));
|
|
|
|
GEnumValue *enum_value = g_enum_get_value (enum_class,
|
|
|
|
g_value_get_enum (value));
|
2001-12-13 09:55:37 +08:00
|
|
|
|
|
|
|
if (enum_value && enum_value->value_nick)
|
2001-12-12 07:10:59 +08:00
|
|
|
{
|
2001-12-13 09:55:37 +08:00
|
|
|
g_string_append (str, enum_value->value_nick);
|
|
|
|
return TRUE;
|
2001-12-12 07:10:59 +08:00
|
|
|
}
|
2001-12-13 09:55:37 +08:00
|
|
|
else
|
|
|
|
{
|
2003-09-16 21:12:50 +08:00
|
|
|
g_warning ("Couldn't get nick for enum_value of %s",
|
2001-12-13 09:55:37 +08:00
|
|
|
G_ENUM_CLASS_TYPE_NAME (enum_class));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2003-09-16 21:12:50 +08:00
|
|
|
|
2001-12-13 09:55:37 +08:00
|
|
|
if (G_VALUE_HOLDS_STRING (value))
|
|
|
|
{
|
|
|
|
const gchar *cstr = g_value_get_string (value);
|
2001-12-12 07:10:59 +08:00
|
|
|
|
2001-12-13 09:55:37 +08:00
|
|
|
if (!cstr)
|
|
|
|
return FALSE;
|
|
|
|
|
2002-05-06 19:04:39 +08:00
|
|
|
if (escaped)
|
2003-03-17 22:23:42 +08:00
|
|
|
gimp_config_string_append_escaped (str, cstr);
|
2002-05-06 19:04:39 +08:00
|
|
|
else
|
2003-03-17 22:23:42 +08:00
|
|
|
g_string_append (str, cstr);
|
|
|
|
|
2001-12-13 09:55:37 +08:00
|
|
|
return TRUE;
|
2001-11-27 11:52:11 +08:00
|
|
|
}
|
2001-12-13 09:55:37 +08:00
|
|
|
|
2002-04-15 17:40:08 +08:00
|
|
|
if (G_VALUE_HOLDS_DOUBLE (value) || G_VALUE_HOLDS_FLOAT (value))
|
|
|
|
{
|
|
|
|
gdouble v_double;
|
|
|
|
gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
|
|
|
|
|
|
|
|
if (G_VALUE_HOLDS_DOUBLE (value))
|
|
|
|
v_double = g_value_get_double (value);
|
|
|
|
else
|
|
|
|
v_double = (gdouble) g_value_get_float (value);
|
|
|
|
|
|
|
|
g_ascii_formatd (buf, sizeof (buf), "%f", v_double);
|
|
|
|
g_string_append (str, buf);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-07-27 03:56:47 +08:00
|
|
|
if (GIMP_VALUE_HOLDS_RGB (value))
|
2002-05-21 23:01:57 +08:00
|
|
|
{
|
2004-07-27 03:56:47 +08:00
|
|
|
GimpRGB *rgb;
|
2002-05-24 21:07:12 +08:00
|
|
|
gchar buf[4][G_ASCII_DTOSTR_BUF_SIZE];
|
2002-05-21 23:01:57 +08:00
|
|
|
|
2004-07-27 03:56:47 +08:00
|
|
|
rgb = g_value_get_boxed (value);
|
2002-05-24 21:07:12 +08:00
|
|
|
|
2004-07-27 03:56:47 +08:00
|
|
|
g_ascii_formatd (buf[0], G_ASCII_DTOSTR_BUF_SIZE, "%f", rgb->r);
|
|
|
|
g_ascii_formatd (buf[1], G_ASCII_DTOSTR_BUF_SIZE, "%f", rgb->g);
|
|
|
|
g_ascii_formatd (buf[2], G_ASCII_DTOSTR_BUF_SIZE, "%f", rgb->b);
|
|
|
|
g_ascii_formatd (buf[3], G_ASCII_DTOSTR_BUF_SIZE, "%f", rgb->a);
|
2002-05-24 21:07:12 +08:00
|
|
|
|
|
|
|
g_string_append_printf (str, "(color-rgba %s %s %s %s)",
|
|
|
|
buf[0], buf[1], buf[2], buf[3]);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-07-08 00:22:45 +08:00
|
|
|
if (GIMP_VALUE_HOLDS_MATRIX2 (value))
|
|
|
|
{
|
|
|
|
GimpMatrix2 *trafo;
|
|
|
|
gchar buf[4][G_ASCII_DTOSTR_BUF_SIZE];
|
|
|
|
gint i, j, k;
|
|
|
|
|
|
|
|
trafo = g_value_get_boxed (value);
|
|
|
|
|
|
|
|
for (i = 0, k = 0; i < 2; i++)
|
|
|
|
for (j = 0; j < 2; j++, k++)
|
|
|
|
g_ascii_formatd (buf[k],
|
|
|
|
G_ASCII_DTOSTR_BUF_SIZE, "%f", trafo->coeff[i][j]);
|
|
|
|
|
|
|
|
g_string_append_printf (str, "(matrix %s %s %s %s)",
|
|
|
|
buf[0], buf[1], buf[2], buf[3]);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-05-24 21:07:12 +08:00
|
|
|
if (G_VALUE_TYPE (value) == G_TYPE_VALUE_ARRAY)
|
|
|
|
{
|
|
|
|
GValueArray *array;
|
|
|
|
|
|
|
|
array = g_value_get_boxed (value);
|
|
|
|
|
|
|
|
if (array)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
g_string_append_printf (str, "%d", array->n_values);
|
|
|
|
|
|
|
|
for (i = 0; i < array->n_values; i++)
|
|
|
|
{
|
|
|
|
g_string_append (str, " ");
|
|
|
|
|
2002-12-02 06:31:36 +08:00
|
|
|
if (! gimp_config_serialize_value (g_value_array_get_nth (array,
|
|
|
|
i),
|
2003-03-01 01:01:13 +08:00
|
|
|
str, TRUE))
|
2002-05-24 21:07:12 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_string_append (str, "NULL");
|
|
|
|
}
|
|
|
|
|
2002-05-21 23:01:57 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-12-13 09:55:37 +08:00
|
|
|
if (g_value_type_transformable (G_VALUE_TYPE (value), G_TYPE_STRING))
|
|
|
|
{
|
|
|
|
GValue tmp_value = { 0, };
|
2003-09-16 21:12:50 +08:00
|
|
|
|
2001-12-13 09:55:37 +08:00
|
|
|
g_value_init (&tmp_value, G_TYPE_STRING);
|
|
|
|
g_value_transform (value, &tmp_value);
|
|
|
|
|
|
|
|
g_string_append (str, g_value_get_string (&tmp_value));
|
|
|
|
|
|
|
|
g_value_unset (&tmp_value);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2003-09-16 21:12:50 +08:00
|
|
|
|
2001-12-13 09:55:37 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|