Commit 19e1acbc authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

configure.in app/Makefile.am app/config/gimpconfig.[ch]

2001-11-27  Sven Neumann  <sven@gimp.org>

	* configure.in
	* app/Makefile.am
	* app/config/gimpconfig.[ch]
	* app/config/gimpconfig-serialize.[ch]
	* app/config/gimpconfig-deserialize.[ch]: added new base class
	GimpConfig that knows how to serialize and deserialize it's properties
	in sexp format. Contains two example properties that will go into
	derived classes once this is really used.

	* app/main.c: deserialize and serialize the test GimpConfig object to
	~/.gimp-1.3/foorc (only for debugging).

	* app/widgets/widgets-types.h
	* app/core/core-types.h: moved GimpPreviewSize enum to core-types.

	* app/core/core-types.h: don't include gdk-pixbuf.h.

	* app/core/gimptoolinfo.h
	* app/core/gimpimagefile.c: include gdk-pixbuf.h.

	* app/core/gimpimage.[ch]: made construct_flag a gboolean.

	* app/core/gimpdrawable-invert.c
	* app/core/gimpunit.c

	* tools/pdbgen/pdb/plug_in.pdb
	* app/pdb/plug_in_cmds.c: removed unused variables.

	* app/display/Makefile.am: removed .PHONY and files cruft

	* app/Makefile.am
	* libgimp/Makefile.am
	* libgimpbase/Makefile.am
	* libgimpcolor/Makefile.am
	* libgimpmath/Makefile.am
	* libgimpwidgets/Makefile.am
	* plug-ins/Makefile.am: removed commented out makefile.mingw rules.
	If we ever need them again, they can easily be resurrected from CVS.
