continuing commit after broken pipe

This commit is contained in:
William Skaggs 2005-01-25 19:11:26 +00:00
parent 0d9284b233
commit 1cee9b7298
143 changed files with 332 additions and 4586 deletions

View File

@ -1,6 +1,7 @@
## Process this file with automake to produce Makefile.in
libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la
libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la
libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la
libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la
libgimpmodule = $(top_builddir)/libgimpmodule/libgimpmodule-$(GIMP_API_VERSION).la
@ -114,6 +115,7 @@ gimp_2_3_LDADD = \
$(libgimpthumb) \
$(libgimpmath) \
$(libgimpbase) \
$(libgimpconfig) \
$(REGEXREPL) \
$(GTK_LIBS) \
$(LIBART_LIBS) \
@ -158,6 +160,7 @@ gimp_console_2_3_LDADD = \
$(libgimpthumb) \
$(libgimpmath) \
$(libgimpbase) \
$(libgimpconfig) \
$(REGEXREPL) \
$(GDK_PIXBUF_LIBS) \
$(LIBART_LIBS) \

View File

@ -20,12 +20,11 @@
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "actions-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-utils.h"
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"

View File

@ -22,13 +22,11 @@
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "actions-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-utils.h"
#include "core/gimp.h"
#include "core/gimplist.h"
#include "core/gimptoolinfo.h"

View File

@ -33,10 +33,11 @@
#include <io.h> /* for _unlink() */
#endif
#include "libgimpconfig/gimpconfig.h"
#include "base-types.h"
#include "config/gimpbaseconfig.h"
#include "config/gimpconfig-path.h"
#include "paint-funcs/paint-funcs.h"
#include "composite/gimp-composite.h"

View File

@ -35,11 +35,11 @@
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
#include "libgimpconfig/gimpconfig.h"
#include "base-types.h"
#include "config/gimpbaseconfig.h"
#include "config/gimpconfig-path.h"
#include "pixel-region.h"
#include "temp-buf.h"

View File

@ -8,26 +8,12 @@ noinst_LIBRARIES = libappconfig.a
libappconfig_a_SOURCES = \
config-types.h \
gimpconfig.c \
gimpconfig.h \
gimpconfig-deserialize.c \
gimpconfig-deserialize.h \
gimpconfig-dump.c \
gimpconfig-dump.h \
gimpconfig-error.c \
gimpconfig-error.h \
gimpconfig-file.c \
gimpconfig-file.h \
gimpconfig-params.h \
gimpconfig-path.c \
gimpconfig-path.h \
gimpconfig-serialize.c \
gimpconfig-serialize.h \
gimpconfig-serialize.h \
gimpconfig-utils.c \
gimpconfig-utils.h \
gimpconfigwriter.c \
gimpconfigwriter.h \
gimpbaseconfig.c \
gimpbaseconfig.h \
gimpcoreconfig.c \
@ -49,8 +35,6 @@ libappconfig_a_SOURCES = \
gimprc-unknown.h \
gimprc-utils.c \
gimprc-utils.h \
gimpscanner.c \
gimpscanner.h \
gimpxmlparser.c \
gimpxmlparser.h
@ -86,6 +70,7 @@ test_config_LDADD = \
$(libgimpcolor) \
$(libgimpmath) \
$(libgimpbase) \
$(libgimpconfig) \
$(GLIB_LIBS)

View File

@ -23,8 +23,6 @@
#define __CONFIG_TYPES_H__
typedef struct _GimpConfig GimpConfig; /* dummy typedef */
typedef struct _GimpBaseConfig GimpBaseConfig;
typedef struct _GimpCoreConfig GimpCoreConfig;
typedef struct _GimpDisplayConfig GimpDisplayConfig;
@ -32,7 +30,6 @@ typedef struct _GimpGuiConfig GimpGuiConfig;
typedef struct _GimpPluginConfig GimpPluginConfig;
typedef struct _GimpRc GimpRc;
typedef struct _GimpConfigWriter GimpConfigWriter;
typedef struct _GimpXmlParser GimpXmlParser;
/* should be in display/display-types.h */

View File

@ -24,11 +24,10 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "config-types.h"
#include "gimpconfig-params.h"
#include "gimprc-blurbs.h"
#include "gimpbaseconfig.h"

View File

@ -1,729 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Object properties deserialization routines
* Copyright (C) 2001-2002 Sven Neumann <sven@gimp.org>
*
* 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>
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
#include "libgimpmath/gimpmath.h"
#include "config-types.h"
#include "gimpconfig.h"
#include "gimpconfig-deserialize.h"
#include "gimpconfig-params.h"
#include "gimpconfig-path.h"
#include "gimpscanner.h"
#include "gimp-intl.h"
/*
* All functions return G_TOKEN_RIGHT_PAREN on success,
* the GTokenType they would have expected but didn't get
* or G_TOKEN_NONE if they got the expected token but
* couldn't parse it.
*/
static GTokenType gimp_config_deserialize_value (GValue *value,
GimpConfig *config,
GParamSpec *prop_spec,
GScanner *scanner);
static GTokenType gimp_config_deserialize_fundamental (GValue *value,
GParamSpec *prop_spec,
GScanner *scanner);
static GTokenType gimp_config_deserialize_enum (GValue *value,
GParamSpec *prop_spec,
GScanner *scanner);
static GTokenType gimp_config_deserialize_memsize (GValue *value,
GParamSpec *prop_spec,
GScanner *scanner);
static GTokenType gimp_config_deserialize_path (GValue *value,
GParamSpec *prop_spec,
GScanner *scanner);
static GTokenType gimp_config_deserialize_rgb (GValue *value,
GParamSpec *prop_spec,
GScanner *scanner);
static GTokenType gimp_config_deserialize_matrix2 (GValue *value,
GParamSpec *prop_spec,
GScanner *scanner);
static GTokenType gimp_config_deserialize_object (GValue *value,
GimpConfig *config,
GParamSpec *prop_spec,
GScanner *scanner,
gint nest_level);
static GTokenType gimp_config_deserialize_value_array (GValue *value,
GimpConfig *config,
GParamSpec *prop_spec,
GScanner *scanner);
static GTokenType gimp_config_deserialize_any (GValue *value,
GParamSpec *prop_spec,
GScanner *scanner);
static inline gboolean scanner_string_utf8_valid (GScanner *scanner,
const gchar *token_name);
static inline gboolean
scanner_string_utf8_valid (GScanner *scanner,
const gchar *token_name)
{
if (g_utf8_validate (scanner->value.v_string, -1, NULL))
return TRUE;
g_scanner_error (scanner,
_("value for token %s is not a valid UTF-8 string"),
token_name);
return FALSE;
}
/**
* gimp_config_deserialize_properties:
* @config: a #GimpConfig.
* @scanner: a #GScanner.
* @nest_level:
*
* This function uses the @scanner to configure the properties of @config.
*
* Return value:
**/
gboolean
gimp_config_deserialize_properties (GimpConfig *config,
GScanner *scanner,
gint nest_level)
{
GObjectClass *klass;
GParamSpec **property_specs;
guint n_property_specs;
guint i;
guint scope_id;
guint old_scope_id;
GTokenType token;
GTokenType next;
g_return_val_if_fail (GIMP_IS_CONFIG (config), FALSE);
klass = G_OBJECT_GET_CLASS (config);
property_specs = g_object_class_list_properties (klass, &n_property_specs);
if (!property_specs)
return TRUE;
scope_id = g_type_qname (G_TYPE_FROM_INSTANCE (config));
old_scope_id = g_scanner_set_scope (scanner, scope_id);
for (i = 0; i < n_property_specs; i++)
{
GParamSpec *prop_spec = property_specs[i];
if (prop_spec->flags & GIMP_PARAM_SERIALIZE)
{
g_scanner_scope_add_symbol (scanner, scope_id,
prop_spec->name, prop_spec);
}
}
g_free (property_specs);
g_object_freeze_notify (G_OBJECT (config));
token = G_TOKEN_LEFT_PAREN;
while (TRUE)
{
next = g_scanner_peek_next_token (scanner);
if (next != token)
break;
token = g_scanner_get_next_token (scanner);
switch (token)
{
case G_TOKEN_LEFT_PAREN:
token = G_TOKEN_SYMBOL;
break;
case G_TOKEN_SYMBOL:
token = gimp_config_deserialize_property (config,
scanner, nest_level);
break;
case G_TOKEN_RIGHT_PAREN:
token = G_TOKEN_LEFT_PAREN;
break;
default: /* do nothing */
break;
}
}
g_scanner_set_scope (scanner, old_scope_id);
g_object_thaw_notify (G_OBJECT (config));
if (token == G_TOKEN_NONE)
return FALSE;
return gimp_config_deserialize_return (scanner, token, nest_level);
}
GTokenType
gimp_config_deserialize_property (GimpConfig *config,
GScanner *scanner,
gint nest_level)
{
GTypeClass *owner_class;
GimpConfigInterface *config_iface;
GimpConfigInterface *parent_iface;
GParamSpec *prop_spec;
GTokenType token = G_TOKEN_RIGHT_PAREN;
GValue value = { 0, };
guint old_scope_id;
old_scope_id = g_scanner_set_scope (scanner, 0);
prop_spec = G_PARAM_SPEC (scanner->value.v_symbol);
g_value_init (&value, prop_spec->value_type);
owner_class = g_type_class_peek (prop_spec->owner_type);
config_iface = g_type_interface_peek (owner_class, GIMP_TYPE_CONFIG);
/* We must call deserialize_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);
}
if (config_iface &&
config_iface != parent_iface && /* see comment above */
config_iface->deserialize_property &&
config_iface->deserialize_property (config,
prop_spec->param_id,
&value,
prop_spec,
scanner,
&token))
{
/* nop */
}
else
{
if (G_VALUE_HOLDS_OBJECT (&value))
token = gimp_config_deserialize_object (&value,
config, prop_spec,
scanner, nest_level);
else
token = gimp_config_deserialize_value (&value,
config, prop_spec, scanner);
}
if (token == G_TOKEN_RIGHT_PAREN &&
g_scanner_peek_next_token (scanner) == token)
{
if (! (G_VALUE_HOLDS_OBJECT (&value) &&
(prop_spec->flags & GIMP_PARAM_AGGREGATE)))
g_object_set_property (G_OBJECT (config), prop_spec->name, &value);
}
#ifdef CONFIG_DEBUG
else
{
g_warning ("%s: couldn't deserialize property %s::%s of type %s",
G_STRFUNC,
g_type_name (G_TYPE_FROM_INSTANCE (config)),
prop_spec->name,
g_type_name (prop_spec->value_type));
}
#endif
g_value_unset (&value);
g_scanner_set_scope (scanner, old_scope_id);
return token;
}
static GTokenType
gimp_config_deserialize_value (GValue *value,
GimpConfig *config,
GParamSpec *prop_spec,
GScanner *scanner)
{
if (G_TYPE_FUNDAMENTAL (prop_spec->value_type) == G_TYPE_ENUM)
{
return gimp_config_deserialize_enum (value, prop_spec, scanner);
}
else if (G_TYPE_IS_FUNDAMENTAL (prop_spec->value_type))
{
return gimp_config_deserialize_fundamental (value, prop_spec, scanner);
}
else if (prop_spec->value_type == GIMP_TYPE_MEMSIZE)
{
return gimp_config_deserialize_memsize (value, prop_spec, scanner);
}
else if (prop_spec->value_type == GIMP_TYPE_PATH)
{
return gimp_config_deserialize_path (value, prop_spec, scanner);
}
else if (prop_spec->value_type == GIMP_TYPE_RGB)
{
return gimp_config_deserialize_rgb (value, prop_spec, scanner);
}
else if (prop_spec->value_type == GIMP_TYPE_MATRIX2)
{
return gimp_config_deserialize_matrix2 (value, prop_spec, scanner);
}
else if (prop_spec->value_type == G_TYPE_VALUE_ARRAY)
{
return gimp_config_deserialize_value_array (value,
config, prop_spec, scanner);
}
/* This fallback will only work for value_types that
* can be transformed from a string value.
*/
return gimp_config_deserialize_any (value, prop_spec, scanner);
}
static GTokenType
gimp_config_deserialize_fundamental (GValue *value,
GParamSpec *prop_spec,
GScanner *scanner)
{
GTokenType token;
GType value_type;
gboolean negate = FALSE;
value_type = G_TYPE_FUNDAMENTAL (prop_spec->value_type);
switch (value_type)
{
case G_TYPE_STRING:
token = G_TOKEN_STRING;
break;
case G_TYPE_BOOLEAN:
token = G_TOKEN_IDENTIFIER;
break;
case G_TYPE_INT:
case G_TYPE_LONG:
case G_TYPE_INT64:
if (g_scanner_peek_next_token (scanner) == '-')
{
negate = TRUE;
g_scanner_get_next_token (scanner);
}
/* fallthrough */
case G_TYPE_UINT:
case G_TYPE_ULONG:
case G_TYPE_UINT64:
token = G_TOKEN_INT;
break;
case G_TYPE_FLOAT:
case G_TYPE_DOUBLE:
if (g_scanner_peek_next_token (scanner) == '-')
{
negate = TRUE;
g_scanner_get_next_token (scanner);
}
token = G_TOKEN_FLOAT;
break;
default:
token = G_TOKEN_NONE;
g_assert_not_reached ();
break;
}
if (g_scanner_peek_next_token (scanner) != token)
{
return token;
}
g_scanner_get_next_token (scanner);
switch (value_type)
{
case G_TYPE_STRING:
if (scanner_string_utf8_valid (scanner, prop_spec->name))
g_value_set_static_string (value, scanner->value.v_string);
else
return G_TOKEN_NONE;
break;
case G_TYPE_BOOLEAN:
if (! g_ascii_strcasecmp (scanner->value.v_identifier, "yes") ||
! g_ascii_strcasecmp (scanner->value.v_identifier, "true"))
g_value_set_boolean (value, TRUE);
else if (! g_ascii_strcasecmp (scanner->value.v_identifier, "no") ||
! g_ascii_strcasecmp (scanner->value.v_identifier, "false"))
g_value_set_boolean (value, FALSE);
else
{
g_scanner_error
(scanner,
/* please don't translate 'yes' and 'no' */
_("expected 'yes' or 'no' for boolean token %s, got '%s'"),
prop_spec->name, scanner->value.v_identifier);
return G_TOKEN_NONE;
}
break;
case G_TYPE_INT:
g_value_set_int (value, (negate ?
- scanner->value.v_int64 :
scanner->value.v_int64));
break;
case G_TYPE_UINT:
g_value_set_uint (value, scanner->value.v_int64);
break;
case G_TYPE_LONG:
g_value_set_long (value, (negate ?
- scanner->value.v_int64 :
scanner->value.v_int64));
break;
case G_TYPE_ULONG:
g_value_set_ulong (value, scanner->value.v_int64);
break;
case G_TYPE_INT64:
g_value_set_int64 (value, (negate ?
- scanner->value.v_int64 :
scanner->value.v_int64));
break;
case G_TYPE_UINT64:
g_value_set_uint64 (value, scanner->value.v_int64);
break;
case G_TYPE_FLOAT:
g_value_set_float (value, negate ?
- scanner->value.v_float : scanner->value.v_float);
break;
case G_TYPE_DOUBLE:
g_value_set_double (value, negate ?
- scanner->value.v_float: scanner->value.v_float);
break;
default:
g_assert_not_reached ();
break;
}
return G_TOKEN_RIGHT_PAREN;
}
static GTokenType
gimp_config_deserialize_enum (GValue *value,
GParamSpec *prop_spec,
GScanner *scanner)
{
GEnumClass *enum_class;
GEnumValue *enum_value;
enum_class = g_type_class_peek (G_VALUE_TYPE (value));
switch (g_scanner_peek_next_token (scanner))
{
case G_TOKEN_IDENTIFIER:
g_scanner_get_next_token (scanner);
enum_value = g_enum_get_value_by_nick (enum_class,
scanner->value.v_identifier);
if (!enum_value)
enum_value = g_enum_get_value_by_name (enum_class,
scanner->value.v_identifier);
if (!enum_value)
{
g_scanner_error (scanner,
_("invalid value '%s' for token %s"),
scanner->value.v_identifier, prop_spec->name);
return G_TOKEN_NONE;
}
break;
case G_TOKEN_INT:
g_scanner_get_next_token (scanner);
enum_value = g_enum_get_value (enum_class,
(gint) scanner->value.v_int64);
if (!enum_value)
{
g_scanner_error (scanner,
_("invalid value '%ld' for token %s"),
(glong) scanner->value.v_int64, prop_spec->name);
return G_TOKEN_NONE;
}
break;
default:
return G_TOKEN_IDENTIFIER;
}
g_value_set_enum (value, enum_value->value);
return G_TOKEN_RIGHT_PAREN;
}
static GTokenType
gimp_config_deserialize_memsize (GValue *value,
GParamSpec *prop_spec,
GScanner *scanner)
{
gchar *orig_cset_first = scanner->config->cset_identifier_first;
gchar *orig_cset_nth = scanner->config->cset_identifier_nth;
guint64 memsize;
scanner->config->cset_identifier_first = G_CSET_DIGITS;
scanner->config->cset_identifier_nth = G_CSET_DIGITS "gGmMkKbB";
if (g_scanner_peek_next_token (scanner) != G_TOKEN_IDENTIFIER)
return G_TOKEN_IDENTIFIER;
g_scanner_get_next_token (scanner);
scanner->config->cset_identifier_first = orig_cset_first;
scanner->config->cset_identifier_nth = orig_cset_nth;
if (! gimp_memsize_deserialize (scanner->value.v_identifier, &memsize))
return G_TOKEN_NONE;
g_value_set_uint64 (value, memsize);
return G_TOKEN_RIGHT_PAREN;
}
static GTokenType
gimp_config_deserialize_path (GValue *value,
GParamSpec *prop_spec,
GScanner *scanner)
{
GError *error = NULL;
if (g_scanner_peek_next_token (scanner) != G_TOKEN_STRING)
return G_TOKEN_STRING;
g_scanner_get_next_token (scanner);
if (!scanner_string_utf8_valid (scanner, prop_spec->name))
return G_TOKEN_NONE;
if (scanner->value.v_string)
{
/* Check if the string can be expanded
* and converted to the filesystem encoding.
*/
gchar *expand = gimp_config_path_expand (scanner->value.v_string,
TRUE, &error);
if (!expand)
{
g_scanner_error (scanner,
_("while parsing token '%s': %s"),
prop_spec->name, error->message);
g_error_free (error);
return G_TOKEN_NONE;
}
g_free (expand);
g_value_set_static_string (value, scanner->value.v_string);
}
return G_TOKEN_RIGHT_PAREN;
}
static GTokenType
gimp_config_deserialize_rgb (GValue *value,
GParamSpec *prop_spec,
GScanner *scanner)
{
GimpRGB rgb;
if (! gimp_scanner_parse_color (scanner, &rgb))
return G_TOKEN_NONE;
g_value_set_boxed (value, &rgb);
return G_TOKEN_RIGHT_PAREN;
}
static GTokenType
gimp_config_deserialize_matrix2 (GValue *value,
GParamSpec *prop_spec,
GScanner *scanner)
{
GimpMatrix2 matrix;
if (! gimp_scanner_parse_matrix2 (scanner, &matrix))
return G_TOKEN_NONE;
g_value_set_boxed (value, &matrix);
return G_TOKEN_RIGHT_PAREN;
}
static GTokenType
gimp_config_deserialize_object (GValue *value,
GimpConfig *config,
GParamSpec *prop_spec,
GScanner *scanner,
gint nest_level)
{
GimpConfigInterface *config_iface;
GimpConfig *prop_object;
g_object_get_property (G_OBJECT (config), prop_spec->name, value);
prop_object = g_value_get_object (value);
if (! prop_object)
{
/* if the object property is not GIMP_PARAM_AGGREGATE, read
* the type of the object and create it
*/
if (! (prop_spec->flags & GIMP_PARAM_AGGREGATE))
{
gchar *type_name;
GType type;
if (! gimp_scanner_parse_string (scanner, &type_name))
return G_TOKEN_STRING;
type = g_type_from_name (type_name);
g_free (type_name);
if (! g_type_is_a (type, prop_spec->value_type))
return G_TOKEN_STRING;
prop_object = g_object_new (type, NULL);
g_value_take_object (value, prop_object);
}
else
{
return G_TOKEN_RIGHT_PAREN;
}
}
config_iface = GIMP_CONFIG_GET_INTERFACE (prop_object);
if (! config_iface)
return gimp_config_deserialize_any (value, prop_spec, scanner);
if (! config_iface->deserialize (prop_object, scanner, nest_level + 1, NULL))
return G_TOKEN_NONE;
return G_TOKEN_RIGHT_PAREN;
}
static GTokenType
gimp_config_deserialize_value_array (GValue *value,
GimpConfig *config,
GParamSpec *prop_spec,
GScanner *scanner)
{
GParamSpecValueArray *array_spec;
GValueArray *array;
GValue array_value = { 0, };
gint n_values;
GTokenType token;
gint i;
array_spec = G_PARAM_SPEC_VALUE_ARRAY (prop_spec);
if (! gimp_scanner_parse_int (scanner, &n_values))
return G_TOKEN_INT;
array = g_value_array_new (n_values);
for (i = 0; i < n_values; i++)
{
g_value_init (&array_value, array_spec->element_spec->value_type);
token = gimp_config_deserialize_value (&array_value,
config,
array_spec->element_spec,
scanner);
if (token == G_TOKEN_RIGHT_PAREN)
g_value_array_append (array, &array_value);
g_value_unset (&array_value);
if (token != G_TOKEN_RIGHT_PAREN)
return token;
}
g_value_take_boxed (value, array);
return G_TOKEN_RIGHT_PAREN;
}
static GTokenType
gimp_config_deserialize_any (GValue *value,
GParamSpec *prop_spec,
GScanner *scanner)
{
GValue src = { 0, };
if (!g_value_type_transformable (G_TYPE_STRING, prop_spec->value_type))
{
g_warning ("%s: %s can not be transformed from a string",
G_STRFUNC, g_type_name (prop_spec->value_type));
return G_TOKEN_NONE;
}
if (g_scanner_peek_next_token (scanner) != G_TOKEN_IDENTIFIER)
return G_TOKEN_IDENTIFIER;
g_scanner_get_next_token (scanner);
g_value_init (&src, G_TYPE_STRING);
g_value_set_static_string (&src, scanner->value.v_identifier);
g_value_transform (&src, value);
g_value_unset (&src);
return G_TOKEN_RIGHT_PAREN;
}

