removed from CVS, they are generated.

2001-12-07  Sven Neumann  <sven@gimp.org>

	* app/core/gimpmarshal.[ch]: removed from CVS, they are generated.

	* app/base/Makefile.am
	* app/base/base-enums.h: new file defining enums that are to be
	registered. Used to build app/base/base-enums.c.

	* app/base/base-types.h: include base-enums.h.

	* tools/pdbgen/Makefile.am
	* tools/pdbgen/enumcode.pl
	* tools/pdbgen/enums.pl: parse the new base-enums.h file and modified
	the perl voodoo so it doesn't prefix enums with GIMP_ that are already
	properly namespaced.

	* app/core/core-types.h: don't need to chop GIMP from enum.

	* app/pdb/color_cmds.c
	* app/pdb/tools_cmds.c
	* libgimp/gimpenums.h
	* plug-ins/script-fu/script-fu-constants.c: regenerated.

	* app/config/gimpconfig-deserialize.[ch]
	* app/config/gimpconfig-serialize.[ch]
	* app/config/gimpconfig.[ch]: made GimpConfig an interface including
	a reasonable default implementation that works on object properties.

	* app/config/Makefile.am
	* app/config/gimpbaseconfig.[ch]: new GimpBaseConfig using the
	GimpConfig interface. Yet only used for testing from app/main.c.

	* app/main.c: test the new GimpBaseConfig object.

	* app/gimprc.c
	* app/base/base-config.h
	* app/base/*.c
	* app/core/gimpdatafiles.c
	* app/core/gimpdrawable-transform.c
	* app/core/gimppreviewcache.c
	* app/gui/preferences-dialog.c
	* app/paint-funcs/paint-funcs.c
	* app/xcf/xcf-seek.c: need to include glib-object.h since base-config
	contains registered enums now. Follow name change of InterpolationType
	to GimpInterpolationType.
This commit is contained in:
Sven Neumann 2001-12-07 16:10:53 +00:00 committed by Sven Neumann
parent 5e01f3b08b
commit d4829df4d3
59 changed files with 879 additions and 2044 deletions

View File

@ -1,8 +1,53 @@
2001-12-07 Sven Neumann <sven@gimp.org>
* app/core/gimpmarshal.[ch]: removed from CVS, they are generated.
* app/base/Makefile.am
* app/base/base-enums.h: new file defining enums that are to be
registered. Used to build app/base/base-enums.c.
* app/base/base-types.h: include base-enums.h.
* tools/pdbgen/Makefile.am
* tools/pdbgen/enumcode.pl
* tools/pdbgen/enums.pl: parse the new base-enums.h file and modified
the perl voodoo so it doesn't prefix enums with GIMP_ that are already
properly namespaced.
* app/core/core-types.h: don't need to chop GIMP from enum.
* app/pdb/color_cmds.c
* app/pdb/tools_cmds.c
* libgimp/gimpenums.h
* plug-ins/script-fu/script-fu-constants.c: regenerated.
* app/config/gimpconfig-deserialize.[ch]
* app/config/gimpconfig-serialize.[ch]
* app/config/gimpconfig.[ch]: made GimpConfig an interface including
a reasonable default implementation that works on object properties.
* app/config/Makefile.am
* app/config/gimpbaseconfig.[ch]: new GimpBaseConfig using the
GimpConfig interface. Yet only used for testing from app/main.c.
* app/main.c: test the new GimpBaseConfig object.
* app/gimprc.c
* app/base/base-config.h
* app/base/*.c
* app/core/gimpdatafiles.c
* app/core/gimpdrawable-transform.c
* app/core/gimppreviewcache.c
* app/gui/preferences-dialog.c
* app/paint-funcs/paint-funcs.c
* app/xcf/xcf-seek.c: need to include glib-object.h since base-config
contains registered enums now. Follow name change of InterpolationType
to GimpInterpolationType.
2001-12-06 David Neary <bolsh@gimp.org>
* plug-ins/common/vpropagate.c: Create Erode and Dilate
filter menu entries with reasonable defaults for
this plug-in.
* plug-ins/common/vpropagate.c: Create Erode and Dilate filter
menu entries with reasonable defaults for this plug-in.
2001-12-06 Sven Neumann <sven@gimp.org>
@ -16,8 +61,8 @@
2001-12-06 Dindinx <David@dindinx.org>
* plug-ins/*/*.c: use the G_N_ELEMENTS macro where appropriate,
removing a bunch of unuseful static variables.
Changed some g_malloc to g_new while I was on it.
removing a bunch of unuseful static variables. Changed some
g_malloc to g_new while I was on it.
2001-12-03 Michael Natterer <mitch@gimp.org>

View File

@ -4,3 +4,4 @@ Makefile.in
.libs
*.lo
libappbase.la
base-enums.c

View File

@ -5,6 +5,8 @@ noinst_LIBRARIES = libappbase.a
libappbase_a_SOURCES = @STRIP_BEGIN@ \
base.c \
base.h \
base-enums.c \
base-enums.h \
base-types.h \
base-config.c \
base-config.h \
@ -57,3 +59,21 @@ INCLUDES = @STRIP_BEGIN@ \
$(GLIB_CFLAGS) \
-I$(includedir) \
@STRIP_END@
#
# rules to generate built sources
#
# setup autogeneration dependancies
gen_sources = xgen-bec
CLEANFILES = $(gen_sources)
$(srcdir)/base-enums.c: $(srcdir)/base-enums.h
glib-mkenums \
--fhead "#include <glib-object.h>\n#include \"base-enums.h\"" \
--fprod "\n/* enumerations from \"@filename@\" */" \
--vhead "\nstatic const GEnumValue @enum_name@_enum_values[] =\n{\n" \
--vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
--vtail " { 0, NULL, NULL }\n};\n\nGType\n@enum_name@_get_type (void)\n{\n static GType enum_type = 0;\n\n if (!enum_type)\n enum_type = g_enum_register_static (\"@EnumName@\", @enum_name@_enum_values);\n\n return enum_type;\n}\n" \
$(srcdir)/base-enums.h > xgen-bec \
&& cp xgen-bec $(@F) \
&& rm -f xgen-bec

View File

@ -18,7 +18,7 @@
#include "config.h"
#include <glib.h>
#include <glib-object.h>
#include "base-types.h"
@ -38,7 +38,7 @@ static GimpBaseConfig static_base_config =
INIT_MEMBER(tile_cache_size , 33554432),
INIT_MEMBER(stingy_memory_use , FALSE),
INIT_MEMBER(interpolation_type , LINEAR_INTERPOLATION),
INIT_MEMBER(interpolation_type , GIMP_LINEAR_INTERPOLATION),
INIT_MEMBER(num_processors , 1)
};

View File

@ -24,12 +24,12 @@ typedef struct _GimpBaseConfig GimpBaseConfig;
struct _GimpBaseConfig
{
gchar *temp_path;
gchar *swap_path;
guint tile_cache_size;
gboolean stingy_memory_use;
InterpolationType interpolation_type;
gint num_processors;
gchar *temp_path;
gchar *swap_path;
guint tile_cache_size;
gboolean stingy_memory_use;
GimpInterpolationType interpolation_type;
gint num_processors;
};

34
app/base/base-enums.h Normal file
View File

@ -0,0 +1,34 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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 __BASE_ENUMS_H__
#define __BASE_ENUMS_H__
#define GIMP_TYPE_INTERPOLATION_TYPE (gimp_interpolation_type_get_type ())
GType gimp_interpolation_type_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_LINEAR_INTERPOLATION,
GIMP_CUBIC_INTERPOLATION,
GIMP_NEAREST_NEIGHBOR_INTERPOLATION
} GimpInterpolationType;
#endif /* __BASE_TYPES_H__ */

View File