parent 0cc4c54c
2001-11-27 Sven Neumann <sven@gimp.org>
* configure.in
* app/Makefile.am
* app/config/gimpconfig.[ch]
* app/config/gimpconfig-serialize.[ch]
* app/config/gimpconfig-deserialize.[ch]: added new base class
GimpConfig that knows how to serialize and deserialize it's properties
in sexp format. Contains two example properties that will go into
derived classes once this is really used.
* app/main.c: deserialize and serialize the test GimpConfig object to
~/.gimp-1.3/foorc (only for debugging).
* app/widgets/widgets-types.h
* app/core/core-types.h: moved GimpPreviewSize enum to core-types.
* app/core/core-types.h: don't include gdk-pixbuf.h.
* app/core/gimptoolinfo.h
* app/core/gimpimagefile.c: include gdk-pixbuf.h.
* app/core/gimpimage.[ch]: made construct_flag a gboolean.
* app/core/gimpdrawable-invert.c
* app/core/gimpunit.c
* tools/pdbgen/pdb/plug_in.pdb
* app/pdb/plug_in_cmds.c: removed unused variables.
* app/display/Makefile.am: removed .PHONY and files cruft
* app/Makefile.am
* libgimp/Makefile.am
* libgimpbase/Makefile.am
* libgimpcolor/Makefile.am
* libgimpmath/Makefile.am
* libgimpwidgets/Makefile.am
* plug-ins/Makefile.am: removed commented out makefile.mingw rules.
If we ever need them again, they can easily be resurrected from CVS.
2001-11-26 Kelly Martin <kmartin@pyrzqxgl.org>
* app/Makefile.am
......@@ -421,7 +462,7 @@
* plug-ins/script-fu/script-fu-enums.h
* plug-ins/script-fu/script-fu-scripts.c
* plug-ins/script-fu/siod-wrapper.c: applied a modified version of a
patch from Matteo Nastasi <nastasi@tiscalinet.it> that adds the new
patch from Matteo Nastasi <matteo.nastasi@milug.org> that adds the new
Script-Fu parameter type SF-DIRNAME.
* plug-ins/script-fu/scripts/test-sphere.scm: use SF-DIRNAME.
......
## Process this file with automake to produce Makefile.in
SUBDIRS = paint-funcs base core xcf file pdb plug-in display tools widgets gui
SUBDIRS = \
paint-funcs \
base \
core \
config \
xcf \
file \
pdb \
plug-in \
display \
tools \
widgets \
gui
scriptdata =
......@@ -138,6 +150,7 @@ gimp_1_3_LDADD = @STRIP_BEGIN@ \
xcf/libappxcf.a \
file/libappfile.a \
pdb/libapppdb.a \
config/libappconfig.a \
paint-funcs/libapppaint-funcs.a \
base/libappbase.a \
$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \
......@@ -151,7 +164,3 @@ gimp_1_3_LDADD = @STRIP_BEGIN@ \
$(INTLLIBS) \
$(REGEXREPL) \
@STRIP_END@
## this is probably cruft, but may not be. -klm
## makefile.mingw: $(top_builddir)/config.status $(top_srcdir)/app/makefile.mingw.in
## cd $(top_builddir) && CONFIG_FILES=app/$@ CONFIG_HEADERS= $(SHELL) ./config.status
Makefile
Makefile.in
.deps
.libs
*.lo
libappconfig.la
## Process this file with automake to produce Makefile.in
noinst_LIBRARIES = libappconfig.a
libappconfig_a_SOURCES = @STRIP_BEGIN@ \
gimpconfig.c \
gimpconfig.h \
gimpconfig-deserialize.c \
gimpconfig-deserialize.h \
gimpconfig-serialize.c \
gimpconfig-serialize.h \
@STRIP_END@
AM_CPPFLAGS = @STRIP_BEGIN@ \
-DG_LOG_DOMAIN=\"Gimp-Config\" \
@GIMP_THREAD_FLAGS@ \
@GIMP_MP_FLAGS@ \
@STRIP_END@
INCLUDES = @STRIP_BEGIN@ \
-I$(top_srcdir) \
-I$(top_srcdir)/app \
$(GLIB_CFLAGS) \
-I$(includedir) \
@STRIP_END@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Object properties deserialization routines
* 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 "gimpconfig.h"
#include "gimpconfig-deserialize.h"
static void gimp_config_deserialize_property (GimpConfig *config,
GScanner *scanner,
GTokenType *token);
gboolean
gimp_config_deserialize_properties (GimpConfig *config,
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);
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 (property_specs != NULL && n_property_specs > 0, FALSE);
scope_id = GPOINTER_TO_UINT (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 & G_PARAM_READWRITE &&
g_type_is_a (prop_spec->owner_type, GIMP_TYPE_CONFIG))
{
g_scanner_scope_add_symbol (scanner, scope_id,
prop_spec->name, prop_spec);
}
}
token = G_TOKEN_LEFT_PAREN;
do
{
if (g_scanner_peek_next_token (scanner) != 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:
gimp_config_deserialize_property (config, scanner, &token);
break;
case G_TOKEN_RIGHT_PAREN:
token = G_TOKEN_LEFT_PAREN;
break;
default: /* do nothing */
break;
}
}
while (token != G_TOKEN_EOF);
if (token != G_TOKEN_LEFT_PAREN)
{
g_scanner_get_next_token (scanner);
g_scanner_unexp_token (scanner, token, NULL, NULL, NULL,
"parse error", TRUE);
}
g_scanner_set_scope (scanner, old_scope_id);
if (property_specs)
g_free (property_specs);
return (token == G_TOKEN_EOF);
}
static void
gimp_config_deserialize_property (GimpConfig *config,
GScanner *scanner,
GTokenType *token)
{
GParamSpec *prop_spec;
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)))
{
case G_TYPE_STRING:
*token = G_TOKEN_STRING;
break;
case G_TYPE_BOOLEAN:
case G_TYPE_ENUM:
*token = G_TOKEN_IDENTIFIER;
break;
case G_TYPE_INT:
case G_TYPE_UINT:
case G_TYPE_LONG:
case G_TYPE_ULONG:
*token = G_TOKEN_INT;
break;
case G_TYPE_FLOAT:
case G_TYPE_DOUBLE:
*token = G_TOKEN_FLOAT;
break;
default:
g_assert_not_reached ();
break;
}
if (g_scanner_peek_next_token (scanner) != *token)
return;
g_scanner_get_next_token (scanner);
switch (G_TYPE_FUNDAMENTAL (G_VALUE_TYPE (&value)))
{
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)
g_value_set_boolean (&value, TRUE);
else if (g_ascii_strcasecmp (scanner->value.v_identifier, "false") == 0)
g_value_set_boolean (&value, FALSE);
else
g_scanner_warn
(scanner,
"expected 'true' or 'false' for boolean property %s, got '%s'",
prop_spec->name, scanner->value.v_identifier);
break;
case G_TYPE_ENUM:
{
GEnumClass *enum_class;
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),
scanner->value.v_identifier);
if (enum_value)
g_value_set_enum (&value, enum_value->value);
else
g_scanner_warn (scanner,
"invalid value '%s' for enum property %s",
scanner->value.v_identifier, prop_spec->name);
}
break;
case G_TYPE_INT:
g_value_set_int (&value, scanner->value.v_int);
break;
case G_TYPE_UINT:
g_value_set_uint (&value, scanner->value.v_int);
break;
case G_TYPE_LONG:
g_value_set_int (&value, scanner->value.v_int);
break;
case G_TYPE_ULONG:
g_value_set_uint (&value, scanner->value.v_int);
break;
case G_TYPE_FLOAT:
g_value_set_float (&value, scanner->value.v_float);
break;
case G_TYPE_DOUBLE:
g_value_set_double (&value, scanner->value.v_float);
break;
default:
g_assert_not_reached ();
}
g_object_set_property (G_OBJECT (config), prop_spec->name, &value);
g_value_unset (&value);
*token = G_TOKEN_RIGHT_PAREN;
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Object peoperties deserialization routines
* 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 __DESERIALIZE_H__
#define __DESERIALIZE_H__
gboolean gimp_config_deserialize_properties (GimpConfig *config,
GScanner *scanner);
#endif /* __DESERIALIZE_H__ */
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Object propoerties serialization routines
* 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 "gimpconfig.h"
#include "gimpconfig-serialize.h"
void
gimp_config_serialize_properties (GimpConfig *config,
FILE *file)
{
GimpConfigClass *klass;
GParamSpec **property_specs;
guint n_property_specs;
guint i;
GValue value = { 0, };
klass = GIMP_CONFIG_GET_CLASS (config);
property_specs = g_object_class_list_properties (G_OBJECT_CLASS (klass),
&n_property_specs);
for (i = 0; i < n_property_specs; i++)
{
GParamSpec *prop_spec;
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)))
continue;
str = NULL;
g_value_init (&value, prop_spec->value_type);
g_object_get_property (G_OBJECT (config), prop_spec->name, &value);
if (G_VALUE_HOLDS_STRING (&value))
{
const gchar *src;
src = g_value_get_string (&value);
if (!src)
str = g_strdup ("NULL");
else
{
gchar *s = g_strescape (src, NULL);
str = g_strdup_printf ("\"%s\"", s);
g_free (s);
}
}
else 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);
str = g_strescape (g_value_get_string (&tmp_value), NULL);
g_value_unset (&tmp_value);
}
fprintf (file, "(%s %s)\n", prop_spec->name, str);
g_free (str);
g_value_unset (&value);
}
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* Object properties serialization routines
* 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 __SERIALIZE_H__
#define __SERIALIZE_H__
void gimp_config_serialize_properties (GimpConfig *config,
FILE *file);
#endif /* __SERIALIZE_H__ */
/* 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 <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"
enum
{
PROP_0,
PROP_MARCHING_ANTS_SPEED,
PROP_PREVIEW_SIZE
};
#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" }
};
GType
gimp_preview_size_get_type (void)
{
static GType size_type = 0;
if (! size_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 =
{
sizeof (GimpConfigClass),
(GBaseInitFunc) NULL,
(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);
}
return config_type;
}
static void
gimp_config_class_init (GimpConfigClass *klass)
{
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));
}
static void
gimp_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
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;
}
}
static void
gimp_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpConfig *gimp_config;
gimp_config = GIMP_CONFIG (object);
switch (property_id)