View File

@ -1,34 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Object properties deserialization routines
* Copyright (C) 2001-2002 Sven Neumann <sven@gimp.org>
*
* 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.
*/
#ifndef __GIMP_CONFIG_DESERIALIZE_H__
#define __GIMP_CONFIG_DESERIALIZE_H__
gboolean gimp_config_deserialize_properties (GimpConfig *config,
GScanner *scanner,
gint nest_level);
GTokenType gimp_config_deserialize_property (GimpConfig *config,
GScanner *scanner,
gint nest_level);
#endif /* __GIMP_CONFIG_DESERIALIZE_H__ */

View File

@ -31,6 +31,7 @@
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
#include "libgimpconfig/gimpconfig.h"
#ifdef G_OS_WIN32
#include "libgimpbase/gimpwin32-io.h"
@ -38,11 +39,7 @@
#include "config-types.h"
#include "gimpconfig.h"
#include "gimpconfig-dump.h"
#include "gimpconfig-params.h"
#include "gimpconfig-serialize.h"
#include "gimpconfigwriter.h"
#include "gimprc.h"

View File

@ -1,37 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Config file serialization and deserialization interface
* Copyright (C) 2001-2002 Sven Neumann <sven@gimp.org>
*
* 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.h>
#include "gimpconfig-error.h"
GQuark
gimp_config_error_quark (void)
{
static GQuark q = 0;
if (q == 0)
q = g_quark_from_static_string ("gimp-config-error-quark");
return q;
}

View File

@ -1,39 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* Copyright (C) 2003 Sven Neumann <sven@gimp.org>
*
* 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.
*/
#ifndef __GIMP_CONFIG_ERROR_H__
#define __GIMP_CONFIG_ERROR_H__
typedef enum
{
GIMP_CONFIG_ERROR_OPEN, /* open failed */
GIMP_CONFIG_ERROR_OPEN_ENOENT, /* file does not exist */
GIMP_CONFIG_ERROR_WRITE, /* write failed */
GIMP_CONFIG_ERROR_PARSE, /* parser error */
GIMP_CONFIG_ERROR_VERSION /* parser failed due to version mismatch */
} GimpConfigError;
#define GIMP_CONFIG_ERROR (gimp_config_error_quark ())
GQuark gimp_config_error_quark (void) G_GNUC_CONST;
#endif /* __GIMP_CONFIG_ERROR_H__ */

View File

@ -29,6 +29,7 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#ifdef G_OS_WIN32
#include "libgimpbase/gimpwin32-io.h"
@ -36,8 +37,6 @@
#include "config-types.h"
#include "gimpconfig-file.h"
#include "gimp-intl.h"

View File