@ -22,6 +22,8 @@
#include "paint-funcs/paint-funcs-types.h"
#include "base/base-enums.h"
/* magic constants */
/* FIXME: Remove magic constants! */
@ -75,13 +77,6 @@ typedef enum
NEGATIVE_CONVOL /* add 127 to values */
} ConvolutionType;
typedef enum
{
LINEAR_INTERPOLATION,
CUBIC_INTERPOLATION,
NEAREST_NEIGHBOR_INTERPOLATION
} InterpolationType;
typedef enum
{
VALUE_LUT,

View File

@ -29,7 +29,7 @@
#endif
#include <sys/types.h>
#include <glib.h>
#include <glib-object.h>
#ifdef G_OS_WIN32
#include <process.h> /* For _getpid() */

View File

@ -20,7 +20,7 @@
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include "base-types.h"

View File

@ -18,7 +18,7 @@
#include "config.h"
#include <glib.h>
#include <glib-object.h>
#include "base-types.h"

View File

@ -24,7 +24,7 @@
#include <pthread.h>
#endif /* ENABLE_MP */
#include <glib.h>
#include <glib-object.h>
#include "libgimpmath/gimpmath.h"

View File

@ -22,7 +22,7 @@
#include <stdio.h>
#include <glib.h>
#include <glib-object.h>
#include "base-types.h"

View File

@ -20,7 +20,7 @@
#include <stdio.h>
#include <glib.h>
#include <glib-object.h>
#include "libgimpmath/gimpmath.h"

View File

@ -27,7 +27,7 @@
#define IF_THREAD(statement)
#endif /* ENABLE_MP */
#include <glib.h>
#include <glib-object.h>
#include "base-types.h"

View File

@ -21,7 +21,7 @@
#include <stdarg.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include "base-types.h"

View File

@ -18,7 +18,7 @@
#include "config.h"
#include <glib.h>
#include <glib-object.h>
#include "base-types.h"

View File

@ -18,8 +18,6 @@
#include "config.h"
#include <glib.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
@ -30,6 +28,8 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <glib-object.h>
#ifdef G_OS_WIN32
#include <process.h> /* For _getpid() */
#endif

View File

@ -22,7 +22,7 @@
#include <pthread.h>
#endif
#include <glib.h>
#include <glib-object.h>
#include "base-types.h"

View File

@ -18,7 +18,7 @@
#include "config.h"
#include <glib.h>
#include <glib-object.h>
#include "base-types.h"

View File

@ -20,7 +20,7 @@
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include "base-types.h"

View File

@ -18,8 +18,6 @@
#include "config.h"
#include <glib.h>
#include <stdio.h> /* SEEK_SET */
#include <errno.h>
#include <sys/types.h>
@ -32,6 +30,8 @@
#include <pthread.h>
#endif
#include <glib-object.h>
#ifdef G_OS_WIN32
#include <io.h>
#endif

View File

@ -18,7 +18,7 @@
#include "config.h"
#include <glib.h>
#include <glib-object.h>
#include "base-types.h"

View File

@ -9,6 +9,8 @@ libappconfig_a_SOURCES = @STRIP_BEGIN@ \
gimpconfig-deserialize.h \
gimpconfig-serialize.c \
gimpconfig-serialize.h \
gimpbaseconfig.c \
gimpbaseconfig.h \
@STRIP_END@
AM_CPPFLAGS = @STRIP_BEGIN@ \

218
app/config/gimpbaseconfig.c Normal file
View File

@ -0,0 +1,218 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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 "base/base-enums.h"
#include "gimpconfig.h"
#include "gimpbaseconfig.h"
static void gimp_base_config_class_init (GimpBaseConfigClass *klass);
static void gimp_base_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_base_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
enum
{
PROP_0,
PROP_TEMP_PATH,
PROP_SWAP_PATH,
PROP_STINGY_MEMORY_USE,
PROP_NUM_PROCESSORS,
PROP_TILE_CACHE_SIZE,
PROP_INTERPOLATION_TYPE,
};
static GObjectClass *parent_class = NULL;
GType
gimp_base_config_get_type (void)
{
static GType config_type = 0;
if (! config_type)
{
static const GTypeInfo config_info =
{
sizeof (GimpBaseConfigClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_base_config_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpBaseConfig),
0, /* n_preallocs */
NULL /* instance_init */
};
static const GInterfaceInfo config_iface_info =
{
NULL, /* iface_init */
NULL, /* iface_finalize */
NULL /* iface_data */
};
config_type = g_type_register_static (G_TYPE_OBJECT, "GimpBaseConfig",
&config_info, 0);
g_type_add_interface_static (config_type, GIMP_TYPE_CONFIG_INTERFACE,
&config_iface_info);
}
return config_type;
}
static void
gimp_base_config_class_init (GimpBaseConfigClass *klass)
{
GObjectClass *object_class;
parent_class = g_type_class_peek_parent (klass);
object_class = G_OBJECT_CLASS (klass);
object_class->set_property = gimp_base_config_set_property;
object_class->get_property = gimp_base_config_get_property;
g_object_class_install_property (object_class,
PROP_TEMP_PATH,
g_param_spec_string ("temp-path",
NULL, NULL,
NULL,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_SWAP_PATH,
g_param_spec_string ("swap-path",
NULL, NULL,
NULL,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_STINGY_MEMORY_USE,
g_param_spec_boolean ("stingy-memory-use",
NULL, NULL,
FALSE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_NUM_PROCESSORS,
g_param_spec_uint ("num-processors",
NULL, NULL,
1, 30, 1,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_TILE_CACHE_SIZE,
g_param_spec_uint ("tile-cache-size",
NULL, NULL,
0, G_MAXINT, 1 << 25,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_INTERPOLATION_TYPE,
g_param_spec_enum ("interpolation-type",
NULL, NULL,
GIMP_TYPE_INTERPOLATION_TYPE,
GIMP_LINEAR_INTERPOLATION,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
}
static void
gimp_base_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpBaseConfig *base_config;
base_config = GIMP_BASE_CONFIG (object);
switch (property_id)
{
case PROP_TEMP_PATH:
g_free (base_config->temp_path);
base_config->temp_path = g_value_dup_string (value);
break;
case PROP_SWAP_PATH:
g_free (base_config->swap_path);
base_config->swap_path = g_value_dup_string (value);
break;
case PROP_STINGY_MEMORY_USE:
base_config->stingy_memory_use = g_value_get_boolean (value);
break;
case PROP_NUM_PROCESSORS:
base_config->num_processors = g_value_get_uint (value);
break;
case PROP_TILE_CACHE_SIZE:
base_config->tile_cache_size = g_value_get_uint (value);
break;
case PROP_INTERPOLATION_TYPE:
base_config->interpolation_type = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_base_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpBaseConfig *base_config;
base_config = GIMP_BASE_CONFIG (object);
switch (property_id)
{
case PROP_TEMP_PATH:
g_value_set_string (value, base_config->temp_path);
break;
case PROP_SWAP_PATH:
g_value_set_string (value, base_config->swap_path);
break;
case PROP_STINGY_MEMORY_USE:
g_value_set_boolean (value, base_config->stingy_memory_use);
break;
case PROP_NUM_PROCESSORS:
g_value_set_uint (value, base_config->num_processors);
break;
case PROP_TILE_CACHE_SIZE:
g_value_set_uint (value, base_config->tile_cache_size);
break;
case PROP_INTERPOLATION_TYPE:
g_value_set_enum (value, base_config->interpolation_type);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}

View File

@ -0,0 +1,56 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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_BASE_CONFIG_H__
#define __GIMP_BASE_CONFIG_H__
#include "base/base-enums.h"
#define GIMP_TYPE_BASE_CONFIG (gimp_base_config_get_type ())
#define GIMP_BASE_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_BASE_CONFIG, GimpBaseConfig))
#define GIMP_BASE_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_BASE_CONFIG, GimpBaseConfigClass))
#define GIMP_IS_BASE_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_BASE_CONFIG))
#define GIMP_IS_BASE_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_BASE_CONFIG))
typedef struct _GimpBaseConfig GimpBaseConfig;
typedef struct _GimpBaseConfigClass GimpBaseConfigClass;
struct _GimpBaseConfig
{
GObject parent_instance;
gchar *temp_path;
gchar *swap_path;
gboolean stingy_memory_use;
guint num_processors;
guint tile_cache_size;
GimpInterpolationType interpolation_type;
};
struct _GimpBaseConfigClass
{
GObjectClass parent_class;
};
GType gimp_base_config_get_type (void) G_GNUC_CONST;
#endif /* GIMP_BASE_CONFIG_H__ */

View File

@ -23,47 +23,47 @@
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <glib-object.h>
#include "gimpconfig.h"
#include "gimpconfig-deserialize.h"
static void gimp_config_deserialize_property (GimpConfig *config,
static void gimp_config_deserialize_property (GObject *object,
GScanner *scanner,
GTokenType *token);
gboolean
gimp_config_deserialize_properties (GimpConfig *config,
GScanner *scanner)
gimp_config_deserialize_properties (GObject *object,
GScanner *scanner)
{
GimpConfigClass *klass;
GParamSpec **property_specs;
guint n_property_specs;
guint i;
guint scope_id;
guint old_scope_id;
GTokenType token;
g_return_val_if_fail (GIMP_IS_CONFIG (config), FALSE);
GObjectClass *klass;
GParamSpec **property_specs;
guint n_property_specs;
guint i;
guint scope_id;
guint old_scope_id;
GTokenType token;
klass = GIMP_CONFIG_GET_CLASS (config);
property_specs = g_object_class_list_properties (G_OBJECT_CLASS (klass),
&n_property_specs);
g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
klass = G_OBJECT_GET_CLASS (object);
property_specs = g_object_class_list_properties (klass, &n_property_specs);
g_return_val_if_fail (property_specs != NULL && n_property_specs > 0, FALSE);
scope_id = GPOINTER_TO_UINT (config);
scope_id = g_quark_from_static_string ("gimp_config_deserialize_properties");
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 & G_PARAM_READWRITE &&
g_type_is_a (prop_spec->owner_type, GIMP_TYPE_CONFIG))
if (prop_spec->flags & G_PARAM_READWRITE)
{
g_scanner_scope_add_symbol (scanner, scope_id,
prop_spec->name, prop_spec);
@ -86,7 +86,7 @@ gimp_config_deserialize_properties (GimpConfig *config,
break;
case G_TOKEN_SYMBOL:
gimp_config_deserialize_property (config, scanner, &token);
gimp_config_deserialize_property (object, scanner, &token);
break;
case G_TOKEN_RIGHT_PAREN:
@ -106,25 +106,29 @@ gimp_config_deserialize_properties (GimpConfig *config,
"parse error", TRUE);
}
g_scanner_set_scope (scanner, old_scope_id);
if (property_specs)
g_free (property_specs);
g_scanner_set_scope (scanner, old_scope_id);
return (token == G_TOKEN_EOF);
}
static void
gimp_config_deserialize_property (GimpConfig *config,
gimp_config_deserialize_property (GObject *object,
GScanner *scanner,
GTokenType *token)
{
GParamSpec *prop_spec;
GType fundamental_type;
GValue value = { 0, };
prop_spec = G_PARAM_SPEC (scanner->value.v_symbol);
g_value_init (&value, prop_spec->value_type);
switch (G_TYPE_FUNDAMENTAL (G_VALUE_TYPE (&value)))
fundamental_type = G_TYPE_FUNDAMENTAL (G_VALUE_TYPE (&value));
switch (fundamental_type)
{
case G_TYPE_STRING:
*token = G_TOKEN_STRING;
@ -157,21 +161,23 @@ gimp_config_deserialize_property (GimpConfig *config,
g_scanner_get_next_token (scanner);
switch (G_TYPE_FUNDAMENTAL (G_VALUE_TYPE (&value)))
switch (fundamental_type)
{
case G_TYPE_STRING:
g_value_set_string (&value, scanner->value.v_string);
break;
case G_TYPE_BOOLEAN:
if (g_ascii_strcasecmp (scanner->value.v_identifier, "true") == 0)
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, "false") == 0)
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_warn
(scanner,
"expected 'true' or 'false' for boolean property %s, got '%s'",
"expected 'yes' or 'no' for boolean property %s, got '%s'",
prop_spec->name, scanner->value.v_identifier);
break;
@ -181,8 +187,12 @@ gimp_config_deserialize_property (GimpConfig *config,
GEnumValue *enum_value;
enum_class = g_type_class_peek (G_VALUE_TYPE (&value));
enum_value = g_enum_get_value_by_name (G_ENUM_CLASS (enum_class),
enum_value = g_enum_get_value_by_nick (G_ENUM_CLASS (enum_class),
scanner->value.v_identifier);
if (!enum_value)
enum_value = g_enum_get_value_by_name (G_ENUM_CLASS (enum_class),
scanner->value.v_identifier);
if (enum_value)
g_value_set_enum (&value, enum_value->value);
else
@ -203,8 +213,7 @@ gimp_config_deserialize_property (GimpConfig *config,
break;
case G_TYPE_ULONG:
g_value_set_uint (&value, scanner->value.v_int);
break;
break;
case G_TYPE_FLOAT:
g_value_set_float (&value, scanner->value.v_float);
break;
@ -216,7 +225,7 @@ gimp_config_deserialize_property (GimpConfig *config,
g_assert_not_reached ();
}
g_object_set_property (G_OBJECT (config), prop_spec->name, &value);
g_object_set_property (object, prop_spec->name, &value);
g_value_unset (&value);
*token = G_TOKEN_RIGHT_PAREN;

View File

@ -23,8 +23,8 @@
#define __DESERIALIZE_H__
gboolean gimp_config_deserialize_properties (GimpConfig *config,
GScanner *scanner);
gboolean gimp_config_deserialize_properties (GObject *object,
GScanner *scanner);
#endif /* __DESERIALIZE_H__ */

View File

@ -26,57 +26,75 @@
#include <glib-object.h>
#include "gimpconfig.h"
#include "gimpconfig-serialize.h"
void
gimp_config_serialize_properties (GimpConfig *config,
FILE *file)
gimp_config_serialize_properties (GObject *object,
FILE *file)
{
GimpConfigClass *klass;
GParamSpec **property_specs;
guint n_property_specs;
guint i;
GValue value = { 0, };
GObjectClass *klass;
GParamSpec **property_specs;
guint n_property_specs;
guint i;
GValue value = { 0, };
klass = GIMP_CONFIG_GET_CLASS (config);
klass = G_OBJECT_GET_CLASS (object);
property_specs = g_object_class_list_properties (G_OBJECT_CLASS (klass),
&n_property_specs);
property_specs = g_object_class_list_properties (klass, &n_property_specs);
for (i = 0; i < n_property_specs; i++)
{
GParamSpec *prop_spec;
gchar *str;
GParamSpec *prop_spec;
const gchar *cstr;
gchar *str;
prop_spec = property_specs[i];
if (! (prop_spec->flags & G_PARAM_READWRITE &&
g_type_is_a (prop_spec->owner_type, GIMP_TYPE_CONFIG)))
if (! (prop_spec->flags & G_PARAM_READWRITE))
continue;
str = NULL;
str = NULL;
cstr = NULL;
g_value_init (&value, prop_spec->value_type);
g_object_get_property (G_OBJECT (config), prop_spec->name, &value);
g_object_get_property (object, prop_spec->name, &value);
if (G_VALUE_HOLDS_STRING (&value))
if (G_VALUE_HOLDS_BOOLEAN (&value))
{
const gchar *src;
gboolean bool;
src = g_value_get_string (&value);
bool = g_value_get_boolean (&value);
cstr = bool ? "yes" : "no";
}
else if (G_VALUE_HOLDS_STRING (&value))
{
cstr = g_value_get_string (&value);
if (!src)
str = g_strdup ("NULL");
else
if (cstr)
{
gchar *s = g_strescape (src, NULL);
gchar *s = g_strescape (cstr, NULL);
str = g_strdup_printf ("\"%s\"", s);
g_free (s);
cstr = NULL;
}
}
else if (G_VALUE_HOLDS_ENUM (&value))
{
GEnumClass *enum_class;
GEnumValue *enum_value;
enum_class = g_type_class_peek (G_VALUE_TYPE (&value));
enum_value = g_enum_get_value (G_ENUM_CLASS (enum_class),
g_value_get_enum (&value));
if (enum_value && enum_value->value_nick)
cstr = enum_value->value_nick;
else
g_warning ("Couldn't get nick for enum_value of %s",
G_ENUM_CLASS_TYPE_NAME (enum_class));
}
else if (g_value_type_transformable (G_VALUE_TYPE (&value),
G_TYPE_STRING))
{
@ -88,9 +106,12 @@ gimp_config_serialize_properties (GimpConfig *config,
g_value_unset (&tmp_value);
}
fprintf (file, "(%s %s)\n", prop_spec->name, str);
if (cstr || str)
{
fprintf (file, "(%s %s)\n", prop_spec->name, cstr ? cstr : str);
g_free (str);
}
g_free (str);
g_value_unset (&value);
}
}

View File

@ -23,8 +23,8 @@
#define __SERIALIZE_H__
void gimp_config_serialize_properties (GimpConfig *config,
FILE *file);
void gimp_config_serialize_properties (GObject *object,
FILE *file);
#endif /* __SERIALIZE_H__ */

View File

@ -1,6 +1,9 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Config file serialization and deserialization interface
* 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
@ -18,206 +21,114 @@
#include "config.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <glib-object.h>
#include "gimpconfig.h"
#include "gimpconfig-deserialize.h"
#include "gimpconfig-serialize.h"
#include "gimpconfig-deserialize.h"
enum
{
PROP_0,
PROP_MARCHING_ANTS_SPEED,
PROP_PREVIEW_SIZE
};
static void gimp_config_iface_init (GimpConfigInterface *gimp_config_iface);
#define GIMP_TYPE_PREVIEW_SIZE (gimp_preview_size_get_type ())
GType gimp_preview_size_get_type (void) G_GNUC_CONST;
static void gimp_config_class_init (GimpConfigClass *klass);
static void gimp_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static GimpObjectClass *parent_class = NULL;
static const GEnumValue gimp_preview_size_enum_values[] =
{
{ GIMP_PREVIEW_SIZE_NONE, "none" },
{ GIMP_PREVIEW_SIZE_TINY, "tiny" },
{ GIMP_PREVIEW_SIZE_EXTRA_SMALL, "extra-small" },
{ GIMP_PREVIEW_SIZE_SMALL, "small" },
{ GIMP_PREVIEW_SIZE_MEDIUM, "medium" },
{ GIMP_PREVIEW_SIZE_LARGE, "large" },
{ GIMP_PREVIEW_SIZE_EXTRA_LARGE, "extra-large" },
{ GIMP_PREVIEW_SIZE_HUGE, "huge" },
{ GIMP_PREVIEW_SIZE_ENORMOUS, "enormous" },
{ GIMP_PREVIEW_SIZE_GIGANTIC, "gigantic" }
};
static void gimp_config_iface_serialize (GObject *object,
FILE *file);
static gboolean gimp_config_iface_deserialize (GObject *object,
GScanner *scanner);
GType
gimp_preview_size_get_type (void)
gimp_config_interface_get_type (void)
{
static GType size_type = 0;
static GType config_iface_type = 0;
if (! size_type)
if (!config_iface_type)
{
size_type = g_enum_register_static ("GimpPreviewSize",
gimp_preview_size_enum_values);
}
return size_type;
}
GType
gimp_config_get_type (void)
{
static GType config_type = 0;
if (! config_type)
{
static const GTypeInfo config_info =
static const GTypeInfo config_iface_info =
{
sizeof (GimpConfigClass),
(GBaseInitFunc) NULL,
sizeof (GimpConfigInterface),
(GBaseInitFunc) gimp_config_iface_init,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_config_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpConfig),
0, /* n_preallocs */
NULL /* instance_init */
};
config_type = g_type_register_static (GIMP_TYPE_OBJECT,
"GimpConfig",
&config_info, 0);
}
config_iface_type = g_type_register_static (G_TYPE_INTERFACE,
"GimpConfigInterface",
&config_iface_info,
0);
return config_type;
g_type_interface_add_prerequisite (config_iface_type,
G_TYPE_OBJECT);
}
return config_iface_type;
}
static void
gimp_config_class_init (GimpConfigClass *klass)
gimp_config_iface_init (GimpConfigInterface *gimp_config_iface)
{
GObjectClass *object_class;
parent_class = g_type_class_peek_parent (klass);
object_class = G_OBJECT_CLASS (klass);
object_class->set_property = gimp_config_set_property;
object_class->get_property = gimp_config_get_property;
g_object_class_install_property (object_class,
PROP_MARCHING_ANTS_SPEED,
g_param_spec_uint ("marching-ants-speed",
NULL, NULL,
50, G_MAXINT,
300,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_PREVIEW_SIZE,
g_param_spec_enum ("preview-size",
NULL, NULL,
GIMP_TYPE_PREVIEW_SIZE,
GIMP_PREVIEW_SIZE_MEDIUM,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
gimp_config_iface->serialize = gimp_config_iface_serialize;
gimp_config_iface->deserialize = gimp_config_iface_deserialize;
}
static void
gimp_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
gimp_config_iface_serialize (GObject *object,
FILE *file)
{
GimpConfig *gimp_config;
gimp_config = GIMP_CONFIG (object);
switch (property_id)
{
case PROP_MARCHING_ANTS_SPEED:
gimp_config->marching_ants_speed = g_value_get_uint (value);
break;
case PROP_PREVIEW_SIZE:
gimp_config->preview_size = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
gimp_config_serialize_properties (object, file);
}
static void
gimp_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
static gboolean
gimp_config_iface_deserialize (GObject *object,
GScanner *scanner)
{
GimpConfig *gimp_config;
gimp_config = GIMP_CONFIG (object);
switch (property_id)
{
case PROP_MARCHING_ANTS_SPEED:
g_value_set_uint (value, gimp_config->marching_ants_speed);
break;
case PROP_PREVIEW_SIZE:
g_value_set_enum (value, gimp_config->preview_size);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
void
gimp_config_serialize (GimpConfig *config)
{
FILE *file;
g_return_if_fail (GIMP_CONFIG (config));
g_return_if_fail (GIMP_OBJECT (config)->name != NULL);
file = fopen (GIMP_OBJECT (config)->name, "w");
if (file)
{
gimp_config_serialize_properties (config, file);
fclose (file);
}
return gimp_config_deserialize_properties (object, scanner);
}
gboolean
gimp_config_deserialize (GimpConfig *config)
gimp_config_serialize (GObject *object,
const gchar *filename)
{
gint fd;
GScanner *scanner;
gboolean success;
GimpConfigInterface *gimp_config_iface;
FILE *file;
g_return_val_if_fail (GIMP_CONFIG (config), FALSE);
g_return_val_if_fail (GIMP_OBJECT (config)->name != NULL, FALSE);
g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
g_return_val_if_fail (filename != NULL, FALSE);
gimp_config_iface = GIMP_GET_CONFIG_INTERFACE (object);
g_return_val_if_fail (gimp_config_iface != NULL, FALSE);
file = fopen (filename, "w");
if (!file)
return FALSE;
gimp_config_iface->serialize (object, file);
fclose (file);
return TRUE;
}
gboolean
gimp_config_deserialize (GObject *object,
const gchar *filename)
{
GimpConfigInterface *gimp_config_iface;
gint fd;
GScanner *scanner;
gboolean success;
g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
g_return_val_if_fail (filename != NULL, FALSE);
fd = open (GIMP_OBJECT (config)->name, O_RDONLY);
gimp_config_iface = GIMP_GET_CONFIG_INTERFACE (object);
g_return_val_if_fail (gimp_config_iface != NULL, FALSE);
fd = open (filename, O_RDONLY);
if (fd == -1)
return FALSE;
@ -228,9 +139,9 @@ gimp_config_deserialize (GimpConfig *config)
scanner->config->cset_identifier_nth = ( G_CSET_a_2_z "-" G_CSET_A_2_Z );
g_scanner_input_file (scanner, fd);
scanner->input_name = GIMP_OBJECT (config)->name;
scanner->input_name = filename;
success = gimp_config_deserialize_properties (config, scanner);
success = gimp_config_iface->deserialize (object, scanner);
g_scanner_destroy (scanner);
close (fd);

View File

@ -1,6 +1,9 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* Config file serialization and deserialization interface
* 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
@ -19,39 +22,31 @@
#ifndef __GIMP_CONFIG_H__
#define __GIMP_CONFIG_H__
#include "core/core-types.h"
#include "core/gimpobject.h"
#include <stdio.h>
#define GIMP_TYPE_CONFIG (gimp_config_get_type ())
#define GIMP_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CONFIG, GimpConfig))
#define GIMP_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CONFIG, GimpConfigClass))
#define GIMP_IS_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CONFIG))
#define GIMP_IS_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CONFIG))
#define GIMP_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CONFIG, GimpConfigClass))
#define GIMP_TYPE_CONFIG_INTERFACE (gimp_config_interface_get_type ())
#define GIMP_GET_CONFIG_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GIMP_TYPE_CONFIG_INTERFACE, GimpConfigInterface))
typedef struct _GimpConfigInterface GimpConfigInterface;
typedef struct _GimpConfig GimpConfig;
typedef struct _GimpConfigClass GimpConfigClass;
struct _GimpConfig
struct _GimpConfigInterface
{
GimpObject parent_instance;
GTypeInterface base_iface;
guint marching_ants_speed;
GimpPreviewSize preview_size;
};
struct _GimpConfigClass
{
GimpObjectClass parent_class;
void (* serialize) (GObject *object,
FILE *fd);
gboolean (* deserialize) (GObject *object,
GScanner *scanner);
};
GType gimp_config_get_type (void) G_GNUC_CONST;
GType gimp_config_interface_get_type (void) G_GNUC_CONST;
void gimp_config_serialize (GimpConfig *config);
gboolean gimp_config_deserialize (GimpConfig *config);
gboolean gimp_config_serialize (GObject *object,
const gchar *filename);
gboolean gimp_config_deserialize (GObject *object,
const gchar *filename);
#endif /* __GIMP_CONFIG_H__ */

View File

@ -4,4 +4,6 @@ Makefile.in
.libs
*.lo
libappcore.la
gimpmarshal.c
gimpmarshal.h
stamp-gimpmarshal.h

View File

@ -115,7 +115,7 @@ typedef enum
NO_FILL /*< nick=NO_IMAGE_FILL >*/
} GimpFillType;
typedef enum /*< chop=GIMP_ >*/
typedef enum
{
GIMP_SHADOWS,
GIMP_MIDTONES,

View File

@ -124,7 +124,7 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
/* turn interpolation off for simple transformations (e.g. rot90) */
if (gimp_matrix3_is_simple (matrix) ||
base_config->interpolation_type == NEAREST_NEIGHBOR_INTERPOLATION)
base_config->interpolation_type == GIMP_NEAREST_NEIGHBOR_INTERPOLATION)
interpolation = FALSE;
/* Get the background color */
@ -232,7 +232,7 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
/* initialise the pixel_surround accessor */
if (interpolation)
{
if (base_config->interpolation_type == CUBIC_INTERPOLATION)
if (base_config->interpolation_type == GIMP_CUBIC_INTERPOLATION)
{
pixel_surround_init (&surround, float_tiles, 4, 4, bg_col);
}
@ -294,7 +294,7 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
if (interpolation)
{
if (base_config->interpolation_type == CUBIC_INTERPOLATION)
if (base_config->interpolation_type == GIMP_CUBIC_INTERPOLATION)
{
/* ttx & tty are the subpixel coordinates of the point in
* the original selection's floating buffer.

View File

@ -21,8 +21,6 @@
#include "config.h"
#include <glib.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@ -35,6 +33,8 @@
#include <dirent.h>
#endif
#include <glib-object.h>
#ifdef G_OS_WIN32
#ifndef S_ISDIR
#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)

View File

@ -124,7 +124,7 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
/* turn interpolation off for simple transformations (e.g. rot90) */
if (gimp_matrix3_is_simple (matrix) ||
base_config->interpolation_type == NEAREST_NEIGHBOR_INTERPOLATION)
base_config->interpolation_type == GIMP_NEAREST_NEIGHBOR_INTERPOLATION)
interpolation = FALSE;
/* Get the background color */
@ -232,7 +232,7 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
/* initialise the pixel_surround accessor */
if (interpolation)
{
if (base_config->interpolation_type == CUBIC_INTERPOLATION)
if (base_config->interpolation_type == GIMP_CUBIC_INTERPOLATION)
{
pixel_surround_init (&surround, float_tiles, 4, 4, bg_col);
}
@ -294,7 +294,7 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
if (interpolation)
{
if (base_config->interpolation_type == CUBIC_INTERPOLATION)
if (base_config->interpolation_type == GIMP_CUBIC_INTERPOLATION)
{
/* ttx & tty are the subpixel coordinates of the point in
* the original selection's floating buffer.

File diff suppressed because it is too large Load Diff

View File

@ -1,265 +0,0 @@
#ifndef __gimp_marshal_MARSHAL_H__
#define __gimp_marshal_MARSHAL_H__
#include <glib-object.h>
G_BEGIN_DECLS
/* BOOLEAN:OBJECT (./gimpmarshal.list:25) */
extern void gimp_marshal_BOOLEAN__OBJECT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* BOOLEAN:POINTER (./gimpmarshal.list:26) */
extern void gimp_marshal_BOOLEAN__POINTER (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* BOOLEAN:VOID (./gimpmarshal.list:27) */
extern void gimp_marshal_BOOLEAN__VOID (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* INT:OBJECT (./gimpmarshal.list:29) */
extern void gimp_marshal_INT__OBJECT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* INT:POINTER (./gimpmarshal.list:30) */
extern void gimp_marshal_INT__POINTER (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* OBJECT:INT (./gimpmarshal.list:32) */
extern void gimp_marshal_OBJECT__INT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* OBJECT:POINTER (./gimpmarshal.list:33) */
extern void gimp_marshal_OBJECT__POINTER (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* POINTER:INT (./gimpmarshal.list:35) */
extern void gimp_marshal_POINTER__INT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* POINTER:INT,INT (./gimpmarshal.list:36) */
extern void gimp_marshal_POINTER__INT_INT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* POINTER:OBJECT,INT (./gimpmarshal.list:37) */
extern void gimp_marshal_POINTER__OBJECT_INT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* POINTER:POINTER (./gimpmarshal.list:38) */
extern void gimp_marshal_POINTER__POINTER (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* POINTER:POINTER,INT (./gimpmarshal.list:39) */
extern void gimp_marshal_POINTER__POINTER_INT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* POINTER:POINTER,INT,INT (./gimpmarshal.list:40) */
extern void gimp_marshal_POINTER__POINTER_INT_INT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* POINTER:VOID (./gimpmarshal.list:41) */
extern void gimp_marshal_POINTER__VOID (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* VOID:DOUBLE (./gimpmarshal.list:43) */
#define gimp_marshal_VOID__DOUBLE g_cclosure_marshal_VOID__DOUBLE
/* VOID:ENUM (./gimpmarshal.list:44) */
#define gimp_marshal_VOID__ENUM g_cclosure_marshal_VOID__ENUM
/* VOID:INT (./gimpmarshal.list:45) */
#define gimp_marshal_VOID__INT g_cclosure_marshal_VOID__INT
/* VOID:INT,BOOLEAN,INT,OBJECT (./gimpmarshal.list:46) */
extern void gimp_marshal_VOID__INT_BOOLEAN_INT_OBJECT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* VOID:INT,INT (./gimpmarshal.list:47) */
extern void gimp_marshal_VOID__INT_INT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* VOID:INT,INT,INT (./gimpmarshal.list:48) */
extern void gimp_marshal_VOID__INT_INT_INT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* VOID:INT,INT,INT,INT (./gimpmarshal.list:49) */
extern void gimp_marshal_VOID__INT_INT_INT_INT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* VOID:INT,OBJECT (./gimpmarshal.list:50) */
extern void gimp_marshal_VOID__INT_OBJECT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* VOID:INT,POINTER (./gimpmarshal.list:51) */
extern void gimp_marshal_VOID__INT_POINTER (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* VOID:INT,POINTER,POINTER (./gimpmarshal.list:52) */
extern void gimp_marshal_VOID__INT_POINTER_POINTER (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* VOID:OBJECT (./gimpmarshal.list:53) */
#define gimp_marshal_VOID__OBJECT g_cclosure_marshal_VOID__OBJECT
/* VOID:OBJECT,INT (./gimpmarshal.list:54) */
extern void gimp_marshal_VOID__OBJECT_INT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* VOID:OBJECT,INT,POINTER (./gimpmarshal.list:55) */
extern void gimp_marshal_VOID__OBJECT_INT_POINTER (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* VOID:OBJECT,POINTER (./gimpmarshal.list:56) */
extern void gimp_marshal_VOID__OBJECT_POINTER (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* VOID:POINTER (./gimpmarshal.list:57) */
#define gimp_marshal_VOID__POINTER g_cclosure_marshal_VOID__POINTER
/* VOID:POINTER,INT (./gimpmarshal.list:58) */
extern void gimp_marshal_VOID__POINTER_INT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* VOID:POINTER,INT,OBJECT (./gimpmarshal.list:59) */
extern void gimp_marshal_VOID__POINTER_INT_OBJECT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* VOID:POINTER,OBJECT (./gimpmarshal.list:60) */
extern void gimp_marshal_VOID__POINTER_OBJECT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* VOID:POINTER,POINTER (./gimpmarshal.list:61) */
extern void gimp_marshal_VOID__POINTER_POINTER (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* VOID:POINTER,UINT,INT,OBJECT (./gimpmarshal.list:62) */
extern void gimp_marshal_VOID__POINTER_UINT_INT_OBJECT (GClosure *closure,
GValue *return_value,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint,
gpointer marshal_data);
/* VOID:UINT (./gimpmarshal.list:63) */
#define gimp_marshal_VOID__UINT g_cclosure_marshal_VOID__UINT
/* VOID:VOID (./gimpmarshal.list:64) */
#define gimp_marshal_VOID__VOID g_cclosure_marshal_VOID__VOID
G_END_DECLS
#endif /* __gimp_marshal_MARSHAL_H__ */

View File

@ -18,7 +18,7 @@
#include "config.h"
#include <glib.h>
#include <glib-object.h>
#include "base/base-types.h"

View File

@ -118,7 +118,7 @@ static gboolean old_no_cursor_updating;
static gboolean old_show_tool_tips;
static gboolean old_show_rulers;
static gboolean old_show_statusbar;
static InterpolationType old_interpolation_type;
static GimpInterpolationType old_interpolation_type;
static gboolean old_confirm_on_close;
static gboolean old_save_session_info;
static gboolean old_save_device_status;
@ -2470,11 +2470,11 @@ preferences_dialog_create (Gimp *gimp)
GINT_TO_POINTER (base_config->interpolation_type),
_("Nearest Neighbor (Fast)"),
GINT_TO_POINTER (NEAREST_NEIGHBOR_INTERPOLATION), NULL,
GINT_TO_POINTER (GIMP_NEAREST_NEIGHBOR_INTERPOLATION), NULL,
_("Linear"),
GINT_TO_POINTER (LINEAR_INTERPOLATION), NULL,
GINT_TO_POINTER (GIMP_LINEAR_INTERPOLATION), NULL,
_("Cubic (Slow)"),
GINT_TO_POINTER (CUBIC_INTERPOLATION), NULL,
GINT_TO_POINTER (GIMP_CUBIC_INTERPOLATION), NULL,
NULL);

View File

@ -1264,11 +1264,11 @@ static gint
parse_interpolation_type (gpointer val1p,
gpointer val2p)
{
gint token;
InterpolationType *typep;
gint token;
GimpInterpolationType *typep;
g_assert (val1p != NULL);
typep = (InterpolationType *) val1p;
typep = (GimpInterpolationType *) val1p;
token = peek_next_token ();
if (!token || (token != TOKEN_SYMBOL))
@ -1276,11 +1276,11 @@ parse_interpolation_type (gpointer val1p,
token = get_next_token ();
if (strcmp (token_sym, "nearest-neighbor") == 0)
*typep = NEAREST_NEIGHBOR_INTERPOLATION;
*typep = GIMP_NEAREST_NEIGHBOR_INTERPOLATION;
else if (strcmp (token_sym, "linear") == 0)
*typep = LINEAR_INTERPOLATION;
*typep = GIMP_LINEAR_INTERPOLATION;
else if (strcmp (token_sym, "cubic") == 0)
*typep = CUBIC_INTERPOLATION;
*typep = GIMP_CUBIC_INTERPOLATION;
else
return ERROR;
@ -2986,16 +2986,16 @@ static inline gchar *
interpolation_type_to_str (gpointer val1p,
gpointer val2p)
{
InterpolationType type;
GimpInterpolationType type;
type = *((InterpolationType *)val1p);
type = *((GimpInterpolationType *)val1p);
switch (type)
{
case LINEAR_INTERPOLATION:
case GIMP_LINEAR_INTERPOLATION:
return g_strdup ("linear");
case CUBIC_INTERPOLATION:
case GIMP_CUBIC_INTERPOLATION:
return g_strdup ("cubic");
case NEAREST_NEIGHBOR_INTERPOLATION:
case GIMP_NEAREST_NEIGHBOR_INTERPOLATION:
return g_strdup ("nearest-neighbor");
default:
return g_strdup ("bad interpolation type");

View File

@ -118,7 +118,7 @@ static gboolean old_no_cursor_updating;
static gboolean old_show_tool_tips;
static gboolean old_show_rulers;
static gboolean old_show_statusbar;
static InterpolationType old_interpolation_type;
static GimpInterpolationType old_interpolation_type;
static gboolean old_confirm_on_close;
static gboolean old_save_session_info;
static gboolean old_save_device_status;
@ -2470,11 +2470,11 @@ preferences_dialog_create (Gimp *gimp)
GINT_TO_POINTER (base_config->interpolation_type),
_("Nearest Neighbor (Fast)"),
GINT_TO_POINTER (NEAREST_NEIGHBOR_INTERPOLATION), NULL,
GINT_TO_POINTER (GIMP_NEAREST_NEIGHBOR_INTERPOLATION), NULL,
_("Linear"),
GINT_TO_POINTER (LINEAR_INTERPOLATION), NULL,
GINT_TO_POINTER (GIMP_LINEAR_INTERPOLATION), NULL,
_("Cubic (Slow)"),
GINT_TO_POINTER (CUBIC_INTERPOLATION), NULL,
GINT_TO_POINTER (GIMP_CUBIC_INTERPOLATION), NULL,
NULL);

View File

@ -43,6 +43,7 @@
#include "core/core-types.h"
#include "config/gimpconfig.h"
#include "config/gimpbaseconfig.h"
#include "gui/gui.h"
@ -146,22 +147,21 @@ main (int argc,
/* test code for GimpConfig, will go away */
{
GimpConfig *config;
gchar *filename;
GimpBaseConfig *config;
gchar *filename;
config = g_object_new (GIMP_TYPE_CONFIG, NULL);
filename = gimp_personal_rc_file ("foorc");
gimp_object_set_name (GIMP_OBJECT (config), filename);
g_free (filename);
config = g_object_new (GIMP_TYPE_BASE_CONFIG, NULL);
g_signal_connect_swapped (G_OBJECT (config), "notify",
G_CALLBACK (g_print),
"GimpConfig property changed\n");
"GimpBaseConfig property changed\n");
gimp_config_serialize (config);
gimp_config_deserialize (config);
filename = gimp_personal_rc_file ("foorc");
gimp_config_serialize (G_OBJECT (config), filename);
gimp_config_deserialize (G_OBJECT (config), filename);
g_free (filename);
g_object_unref (config);
}

View File

@ -22,7 +22,7 @@
#include <string.h>
#include <stdio.h>
#include <glib.h>
#include <glib-object.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpmath/gimpmath.h"
@ -2784,12 +2784,12 @@ get_premultiplied_double_row (PixelRegion *srcPR,
static void
expand_line (gdouble *dest,
gdouble *src,
guint bytes,
guint old_width,
gint width,
InterpolationType interp)
expand_line (gdouble *dest,
gdouble *src,
guint bytes,
guint old_width,
gint width,
GimpInterpolationType interp)
{
gdouble ratio;
gint x,b;
@ -2803,7 +2803,7 @@ expand_line (gdouble *dest,
each x */
switch(interp)
{
case CUBIC_INTERPOLATION:
case GIMP_CUBIC_INTERPOLATION:
for (x = 0; x < width; x++)
{
src_col = ((int)((x) * ratio + 2.0 - 0.5)) - 2;
@ -2816,7 +2816,8 @@ expand_line (gdouble *dest,
dest += bytes;
}
break;
case LINEAR_INTERPOLATION:
case GIMP_LINEAR_INTERPOLATION:
for (x = 0; x < width; x++)
{
src_col = ((int)((x) * ratio + 2.0 - 0.5)) - 2;
@ -2829,20 +2830,21 @@ expand_line (gdouble *dest,
dest += bytes;
}
break;
case NEAREST_NEIGHBOR_INTERPOLATION:
g_error("sampling_type can't be "
"NEAREST_NEIGHBOR_INTERPOLATION");
case GIMP_NEAREST_NEIGHBOR_INTERPOLATION:
g_error("sampling_type can't be GIMP_NEAREST_NEIGHBOR_INTERPOLATION");
break;
}
}
static void
shrink_line (gdouble *dest,
gdouble *src,
guint bytes,
gint old_width,
gint width,
InterpolationType interp)
shrink_line (gdouble *dest,
gdouble *src,
guint bytes,
gint old_width,
gint width,
GimpInterpolationType interp)
{
gint x, b;
gdouble *source, *destp;
@ -2938,7 +2940,7 @@ scale_region (PixelRegion *srcPR,
gint old_y = -4, new_y;
gint x, y;
if (base_config->interpolation_type == NEAREST_NEIGHBOR_INTERPOLATION)
if (base_config->interpolation_type == GIMP_NEAREST_NEIGHBOR_INTERPOLATION)
{
scale_region_no_resample (srcPR, destPR);
return;
@ -3023,7 +3025,7 @@ scale_region (PixelRegion *srcPR,
}
switch(base_config->interpolation_type)
{
case CUBIC_INTERPOLATION:
case GIMP_CUBIC_INTERPOLATION:
{
double p0, p1, p2, p3;
double dy = ((y) * y_rat - .5) - new_y;
@ -3035,17 +3037,19 @@ scale_region (PixelRegion *srcPR,
accum[x] = p0 * src[0][x] + p1 * src[1][x] +
p2 * src[2][x] + p3 * src[3][x];
} break;
case LINEAR_INTERPOLATION:
case GIMP_LINEAR_INTERPOLATION:
{
double idy = ((y) * y_rat - 0.5) - new_y;
double dy = 1.0 - idy;
for (x = 0; x < width * bytes; x++)
accum[x] = dy * src[1][x] + idy * src[2][x];
} break;
case NEAREST_NEIGHBOR_INTERPOLATION:
g_error("sampling_type can't be "
"NEAREST_NEIGHBOR_INTERPOLATION");
case GIMP_NEAREST_NEIGHBOR_INTERPOLATION:
g_error ("sampling_type can't be "
"GIMP_NEAREST_NEIGHBOR_INTERPOLATION");
break;
}
}
else /* height == orig_height */

View File

@ -871,7 +871,7 @@ static ProcArg color_balance_inargs[] =
{
GIMP_PDB_INT32,
"transfer_mode",
"Transfer mode: { SHADOWS (0), MIDTONES (1), HIGHLIGHTS (2) }"
"Transfer mode: { GIMP_SHADOWS (0), GIMP_MIDTONES (1), GIMP_HIGHLIGHTS (2) }"
},
{
GIMP_PDB_INT32,

View File

@ -1023,7 +1023,7 @@ static ProcArg dodgeburn_inargs[] =
{
GIMP_PDB_INT32,
"dodgeburn_mode",
"The mode: { SHADOWS (0), MIDTONES (1), HIGHLIGHTS (2) }"
"The mode: { GIMP_SHADOWS (0), GIMP_MIDTONES (1), GIMP_HIGHLIGHTS (2) }"
},
{
GIMP_PDB_INT32,

View File

@ -20,7 +20,7 @@
#include <stdio.h>
#include <glib.h>
#include <glib-object.h>
#include "core/core-types.h"

View File

@ -152,6 +152,13 @@ typedef enum
GIMP_INDEXEDA_IMAGE
} GimpImageType;
typedef enum
{
GIMP_LINEAR_INTERPOLATION,
GIMP_CUBIC_INTERPOLATION,
GIMP_NEAREST_NEIGHBOR_INTERPOLATION
} GimpInterpolationType;
typedef enum
{
GIMP_OFFSET_BACKGROUND,
@ -200,13 +207,6 @@ typedef enum
GIMP_MAGENTA_HUES
} GimpHueRange;
typedef enum
{
GIMP_LINEAR_INTERPOLATION,
GIMP_CUBIC_INTERPOLATION,
GIMP_NEAREST_NEIGHBOR_INTERPOLATION
} GimpInterpolationType;
typedef enum
{
GIMP_NORMAL_MODE,

View File

@ -21,8 +21,6 @@
#include "config.h"
#include <glib.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@ -35,6 +33,8 @@
#include <dirent.h>
#endif
#include <glib-object.h>
#ifdef G_OS_WIN32
#ifndef S_ISDIR
#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)

View File

@ -23,47 +23,47 @@
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <glib-object.h>
#include "gimpconfig.h"
#include "gimpconfig-deserialize.h"
static void gimp_config_deserialize_property (GimpConfig *config,
static void gimp_config_deserialize_property (GObject *object,
GScanner *scanner,
GTokenType *token);
gboolean
gimp_config_deserialize_properties (GimpConfig *config,
GScanner *scanner)
gimp_config_deserialize_properties (GObject *object,
GScanner *scanner)
{
GimpConfigClass *klass;
GParamSpec **property_specs;
guint n_property_specs;
guint i;
guint scope_id;
guint old_scope_id;
GTokenType token;
g_return_val_if_fail (GIMP_IS_CONFIG (config), FALSE);
GObjectClass *klass;
GParamSpec **property_specs;
guint n_property_specs;
guint i;
guint scope_id;
guint old_scope_id;
GTokenType token;
klass = GIMP_CONFIG_GET_CLASS (config);
property_specs = g_object_class_list_properties (G_OBJECT_CLASS (klass),
&n_property_specs);
g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
klass = G_OBJECT_GET_CLASS (object);
property_specs = g_object_class_list_properties (klass, &n_property_specs);
g_return_val_if_fail (property_specs != NULL && n_property_specs > 0, FALSE);
scope_id = GPOINTER_TO_UINT (config);
scope_id = g_quark_from_static_string ("gimp_config_deserialize_properties");
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 & G_PARAM_READWRITE &&
g_type_is_a (prop_spec->owner_type, GIMP_TYPE_CONFIG))
if (prop_spec->flags & G_PARAM_READWRITE)
{
g_scanner_scope_add_symbol (scanner, scope_id,
prop_spec->name, prop_spec);
@ -86,7 +86,7 @@ gimp_config_deserialize_properties (GimpConfig *config,
break;
case G_TOKEN_SYMBOL:
gimp_config_deserialize_property (config, scanner, &token);
gimp_config_deserialize_property (object, scanner, &token);
break;
case G_TOKEN_RIGHT_PAREN:
@ -106,25 +106,29 @@ gimp_config_deserialize_properties (GimpConfig *config,
"parse error", TRUE);
}
g_scanner_set_scope (scanner, old_scope_id);
if (property_specs)
g_free (property_specs);
g_scanner_set_scope (scanner, old_scope_id);
return (token == G_TOKEN_EOF);
}
static void
gimp_config_deserialize_property (GimpConfig *config,
gimp_config_deserialize_property (GObject *object,
GScanner *scanner,
GTokenType *token)
{
GParamSpec *prop_spec;
GType fundamental_type;
GValue value = { 0, };
prop_spec = G_PARAM_SPEC (scanner->value.v_symbol);
g_value_init (&value, prop_spec->value_type);
switch (G_TYPE_FUNDAMENTAL (G_VALUE_TYPE (&value)))
fundamental_type = G_TYPE_FUNDAMENTAL (G_VALUE_TYPE (&value));
switch (fundamental_type)
{
case G_TYPE_STRING:
*token = G_TOKEN_STRING;
@ -157,21 +161,23 @@ gimp_config_deserialize_property (GimpConfig *config,
g_scanner_get_next_token (scanner);
switch (G_TYPE_FUNDAMENTAL (G_VALUE_TYPE (&value)))
switch (fundamental_type)
{
case G_TYPE_STRING:
g_value_set_string (&value, scanner->value.v_string);
break;
case G_TYPE_BOOLEAN:
if (g_ascii_strcasecmp (scanner->value.v_identifier, "true") == 0)
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, "false") == 0)
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_warn
(scanner,
"expected 'true' or 'false' for boolean property %s, got '%s'",
"expected 'yes' or 'no' for boolean property %s, got '%s'",
prop_spec->name, scanner->value.v_identifier);
break;
@ -181,8 +187,12 @@ gimp_config_deserialize_property (GimpConfig *config,
GEnumValue *enum_value;
enum_class = g_type_class_peek (G_VALUE_TYPE (&value));
enum_value = g_enum_get_value_by_name (G_ENUM_CLASS (enum_class),
enum_value = g_enum_get_value_by_nick (G_ENUM_CLASS (enum_class),
scanner->value.v_identifier);
if (!enum_value)
enum_value = g_enum_get_value_by_name (G_ENUM_CLASS (enum_class),
scanner->value.v_identifier);
if (enum_value)
g_value_set_enum (&value, enum_value->value);
else
@ -203,8 +213,7 @@ gimp_config_deserialize_property (GimpConfig *config,
break;
case G_TYPE_ULONG:
g_value_set_uint (&value, scanner->value.v_int);
break;
break;
case G_TYPE_FLOAT:
g_value_set_float (&value, scanner->value.v_float);
break;
@ -216,7 +225,7 @@ gimp_config_deserialize_property (GimpConfig *config,
g_assert_not_reached ();
}
g_object_set_property (G_OBJECT (config), prop_spec->name, &value);
g_object_set_property (object, prop_spec->name, &value);
g_value_unset (&value);
*token = G_TOKEN_RIGHT_PAREN;

View File

@ -23,8 +23,8 @@
#define __DESERIALIZE_H__
gboolean gimp_config_deserialize_properties (GimpConfig *config,
GScanner *scanner);
gboolean gimp_config_deserialize_properties (GObject *object,
GScanner *scanner);
#endif /* __DESERIALIZE_H__ */

View File

@ -1,6 +1,9 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Config file serialization and deserialization interface
* 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
@ -18,206 +21,114 @@
#include "config.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <glib-object.h>
#include "gimpconfig.h"
#include "gimpconfig-deserialize.h"
#include "gimpconfig-serialize.h"
#include "gimpconfig-deserialize.h"
enum
{
PROP_0,
PROP_MARCHING_ANTS_SPEED,
PROP_PREVIEW_SIZE
};
static void gimp_config_iface_init (GimpConfigInterface *gimp_config_iface);
#define GIMP_TYPE_PREVIEW_SIZE (gimp_preview_size_get_type ())
GType gimp_preview_size_get_type (void) G_GNUC_CONST;
static void gimp_config_class_init (GimpConfigClass *klass);
static void gimp_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static GimpObjectClass *parent_class = NULL;
static const GEnumValue gimp_preview_size_enum_values[] =
{
{ GIMP_PREVIEW_SIZE_NONE, "none" },
{ GIMP_PREVIEW_SIZE_TINY, "tiny" },
{ GIMP_PREVIEW_SIZE_EXTRA_SMALL, "extra-small" },
{ GIMP_PREVIEW_SIZE_SMALL, "small" },
{ GIMP_PREVIEW_SIZE_MEDIUM, "medium" },
{ GIMP_PREVIEW_SIZE_LARGE, "large" },
{ GIMP_PREVIEW_SIZE_EXTRA_LARGE, "extra-large" },
{ GIMP_PREVIEW_SIZE_HUGE, "huge" },
{ GIMP_PREVIEW_SIZE_ENORMOUS, "enormous" },
{ GIMP_PREVIEW_SIZE_GIGANTIC, "gigantic" }
};
static void gimp_config_iface_serialize (GObject *object,
FILE *file);
static gboolean gimp_config_iface_deserialize (GObject *object,
GScanner *scanner);
GType
gimp_preview_size_get_type (void)
gimp_config_interface_get_type (void)
{
static GType size_type = 0;
static GType config_iface_type = 0;
if (! size_type)
if (!config_iface_type)
{
size_type = g_enum_register_static ("GimpPreviewSize",
gimp_preview_size_enum_values);
}
return size_type;
}
GType
gimp_config_get_type (void)
{
static GType config_type = 0;
if (! config_type)
{
static const GTypeInfo config_info =
static const GTypeInfo config_iface_info =
{
sizeof (GimpConfigClass),
(GBaseInitFunc) NULL,
sizeof (GimpConfigInterface),
(GBaseInitFunc) gimp_config_iface_init,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_config_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpConfig),
0, /* n_preallocs */
NULL /* instance_init */
};
config_type = g_type_register_static (GIMP_TYPE_OBJECT,
"GimpConfig",
&config_info, 0);
}
config_iface_type = g_type_register_static (G_TYPE_INTERFACE,
"GimpConfigInterface",
&config_iface_info,
0);
return config_type;
g_type_interface_add_prerequisite (config_iface_type,
G_TYPE_OBJECT);
}
return config_iface_type;
}
static void
gimp_config_class_init (GimpConfigClass *klass)
gimp_config_iface_init (GimpConfigInterface *gimp_config_iface)
{
GObjectClass *object_class;
parent_class = g_type_class_peek_parent (klass);
object_class = G_OBJECT_CLASS (klass);
object_class->set_property = gimp_config_set_property;
object_class->get_property = gimp_config_get_property;
g_object_class_install_property (object_class,
PROP_MARCHING_ANTS_SPEED,
g_param_spec_uint ("marching-ants-speed",
NULL, NULL,
50, G_MAXINT,
300,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_PREVIEW_SIZE,
g_param_spec_enum ("preview-size",
NULL, NULL,
GIMP_TYPE_PREVIEW_SIZE,
GIMP_PREVIEW_SIZE_MEDIUM,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
gimp_config_iface->serialize = gimp_config_iface_serialize;
gimp_config_iface->deserialize = gimp_config_iface_deserialize;
}
static void
gimp_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
gimp_config_iface_serialize (GObject *object,
FILE *file)
{
GimpConfig *gimp_config;
gimp_config = GIMP_CONFIG (object);
switch (property_id)
{
case PROP_MARCHING_ANTS_SPEED:
gimp_config->marching_ants_speed = g_value_get_uint (value);
break;
case PROP_PREVIEW_SIZE:
gimp_config->preview_size = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
gimp_config_serialize_properties (object, file);
}
static void
gimp_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
static gboolean
gimp_config_iface_deserialize (GObject *object,
GScanner *scanner)
{
GimpConfig *gimp_config;
gimp_config = GIMP_CONFIG (object);
switch (property_id)
{
case PROP_MARCHING_ANTS_SPEED:
g_value_set_uint (value, gimp_config->marching_ants_speed);
break;
case PROP_PREVIEW_SIZE:
g_value_set_enum (value, gimp_config->preview_size);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
void
gimp_config_serialize (GimpConfig *config)
{
FILE *file;
g_return_if_fail (GIMP_CONFIG (config));
g_return_if_fail (GIMP_OBJECT (config)->name != NULL);
file = fopen (GIMP_OBJECT (config)->name, "w");
if (file)
{
gimp_config_serialize_properties (config, file);
fclose (file);
}
return gimp_config_deserialize_properties (object, scanner);
}
gboolean
gimp_config_deserialize (GimpConfig *config)
gimp_config_serialize (GObject *object,
const gchar *filename)
{
gint fd;
GScanner *scanner;
gboolean success;
GimpConfigInterface *gimp_config_iface;
FILE *file;
g_return_val_if_fail (GIMP_CONFIG (config), FALSE);
g_return_val_if_fail (GIMP_OBJECT (config)->name != NULL, FALSE);
g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
g_return_val_if_fail (filename != NULL, FALSE);
gimp_config_iface = GIMP_GET_CONFIG_INTERFACE (object);
g_return_val_if_fail (gimp_config_iface != NULL, FALSE);
file = fopen (filename, "w");
if (!file)
return FALSE;
gimp_config_iface->serialize (object, file);
fclose (file);
return TRUE;
}
gboolean
gimp_config_deserialize (GObject *object,
const gchar *filename)
{
GimpConfigInterface *gimp_config_iface;
gint fd;
GScanner *scanner;
gboolean success;
g_return_val_if_fail (G_IS_OBJECT (object), FALSE);
g_return_val_if_fail (filename != NULL, FALSE);
fd = open (GIMP_OBJECT (config)->name, O_RDONLY);
gimp_config_iface = GIMP_GET_CONFIG_INTERFACE (object);
g_return_val_if_fail (gimp_config_iface != NULL, FALSE);
fd = open (filename, O_RDONLY);
if (fd == -1)
return FALSE;
@ -228,9 +139,9 @@ gimp_config_deserialize (GimpConfig *config)
scanner->config->cset_identifier_nth = ( G_CSET_a_2_z "-" G_CSET_A_2_Z );
g_scanner_input_file (scanner, fd);
scanner->input_name = GIMP_OBJECT (config)->name;
scanner->input_name = filename;
success = gimp_config_deserialize_properties (config, scanner);
success = gimp_config_iface->deserialize (object, scanner);
g_scanner_destroy (scanner);
close (fd);

View File

@ -1,6 +1,9 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* Config file serialization and deserialization interface
* 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
@ -19,39 +22,31 @@
#ifndef __GIMP_CONFIG_H__
#define __GIMP_CONFIG_H__
#include "core/core-types.h"
#include "core/gimpobject.h"
#include <stdio.h>
#define GIMP_TYPE_CONFIG (gimp_config_get_type ())
#define GIMP_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CONFIG, GimpConfig))
#define GIMP_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CONFIG, GimpConfigClass))
#define GIMP_IS_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CONFIG))
#define GIMP_IS_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CONFIG))
#define GIMP_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CONFIG, GimpConfigClass))
#define GIMP_TYPE_CONFIG_INTERFACE (gimp_config_interface_get_type ())
#define GIMP_GET_CONFIG_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GIMP_TYPE_CONFIG_INTERFACE, GimpConfigInterface))
typedef struct _GimpConfigInterface GimpConfigInterface;
typedef struct _GimpConfig GimpConfig;
typedef struct _GimpConfigClass GimpConfigClass;
struct _GimpConfig
struct _GimpConfigInterface
{
GimpObject parent_instance;
GTypeInterface base_iface;
guint marching_ants_speed;
GimpPreviewSize preview_size;
};
struct _GimpConfigClass
{
GimpObjectClass parent_class;
void (* serialize) (GObject *object,
FILE *fd);
gboolean (* deserialize) (GObject *object,
GScanner *scanner);
};
GType gimp_config_get_type (void) G_GNUC_CONST;
GType gimp_config_interface_get_type (void) G_GNUC_CONST;
void gimp_config_serialize (GimpConfig *config);
gboolean gimp_config_deserialize (GimpConfig *config);
gboolean gimp_config_serialize (GObject *object,
const gchar *filename);
gboolean gimp_config_deserialize (GObject *object,
const gchar *filename);
#endif /* __GIMP_CONFIG_H__ */

View File

@ -26,57 +26,75 @@
#include <glib-object.h>
#include "gimpconfig.h"
#include "gimpconfig-serialize.h"
void
gimp_config_serialize_properties (GimpConfig *config,
FILE *file)
gimp_config_serialize_properties (GObject *object,
FILE *file)
{
GimpConfigClass *klass;
GParamSpec **property_specs;
guint n_property_specs;
guint i;
GValue value = { 0, };
GObjectClass *klass;
GParamSpec **property_specs;
guint n_property_specs;
guint i;
GValue value = { 0, };
klass = GIMP_CONFIG_GET_CLASS (config);
klass = G_OBJECT_GET_CLASS (object);
property_specs = g_object_class_list_properties (G_OBJECT_CLASS (klass),
&n_property_specs);
property_specs = g_object_class_list_properties (klass, &n_property_specs);
for (i = 0; i < n_property_specs; i++)
{
GParamSpec *prop_spec;
gchar *str;
GParamSpec *prop_spec;
const gchar *cstr;
gchar *str;
prop_spec = property_specs[i];
if (! (prop_spec->flags & G_PARAM_READWRITE &&
g_type_is_a (prop_spec->owner_type, GIMP_TYPE_CONFIG)))
if (! (prop_spec->flags & G_PARAM_READWRITE))
continue;
str = NULL;
str = NULL;
cstr = NULL;
g_value_init (&value, prop_spec->value_type);
g_object_get_property (G_OBJECT (config), prop_spec->name, &value);
g_object_get_property (object, prop_spec->name, &value);
if (G_VALUE_HOLDS_STRING (&value))
if (G_VALUE_HOLDS_BOOLEAN (&value))
{
const gchar *src;
gboolean bool;
src = g_value_get_string (&value);
bool = g_value_get_boolean (&value);
cstr = bool ? "yes" : "no";
}
else if (G_VALUE_HOLDS_STRING (&value))
{
cstr = g_value_get_string (&value);
if (!src)
str = g_strdup ("NULL");
else
if (cstr)
{
gchar *s = g_strescape (src, NULL);
gchar *s = g_strescape (cstr, NULL);
str = g_strdup_printf ("\"%s\"", s);
g_free (s);
cstr = NULL;
}
}
else if (G_VALUE_HOLDS_ENUM (&value))
{
GEnumClass *enum_class;
GEnumValue *enum_value;
enum_class = g_type_class_peek (G_VALUE_TYPE (&value));
enum_value = g_enum_get_value (G_ENUM_CLASS (enum_class),
g_value_get_enum (&value));
if (enum_value && enum_value->value_nick)
cstr = enum_value->value_nick;
else
g_warning ("Couldn't get nick for enum_value of %s",
G_ENUM_CLASS_TYPE_NAME (enum_class));
}
else if (g_value_type_transformable (G_VALUE_TYPE (&value),
G_TYPE_STRING))
{
@ -88,9 +106,12 @@ gimp_config_serialize_properties (GimpConfig *config,
g_value_unset (&tmp_value);
}
fprintf (file, "(%s %s)\n", prop_spec->name, str);
if (cstr || str)
{
fprintf (file, "(%s %s)\n", prop_spec->name, cstr ? cstr : str);
g_free (str);
}
g_free (str);
g_value_unset (&value);
}
}

View File

@ -23,8 +23,8 @@
#define __SERIALIZE_H__
void gimp_config_serialize_properties (GimpConfig *config,
FILE *file);
void gimp_config_serialize_properties (GObject *object,
FILE *file);
#endif /* __SERIALIZE_H__ */

View File

@ -103,6 +103,10 @@ init_generated_constants (void)
setvar (cintern ("INDEXED-IMAGE"), flocons (4), NIL);
setvar (cintern ("INDEXEDA-IMAGE"), flocons (5), NIL);
setvar (cintern ("LINEAR-INTERPOLATION"), flocons (0), NIL);
setvar (cintern ("CUBIC-INTERPOLATION"), flocons (1), NIL);
setvar (cintern ("NEAREST-NEIGHBOR-INTERPOLATION"), flocons (2), NIL);
setvar (cintern ("MESSAGE-BOX"), flocons (0), NIL);
setvar (cintern ("CONSOLE"), flocons (1), NIL);
setvar (cintern ("ERROR-CONSOLE"), flocons (2), NIL);
@ -186,10 +190,6 @@ init_generated_constants (void)
setvar (cintern ("BLUE-HUES"), flocons (5), NIL);
setvar (cintern ("MAGENTA-HUES"), flocons (6), NIL);
setvar (cintern ("LINEAR-INTERPOLATION"), flocons (0), NIL);
setvar (cintern ("CUBIC-INTERPOLATION"), flocons (1), NIL);
setvar (cintern ("NEAREST-NEIGHBOR-INTERPOLATION"), flocons (2), NIL);
setvar (cintern ("NORMAL-MODE"), flocons (0), NIL);
setvar (cintern ("DISSOLVE-MODE"), flocons (1), NIL);
setvar (cintern ("BEHIND-MODE"), flocons (2), NIL);

View File

@ -52,6 +52,7 @@ EXTRA_DIST = \
enum_headers = \
../../libgimpbase/gimpbasetypes.h \
../../app/paint-funcs/paint-funcs-types.h \
../../app/base/base-enums.h \
../../app/base/base-types.h \
../../app/core/core-types.h \
../../app/plug-in/plug-in-types.h \

View File

@ -71,6 +71,7 @@ foreach (sort keys %enums) {
foreach $symbol (@{$enum->{symbols}}) {
my $sym = $symbol;
$sym = $enum->{nicks}->{$sym} if exists $enum->{nicks}->{$sym};
$sym =~ s/^GIMP\_//;
$sym =~ s/_/-/g;
print ENUMFILE <<CODE;
@ -128,14 +129,18 @@ foreach (sort keys %enums) {
foreach $symbol (@{$enum->{symbols}}) {
my $sym = $symbol;
$sym = $enum->{nicks}->{$sym} if exists $enum->{nicks}->{$sym};
$body .= " GIMP_$sym";
if ($sym =~ /^GIMP\_/) {
$body .= " $sym";
} else {
$body .= " GIMP_$sym";
}
$body .= " = $enum->{mapping}->{$symbol}" if !$enum->{contig};
$body .= ",\n";
}
$body =~ s/,\n$//s;
$body .= "\n} ";
$body .= "Gimp" if !/^Gimp/;
$body .= "Gimp" unless /^Gimp/;
$body .= "$_;\n\n";
print ENUMFILE $body
}

View File

@ -151,6 +151,15 @@ package Gimp::CodeGen::enums;
GIMP_STACK_TRACE_QUERY => 'STACK_TRACE_QUERY',
GIMP_STACK_TRACE_ALWAYS => 'STACK_TRACE_ALWAYS' }
},
GimpInterpolationType =>
{ contig => 1,
header => 'base/base-enums.h',
symbols => [ qw(GIMP_LINEAR_INTERPOLATION GIMP_CUBIC_INTERPOLATION
GIMP_NEAREST_NEIGHBOR_INTERPOLATION) ],
mapping => { GIMP_LINEAR_INTERPOLATION => '0',
GIMP_CUBIC_INTERPOLATION => '1',
GIMP_NEAREST_NEIGHBOR_INTERPOLATION => '2' }
},
LayerModeEffects =>
{ contig => 1,
header => 'base/base-types.h',
@ -190,15 +199,6 @@ package Gimp::CodeGen::enums;
ABSOLUTE_CONVOL => '1',
NEGATIVE_CONVOL => '2' }
},
InterpolationType =>
{ contig => 1,
header => 'base/base-types.h',
symbols => [ qw(LINEAR_INTERPOLATION CUBIC_INTERPOLATION
NEAREST_NEIGHBOR_INTERPOLATION) ],
mapping => { LINEAR_INTERPOLATION => '0',
CUBIC_INTERPOLATION => '1',
NEAREST_NEIGHBOR_INTERPOLATION => '2' }
},
ChannelLutType =>
{ contig => 1,
header => 'base/base-types.h',
@ -314,10 +314,7 @@ package Gimp::CodeGen::enums;
symbols => [ qw(GIMP_SHADOWS GIMP_MIDTONES GIMP_HIGHLIGHTS) ],
mapping => { GIMP_SHADOWS => '0',
GIMP_MIDTONES => '1',
GIMP_HIGHLIGHTS => '2' },
nicks => { GIMP_SHADOWS => 'SHADOWS',
GIMP_MIDTONES => 'MIDTONES',
GIMP_HIGHLIGHTS => 'HIGHLIGHTS' }
GIMP_HIGHLIGHTS => '2' }
},
GimpOffsetType =>
{ contig => 1,