@ -1,150 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* ParamSpecs for config objects
* Copyright (C) 2001 Sven Neumann <sven@gimp.org>
*
* 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.
*/
#ifndef __GIMP_CONFIG_PARAMS_H__
#define __GIMP_CONFIG_PARAMS_H__
/*
* GIMP_PARAM_SERIALIZE - A property that can and should be
* serialized and deserialized.
* GIMP_PARAM_AGGREGATE - The object property is to be treated as
* part of the parent object.
* GIMP_PARAM_RESTART - Changes to this property take effect only
* after a restart.
* GIMP_PARAM_CONFIRM - Changes to this property should be
* confirmed by the user before being applied.
* GIMP_PARAM_DEFAULTS - Don't serialize this property if it has the
* default value.
* GIMP_PARAM_IGNORE - This property exists for obscure reasons
* and is needed for backward compatibility.
* Ignore the value read and don't serialize it.
*/
#define GIMP_PARAM_SERIALIZE (1 << (0 + G_PARAM_USER_SHIFT))
#define GIMP_PARAM_AGGREGATE (1 << (1 + G_PARAM_USER_SHIFT))
#define GIMP_PARAM_RESTART (1 << (2 + G_PARAM_USER_SHIFT))
#define GIMP_PARAM_CONFIRM (1 << (3 + G_PARAM_USER_SHIFT))
#define GIMP_PARAM_DEFAULTS (1 << (4 + G_PARAM_USER_SHIFT))
#define GIMP_PARAM_IGNORE (1 << (5 + G_PARAM_USER_SHIFT))
#define GIMP_CONFIG_PARAM_FLAGS (G_PARAM_READWRITE | \
G_PARAM_CONSTRUCT | \
GIMP_PARAM_SERIALIZE)
/* some convenience macros to install object properties */
#define GIMP_CONFIG_INSTALL_PROP_BOOLEAN(class, id,\
name, blurb, default, flags)\
g_object_class_install_property (class, id,\
g_param_spec_boolean (name, NULL, blurb,\
default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_INSTALL_PROP_RGB(class, id,\
name, blurb, default, flags)\
g_object_class_install_property (class, id,\
gimp_param_spec_rgb (name, NULL, blurb,\
default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_INSTALL_PROP_DOUBLE(class, id,\
name, blurb, min, max, default, flags)\
g_object_class_install_property (class, id,\
g_param_spec_double (name, NULL, blurb,\
min, max, default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_INSTALL_PROP_RESOLUTION(class, id,\
name, blurb, default, flags)\
g_object_class_install_property (class, id,\
g_param_spec_double (name, NULL, blurb,\
GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION, \
default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_INSTALL_PROP_ENUM(class, id,\
name, blurb, enum_type, default, flags)\
g_object_class_install_property (class, id,\
g_param_spec_enum (name, NULL, blurb,\
enum_type, default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_INSTALL_PROP_INT(class, id,\
name, blurb, min, max, default, flags)\
g_object_class_install_property (class, id,\
g_param_spec_int (name, NULL, blurb,\
min, max, default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_INSTALL_PROP_MATRIX2(class, id,\
name, blurb, default, flags)\
g_object_class_install_property (class, id,\
gimp_param_spec_matrix2 (name, NULL, blurb,\
default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_INSTALL_PROP_MEMSIZE(class, id,\
name, blurb, min, max, default, flags)\
g_object_class_install_property (class, id,\
gimp_param_spec_memsize (name, NULL, blurb,\
min, max, default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_INSTALL_PROP_PATH(class, id,\
name, blurb, type, default, flags)\
g_object_class_install_property (class, id,\
gimp_param_spec_path (name, NULL, blurb,\
type, default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_INSTALL_PROP_STRING(class, id,\
name, blurb, default, flags)\
g_object_class_install_property (class, id,\
g_param_spec_string (name, NULL, blurb,\
default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_INSTALL_PROP_UINT(class, id,\
name, blurb, min, max, default, flags)\
g_object_class_install_property (class, id,\
g_param_spec_uint (name, NULL, blurb,\
min, max, default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_INSTALL_PROP_UNIT(class, id,\
name, blurb, pixels, percent, default, flags)\
g_object_class_install_property (class, id,\
gimp_param_spec_unit (name, NULL, blurb,\
pixels, percent, default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
/* object and pointer properties are _not_ G_PARAM_CONSTRUCT */
#define GIMP_CONFIG_INSTALL_PROP_OBJECT(class, id,\
name, blurb, object_type, flags)\
g_object_class_install_property (class, id,\
g_param_spec_object (name, NULL, blurb,\
object_type,\
flags |\
G_PARAM_READWRITE | GIMP_PARAM_SERIALIZE))
#define GIMP_CONFIG_INSTALL_PROP_POINTER(class, id,\
name, blurb, flags)\
g_object_class_install_property (class, id,\
g_param_spec_pointer (name, NULL, blurb,\
flags |\
G_PARAM_READWRITE | GIMP_PARAM_SERIALIZE))
#endif /* __GIMP_CONFIG_PARAMS_H__ */

View File

@ -1,286 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* String substitution utilities for config files
* Copyright (C) 2001 Sven Neumann <sven@gimp.org>
*
* 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 <stdio.h>
#include <string.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "gimpconfig-path.h"
#include "gimp-intl.h"
static gchar * gimp_config_path_expand_only (const gchar *path,
GError **error);
static inline gchar * extract_token (const gchar **str);
/*
* GimpConfig path utilities
*/
gchar *
gimp_config_build_data_path (const gchar *name)
{
return g_strconcat ("${gimp_dir}", G_DIR_SEPARATOR_S, name,
G_SEARCHPATH_SEPARATOR_S,
"${gimp_data_dir}", G_DIR_SEPARATOR_S, name,
NULL);
}
gchar *
gimp_config_build_writable_path (const gchar *name)
{
return g_strconcat ("${gimp_dir}", G_DIR_SEPARATOR_S, name, NULL);
}
gchar *
gimp_config_build_plug_in_path (const gchar *name)
{
return g_strconcat ("${gimp_dir}", G_DIR_SEPARATOR_S, name,
G_SEARCHPATH_SEPARATOR_S,
"${gimp_plug_in_dir}", G_DIR_SEPARATOR_S, name,
NULL);
}
/**
* gimp_config_path_expand:
* @path: a %NUL-terminated string in UTF-8 encoding
* @recode: whether to convert to the filesystem's encoding
* @error: return location for errors
*
* Paths as stored in the gimprc have to be treated special. The
* string may contain special identifiers such as for example
* ${gimp_dir} that have to be substituted before use. Also the user's
* filesystem may be in a different encoding than UTF-8 (which is what
* is used for the gimprc). This function does the variable
* substitution for you and can also attempt to convert to the
* filesystem encoding.
*
* Return value: a newly allocated %NUL-terminated string
**/
gchar *
gimp_config_path_expand (const gchar *path,
gboolean recode,
GError **error)
{
g_return_val_if_fail (path != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
if (recode)
{
gchar *retval;
gchar *expanded = gimp_config_path_expand_only (path, error);
if (! expanded)
return NULL;
retval = g_filename_from_utf8 (expanded, -1, NULL, NULL, error);
g_free (expanded);
return retval;
}
return gimp_config_path_expand_only (path, error);
}
#define SUBSTS_ALLOC 4
static gchar *
gimp_config_path_expand_only (const gchar *path,
GError **error)
{
const gchar *p;
const gchar *s;
gchar *n;
gchar *token;
gchar *filename = NULL;
gchar *expanded = NULL;
gchar **substs = NULL;
guint n_substs = 0;
gint length = 0;
gint i;
p = path;
while (*p)
{
#ifndef G_OS_WIN32
if (*p == '~')
{
length += strlen (gimp_filename_to_utf8 (g_get_home_dir ()));
p += 1;
}
else
#endif /* G_OS_WIN32 */
if ((token = extract_token (&p)) != NULL)
{
for (i = 0; i < n_substs; i++)
if (strcmp (substs[2*i], token) == 0)
break;
if (i < n_substs)
{
s = substs[2*i+1];
}
else
{
s = NULL;
if (strcmp (token, "gimp_dir") == 0)
s = gimp_directory ();
else if (strcmp (token, "gimp_data_dir") == 0)
s = gimp_data_directory ();
else if (strcmp (token, "gimp_plug_in_dir") == 0 ||
strcmp (token, "gimp_plugin_dir") == 0)
s = gimp_plug_in_directory ();
else if (strcmp (token, "gimp_sysconf_dir") == 0)
s = gimp_sysconf_directory ();
if (!s)
s = g_getenv (token);
#ifdef G_OS_WIN32
/* The default user gimprc on Windows references
* ${TEMP}, but not all Windows installations have that
* environment variable, even if it should be kinda
* standard. So special-case it.
*/
if (!s && strcmp (token, "TEMP") == 0)
s = g_get_tmp_dir ();
#endif /* G_OS_WIN32 */
}
if (!s)
{
g_set_error (error, 0, 0, _("Cannot expand ${%s}"), token);
g_free (token);
goto cleanup;
}
if (n_substs % SUBSTS_ALLOC == 0)
substs = g_renew (gchar *, substs, 2 * (n_substs + SUBSTS_ALLOC));
substs[2*n_substs] = token;
substs[2*n_substs + 1] = (gchar *) gimp_filename_to_utf8 (s);
length += strlen (substs[2*n_substs + 1]);
n_substs++;
}
else
{
length += g_utf8_skip[(const guchar) *p];
p = g_utf8_next_char (p);
}
}
if (n_substs == 0)
return g_strdup (path);
expanded = g_new (gchar, length + 1);
p = path;
n = expanded;
while (*p)
{
#ifndef G_OS_WIN32
if (*p == '~')
{
*n = '\0';
strcat (n, gimp_filename_to_utf8 (g_get_home_dir ()));
n += strlen (gimp_filename_to_utf8 (g_get_home_dir ()));
p += 1;
}
else
#endif /* G_OS_WIN32 */
if ((token = extract_token (&p)) != NULL)
{
for (i = 0; i < n_substs; i++)
{
if (strcmp (substs[2*i], token) == 0)
{
s = substs[2*i+1];
*n = '\0';
strcat (n, s);
n += strlen (s);
break;
}
}
g_free (token);
}
else
{
*n++ = *p++;
}
}
*n = '\0';
cleanup:
for (i = 0; i < n_substs; i++)
g_free (substs[2*i]);
g_free (substs);
g_free (filename);
return expanded;
}
static inline gchar *
extract_token (const gchar **str)
{
const gchar *p;
gchar *token;
if (strncmp (*str, "${", 2))
return NULL;
p = *str + 2;
while (*p && (*p != '}'))
p = g_utf8_next_char (p);
if (!p)
return NULL;
token = g_strndup (*str + 2, g_utf8_pointer_to_offset (*str + 2, p));
*str = p + 1; /* after the closing bracket */
return token;
}

View File

@ -1,31 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpconfig-path.h
* Copyright (C) 2001-2002 Sven Neumann <sven@gimp.org>
*
* 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.
*/
#ifndef __GIMP_CONFIG_PATH_H__
#define __GIMP_CONFIG_PATH_H__
gchar * gimp_config_path_expand (const gchar *path,
gboolean recode,
GError **error);
#endif /* __GIMP_CONFIG_PATH_H__ */

View File

@ -1,429 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Object properties serialization routines
* Copyright (C) 2001-2002 Sven Neumann <sven@gimp.org>
*
* 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>
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "libgimpcolor/gimpcolor.h"
#include "config-types.h"
#include "gimpconfig.h"
#include "gimpconfig-params.h"
#include "gimpconfig-serialize.h"
#include "gimpconfig-utils.h"
#include "gimpconfigwriter.h"
/**
* gimp_config_serialize_properties:
* @config: a #GimpConfig.
* @writer: a #GimpConfigWriter.
*
* This function writes all object properties to the @writer.
*
* Returns: %TRUE if serialization succeeded, %FALSE otherwise
**/
gboolean
gimp_config_serialize_properties (GimpConfig *config,
GimpConfigWriter *writer)
{
GObjectClass *klass;
GParamSpec **property_specs;
guint n_property_specs;
guint i;
g_return_val_if_fail (G_IS_OBJECT (config), FALSE);
klass = G_OBJECT_GET_CLASS (config);
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;
if (! gimp_config_serialize_property (config, prop_spec, writer))
return FALSE;
}
g_free (property_specs);
return TRUE;
}
/**
* gimp_config_serialize_changed_properties:
* @config: a #GimpConfig.
* @writer: a #GimpConfigWriter.
*
* This function writes all object properties that have been changed from
* their default values to the @writer.
*
* Returns: %TRUE if serialization succeeded, %FALSE otherwise
**/
gboolean
gimp_config_serialize_changed_properties (GimpConfig *config,
GimpConfigWriter *writer)
{
GObjectClass *klass;
GParamSpec **property_specs;
guint n_property_specs;
guint i;
GValue value = { 0, };
g_return_val_if_fail (G_IS_OBJECT (config), FALSE);
klass = G_OBJECT_GET_CLASS (config);
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);
g_object_get_property (G_OBJECT (config), prop_spec->name, &value);
if (! g_param_value_defaults (prop_spec, &value))
{
if (! gimp_config_serialize_property (config, prop_spec, writer))
return FALSE;
}
g_value_unset (&value);
}
g_free (property_specs);
return TRUE;
}
gboolean
gimp_config_serialize_property (GimpConfig *config,
GParamSpec *param_spec,
GimpConfigWriter *writer)
{
GTypeClass *owner_class;
GimpConfigInterface *config_iface;
GimpConfigInterface *parent_iface = NULL;
GValue value = { 0, };
gboolean success = FALSE;
if (! (param_spec->flags & GIMP_PARAM_SERIALIZE))
return FALSE;
if (param_spec->flags & GIMP_PARAM_IGNORE)
return TRUE;
g_value_init (&value, param_spec->value_type);
g_object_get_property (G_OBJECT (config), param_spec->name, &value);
if (param_spec->flags & GIMP_PARAM_DEFAULTS &&
g_param_value_defaults (param_spec, &value))
{
g_value_unset (&value);
return TRUE;
}
owner_class = g_type_class_peek (param_spec->owner_type);
config_iface = g_type_interface_peek (owner_class, GIMP_TYPE_CONFIG);
/* 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);
}
if (config_iface &&
config_iface != parent_iface && /* see comment above */
config_iface->serialize_property &&
config_iface->serialize_property (config,
param_spec->param_id,
(const GValue *) &value,
param_spec,
writer))
{
success = TRUE;
}
/* If there is no serialize_property() method *or* if it returned
* FALSE, continue with the default implementation
*/
if (! success)
{
if (G_VALUE_HOLDS_OBJECT (&value))
{
GimpConfigInterface *config_iface = NULL;
GimpConfig *prop_object;
prop_object = g_value_get_object (&value);
if (prop_object)
config_iface = GIMP_CONFIG_GET_INTERFACE (prop_object);
else
success = TRUE;
if (config_iface)
{
gimp_config_writer_open (writer, param_spec->name);
/* 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));
}
success = config_iface->serialize (prop_object, writer, NULL);
if (success)
gimp_config_writer_close (writer);
else
gimp_config_writer_revert (writer);
}
}
else if (! G_VALUE_HOLDS_OBJECT (&value))
{
GString *str = g_string_new (NULL);
success = gimp_config_serialize_value (&value, str, TRUE);
if (success)
{
gimp_config_writer_open (writer, param_spec->name);
gimp_config_writer_print (writer, str->str, str->len);
gimp_config_writer_close (writer);
}
g_string_free (str, TRUE);
}
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",
g_type_name (G_TYPE_FROM_INSTANCE (config)),
param_spec->name,
g_type_name (param_spec->value_type));
}
}
}
g_value_unset (&value);
return success;
}
/**
* gimp_config_serialize_value:
* @value: a #GValue.
* @str: a #Gstring.
* @escaped: whether to escape string values.
*
* This utility function appends a string representation of #GValue to @str.
*
* Return value: %TRUE if serialization succeeded, %FALSE otherwise.
**/
gboolean
gimp_config_serialize_value (const GValue *value,
GString *str,
gboolean escaped)
{
if (G_VALUE_HOLDS_BOOLEAN (value))
{
gboolean bool;
bool = g_value_get_boolean (value);
g_string_append (str, bool ? "yes" : "no");
return TRUE;
}
if (G_VALUE_HOLDS_ENUM (value))
{
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));
if (enum_value && enum_value->value_nick)
{
g_string_append (str, enum_value->value_nick);
return TRUE;
}
else
{
g_warning ("Couldn't get nick for enum_value of %s",
G_ENUM_CLASS_TYPE_NAME (enum_class));
return FALSE;
}
}
if (G_VALUE_HOLDS_STRING (value))
{
const gchar *cstr = g_value_get_string (value);
if (!cstr)
return FALSE;
if (escaped)
gimp_config_string_append_escaped (str, cstr);
else
g_string_append (str, cstr);
return TRUE;
}
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;
}
if (GIMP_VALUE_HOLDS_RGB (value))
{
GimpRGB *rgb;
gchar buf[4][G_ASCII_DTOSTR_BUF_SIZE];
rgb = g_value_get_boxed (value);
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);
g_string_append_printf (str, "(color-rgba %s %s %s %s)",
buf[0], buf[1], buf[2], buf[3]);
return TRUE;
}
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;
}
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, " ");
if (! gimp_config_serialize_value (g_value_array_get_nth (array,
i),
str, TRUE))
return FALSE;
}
}
else
{
g_string_append (str, "NULL");
}
return TRUE;
}
if (g_value_type_transformable (G_VALUE_TYPE (value), G_TYPE_STRING))
{
GValue tmp_value = { 0, };
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;
}
return FALSE;
}

View File

@ -1,39 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Object properties serialization routines
* Copyright (C) 2001-2002 Sven Neumann <sven@gimp.org>
*
* 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.
*/
#ifndef __GIMP_CONFIG_SERIALIZE_H__
#define __GIMP_CONFIG_SERIALIZE_H__
gboolean gimp_config_serialize_properties (GimpConfig *config,
GimpConfigWriter *writer);
gboolean gimp_config_serialize_changed_properties (GimpConfig *config,
GimpConfigWriter *writer);
gboolean gimp_config_serialize_property (GimpConfig *config,
GParamSpec *param_spec,
GimpConfigWriter *writer);
gboolean gimp_config_serialize_value (const GValue *value,
GString *str,
gboolean escaped);
#endif /* __GIMP_CONFIG_SERIALIZE_H__ */

View File

@ -24,11 +24,10 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "config-types.h"
#include "gimpconfig.h"
#include "gimpconfig-params.h"
#include "gimpconfig-utils.h"
@ -128,362 +127,3 @@ gimp_config_disconnect (GObject *a,
b);
}
static gboolean
gimp_config_diff_property (GObject *a,
GObject *b,
GParamSpec *prop_spec)
{
GValue a_value = { 0, };
GValue b_value = { 0, };
gboolean retval = FALSE;
g_value_init (&a_value, prop_spec->value_type);
g_value_init (&b_value, prop_spec->value_type);
g_object_get_property (a, prop_spec->name, &a_value);
g_object_get_property (b, prop_spec->name, &b_value);
if (g_param_values_cmp (prop_spec, &a_value, &b_value))
{
if ((prop_spec->flags & GIMP_PARAM_AGGREGATE) &&
G_IS_PARAM_SPEC_OBJECT (prop_spec) &&
g_type_interface_peek (g_type_class_peek (prop_spec->value_type),
GIMP_TYPE_CONFIG))
{
if (! gimp_config_is_equal_to (g_value_get_object (&a_value),
g_value_get_object (&b_value)))
{
retval = TRUE;
}
}
else
{
retval = TRUE;
}
}
g_value_unset (&a_value);
g_value_unset (&b_value);
return retval;
}
static GList *
gimp_config_diff_same (GimpConfig *a,
GimpConfig *b,
GParamFlags flags)
{
GParamSpec **param_specs;
guint n_param_specs;
gint i;
GList *list = NULL;
param_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (a),
&n_param_specs);
for (i = 0; i < n_param_specs; i++)
{
GParamSpec *prop_spec = param_specs[i];
if (! flags || ((prop_spec->flags & flags) == flags))
{
if (gimp_config_diff_property (G_OBJECT (a),
G_OBJECT (b), prop_spec))
list = g_list_prepend (list, prop_spec);
}
}
g_free (param_specs);
return list;
}
static GList *
gimp_config_diff_other (GimpConfig *a,
GimpConfig *b,
GParamFlags flags)
{
GParamSpec **param_specs;
guint n_param_specs;
gint i;
GList *list = NULL;
param_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (a),
&n_param_specs);
for (i = 0; i < n_param_specs; i++)
{
GParamSpec *a_spec = param_specs[i];
GParamSpec *b_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (b),
a_spec->name);
if (b_spec &&
(a_spec->value_type == b_spec->value_type) &&
(! flags || (a_spec->flags & b_spec->flags & flags) == flags))
{
if (gimp_config_diff_property (G_OBJECT (a), G_OBJECT (b), b_spec))
list = g_list_prepend (list, b_spec);
}
}
g_free (param_specs);
return list;
}
/**
* gimp_config_diff:
* @a: a #GimpConfig object
* @b: another #GimpConfig object
* @flags: a mask of GParamFlags
*
* Compares all properties of @a and @b that have all @flags set. If
* @flags is 0, all properties are compared.
*
* If the two objects are not of the same type, only properties that
* exist in both object classes and are of the same value_type are
* compared.
*
* Return value: a GList of differing GParamSpecs.
**/
GList *
gimp_config_diff (GimpConfig *a,
GimpConfig *b,
GParamFlags flags)
{
GList *diff;
g_return_val_if_fail (GIMP_IS_CONFIG (a), NULL);
g_return_val_if_fail (GIMP_IS_CONFIG (b), NULL);
if (G_TYPE_FROM_INSTANCE (a) == G_TYPE_FROM_INSTANCE (b))
diff = gimp_config_diff_same (a, b, flags);
else
diff = gimp_config_diff_other (a, b, flags);
return g_list_reverse (diff);
}
/**
* gimp_config_sync:
* @src: a #GimpConfig object
* @dest: another #GimpConfig object
* @flags: a mask of GParamFlags
*
* Compares all read- and write-able properties from @src and @dest
* that have all @flags set. Differing values are then copied from
* @src to @dest. If @flags is 0, all differing read/write properties.
*
* Properties marked as "construct-only" are not touched.
*
* If the two objects are not of the same type, only
* properties that exist in both object classes and are of the same
* value_type are synchronized
*
* Return value: %TRUE if @dest was modified, %FALSE otherwise
**/
gboolean
gimp_config_sync (GimpConfig *src,
GimpConfig *dest,
GParamFlags flags)
{
GList *diff;
GList *list;
g_return_val_if_fail (GIMP_IS_CONFIG (src), FALSE);
g_return_val_if_fail (GIMP_IS_CONFIG (dest), FALSE);
/* we use the internal versions here for a number of reasons:
* - it saves a g_list_reverse()
* - it avoids duplicated parameter checks
* - it makes GimpTemplateEditor work (resolution is set before size)
*/
if (G_TYPE_FROM_INSTANCE (src) == G_TYPE_FROM_INSTANCE (dest))
diff = gimp_config_diff_same (src, dest, (flags | G_PARAM_READWRITE));
else
diff = gimp_config_diff_other (src, dest, flags);
if (!diff)
return FALSE;
for (list = diff; list; list = list->next)
{
GParamSpec *prop_spec = list->data;
if (! (prop_spec->flags & G_PARAM_CONSTRUCT_ONLY))
{
GValue value = { 0, };
g_value_init (&value, prop_spec->value_type);
g_object_get_property (G_OBJECT (src), prop_spec->name, &value);
g_object_set_property (G_OBJECT (dest), prop_spec->name, &value);
g_value_unset (&value);
}
}
g_list_free (diff);
return TRUE;
}
/**
* gimp_config_reset_properties:
* @config: a #GimpConfig
*
* Resets all writable properties of @object to the default values as
* defined in their #GParamSpec. Properties marked as "construct-only"
* are not touched.
**/
void
gimp_config_reset_properties (GimpConfig *config)
{
GObject *object;
GObjectClass *klass;
GParamSpec **property_specs;
GValue value = { 0, };
guint n_property_specs;
guint i;
g_return_if_fail (GIMP_IS_CONFIG (config));
klass = G_OBJECT_GET_CLASS (config);
property_specs = g_object_class_list_properties (klass, &n_property_specs);
if (!property_specs)
return;
object = G_OBJECT (config);
g_object_freeze_notify (object);
for (i = 0; i < n_property_specs; i++)
{
GParamSpec *prop_spec;
prop_spec = property_specs[i];
if ((prop_spec->flags & G_PARAM_WRITABLE) &&
! (prop_spec->flags & G_PARAM_CONSTRUCT_ONLY))
{
if (G_IS_PARAM_SPEC_OBJECT (prop_spec))
{
if ((prop_spec->flags & GIMP_PARAM_SERIALIZE) &&
(prop_spec->flags & GIMP_PARAM_AGGREGATE) &&
g_type_interface_peek (g_type_class_peek (prop_spec->value_type),
GIMP_TYPE_CONFIG))
{
g_value_init (&value, prop_spec->value_type);
g_object_get_property (object, prop_spec->name, &value);
gimp_config_reset (GIMP_CONFIG (g_value_get_object (&value)));
g_value_unset (&value);
}
}
else
{
g_value_init (&value, prop_spec->value_type);
g_param_value_set_default (prop_spec, &value);
g_object_set_property (object, prop_spec->name, &value);
g_value_unset (&value);
}
}
}
g_free (property_specs);
g_object_thaw_notify (object);
}
/*
* GimpConfig string utilities
*/
/**
* gimp_config_string_append_escaped:
* @string: pointer to a #GString
* @val: a string to append or %NULL
*
* Escapes and quotes @val and appends it to @string. The escape
* algorithm is different from the one used by g_strescape() since it
* leaves non-ASCII characters intact and thus preserves UTF-8
* strings. Only control characters and quotes are being escaped.
**/
void
gimp_config_string_append_escaped (GString *string,
const gchar *val)
{
g_return_if_fail (string != NULL);
if (val)
{
const guchar *p;
gchar buf[4] = { '\\', 0, 0, 0 };
gint len;
g_string_append_c (string, '\"');
for (p = val, len = 0; *p; p++)
{
if (*p < ' ' || *p == '\\' || *p == '\"')
{
g_string_append_len (string, val, len);
len = 2;
switch (*p)
{
case '\b':
buf[1] = 'b';
break;
case '\f':
buf[1] = 'f';
break;
case '\n':
buf[1] = 'n';
break;
case '\r':
buf[1] = 'r';
break;
case '\t':
buf[1] = 't';
break;
case '\\':
case '"':
buf[1] = *p;
break;
default:
len = 4;
buf[1] = '0' + (((*p) >> 6) & 07);
buf[2] = '0' + (((*p) >> 3) & 07);
buf[3] = '0' + ((*p) & 07);
break;
}
g_string_append_len (string, buf, len);
val = p + 1;
len = 0;
}
else
{
len++;
}
}
g_string_append_len (string, val, len);
g_string_append_c (string, '\"');
}
else
{
g_string_append_len (string, "\"\"", 2);
}
}

View File

@ -29,17 +29,4 @@ void gimp_config_connect (GObject *a,
void gimp_config_disconnect (GObject *a,
GObject *b);
GList * gimp_config_diff (GimpConfig *a,
GimpConfig *b,
GParamFlags flags);
gboolean gimp_config_sync (GimpConfig *src,
GimpConfig *dest,
GParamFlags flags);
void gimp_config_reset_properties (GimpConfig *config);
void gimp_config_string_append_escaped (GString *string,
const gchar *val);
#endif /* __GIMP_CONFIG_UTILS_H__ */

View File

@ -1,502 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Config file serialization and deserialization interface
* Copyright (C) 2001-2002 Sven Neumann <sven@gimp.org>
*
* 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 <string.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "config-types.h"
#include "gimpconfig.h"
#include "gimpconfig-deserialize.h"
#include "gimpconfig-serialize.h"
#include "gimpconfig-params.h"
#include "gimpconfig-utils.h"
#include "gimpconfigwriter.h"
#include "gimpscanner.h"
#include "gimp-intl.h"
/*
* The GimpConfig serialization and deserialization interface.
*/
static void gimp_config_iface_base_init (GimpConfigInterface *config_iface);
static gboolean gimp_config_iface_serialize (GimpConfig *config,
GimpConfigWriter *writer,
gpointer data);
static gboolean gimp_config_iface_deserialize (GimpConfig *config,
GScanner *scanner,
gint nest_level,
gpointer data);
static GimpConfig * gimp_config_iface_duplicate (GimpConfig *config);
static gboolean gimp_config_iface_equal (GimpConfig *a,
GimpConfig *b);
static void gimp_config_iface_reset (GimpConfig *config);
GType
gimp_config_interface_get_type (void)
{
static GType config_iface_type = 0;
if (!config_iface_type)
{
static const GTypeInfo config_iface_info =
{
sizeof (GimpConfigInterface),
(GBaseInitFunc) gimp_config_iface_base_init,
(GBaseFinalizeFunc) NULL,
};
config_iface_type = g_type_register_static (G_TYPE_INTERFACE,
"GimpConfigInterface",
&config_iface_info,
0);
g_type_interface_add_prerequisite (config_iface_type, G_TYPE_OBJECT);
}
return config_iface_type;
}
static void
gimp_config_iface_base_init (GimpConfigInterface *config_iface)
{
if (! config_iface->serialize)
{
config_iface->serialize = gimp_config_iface_serialize;
config_iface->deserialize = gimp_config_iface_deserialize;
config_iface->duplicate = gimp_config_iface_duplicate;
config_iface->equal = gimp_config_iface_equal;
config_iface->reset = gimp_config_iface_reset;
}
/* always set these to NULL since we don't want to inherit them
* from parent classes
*/
config_iface->serialize_property = NULL;
config_iface->deserialize_property = NULL;
}
static gboolean
gimp_config_iface_serialize (GimpConfig *config,
GimpConfigWriter *writer,
gpointer data)
{
return gimp_config_serialize_properties (config, writer);
}
static gboolean
gimp_config_iface_deserialize (GimpConfig *config,
GScanner *scanner,
gint nest_level,
gpointer data)
{
return gimp_config_deserialize_properties (config, scanner, nest_level);
}
static GimpConfig *
gimp_config_iface_duplicate (GimpConfig *config)
{
GObjectClass *klass;
GParamSpec **property_specs;
guint n_property_specs;
GParameter *construct_params = NULL;
gint n_construct_params = 0;
guint i;
GimpConfig *dup;
klass = G_OBJECT_GET_CLASS (config);
property_specs = g_object_class_list_properties (klass, &n_property_specs);
construct_params = g_new0 (GParameter, n_property_specs);
for (i = 0; i < n_property_specs; i++)
{
GParamSpec *prop_spec = property_specs[i];
if ((prop_spec->flags & G_PARAM_READABLE) &&
(prop_spec->flags & G_PARAM_WRITABLE) &&
(prop_spec->flags & G_PARAM_CONSTRUCT_ONLY))
{
GParameter *construct_param;
construct_param = &construct_params[n_construct_params++];
construct_param->name = prop_spec->name;
g_value_init (&construct_param->value, prop_spec->value_type);
g_object_get_property (G_OBJECT (config), prop_spec->name,
&construct_param->value);
}
}
g_free (property_specs);
dup = g_object_newv (G_TYPE_FROM_INSTANCE (config),
n_construct_params, construct_params);
for (i = 0; i < n_construct_params; i++)
g_value_unset (&construct_params[i].value);
g_free (construct_params);
gimp_config_sync (config, dup, 0);
return dup;
}
static gboolean
gimp_config_iface_equal (GimpConfig *a,
GimpConfig *b)
{
GObjectClass *klass;
GParamSpec **property_specs;
guint n_property_specs;
guint i;
gboolean equal = TRUE;
klass = G_OBJECT_GET_CLASS (a);
property_specs = g_object_class_list_properties (klass, &n_property_specs);
for (i = 0; equal && i < n_property_specs; i++)
{
GParamSpec *prop_spec;
GValue a_value = { 0, };
GValue b_value = { 0, };
prop_spec = property_specs[i];
if (! (prop_spec->flags & G_PARAM_READABLE))
continue;
g_value_init (&a_value, prop_spec->value_type);
g_value_init (&b_value, prop_spec->value_type);
g_object_get_property (G_OBJECT (a), prop_spec->name, &a_value);
g_object_get_property (G_OBJECT (b), prop_spec->name, &b_value);
if (g_param_values_cmp (prop_spec, &a_value, &b_value))
{
if ((prop_spec->flags & GIMP_PARAM_AGGREGATE) &&
G_IS_PARAM_SPEC_OBJECT (prop_spec) &&
g_type_interface_peek (g_type_class_peek (prop_spec->value_type),
GIMP_TYPE_CONFIG))
{
if (! gimp_config_is_equal_to (g_value_get_object (&a_value),
g_value_get_object (&b_value)))
{
equal = FALSE;
}
}
else
{
equal = FALSE;
}
}
g_value_unset (&a_value);
g_value_unset (&b_value);
}
g_free (property_specs);
return equal;
}
static void
gimp_config_iface_reset (GimpConfig *config)
{
gimp_config_reset_properties (config);
}
/**
* gimp_config_serialize_to_file:
* @config: a #GObject that implements the #GimpConfigInterface.
* @filename: the name of the file to write the configuration to.
* @header: optional file header (must be ASCII only)
* @footer: optional file footer (must be ASCII only)
* @data: user data passed to the serialize implementation.
* @error:
*
* Serializes the object properties of @config to the file specified
* by @filename. If a file with that name already exists, it is
* overwritten. Basically this function opens @filename for you and
* calls the serialize function of the @config's #GimpConfigInterface.
*
* Return value: %TRUE if serialization succeeded, %FALSE otherwise.
**/
gboolean
gimp_config_serialize_to_file (GimpConfig *config,
const gchar *filename,
const gchar *header,
const gchar *footer,
gpointer data,
GError **error)
{
GimpConfigWriter *writer;
g_return_val_if_fail (GIMP_IS_CONFIG (config), FALSE);
g_return_val_if_fail (filename != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
writer = gimp_config_writer_new_file (filename, TRUE, header, error);
if (!writer)
return FALSE;
GIMP_CONFIG_GET_INTERFACE (config)->serialize (config, writer, data);
return gimp_config_writer_finish (writer, footer, error);
}
gboolean
gimp_config_serialize_to_fd (GimpConfig *config,
gint fd,
gpointer data)
{
GimpConfigWriter *writer;
g_return_val_if_fail (GIMP_IS_CONFIG (config), FALSE);
g_return_val_if_fail (fd > 0, FALSE);
writer = gimp_config_writer_new_fd (fd);
if (!writer)
return FALSE;
GIMP_CONFIG_GET_INTERFACE (config)->serialize (config, writer, data);
return gimp_config_writer_finish (writer, NULL, NULL);
}
/**
* gimp_config_serialize_to_string:
* @config: a #GObject that implements the #GimpConfigInterface.
* @data: user data passed to the serialize implementation.
*
* Serializes the object properties of @config to a string.
*
* Return value: a newly allocated %NUL-terminated string.
**/
gchar *
gimp_config_serialize_to_string (GimpConfig *config,
gpointer data)
{
GimpConfigWriter *writer;
GString *str;
g_return_val_if_fail (GIMP_IS_CONFIG (config), NULL);
str = g_string_new (NULL);
writer = gimp_config_writer_new_string (str);
GIMP_CONFIG_GET_INTERFACE (config)->serialize (config, writer, data);
gimp_config_writer_finish (writer, NULL, NULL);
return g_string_free (str, FALSE);
}
/**
* gimp_config_deserialize:
* @config: a #GObject that implements the #GimpConfigInterface.
* @filename: the name of the file to read configuration from.
* @data: user data passed to the deserialize implementation.
* @error:
*
* Opens the file specified by @filename, reads configuration data
* from it and configures @config accordingly. Basically this function
* creates a properly configured #GScanner for you and calls the
* deserialize function of the @config's #GimpConfigInterface.
*
* Return value: %TRUE if deserialization succeeded, %FALSE otherwise.
**/
gboolean
gimp_config_deserialize_file (GimpConfig *config,
const gchar *filename,
gpointer data,
GError **error)
{
GScanner *scanner;
gboolean success;
g_return_val_if_fail (GIMP_IS_CONFIG (config), FALSE);
g_return_val_if_fail (filename != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
scanner = gimp_scanner_new_file (filename, error);
if (! scanner)
return FALSE;
success = GIMP_CONFIG_GET_INTERFACE (config)->deserialize (config,
scanner, 0, data);
gimp_scanner_destroy (scanner);
if (! success)
g_assert (error == NULL || *error != NULL);
return success;
}
/**
* gimp_config_deserialize_string:
* @config: a #GObject that implements the #GimpConfigInterface.
* @text: string to deserialize (in UTF-8 encoding)
* @text_len: length of @text in bytes or -1
* @data:
* @error:
*
* Configures @config from @text. Basically this function creates a
* properly configured #GScanner for you and calls the deserialize
* function of the @config's #GimpConfigInterface.
*
* Returns: %TRUE if deserialization succeeded, %FALSE otherwise.
**/
gboolean
gimp_config_deserialize_string (GimpConfig *config,
const gchar *text,
gint text_len,
gpointer data,
GError **error)
{
GScanner *scanner;
gboolean success;
g_return_val_if_fail (GIMP_IS_CONFIG (config), FALSE);
g_return_val_if_fail (text != NULL || text_len == 0, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
scanner = gimp_scanner_new_string (text, text_len, error);
success = GIMP_CONFIG_GET_INTERFACE (config)->deserialize (config,
scanner, 0, data);
gimp_scanner_destroy (scanner);
if (! success)
g_assert (error == NULL || *error != NULL);
return success;
}
gboolean
gimp_config_deserialize_return (GScanner *scanner,
GTokenType expected_token,
gint nest_level)
{
GTokenType next_token;
g_return_val_if_fail (scanner != NULL, FALSE);
next_token = g_scanner_peek_next_token (scanner);
if (expected_token != G_TOKEN_LEFT_PAREN)
{
g_scanner_get_next_token (scanner);
g_scanner_unexp_token (scanner, expected_token, NULL, NULL, NULL,
_("fatal parse error"), TRUE);
return FALSE;
}
else
{
if (nest_level > 0 && next_token == G_TOKEN_RIGHT_PAREN)
{
return TRUE;
}
else if (next_token != G_TOKEN_EOF)
{
g_scanner_get_next_token (scanner);
g_scanner_unexp_token (scanner, expected_token, NULL, NULL, NULL,
_("fatal parse error"), TRUE);
return FALSE;
}
}
return TRUE;
}
/**
* gimp_config_duplicate:
* @config: a #GObject that implements the #GimpConfigInterface.
*
* Creates a copy of the passed object by copying all object
* properties. The default implementation of the #GimpConfigInterface
* only works for objects that are completely defined by their
* properties.
*
* Return value: the duplicated #GimpConfig object
**/
gpointer
gimp_config_duplicate (GimpConfig *config)
{
g_return_val_if_fail (GIMP_IS_CONFIG (config), NULL);
return GIMP_CONFIG_GET_INTERFACE (config)->duplicate (config);
}
/**
* gimp_config_is_equal_to:
* @a: a #GObject that implements the #GimpConfigInterface.
* @b: another #GObject of the same type as @a.
*
* Compares the two objects. The default implementation of the
* #GimpConfigInterface compares the object properties and thus only
* works for objects that are completely defined by their
* properties.
*
* Return value: %TRUE if the two objects are equal.
**/
gboolean
gimp_config_is_equal_to (GimpConfig *a,
GimpConfig *b)
{
g_return_val_if_fail (GIMP_IS_CONFIG (a), FALSE);
g_return_val_if_fail (GIMP_IS_CONFIG (b), FALSE);
g_return_val_if_fail (G_TYPE_FROM_INSTANCE (a) == G_TYPE_FROM_INSTANCE (b),
FALSE);
return GIMP_CONFIG_GET_INTERFACE (a)->equal (a, b);
}
/**
* gimp_config_reset:
* @config: a #GObject that implements the #GimpConfigInterface.
*
* Resets the object to its default state. The default implementation of the
* #GimpConfigInterface only works for objects that are completely defined by
* their properties.
**/
void
gimp_config_reset (GimpConfig *config)
{
g_return_if_fail (GIMP_IS_CONFIG (config));
GIMP_CONFIG_GET_INTERFACE (config)->reset (config);
}

View File

@ -1,95 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* Config file serialization and deserialization interface
* Copyright (C) 2001-2003 Sven Neumann <sven@gimp.org>
*
* 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.
*/
#ifndef __GIMP_CONFIG_H__
#define __GIMP_CONFIG_H__
#define GIMP_TYPE_CONFIG (gimp_config_interface_get_type ())
#define GIMP_IS_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CONFIG))
#define GIMP_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CONFIG, GimpConfig))
#define GIMP_CONFIG_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GIMP_TYPE_CONFIG, GimpConfigInterface))
typedef struct _GimpConfigInterface GimpConfigInterface;
struct _GimpConfigInterface
{
GTypeInterface base_iface;
gboolean (* serialize) (GimpConfig *config,
GimpConfigWriter *writer,
gpointer data);
gboolean (* deserialize) (GimpConfig *config,
GScanner *scanner,
gint nest_level,
gpointer data);
gboolean (* serialize_property) (GimpConfig *config,
guint property_id,
const GValue *value,
GParamSpec *pspec,
GimpConfigWriter *writer);
gboolean (* deserialize_property) (GimpConfig *config,
guint property_id,
GValue *value,
GParamSpec *pspec,
GScanner *scanner,
GTokenType *expected);
GimpConfig * (* duplicate) (GimpConfig *config);
gboolean (* equal) (GimpConfig *a,
GimpConfig *b);
void (* reset) (GimpConfig *config);
};
GType gimp_config_interface_get_type (void) G_GNUC_CONST;
gboolean gimp_config_serialize_to_file (GimpConfig *config,
const gchar *filename,
const gchar *header,
const gchar *footer,
gpointer data,
GError **error);
gboolean gimp_config_serialize_to_fd (GimpConfig *config,
gint fd,
gpointer data);
gchar * gimp_config_serialize_to_string (GimpConfig *config,
gpointer data);
gboolean gimp_config_deserialize_file (GimpConfig *config,
const gchar *filename,
gpointer data,
GError **error);
gboolean gimp_config_deserialize_string (GimpConfig *config,
const gchar *text,
gint text_len,
gpointer data,
GError **error);
gboolean gimp_config_deserialize_return (GScanner *scanner,
GTokenType expected_token,
gint nest_level);
gpointer gimp_config_duplicate (GimpConfig *config);
gboolean gimp_config_is_equal_to (GimpConfig *a,
GimpConfig *b);
void gimp_config_reset (GimpConfig *config);
#endif /* __GIMP_CONFIG_H__ */

View File

@ -1,664 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* GimpConfigWriter
* Copyright (C) 2003 Sven Neumann <sven@gimp.org>
*
* 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 <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <glib-object.h>
#ifdef G_OS_WIN32
#include <io.h>
#endif
#include "libgimpbase/gimpbase.h"
#include "config-types.h"
#include "gimpconfig-error.h"
#include "gimpconfig-serialize.h"
#include "gimpconfig-utils.h"
#include "gimpconfigwriter.h"
#include "gimp-intl.h"
struct _GimpConfigWriter
{
gint fd;
gchar *filename;
gchar *tmpname;
GError *error;
GString *buffer;
gboolean comment;
gint depth;
gint marker;
};
static inline void gimp_config_writer_flush (GimpConfigWriter *writer);
static inline void gimp_config_writer_newline (GimpConfigWriter *writer);
static gboolean gimp_config_writer_close_file (GimpConfigWriter *writer,
GError **error);
static inline void
gimp_config_writer_flush (GimpConfigWriter *writer)
{
if (write (writer->fd, writer->buffer->str, writer->buffer->len) < 0)
g_set_error (&writer->error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
g_strerror (errno));
g_string_truncate (writer->buffer, 0);
}
static inline void
gimp_config_writer_newline (GimpConfigWriter *writer)
{
gint i;
g_string_append_c (writer->buffer, '\n');
if (writer->comment)
g_string_append_len (writer->buffer, "# ", 2);
for (i = 0; i < writer->depth; i++)
g_string_append_len (writer->buffer, " ", 4);
}
/**
* gimp_config_writer_new_file:
* @filename: a filename
* @atomic: if %TRUE the file is written atomically
* @header: text to include as comment at the top of the file
* @error: return location for errors
*
* Creates a new #GimpConfigWriter and sets it up to write to
* @filename. If @atomic is %TRUE, a temporary file is used to avoid
* possible race conditions. The temporary file is then moved to
* @filename when the writer is closed.
*
* Return value: a new #GimpConfigWriter or %NULL in case of an error
**/
GimpConfigWriter *
gimp_config_writer_new_file (const gchar *filename,
gboolean atomic,
const gchar *header,
GError **error)
{
GimpConfigWriter *writer;
gchar *tmpname = NULL;
gint fd;
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
if (atomic)
{
tmpname = g_strconcat (filename, "XXXXXX", NULL);
fd = g_mkstemp (tmpname);
if (fd == -1)
{
g_set_error (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
_("Could not create temporary file for '%s': %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
g_free (tmpname);
return NULL;
}
}
else
{
fd = creat (filename, 0644);
if (fd == -1)
{
g_set_error (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
_("Could not open '%s' for writing: %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
return NULL;
}
}
writer = g_new0 (GimpConfigWriter, 1);
writer->fd = fd;
writer->filename = g_strdup (filename);
writer->tmpname = tmpname;
writer->buffer = g_string_new (NULL);
if (header)
{
gimp_config_writer_comment (writer, header);
gimp_config_writer_linefeed (writer);
}
return writer;
}
GimpConfigWriter *
gimp_config_writer_new_fd (gint fd)
{
GimpConfigWriter *writer;
g_return_val_if_fail (fd > 0, NULL);
writer = g_new0 (GimpConfigWriter, 1);
writer->fd = fd;
writer->buffer = g_string_new (NULL);
return writer;
}
GimpConfigWriter *
gimp_config_writer_new_string (GString *string)
{
GimpConfigWriter *writer;
g_return_val_if_fail (string != NULL, NULL);
writer = g_new0 (GimpConfigWriter, 1);
writer->buffer = string;
return writer;
}
/**
* gimp_config_writer_comment_mode:
* @writer: a #GimpConfigWriter
* @enable: %TRUE to enable comment mode, %FALSE to disable it
*
* This function toggles whether the @writer should create commented
* or uncommented output. This feature is used to generate the
* system-wide installed gimprc that documents the default settings.
*
* Since comments have to start at the beginning of a line, this
* funtion will insert a newline if necessary.
**/
void
gimp_config_writer_comment_mode (GimpConfigWriter *writer,
gboolean enable)
{
g_return_if_fail (writer != NULL);
if (writer->error)
return;
enable = (enable ? TRUE : FALSE);
if (writer->comment == enable)
return;
writer->comment = enable;
if (enable)
{
if (writer->buffer->len == 0)
g_string_append_len (writer->buffer, "# ", 2);
else
gimp_config_writer_newline (writer);
}
}
/**
* gimp_config_writer_open:
* @writer: a #GimpConfigWriter
* @name: name of the element to open
*
* This function writes the opening parenthese followed by @name.
* It also increases the indentation level and sets a mark that
* can be used by gimp_config_writer_revert().
**/
void
gimp_config_writer_open (GimpConfigWriter *writer,
const gchar *name)
{
g_return_if_fail (writer != NULL);
g_return_if_fail (name != NULL);
if (writer->error)
return;
/* store the current buffer length so we can revert to this state */
writer->marker = writer->buffer->len;
if (writer->depth > 0)
gimp_config_writer_newline (writer);
writer->depth++;
g_string_append_printf (writer->buffer, "(%s", name);
}
/**
* gimp_config_writer_print:
* @writer: a #GimpConfigWriter
* @string: a string to write
* @len: number of bytes from @string or -1 if @string is NUL-terminated.
*
* Appends a space followed by @string to the @writer. Note that string
* must not contain any special characters that might need to be escaped.
**/
void
gimp_config_writer_print (GimpConfigWriter *writer,
const gchar *string,
gint len)
{
g_return_if_fail (writer != NULL);
g_return_if_fail (len == 0 || string != NULL);
if (writer->error)
return;
if (len < 0)
len = strlen (string);
if (len)
{
g_string_append_c (writer->buffer, ' ');
g_string_append_len (writer->buffer, string, len);
}
}
/**
* gimp_config_writer_printf:
* @writer: a #GimpConfigWriter
* @format: a format string as described for g_strdup_printf().
* @Varargs: list of arguments according to @format
*
* A printf-like function for #GimpConfigWriter.
**/
void
gimp_config_writer_printf (GimpConfigWriter *writer,
const gchar *format,
...)
{
gchar *buffer;
va_list args;
g_return_if_fail (writer != NULL);
g_return_if_fail (format != NULL);
if (writer->error)
return;
va_start (args, format);
buffer = g_strdup_vprintf (format, args);
va_end (args);
g_string_append_c (writer->buffer, ' ');
g_string_append (writer->buffer, buffer);
g_free (buffer);
}
/**
* gimp_config_writer_string:
* @writer: a #GimpConfigWriter
* @string: a NUL-terminated string
*
* Writes a string value to @writer. The @string is quoted and special
* characters are escaped.
**/
void
gimp_config_writer_string (GimpConfigWriter *writer,
const gchar *string)
{
g_return_if_fail (writer != NULL);
if (writer->error)
return;
g_string_append_c (writer->buffer, ' ');
gimp_config_string_append_escaped (writer->buffer, string);
}
/**
* gimp_config_writer_identifier:
* @writer: a #GimpConfigWriter
* @identifier: a NUL-terminated string
*
* Writes an identifier to @writer. The @string is *not* quoted and special
* characters are *not* escaped.
**/
void
gimp_config_writer_identifier (GimpConfigWriter *writer,
const gchar *identifier)
{
g_return_if_fail (writer != NULL);
g_return_if_fail (identifier != NULL);
if (writer->error)
return;
g_string_append_printf (writer->buffer, " %s", identifier);
}
void
gimp_config_writer_data (GimpConfigWriter *writer,
gint length,
const guint8 *data)
{
gint i;
g_return_if_fail (writer != NULL);
g_return_if_fail (length > 0);
g_return_if_fail (data != NULL);
if (writer->error)
return;
g_string_append (writer->buffer, " \"");
for (i = 0; i < length; i++)
{
if (g_ascii_isalpha (data[i]))
g_string_append_c (writer->buffer, data[i]);
else
g_string_append_printf (writer->buffer, "\\%o", data[i]);
}
g_string_append (writer->buffer, "\"");
}
/**
* gimp_config_writer_revert:
* @writer: a #GimpConfigWriter
*
* Reverts all changes to @writer that were done since the last call
* to gimp_config_writer_open(). This can only work if you didn't call
* gimp_config_writer_close() yet.
**/
void
gimp_config_writer_revert (GimpConfigWriter *writer)
{
g_return_if_fail (writer != NULL);
if (writer->error)
return;
g_return_if_fail (writer->depth > 0);
g_return_if_fail (writer->marker != -1);
g_string_truncate (writer->buffer, writer->marker);
writer->depth--;
writer->marker = -1;
}
/**
* gimp_config_writer_close:
* @writer: a #GimpConfigWriter
*
* Closes an element opened with gimp_config_writer_open().
**/
void
gimp_config_writer_close (GimpConfigWriter *writer)
{
g_return_if_fail (writer != NULL);
if (writer->error)
return;
g_return_if_fail (writer->depth > 0);
g_string_append_c (writer->buffer, ')');
if (--writer->depth == 0)
{
g_string_append_c (writer->buffer, '\n');
if (writer->fd)
gimp_config_writer_flush (writer);
}
}
/**
* gimp_config_writer_finish:
* @writer: a #GimpConfigWriter
* @footer: text to include as comment at the bottom of the file
* @error: return location for possible errors
*
* This function finishes the work of @writer and frees it afterwards.
* It closes all open elements, appends an optional comment and
* releases all resources allocated by @writer. You must not access
* the @writer afterwards.
*
* Return value: %TRUE if everything could be successfully written,
* %FALSE otherwise
**/
gboolean
gimp_config_writer_finish (GimpConfigWriter *writer,
const gchar *footer,
GError **error)
{
gboolean success = TRUE;
g_return_val_if_fail (writer != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (writer->depth < 0)
{
g_warning ("gimp_config_writer_finish: depth < 0 !!");
}
else
{
while (writer->depth)
gimp_config_writer_close (writer);
}
if (footer)
{
gimp_config_writer_linefeed (writer);
gimp_config_writer_comment (writer, footer);
}
if (writer->fd)
{
success = gimp_config_writer_close_file (writer, error);
g_free (writer->filename);
g_free (writer->tmpname);
g_string_free (writer->buffer, TRUE);
}
else
{
success = TRUE;
}
g_free (writer);
return success;
}
void
gimp_config_writer_linefeed (GimpConfigWriter *writer)
{
g_return_if_fail (writer != NULL);
if (writer->error)
return;
if (writer->buffer->len == 0 && !writer->comment)
{
if (write (writer->fd, "\n", 1) < 0)
g_set_error (&writer->error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
g_strerror (errno));
}
else
{
gimp_config_writer_newline (writer);
}
}
/**
* gimp_config_writer_comment:
* @writer: a #GimpConfigWriter
* @comment: the comment to write (ASCII only)
*
* Appends the @comment to @str and inserts linebreaks and hash-marks to
* format it as a comment. Note that this function does not handle non-ASCII
* characters.
**/
void
gimp_config_writer_comment (GimpConfigWriter *writer,
const gchar *comment)
{
const gchar *s;
gboolean comment_mode;
gint i, len, space;
#define LINE_LENGTH 75
g_return_if_fail (writer != NULL);
if (writer->error)
return;
g_return_if_fail (writer->depth == 0);
if (!comment)
return;
comment_mode = writer->comment;
gimp_config_writer_comment_mode (writer, TRUE);
len = strlen (comment);
while (len > 0)
{
for (s = comment, i = 0, space = 0;
*s != '\n' && (i <= LINE_LENGTH || space == 0) && i < len;
s++, i++)
{
if (g_ascii_isspace (*s))
space = i;
}
if (i > LINE_LENGTH && space && *s != '\n')
i = space;
g_string_append_len (writer->buffer, comment, i);
i++;
comment += i;
len -= i;
if (len > 0)
gimp_config_writer_newline (writer);
}
gimp_config_writer_comment_mode (writer, comment_mode);
gimp_config_writer_newline (writer);
if (writer->depth == 0)
gimp_config_writer_flush (writer);
#undef LINE_LENGTH
}
static gboolean
gimp_config_writer_close_file (GimpConfigWriter *writer,
GError **error)
{
g_return_val_if_fail (writer->fd != 0, FALSE);
if (! writer->filename)
return TRUE;
if (writer->error)
{
close (writer->fd);
if (writer->tmpname)
unlink (writer->tmpname);
return TRUE;
}
if (close (writer->fd) != 0)
{
if (writer->tmpname)
{
if (g_file_test (writer->filename, G_FILE_TEST_EXISTS))
{
g_set_error (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
_("Error writing to temporary file for '%s': %s\n"
"The original file has not been touched."),
gimp_filename_to_utf8 (writer->filename),
g_strerror (errno));
}
else
{
g_set_error (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
_("Error writing to temporary file for '%s': %s\n"
"No file has been created."),
gimp_filename_to_utf8 (writer->filename),
g_strerror (errno));
}
unlink (writer->tmpname);
}
else
{
g_set_error (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
_("Error writing to '%s': %s"),
gimp_filename_to_utf8 (writer->filename),
g_strerror (errno));
}
return FALSE;
}
if (writer->tmpname)
{
#ifdef G_OS_WIN32
/* win32 rename can't overwrite */
unlink (writer->filename);
#endif
if (rename (writer->tmpname, writer->filename) == -1)
{
g_set_error (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
_("Could not create '%s': %s"),
gimp_filename_to_utf8 (writer->filename),
g_strerror (errno));
unlink (writer->tmpname);
return FALSE;
}
}
return TRUE;
}

View File

@ -1,63 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* GimpConfigWriter
* Copyright (C) 2003 Sven Neumann <sven@gimp.org>
*
* 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.
*/
#ifndef __GIMP_CONFIG_WRITER_H__
#define __GIMP_CONFIG_WRITER_H__
GimpConfigWriter * gimp_config_writer_new_file (const gchar *filename,
gboolean atomic,
const gchar *header,
GError **error);
GimpConfigWriter * gimp_config_writer_new_fd (gint fd);
GimpConfigWriter * gimp_config_writer_new_string (GString *string);
void gimp_config_writer_open (GimpConfigWriter *writer,
const gchar *name);
void gimp_config_writer_comment_mode (GimpConfigWriter *writer,
gboolean enable);
void gimp_config_writer_print (GimpConfigWriter *writer,
const gchar *string,
gint len);
void gimp_config_writer_printf (GimpConfigWriter *writer,
const gchar *format,
...);
void gimp_config_writer_identifier (GimpConfigWriter *writer,
const gchar *identifier);
void gimp_config_writer_string (GimpConfigWriter *writer,
const gchar *string);
void gimp_config_writer_data (GimpConfigWriter *writer,
gint length,
const guint8 *data);
void gimp_config_writer_comment (GimpConfigWriter *writer,
const gchar *comment);
void gimp_config_writer_linefeed (GimpConfigWriter *writer);
void gimp_config_writer_revert (GimpConfigWriter *writer);
void gimp_config_writer_close (GimpConfigWriter *writer);
gboolean gimp_config_writer_finish (GimpConfigWriter *writer,
const gchar *footer,
GError **error);
#endif /* __GIMP_CONFIG_WRITER_H__ */

View File

@ -24,6 +24,7 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "config-types.h"
@ -31,10 +32,6 @@
#include "core/gimpgrid.h"
#include "core/gimptemplate.h"
#include "gimpconfig.h"
#include "gimpconfig-params.h"
#include "gimpconfig-utils.h"
#include "gimprc-blurbs.h"
#include "gimprc-utils.h"
#include "gimpcoreconfig.h"

View File

@ -25,16 +25,13 @@
#include "libgimpcolor/gimpcolor.h"
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "config-types.h"
#include "display/display-enums.h"
#include "display/gimpdisplayoptions.h"
#include "gimpconfig.h"
#include "gimpconfig-params.h"
#include "gimpconfig-utils.h"
#include "gimprc-blurbs.h"
#include "gimpdisplayconfig.h"

View File

@ -24,11 +24,10 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "config-types.h"
#include "gimpconfig-params.h"
#include "gimprc-blurbs.h"
#include "gimprc-utils.h"
#include "gimpguiconfig.h"

View File

@ -24,11 +24,10 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "config-types.h"
#include "gimpconfig-params.h"
#include "gimprc-blurbs.h"
#include "gimprc-utils.h"
#include "gimppluginconfig.h"

View File

@ -25,15 +25,12 @@
#include "libgimpcolor/gimpcolor.h"
#include "libgimpmath/gimpmath.h"
#include "libgimpconfig/gimpconfig.h"
#include "config-types.h"
#include "gimpconfig.h"
#include "gimpconfig-deserialize.h"
#include "gimpconfig-params.h"
#include "gimprc-deserialize.h"
#include "gimprc-unknown.h"
#include "gimpscanner.h"
#include "gimp-intl.h"

View File

@ -24,14 +24,10 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "config-types.h"
#include "gimpconfig.h"
#include "gimpconfig-serialize.h"
#include "gimpconfig-params.h"
#include "gimpconfig-utils.h"
#include "gimpconfigwriter.h"
#include "gimprc.h"
#include "gimprc-serialize.h"
#include "gimprc-unknown.h"

View File

@ -25,9 +25,11 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "config-types.h"
#include "gimpconfig.h"
#include "gimprc-unknown.h"

View File

@ -26,17 +26,11 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "config-types.h"
#include "gimpconfig.h"
#include "gimpconfig-deserialize.h"
#include "gimpconfig-error.h"
#include "gimpconfig-file.h"
#include "gimpconfig-params.h"
#include "gimpconfig-path.h"
#include "gimpconfig-serialize.h"
#include "gimpconfig-utils.h"
#include "gimprc.h"
#include "gimprc-deserialize.h"
#include "gimprc-serialize.h"

View File

@ -1,522 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpscanner.c
* Copyright (C) 2002 Sven Neumann <sven@gimp.org>
* Michael Natterer <mitch@gimp.org>
*
* 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 <string.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h>
#include <glib-object.h>
#ifdef G_OS_WIN32
#include <io.h>
#endif
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
#include "libgimpmath/gimpmath.h"
#include "config-types.h"
#include "gimpconfig-error.h"
#include "gimpscanner.h"
#include "gimp-intl.h"
typedef struct
{
gint fd;
gchar *name;
GError **error;
} GimpScannerData;
/* local function prototypes */
static GScanner * gimp_scanner_new (const gchar *name,
gint fd,
GError **error);
static void gimp_scanner_message (GScanner *scanner,
gchar *message,
gboolean is_error);
/* public functions */
GScanner *
gimp_scanner_new_file (const gchar *filename,
GError **error)
{
GScanner *scanner;
gint fd;
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
fd = open (filename, O_RDONLY);
if (fd == -1)
{
GimpConfigError code;
code = (errno == ENOENT ?
GIMP_CONFIG_ERROR_OPEN_ENOENT : GIMP_CONFIG_ERROR_OPEN);
g_set_error (error, GIMP_CONFIG_ERROR, code,
_("Could not open '%s' for reading: %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
return NULL;
}
/* gimp_scanner_new() takes a "name" for the scanner, not a filename. Thus
* do convert to UTF-8.
*/
scanner = gimp_scanner_new (gimp_filename_to_utf8 (filename), fd, error);
g_scanner_input_file (scanner, fd);
return scanner;
}
GScanner *
gimp_scanner_new_string (const gchar *text,
gint text_len,
GError **error)
{
GScanner *scanner;
g_return_val_if_fail (text != NULL || text_len == 0, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
if (text_len < 0)
text_len = strlen (text);
scanner = gimp_scanner_new (NULL, -1, error);
g_scanner_input_text (scanner, text, text_len);
return scanner;
}
static GScanner *
gimp_scanner_new (const gchar *name,
gint fd,
GError **error)
{
GScanner *scanner;
GimpScannerData *data;
scanner = g_scanner_new (NULL);
data = g_new0 (GimpScannerData, 1);
data->name = g_strdup (name);
data->fd = fd;
data->error = error;
scanner->user_data = data;
scanner->msg_handler = gimp_scanner_message;
scanner->config->cset_identifier_first = ( G_CSET_a_2_z G_CSET_A_2_Z );
scanner->config->cset_identifier_nth = ( G_CSET_a_2_z G_CSET_A_2_Z
G_CSET_DIGITS "-_" );
scanner->config->scan_identifier_1char = TRUE;
scanner->config->store_int64 = TRUE;
return scanner;
}
void
gimp_scanner_destroy (GScanner *scanner)
{
GimpScannerData *data;
g_return_if_fail (scanner != NULL);
data = scanner->user_data;
if (data->fd > 0)
{
if (close (data->fd))
g_warning ("%s: could not close file descriptor: %s",
G_STRFUNC, g_strerror (errno));
}
g_free (data->name);
g_free (data);
g_scanner_destroy (scanner);
}
gboolean
gimp_scanner_parse_token (GScanner *scanner,
GTokenType token)
{
if (g_scanner_peek_next_token (scanner) != token)
return FALSE;
g_scanner_get_next_token (scanner);
return TRUE;
}
gboolean
gimp_scanner_parse_identifier (GScanner *scanner,
const gchar *identifier)
{
if (g_scanner_peek_next_token (scanner) != G_TOKEN_IDENTIFIER)
return FALSE;
g_scanner_get_next_token (scanner);
if (strcmp (scanner->value.v_identifier, identifier))
return FALSE;
return TRUE;
}
gboolean
gimp_scanner_parse_string (GScanner *scanner,
gchar **dest)
{
if (g_scanner_peek_next_token (scanner) != G_TOKEN_STRING)
return FALSE;
g_scanner_get_next_token (scanner);
if (*scanner->value.v_string)
{
if (! g_utf8_validate (scanner->value.v_string, -1, NULL))
{
g_scanner_warn (scanner, _("invalid UTF-8 string"));
return FALSE;
}
*dest = g_strdup (scanner->value.v_string);
}
else
{
*dest = NULL;
}
return TRUE;
}
gboolean
gimp_scanner_parse_string_no_validate (GScanner *scanner,
gchar **dest)
{
if (g_scanner_peek_next_token (scanner) != G_TOKEN_STRING)
return FALSE;
g_scanner_get_next_token (scanner);
if (*scanner->value.v_string)
*dest = g_strdup (scanner->value.v_string);
else
*dest = NULL;
return TRUE;
}
gboolean
gimp_scanner_parse_data (GScanner *scanner,
gint length,
guint8 **dest)
{
if (g_scanner_peek_next_token (scanner) != G_TOKEN_STRING)
return FALSE;
g_scanner_get_next_token (scanner);
if (scanner->value.v_string)
*dest = g_memdup (scanner->value.v_string, length);
else
*dest = NULL;
return TRUE;
}
gboolean
gimp_scanner_parse_int (GScanner *scanner,
gint *dest)
{
gboolean negate = FALSE;
if (g_scanner_peek_next_token (scanner) == '-')
{
negate = TRUE;
g_scanner_get_next_token (scanner);
}
if (g_scanner_peek_next_token (scanner) != G_TOKEN_INT)
return FALSE;
g_scanner_get_next_token (scanner);
if (negate)
*dest = -scanner->value.v_int64;
else
*dest = scanner->value.v_int64;
return TRUE;
}
gboolean
gimp_scanner_parse_float (GScanner *scanner,
gdouble *dest)
{
if (g_scanner_peek_next_token (scanner) != G_TOKEN_FLOAT)
return FALSE;
g_scanner_get_next_token (scanner);
*dest = scanner->value.v_float;
return TRUE;
}
enum
{
COLOR_RGB = 1,
COLOR_RGBA,
COLOR_HSV,
COLOR_HSVA
};
gboolean
gimp_scanner_parse_color (GScanner *scanner,
GimpRGB *dest)
{
guint scope_id;
guint old_scope_id;
GTokenType token;
GimpRGB color;
scope_id = g_quark_from_static_string ("gimp_scanner_parse_color");
old_scope_id = g_scanner_set_scope (scanner, scope_id);
if (! g_scanner_scope_lookup_symbol (scanner, scope_id, "color-rgb"))
{
g_scanner_scope_add_symbol (scanner, scope_id,
"color-rgb", GINT_TO_POINTER (COLOR_RGB));
g_scanner_scope_add_symbol (scanner, scope_id,
"color-rgba", GINT_TO_POINTER (COLOR_RGBA));
g_scanner_scope_add_symbol (scanner, scope_id,
"color-hsv", GINT_TO_POINTER (COLOR_HSV));
g_scanner_scope_add_symbol (scanner, scope_id,
"color-hsva", GINT_TO_POINTER (COLOR_HSVA));
}
token = G_TOKEN_LEFT_PAREN;
while (g_scanner_peek_next_token (scanner) == token)
{
token = g_scanner_get_next_token (scanner);
switch (token)
{
case G_TOKEN_LEFT_PAREN:
token = G_TOKEN_SYMBOL;
break;
case G_TOKEN_SYMBOL:
{
gdouble col[4] = { 0.0, 0.0, 0.0, 1.0 };
gint n_channels = 4;
gboolean is_hsv = FALSE;
gint i;
switch (GPOINTER_TO_INT (scanner->value.v_symbol))
{
case COLOR_RGB:
n_channels = 3;
/* fallthrough */
case COLOR_RGBA:
break;
case COLOR_HSV:
n_channels = 3;
/* fallthrough */
case COLOR_HSVA:
is_hsv = TRUE;
break;
}
token = G_TOKEN_FLOAT;
for (i = 0; i < n_channels; i++)
{
if (! gimp_scanner_parse_float (scanner, &col[i]))
goto finish;
}
if (is_hsv)
{
GimpHSV hsv;
gimp_hsva_set (&hsv, col[0], col[1], col[2], col[3]);
gimp_hsv_clamp (&hsv);
gimp_hsv_to_rgb (&hsv, &color);
}
else
{
gimp_rgba_set (&color, col[0], col[1], col[2], col[3]);
gimp_rgb_clamp (&color);
}
token = G_TOKEN_RIGHT_PAREN;
}
break;
case G_TOKEN_RIGHT_PAREN:
token = G_TOKEN_NONE; /* indicates success */
goto finish;
default: /* do nothing */
break;
}
}
finish:
if (token != G_TOKEN_NONE)
{
g_scanner_get_next_token (scanner);
g_scanner_unexp_token (scanner, token, NULL, NULL, NULL,
_("fatal parse error"), TRUE);
}
else
{
*dest = color;
}
g_scanner_set_scope (scanner, old_scope_id);
return (token == G_TOKEN_NONE);
}
gboolean
gimp_scanner_parse_matrix2 (GScanner *scanner,
GimpMatrix2 *dest)
{
guint scope_id;
guint old_scope_id;
GTokenType token;
GimpMatrix2 matrix;
scope_id = g_quark_from_static_string ("gimp_scanner_parse_matrix");
old_scope_id = g_scanner_set_scope (scanner, scope_id);
if (! g_scanner_scope_lookup_symbol (scanner, scope_id, "matrix"))
g_scanner_scope_add_symbol (scanner, scope_id,
"matrix", GINT_TO_POINTER (0));
token = G_TOKEN_LEFT_PAREN;
while (g_scanner_peek_next_token (scanner) == token)
{
token = g_scanner_get_next_token (scanner);
switch (token)
{
case G_TOKEN_LEFT_PAREN:
token = G_TOKEN_SYMBOL;
break;
case G_TOKEN_SYMBOL:
{
token = G_TOKEN_FLOAT;
if (! gimp_scanner_parse_float (scanner, &matrix.coeff[0][0]))
goto finish;
if (! gimp_scanner_parse_float (scanner, &matrix.coeff[0][1]))
goto finish;
if (! gimp_scanner_parse_float (scanner, &matrix.coeff[1][0]))
goto finish;
if (! gimp_scanner_parse_float (scanner, &matrix.coeff[1][1]))
goto finish;
token = G_TOKEN_RIGHT_PAREN;
}
break;
case G_TOKEN_RIGHT_PAREN:
token = G_TOKEN_NONE; /* indicates success */
goto finish;
default: /* do nothing */
break;
}
}
finish:
if (token != G_TOKEN_NONE)
{
g_scanner_get_next_token (scanner);
g_scanner_unexp_token (scanner, token, NULL, NULL, NULL,
_("fatal parse error"), TRUE);
}
else
{
*dest = matrix;
}
g_scanner_set_scope (scanner, old_scope_id);
return (token == G_TOKEN_NONE);
}
/* private functions */
static void
gimp_scanner_message (GScanner *scanner,
gchar *message,
gboolean is_error)
{
GimpScannerData *data = scanner->user_data;
/* we don't expect warnings */
g_return_if_fail (is_error);
if (data->name)
g_set_error (data->error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_PARSE,
_("Error while parsing '%s' in line %d: %s"),
data->name, scanner->line, message);
else
/* should never happen, thus not marked for translation */
g_set_error (data->error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_PARSE,
"Error parsing internal buffer: %s", message);
}

View File

@ -1,55 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpscanner.h
* Copyright (C) 2002 Sven Neumann <sven@gimp.org>
* Michael Natterer <mitch@gimp.org>
*
* 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.
*/
#ifndef __GIMP_SCANNER_H__
#define __GIMP_SCANNER_H__
GScanner * gimp_scanner_new_file (const gchar *filename,
GError **error);
GScanner * gimp_scanner_new_string (const gchar *text,
gint text_len,
GError **error);
void gimp_scanner_destroy (GScanner *scanner);
gboolean gimp_scanner_parse_token (GScanner *scanner,
GTokenType token);
gboolean gimp_scanner_parse_identifier (GScanner *scanner,
const gchar *identifier);
gboolean gimp_scanner_parse_string (GScanner *scanner,
gchar **dest);
gboolean gimp_scanner_parse_string_no_validate (GScanner *scanner,
gchar **dest);
gboolean gimp_scanner_parse_data (GScanner *scanner,
gint length,
guint8 **dest);
gboolean gimp_scanner_parse_int (GScanner *scanner,
gint *dest);
gboolean gimp_scanner_parse_float (GScanner *scanner,
gdouble *dest);
gboolean gimp_scanner_parse_color (GScanner *scanner,
GimpRGB *dest);
gboolean gimp_scanner_parse_matrix2 (GScanner *scanner,
GimpMatrix2 *dest);
#endif /* __GIMP_SCANNER_H__ */

View File

@ -27,13 +27,11 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "core/core-types.h"
#include "core/gimpgrid.h"
#include "gimpconfig.h"
#include "gimpconfig-serialize.h"
#include "gimpconfig-utils.h"
#include "gimprc-unknown.h"

View File

@ -21,11 +21,10 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "core-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-error.h"
#include "config/gimpcoreconfig.h"
#include "gimp.h"

View File

@ -25,13 +25,11 @@
#include "libgimpbase/gimpbase.h"
#include "libgimpmodule/gimpmodule.h"
#include "libgimpconfig/gimpconfig.h"
#include "core-types.h"
#include "config/gimpconfig-path.h"
#include "config/gimpconfigwriter.h"
#include "config/gimpcoreconfig.h"
#include "config/gimpscanner.h"
#include "gimp.h"
#include "gimp-modules.h"

View File

@ -20,12 +20,10 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "core-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-error.h"
#include "gimp.h"
#include "gimp-parasites.h"
#include "gimpparasitelist.h"

View File

@ -21,12 +21,10 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "core-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-error.h"
#include "gimp.h"
#include "gimp-templates.h"
#include "gimplist.h"

View File

@ -24,6 +24,7 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "core-types.h"
@ -31,10 +32,7 @@
#include "gimp-units.h"
#include "gimpunit.h"
#include "config/gimpconfig-error.h"
#include "config/gimpconfig-file.h"
#include "config/gimpconfigwriter.h"
#include "config/gimpscanner.h"
#include "gimp-intl.h"

View File

@ -23,12 +23,10 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "core-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "config/gimpconfig-path.h"
#include "config/gimprc.h"
#include "pdb/procedural_db.h"

View File

@ -25,17 +25,14 @@
#include <glib-object.h>
#include "libgimpconfig/gimpconfig.h"
#include "core-types.h"
#include "gimp.h"
#include "gimpcontainer.h"
#include "gimpmarshal.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-deserialize.h"
#include "config/gimpconfigwriter.h"
#include "config/gimpscanner.h"
/* #define DEBUG_CONTAINER */

View File

@ -27,17 +27,13 @@
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
#include "libgimpconfig/gimpconfig.h"
#include "core-types.h"
#include "base/temp-buf.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "config/gimpconfig-serialize.h"
#include "config/gimpconfigwriter.h"
#include "config/gimpcoreconfig.h"
#include "config/gimpscanner.h"
#include "gimp.h"
#include "gimpbrush.h"

View File

@ -27,11 +27,11 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "core-types.h"
#include "config/gimpbaseconfig.h"
#include "config/gimpconfig-path.h"
#include "gimp.h"
#include "gimpcontext.h"

View File

@ -20,11 +20,9 @@
#include <glib-object.h>
#include "core-types.h"
#include "libgimpconfig/gimpconfig.h"
#include "config/gimpconfig.h"
#include "config/gimpconfigwriter.h"
#include "config/gimpscanner.h"
#include "core-types.h"
#include "gimp.h"
#include "gimpdocumentlist.h"

View File

@ -27,14 +27,12 @@
#include "libgimpbase/gimpbase.h"
#include "libgimpbase/gimplimits.h"
#include "libgimpconfig/gimpconfig.h"
#include "libgimpcolor/gimpcolor.h"
#include "core-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "gimpgrid.h"
#include "gimp-intl.h"

View File

@ -24,8 +24,6 @@
#include "base/pixel-region.h"
#include "config/gimpconfig.h"
#include "paint-funcs/paint-funcs.h"
#include "gimp.h"

View File

@ -23,10 +23,9 @@
#include <glib-object.h>
#include "core-types.h"
#include "libgimpconfig/gimpconfig.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-utils.h"
#include "core-types.h"
#include "gimpgrid.h"
#include "gimpimage.h"

View File

@ -20,10 +20,9 @@
#include <glib-object.h>
#include "core-types.h"
#include "libgimpconfig/gimpconfig.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-utils.h"
#include "core-types.h"
#include "gimp.h"
#include "gimpbuffer.h"

View File

@ -23,12 +23,10 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "core-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-utils.h"
#include "base/pixel-region.h"
#include "base/tile-manager.h"

View File

@ -26,14 +26,13 @@
#include "libgimpcolor/gimpcolor.h"
#include "libgimpmath/gimpmath.h"
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "core-types.h"
#include "base/temp-buf.h"
#include "base/tile-manager.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-utils.h"
#include "config/gimpcoreconfig.h"
#include "gimp.h"

View File

@ -29,13 +29,10 @@
#endif
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "core-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfigwriter.h"
#include "config/gimpscanner.h"
#include "gimp-utils.h"
#include "gimpmarshal.h"
#include "gimpparasitelist.h"

View File

@ -24,12 +24,10 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "core-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "config/gimpconfig-utils.h"
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"

View File

@ -24,11 +24,10 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "core-types.h"
#include "config/gimpconfig-params.h"
#include "gimpmarshal.h"
#include "gimpstrokeoptions.h"

View File

@ -26,12 +26,10 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "core-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "gimp.h"
#include "gimpcontext.h"
#include "gimpimage.h"

View File

@ -22,12 +22,12 @@
#include <glib-object.h>
#include "libgimpconfig/gimpconfig.h"
#include "core-types.h"
#include "base/temp-buf.h"
#include "config/gimpconfig-params.h"
#include "gimp.h"
#include "gimpcontainer.h"
#include "gimpcontext.h"

View File

@ -21,11 +21,10 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "core-types.h"
#include "config/gimpconfig.h"
#include "gimptoolinfo.h"
#include "gimptooloptions.h"

View File

@ -25,14 +25,12 @@
#include <glib-object.h>
#include "libgimpconfig/gimpconfig.h"
#include "core-types.h"
#include "base/temp-buf.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "config/gimpconfigwriter.h"
#include "gimp-utils.h"
#include "gimpmarshal.h"
#include "gimpviewable.h"

View File

@ -24,12 +24,11 @@
#include <gtk/gtk.h>
#include "libgimpbase/gimplimits.h"
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "dialogs-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-utils.h"
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"

View File

@ -23,12 +23,11 @@
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "dialogs-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-utils.h"
#include "config/gimpguiconfig.h"
#include "core/gimp.h"

View File

@ -24,13 +24,11 @@
#include "libgimpmath/gimpmath.h"
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "dialogs-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "config/gimpconfig-utils.h"
#include "config/gimprc.h"
#include "core/gimp.h"

View File

@ -22,13 +22,11 @@
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "dialogs-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-utils.h"
#include "core/gimp.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"

View File

@ -20,11 +20,11 @@
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "dialogs-types.h"
#include "config/gimpconfig.h"
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"

View File

@ -26,13 +26,11 @@
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "libgimpcolor/gimpcolor.h"
#include "libgimpconfig/gimpconfig.h"
#include "core/core-types.h"
#include "display-enums.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "config/gimprc-blurbs.h"
#include "gimpdisplayoptions.h"

View File

@ -23,14 +23,12 @@
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "display-types.h"
#include "tools/tools-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "config/gimpconfig-utils.h"
#include "config/gimpdisplayconfig.h"
#include "core/gimp.h"

View File

@ -25,13 +25,10 @@
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
#include "libgimpconfig/gimpconfig.h"
#include "gui-types.h"
#include "config/gimpconfig-utils.h"
#include "config/gimpconfigwriter.h"
#include "config/gimpscanner.h"
#include "color-history.h"

View File

@ -31,6 +31,7 @@
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#ifdef G_OS_WIN32
#include "libgimpbase/gimpwin32-io.h"
@ -38,11 +39,8 @@
#include "gui-types.h"
#include "config/gimpconfig-error.h"
#include "config/gimpconfig-file.h"
#include "config/gimpconfigwriter.h"
#include "config/gimpguiconfig.h"
#include "config/gimpscanner.h"
#include "core/gimp.h"

View File

@ -25,10 +25,10 @@
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "gui-types.h"
#include "config/gimpconfig-path.h"
#include "config/gimpguiconfig.h"
#include "core/gimp.h"

View File

@ -20,9 +20,9 @@
#include <glib-object.h>
#include "paint-types.h"
#include "libgimpconfig/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "paint-types.h"
#include "gimpairbrushoptions.h"

View File

@ -20,9 +20,9 @@
#include <glib-object.h>
#include "paint-types.h"
#include "libgimpconfig/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "paint-types.h"
#include "gimpcloneoptions.h"

View File

@ -20,9 +20,9 @@
#include <glib-object.h>
#include "paint-types.h"
#include "libgimpconfig/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "paint-types.h"
#include "gimpconvolveoptions.h"

View File

@ -20,9 +20,9 @@
#include <glib-object.h>
#include "paint-types.h"
#include "libgimpconfig/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "paint-types.h"
#include "gimpdodgeburnoptions.h"

View File

@ -20,9 +20,9 @@
#include <glib-object.h>
#include "paint-types.h"
#include "libgimpconfig/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "paint-types.h"
#include "gimperaseroptions.h"

View File

@ -20,9 +20,9 @@
#include <glib-object.h>
#include "paint-types.h"
#include "libgimpconfig/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "paint-types.h"
#include "core/gimp.h"
#include "core/gimpdrawable.h"

View File

@ -21,12 +21,10 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "paint-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "core/gimp.h"
#include "core/gimpimage.h"
#include "core/gimpgradient.h"

View File

@ -20,9 +20,9 @@
#include <glib-object.h>
#include "paint-types.h"
#include "libgimpconfig/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "paint-types.h"
#include "gimppenciloptions.h"

View File

@ -20,9 +20,9 @@
#include <glib-object.h>
#include "paint-types.h"
#include "libgimpconfig/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "paint-types.h"
#include "gimpsmudgeoptions.h"

View File

@ -20,9 +20,9 @@
#include <glib-object.h>
#include "paint-types.h"
#include "libgimpconfig/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "paint-types.h"
#include "gimpcloneoptions.h"

View File

@ -39,13 +39,13 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "libgimpthumb/gimpthumb.h"
#include "pdb-types.h"
#include "procedural_db.h"
#include "config/gimpbaseconfig.h"
#include "config/gimpconfig-path.h"
#include "core/gimp.h"
#include "core/gimpimage.h"
#include "core/gimpimagefile.h"

View File

@ -24,12 +24,12 @@
#include <glib-object.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpmodule/gimpmodule.h"
#include "pdb-types.h"
#include "procedural_db.h"
#include "config/gimpconfig.h"
#include "config/gimpcoreconfig.h"
#include "config/gimpdisplayconfig.h"
#include "config/gimprc.h"

View File

@ -27,12 +27,11 @@
#include "libgimpbase/gimpbase.h"
#include "libgimpbase/gimpprotocol.h"
#include "libgimpbase/gimpwire.h"
#include "libgimpconfig/gimpconfig.h"
#include "plug-in-types.h"
#include "config/gimpcoreconfig.h"
#include "config/gimpconfig-error.h"
#include "config/gimpconfig-path.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"

View File

@ -25,13 +25,10 @@
#include "libgimpbase/gimpbase.h"
#include "libgimpbase/gimpprotocol.h"
#include "libgimpconfig/gimpconfig.h"
#include "plug-in-types.h"
#include "config/gimpconfig-error.h"
#include "config/gimpconfigwriter.h"
#include "config/gimpscanner.h"
#include "core/gimp.h"
#include "plug-ins.h"

View File

@ -27,12 +27,11 @@
#include "libgimpbase/gimpbase.h"
#include "libgimpbase/gimpprotocol.h"
#include "libgimpbase/gimpwire.h"
#include "libgimpconfig/gimpconfig.h"
#include "plug-in-types.h"
#include "config/gimpcoreconfig.h"
#include "config/gimpconfig-error.h"
#include "config/gimpconfig-path.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"

View File

@ -28,10 +28,10 @@
#include <fontconfig/fontconfig.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "text-types.h"
#include "config/gimpconfig-path.h"
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"

View File

@ -28,11 +28,10 @@
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
#include "libgimpconfig/gimpconfig.h"
#include "text-types.h"
#include "config/gimpconfig.h"
#include "gimptext.h"
#include "gimptext-parasite.h"
#include "gimptext-xlfd.h"

View File

@ -28,12 +28,10 @@
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
#include "libgimpconfig/gimpconfig.h"
#include "text-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "core/gimpstrokeoptions.h"
#include "core/gimp-utils.h"

View File

@ -26,6 +26,8 @@
#include <glib-object.h>
#include <pango/pangoft2.h>
#include "libgimpconfig/gimpconfig.h"
#include "text-types.h"
#include "base/pixel-region.h"
@ -33,10 +35,6 @@
#include "paint-funcs/paint-funcs.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "config/gimpconfig-utils.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpcontainer.h"

View File

@ -20,10 +20,9 @@
#include <glib-object.h>
#include "text-types.h"
#include "libgimpconfig/gimpconfig.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-utils.h"
#include "text-types.h"
#include "core/gimpitem.h"
#include "core/gimpitemundo.h"

View File

@ -21,11 +21,10 @@
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "tools-types.h"
#include "config/gimpconfig.h"
#include "core/gimp.h"
#include "core/gimplist.h"
#include "core/gimptoolinfo.h"

View File

@ -20,12 +20,11 @@
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
#include "config/gimpconfig-params.h"
#include "core/gimp.h"
#include "core/gimpdatafactory.h"
#include "core/gimptoolinfo.h"

View File

@ -20,11 +20,11 @@
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
#include "config/gimpconfig-params.h"
#include "config/gimpguiconfig.h"
#include "core/gimp.h"

View File

@ -20,12 +20,11 @@
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
#include "config/gimpconfig-params.h"
#include "widgets/gimppropwidgets.h"
#include "gimphistogramoptions.h"

View File

@ -20,12 +20,11 @@
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
#include "config/gimpconfig-params.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gimpwidgets-utils.h"

View File

@ -21,6 +21,7 @@
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"

View File

@ -20,12 +20,11 @@
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
#include "config/gimpconfig-params.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gimpwidgets-utils.h"

View File

@ -23,6 +23,7 @@
#include "libgimpmath/gimpmath.h"
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"

View File

@ -20,12 +20,11 @@
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
#include "config/gimpconfig-params.h"
#include "core/gimptoolinfo.h"
#include "widgets/gimppropwidgets.h"

View File

@ -20,10 +20,9 @@
#include <gtk/gtk.h>
#include "tools-types.h"
#include "libgimpconfig/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "config/gimpconfig-utils.h"
#include "tools-types.h"
#include "widgets/gimphistogramview.h"
#include "widgets/gimppropwidgets.h"

View File

@ -20,9 +20,9 @@
#include <gtk/gtk.h>
#include "tools-types.h"
#include "libgimpconfig/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "tools-types.h"
#include "gimpimagemapoptions.h"

Some files were not shown because too many files have changed in this diff Show More