From 19e1acbcd77f28faaff45c29fc6d3db6017c4109 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Tue, 27 Nov 2001 03:52:11 +0000 Subject: [PATCH] configure.in app/Makefile.am app/config/gimpconfig.[ch] 2001-11-27 Sven Neumann * 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. --- ChangeLog | 43 ++++- app/Makefile.am | 19 +- app/config/.cvsignore | 6 + app/config/Makefile.am | 25 +++ app/config/gimpconfig-deserialize.c | 223 +++++++++++++++++++++++ app/config/gimpconfig-deserialize.h | 30 ++++ app/config/gimpconfig-serialize.c | 96 ++++++++++ app/config/gimpconfig-serialize.h | 30 ++++ app/config/gimpconfig.c | 238 +++++++++++++++++++++++++ app/config/gimpconfig.h | 57 ++++++ app/core/core-types.h | 16 +- app/core/gimpdrawable-invert.c | 2 +- app/core/gimpimage-guides.c | 62 ++----- app/core/gimpimage-guides.h | 4 +- app/core/gimpimage-merge.c | 62 ++----- app/core/gimpimage-merge.h | 4 +- app/core/gimpimage-projection.c | 62 ++----- app/core/gimpimage-projection.h | 4 +- app/core/gimpimage-resize.c | 62 ++----- app/core/gimpimage-resize.h | 4 +- app/core/gimpimage-scale.c | 62 ++----- app/core/gimpimage-scale.h | 4 +- app/core/gimpimage.c | 62 ++----- app/core/gimpimage.h | 4 +- app/core/gimpimagefile.c | 1 + app/core/gimpprojection-construct.c | 62 ++----- app/core/gimpprojection-construct.h | 4 +- app/core/gimptoolinfo.h | 2 + app/core/gimpunit.c | 2 +- app/display/Makefile.am | 7 - app/main.c | 23 +++ app/pdb/plug_in_cmds.c | 2 - app/widgets/widgets-types.h | 14 -- configure.in | 1 + libgimp/Makefile.am | 4 - libgimpbase/Makefile.am | 4 - libgimpcolor/Makefile.am | 5 - libgimpconfig/gimpconfig-deserialize.c | 223 +++++++++++++++++++++++ libgimpconfig/gimpconfig-deserialize.h | 30 ++++ libgimpconfig/gimpconfig-iface.c | 238 +++++++++++++++++++++++++ libgimpconfig/gimpconfig-iface.h | 57 ++++++ libgimpconfig/gimpconfig-serialize.c | 96 ++++++++++ libgimpconfig/gimpconfig-serialize.h | 30 ++++ libgimpmath/Makefile.am | 4 - libgimpwidgets/Makefile.am | 4 - plug-ins/Makefile.am | 4 - tools/pdbgen/pdb/plug_in.pdb | 2 - 47 files changed, 1625 insertions(+), 375 deletions(-) create mode 100644 app/config/.cvsignore create mode 100644 app/config/Makefile.am create mode 100644 app/config/gimpconfig-deserialize.c create mode 100644 app/config/gimpconfig-deserialize.h create mode 100644 app/config/gimpconfig-serialize.c create mode 100644 app/config/gimpconfig-serialize.h create mode 100644 app/config/gimpconfig.c create mode 100644 app/config/gimpconfig.h create mode 100644 libgimpconfig/gimpconfig-deserialize.c create mode 100644 libgimpconfig/gimpconfig-deserialize.h create mode 100644 libgimpconfig/gimpconfig-iface.c create mode 100644 libgimpconfig/gimpconfig-iface.h create mode 100644 libgimpconfig/gimpconfig-serialize.c create mode 100644 libgimpconfig/gimpconfig-serialize.h diff --git a/ChangeLog b/ChangeLog index c4f6199bf0..1f16d451a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,44 @@ +2001-11-27 Sven Neumann + + * 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 * 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 that adds the new + patch from Matteo Nastasi that adds the new Script-Fu parameter type SF-DIRNAME. * plug-ins/script-fu/scripts/test-sphere.scm: use SF-DIRNAME. diff --git a/app/Makefile.am b/app/Makefile.am index f094d51570..1163751c26 100644 --- a/app/Makefile.am +++ b/app/Makefile.am @@ -1,6 +1,18 @@ ## 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 diff --git a/app/config/.cvsignore b/app/config/.cvsignore new file mode 100644 index 0000000000..a30d2e4cd2 --- /dev/null +++ b/app/config/.cvsignore @@ -0,0 +1,6 @@ +Makefile +Makefile.in +.deps +.libs +*.lo +libappconfig.la diff --git a/app/config/Makefile.am b/app/config/Makefile.am new file mode 100644 index 0000000000..7349702d25 --- /dev/null +++ b/app/config/Makefile.am @@ -0,0 +1,25 @@ +## 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@ diff --git a/app/config/gimpconfig-deserialize.c b/app/config/gimpconfig-deserialize.c new file mode 100644 index 0000000000..d9bd4a082a --- /dev/null +++ b/app/config/gimpconfig-deserialize.c @@ -0,0 +1,223 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * Object properties deserialization routines + * Copyright (C) 2001 Sven Neumann + * + * 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 +#include + +#include + +#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; +} diff --git a/app/config/gimpconfig-deserialize.h b/app/config/gimpconfig-deserialize.h new file mode 100644 index 0000000000..81a39115c6 --- /dev/null +++ b/app/config/gimpconfig-deserialize.h @@ -0,0 +1,30 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * Object peoperties deserialization routines + * Copyright (C) 2001 Sven Neumann + * + * 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__ */ diff --git a/app/config/gimpconfig-serialize.c b/app/config/gimpconfig-serialize.c new file mode 100644 index 0000000000..31164a8cdf --- /dev/null +++ b/app/config/gimpconfig-serialize.c @@ -0,0 +1,96 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * Object propoerties serialization routines + * Copyright (C) 2001 Sven Neumann + * + * 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 +#include + +#include + +#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); + } +} diff --git a/app/config/gimpconfig-serialize.h b/app/config/gimpconfig-serialize.h new file mode 100644 index 0000000000..80e4ff53bf --- /dev/null +++ b/app/config/gimpconfig-serialize.h @@ -0,0 +1,30 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * Object properties serialization routines + * Copyright (C) 2001 Sven Neumann + * + * 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__ */ diff --git a/app/config/gimpconfig.c b/app/config/gimpconfig.c new file mode 100644 index 0000000000..058cc82af5 --- /dev/null +++ b/app/config/gimpconfig.c @@ -0,0 +1,238 @@ +/* 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 +#include +#include +#include +#include + +#include + +#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) + { + 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); +} + +gboolean +gimp_config_deserialize (GimpConfig *config) +{ + gint fd; + GScanner *scanner; + gboolean success; + + g_return_val_if_fail (GIMP_CONFIG (config), FALSE); + g_return_val_if_fail (GIMP_OBJECT (config)->name != NULL, FALSE); + + fd = open (GIMP_OBJECT (config)->name, O_RDONLY); + + if (fd == -1) + return FALSE; + + scanner = g_scanner_new (NULL); + + 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_scanner_input_file (scanner, fd); + scanner->input_name = GIMP_OBJECT (config)->name; + + success = gimp_config_deserialize_properties (config, scanner); + + g_scanner_destroy (scanner); + close (fd); + + return success; +} diff --git a/app/config/gimpconfig.h b/app/config/gimpconfig.h new file mode 100644 index 0000000000..665d8a969a --- /dev/null +++ b/app/config/gimpconfig.h @@ -0,0 +1,57 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995-1997 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_CONFIG_H__ +#define __GIMP_CONFIG_H__ + +#include "core/core-types.h" +#include "core/gimpobject.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)) + + +typedef struct _GimpConfig GimpConfig; +typedef struct _GimpConfigClass GimpConfigClass; + +struct _GimpConfig +{ + GimpObject parent_instance; + + guint marching_ants_speed; + GimpPreviewSize preview_size; +}; + +struct _GimpConfigClass +{ + GimpObjectClass parent_class; +}; + + +GType gimp_config_get_type (void) G_GNUC_CONST; + +void gimp_config_serialize (GimpConfig *config); +gboolean gimp_config_deserialize (GimpConfig *config); + + +#endif /* __GIMP_CONFIG_H__ */ diff --git a/app/core/core-types.h b/app/core/core-types.h index 9278a9f4bd..3f40e42f79 100644 --- a/app/core/core-types.h +++ b/app/core/core-types.h @@ -20,8 +20,6 @@ #define __CORE_TYPES_H__ -#include /* EEK */ - #include "libgimpbase/gimpbasetypes.h" #include "libgimpmath/gimpmath.h" @@ -199,6 +197,20 @@ typedef enum /*< skip >*/ GIMP_TRANSFORM_BACKWARD } GimpTransformDirection; +typedef enum /*< skip >*/ +{ + GIMP_PREVIEW_SIZE_NONE = 0, + GIMP_PREVIEW_SIZE_TINY = 16, + GIMP_PREVIEW_SIZE_EXTRA_SMALL = 24, + GIMP_PREVIEW_SIZE_SMALL = 32, + GIMP_PREVIEW_SIZE_MEDIUM = 48, + GIMP_PREVIEW_SIZE_LARGE = 64, + GIMP_PREVIEW_SIZE_EXTRA_LARGE = 96, + GIMP_PREVIEW_SIZE_HUGE = 128, + GIMP_PREVIEW_SIZE_ENORMOUS = 192, + GIMP_PREVIEW_SIZE_GIGANTIC = 256 +} GimpPreviewSize; + /* base objects */ diff --git a/app/core/gimpdrawable-invert.c b/app/core/gimpdrawable-invert.c index 17278af978..246f7b50a5 100644 --- a/app/core/gimpdrawable-invert.c +++ b/app/core/gimpdrawable-invert.c @@ -18,7 +18,7 @@ #include "config.h" -#include +#include #include "core-types.h" diff --git a/app/core/gimpimage-guides.c b/app/core/gimpimage-guides.c index 4020f9d656..44ecae6ced 100644 --- a/app/core/gimpimage-guides.c +++ b/app/core/gimpimage-guides.c @@ -467,7 +467,7 @@ gimp_image_init (GimpImage *gimage) gimage->shadow = NULL; - gimage->construct_flag = -1; + gimage->construct_flag = FALSE; gimage->proj_type = RGBA_GIMAGE; gimage->projection = NULL; @@ -2260,7 +2260,7 @@ gimp_image_construct_layers (GimpImage *gimage, PixelRegion src1PR, src2PR, maskPR; PixelRegion * mask; GList *list; - GList *reverse_list = NULL; + GList *reverse_list; gint off_x; gint off_y; @@ -2268,36 +2268,8 @@ gimp_image_construct_layers (GimpImage *gimage, if ((layer = gimp_image_floating_sel (gimage))) floating_sel_composite (layer, x, y, w, h, FALSE); - /* Note added by Raph Levien, 27 Jan 1998 - This looks it was intended as an optimization, but it seems to - have correctness problems. In particular, if all channels are - turned off, the screen simply does not update the projected - image. It should be black. Turning off this optimization seems to - restore correct behavior. At some future point, it may be - desirable to turn the optimization back on. - - */ -#if 0 - /* If all channels are not visible, simply return */ - switch (gimp_image_base_type (gimage)) - { - case RGB: - if (! gimp_image_get_component_visible (gimage, RED_CHANNEL) && - ! gimp_image_get_component_visible (gimage, GREEN_CHANNEL) && - ! gimp_image_get_component_visible (gimage, BLUE_CHANNEL)) - return; - break; - case GRAY: - if (! gimp_image_get_component_visible (gimage, GRAY_CHANNEL)) - return; - break; - case INDEXED: - if (! gimp_image_get_component_visible (gimage, INDEXED_CHANNEL)) - return; - break; - } -#endif + reverse_list = NULL; for (list = GIMP_LIST (gimage->layers)->list; list; @@ -2323,8 +2295,10 @@ gimp_image_construct_layers (GimpImage *gimage, x1 = CLAMP (off_x, x, x + w); y1 = CLAMP (off_y, y, y + h); - x2 = CLAMP (off_x + gimp_drawable_width (GIMP_DRAWABLE (layer)), x, x + w); - y2 = CLAMP (off_y + gimp_drawable_height (GIMP_DRAWABLE (layer)), y, y + h); + x2 = CLAMP (off_x + gimp_drawable_width (GIMP_DRAWABLE (layer)), + x, x + w); + y2 = CLAMP (off_y + gimp_drawable_height (GIMP_DRAWABLE (layer)), + y, y + h); /* configure the pixel regions */ pixel_region_init (&src1PR, gimp_image_projection (gimage), @@ -2388,7 +2362,7 @@ gimp_image_construct_layers (GimpImage *gimage, } } - gimage->construct_flag = 1; /* something was projected */ + gimage->construct_flag = TRUE; /* something was projected */ } g_list_free (reverse_list); @@ -2433,7 +2407,7 @@ gimp_image_construct_channels (GimpImage *gimage, project_channel (gimage, channel, &src1PR, &src2PR); - gimage->construct_flag = 1; + gimage->construct_flag = TRUE; } } @@ -2535,7 +2509,7 @@ gimp_image_construct (GimpImage *gimage, /* set the construct flag, used to determine if anything * has been written to the gimage raw image yet. */ - gimage->construct_flag = 0; + gimage->construct_flag = FALSE; if (gimage->layers) { @@ -2544,17 +2518,19 @@ gimp_image_construct (GimpImage *gimage, } if ((gimage->layers) && /* There's a layer. */ - (! g_slist_next (gimage->layers)) && /* It's the only layer. */ - (gimp_layer_has_alpha ((GimpLayer *) (gimage->layers->data))) && /* It's !flat. */ - /* It's visible. */ + (! g_slist_next (gimage->layers)) && /* It's the only layer. */ + (gimp_layer_has_alpha ((GimpLayer *) (gimage->layers->data))) && + /* It's !flat. */ (gimp_drawable_get_visible (GIMP_DRAWABLE (gimage->layers->data))) && + /* It's visible. */ (gimp_drawable_width (GIMP_DRAWABLE (gimage->layers->data)) == gimage->width) && (gimp_drawable_height (GIMP_DRAWABLE (gimage->layers->data)) == gimage->height) && /* Covers all. */ - /* Not indexed. */ (!gimp_drawable_is_indexed (GIMP_DRAWABLE (gimage->layers->data))) && - (((GimpLayer *)(gimage->layers->data))->opacity == OPAQUE_OPACITY) /*opaq */ + /* Not indexed. */ + (((GimpLayer *)(gimage->layers->data))->opacity == OPAQUE_OPACITY) + /* Opaque */ ) { gint xoff; @@ -2585,14 +2561,14 @@ gimp_image_construct (GimpImage *gimage, destPR.curtile, srcPR.curtile); } - gimage->construct_flag = 1; + gimage->construct_flag = TRUE; gimp_image_construct_channels (gimage, x, y, w, h); return; } } #else - gimage->construct_flag = 0; + gimage->construct_flag = FALSE; #endif /* First, determine if the projection image needs to be diff --git a/app/core/gimpimage-guides.h b/app/core/gimpimage-guides.h index a07924d82b..cbd5f6ff98 100644 --- a/app/core/gimpimage-guides.h +++ b/app/core/gimpimage-guides.h @@ -53,7 +53,7 @@ struct _GimpImage { GimpViewable parent_instance; - Gimp *gimp; /* The GIMP we image belongs to */ + Gimp *gimp; /* the GIMP the image belongs to*/ gint ID; /* provides a unique ID */ @@ -79,7 +79,7 @@ struct _GimpImage TileManager *shadow; /* shadow buffer tiles */ /* Projection attributes */ - gint construct_flag; /* flag for construction */ + gboolean construct_flag; /* flag for construction */ GimpImageType proj_type; /* type of the projection image */ gint proj_bytes; /* bpp in projection image */ gint proj_level; /* projection level */ diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c index 4020f9d656..44ecae6ced 100644 --- a/app/core/gimpimage-merge.c +++ b/app/core/gimpimage-merge.c @@ -467,7 +467,7 @@ gimp_image_init (GimpImage *gimage) gimage->shadow = NULL; - gimage->construct_flag = -1; + gimage->construct_flag = FALSE; gimage->proj_type = RGBA_GIMAGE; gimage->projection = NULL; @@ -2260,7 +2260,7 @@ gimp_image_construct_layers (GimpImage *gimage, PixelRegion src1PR, src2PR, maskPR; PixelRegion * mask; GList *list; - GList *reverse_list = NULL; + GList *reverse_list; gint off_x; gint off_y; @@ -2268,36 +2268,8 @@ gimp_image_construct_layers (GimpImage *gimage, if ((layer = gimp_image_floating_sel (gimage))) floating_sel_composite (layer, x, y, w, h, FALSE); - /* Note added by Raph Levien, 27 Jan 1998 - This looks it was intended as an optimization, but it seems to - have correctness problems. In particular, if all channels are - turned off, the screen simply does not update the projected - image. It should be black. Turning off this optimization seems to - restore correct behavior. At some future point, it may be - desirable to turn the optimization back on. - - */ -#if 0 - /* If all channels are not visible, simply return */ - switch (gimp_image_base_type (gimage)) - { - case RGB: - if (! gimp_image_get_component_visible (gimage, RED_CHANNEL) && - ! gimp_image_get_component_visible (gimage, GREEN_CHANNEL) && - ! gimp_image_get_component_visible (gimage, BLUE_CHANNEL)) - return; - break; - case GRAY: - if (! gimp_image_get_component_visible (gimage, GRAY_CHANNEL)) - return; - break; - case INDEXED: - if (! gimp_image_get_component_visible (gimage, INDEXED_CHANNEL)) - return; - break; - } -#endif + reverse_list = NULL; for (list = GIMP_LIST (gimage->layers)->list; list; @@ -2323,8 +2295,10 @@ gimp_image_construct_layers (GimpImage *gimage, x1 = CLAMP (off_x, x, x + w); y1 = CLAMP (off_y, y, y + h); - x2 = CLAMP (off_x + gimp_drawable_width (GIMP_DRAWABLE (layer)), x, x + w); - y2 = CLAMP (off_y + gimp_drawable_height (GIMP_DRAWABLE (layer)), y, y + h); + x2 = CLAMP (off_x + gimp_drawable_width (GIMP_DRAWABLE (layer)), + x, x + w); + y2 = CLAMP (off_y + gimp_drawable_height (GIMP_DRAWABLE (layer)), + y, y + h); /* configure the pixel regions */ pixel_region_init (&src1PR, gimp_image_projection (gimage), @@ -2388,7 +2362,7 @@ gimp_image_construct_layers (GimpImage *gimage, } } - gimage->construct_flag = 1; /* something was projected */ + gimage->construct_flag = TRUE; /* something was projected */ } g_list_free (reverse_list); @@ -2433,7 +2407,7 @@ gimp_image_construct_channels (GimpImage *gimage, project_channel (gimage, channel, &src1PR, &src2PR); - gimage->construct_flag = 1; + gimage->construct_flag = TRUE; } } @@ -2535,7 +2509,7 @@ gimp_image_construct (GimpImage *gimage, /* set the construct flag, used to determine if anything * has been written to the gimage raw image yet. */ - gimage->construct_flag = 0; + gimage->construct_flag = FALSE; if (gimage->layers) { @@ -2544,17 +2518,19 @@ gimp_image_construct (GimpImage *gimage, } if ((gimage->layers) && /* There's a layer. */ - (! g_slist_next (gimage->layers)) && /* It's the only layer. */ - (gimp_layer_has_alpha ((GimpLayer *) (gimage->layers->data))) && /* It's !flat. */ - /* It's visible. */ + (! g_slist_next (gimage->layers)) && /* It's the only layer. */ + (gimp_layer_has_alpha ((GimpLayer *) (gimage->layers->data))) && + /* It's !flat. */ (gimp_drawable_get_visible (GIMP_DRAWABLE (gimage->layers->data))) && + /* It's visible. */ (gimp_drawable_width (GIMP_DRAWABLE (gimage->layers->data)) == gimage->width) && (gimp_drawable_height (GIMP_DRAWABLE (gimage->layers->data)) == gimage->height) && /* Covers all. */ - /* Not indexed. */ (!gimp_drawable_is_indexed (GIMP_DRAWABLE (gimage->layers->data))) && - (((GimpLayer *)(gimage->layers->data))->opacity == OPAQUE_OPACITY) /*opaq */ + /* Not indexed. */ + (((GimpLayer *)(gimage->layers->data))->opacity == OPAQUE_OPACITY) + /* Opaque */ ) { gint xoff; @@ -2585,14 +2561,14 @@ gimp_image_construct (GimpImage *gimage, destPR.curtile, srcPR.curtile); } - gimage->construct_flag = 1; + gimage->construct_flag = TRUE; gimp_image_construct_channels (gimage, x, y, w, h); return; } } #else - gimage->construct_flag = 0; + gimage->construct_flag = FALSE; #endif /* First, determine if the projection image needs to be diff --git a/app/core/gimpimage-merge.h b/app/core/gimpimage-merge.h index a07924d82b..cbd5f6ff98 100644 --- a/app/core/gimpimage-merge.h +++ b/app/core/gimpimage-merge.h @@ -53,7 +53,7 @@ struct _GimpImage { GimpViewable parent_instance; - Gimp *gimp; /* The GIMP we image belongs to */ + Gimp *gimp; /* the GIMP the image belongs to*/ gint ID; /* provides a unique ID */ @@ -79,7 +79,7 @@ struct _GimpImage TileManager *shadow; /* shadow buffer tiles */ /* Projection attributes */ - gint construct_flag; /* flag for construction */ + gboolean construct_flag; /* flag for construction */ GimpImageType proj_type; /* type of the projection image */ gint proj_bytes; /* bpp in projection image */ gint proj_level; /* projection level */ diff --git a/app/core/gimpimage-projection.c b/app/core/gimpimage-projection.c index 4020f9d656..44ecae6ced 100644 --- a/app/core/gimpimage-projection.c +++ b/app/core/gimpimage-projection.c @@ -467,7 +467,7 @@ gimp_image_init (GimpImage *gimage) gimage->shadow = NULL; - gimage->construct_flag = -1; + gimage->construct_flag = FALSE; gimage->proj_type = RGBA_GIMAGE; gimage->projection = NULL; @@ -2260,7 +2260,7 @@ gimp_image_construct_layers (GimpImage *gimage, PixelRegion src1PR, src2PR, maskPR; PixelRegion * mask; GList *list; - GList *reverse_list = NULL; + GList *reverse_list; gint off_x; gint off_y; @@ -2268,36 +2268,8 @@ gimp_image_construct_layers (GimpImage *gimage, if ((layer = gimp_image_floating_sel (gimage))) floating_sel_composite (layer, x, y, w, h, FALSE); - /* Note added by Raph Levien, 27 Jan 1998 - This looks it was intended as an optimization, but it seems to - have correctness problems. In particular, if all channels are - turned off, the screen simply does not update the projected - image. It should be black. Turning off this optimization seems to - restore correct behavior. At some future point, it may be - desirable to turn the optimization back on. - - */ -#if 0 - /* If all channels are not visible, simply return */ - switch (gimp_image_base_type (gimage)) - { - case RGB: - if (! gimp_image_get_component_visible (gimage, RED_CHANNEL) && - ! gimp_image_get_component_visible (gimage, GREEN_CHANNEL) && - ! gimp_image_get_component_visible (gimage, BLUE_CHANNEL)) - return; - break; - case GRAY: - if (! gimp_image_get_component_visible (gimage, GRAY_CHANNEL)) - return; - break; - case INDEXED: - if (! gimp_image_get_component_visible (gimage, INDEXED_CHANNEL)) - return; - break; - } -#endif + reverse_list = NULL; for (list = GIMP_LIST (gimage->layers)->list; list; @@ -2323,8 +2295,10 @@ gimp_image_construct_layers (GimpImage *gimage, x1 = CLAMP (off_x, x, x + w); y1 = CLAMP (off_y, y, y + h); - x2 = CLAMP (off_x + gimp_drawable_width (GIMP_DRAWABLE (layer)), x, x + w); - y2 = CLAMP (off_y + gimp_drawable_height (GIMP_DRAWABLE (layer)), y, y + h); + x2 = CLAMP (off_x + gimp_drawable_width (GIMP_DRAWABLE (layer)), + x, x + w); + y2 = CLAMP (off_y + gimp_drawable_height (GIMP_DRAWABLE (layer)), + y, y + h); /* configure the pixel regions */ pixel_region_init (&src1PR, gimp_image_projection (gimage), @@ -2388,7 +2362,7 @@ gimp_image_construct_layers (GimpImage *gimage, } } - gimage->construct_flag = 1; /* something was projected */ + gimage->construct_flag = TRUE; /* something was projected */ } g_list_free (reverse_list); @@ -2433,7 +2407,7 @@ gimp_image_construct_channels (GimpImage *gimage, project_channel (gimage, channel, &src1PR, &src2PR); - gimage->construct_flag = 1; + gimage->construct_flag = TRUE; } } @@ -2535,7 +2509,7 @@ gimp_image_construct (GimpImage *gimage, /* set the construct flag, used to determine if anything * has been written to the gimage raw image yet. */ - gimage->construct_flag = 0; + gimage->construct_flag = FALSE; if (gimage->layers) { @@ -2544,17 +2518,19 @@ gimp_image_construct (GimpImage *gimage, } if ((gimage->layers) && /* There's a layer. */ - (! g_slist_next (gimage->layers)) && /* It's the only layer. */ - (gimp_layer_has_alpha ((GimpLayer *) (gimage->layers->data))) && /* It's !flat. */ - /* It's visible. */ + (! g_slist_next (gimage->layers)) && /* It's the only layer. */ + (gimp_layer_has_alpha ((GimpLayer *) (gimage->layers->data))) && + /* It's !flat. */ (gimp_drawable_get_visible (GIMP_DRAWABLE (gimage->layers->data))) && + /* It's visible. */ (gimp_drawable_width (GIMP_DRAWABLE (gimage->layers->data)) == gimage->width) && (gimp_drawable_height (GIMP_DRAWABLE (gimage->layers->data)) == gimage->height) && /* Covers all. */ - /* Not indexed. */ (!gimp_drawable_is_indexed (GIMP_DRAWABLE (gimage->layers->data))) && - (((GimpLayer *)(gimage->layers->data))->opacity == OPAQUE_OPACITY) /*opaq */ + /* Not indexed. */ + (((GimpLayer *)(gimage->layers->data))->opacity == OPAQUE_OPACITY) + /* Opaque */ ) { gint xoff; @@ -2585,14 +2561,14 @@ gimp_image_construct (GimpImage *gimage, destPR.curtile, srcPR.curtile); } - gimage->construct_flag = 1; + gimage->construct_flag = TRUE; gimp_image_construct_channels (gimage, x, y, w, h); return; } } #else - gimage->construct_flag = 0; + gimage->construct_flag = FALSE; #endif /* First, determine if the projection image needs to be diff --git a/app/core/gimpimage-projection.h b/app/core/gimpimage-projection.h index a07924d82b..cbd5f6ff98 100644 --- a/app/core/gimpimage-projection.h +++ b/app/core/gimpimage-projection.h @@ -53,7 +53,7 @@ struct _GimpImage { GimpViewable parent_instance; - Gimp *gimp; /* The GIMP we image belongs to */ + Gimp *gimp; /* the GIMP the image belongs to*/ gint ID; /* provides a unique ID */ @@ -79,7 +79,7 @@ struct _GimpImage TileManager *shadow; /* shadow buffer tiles */ /* Projection attributes */ - gint construct_flag; /* flag for construction */ + gboolean construct_flag; /* flag for construction */ GimpImageType proj_type; /* type of the projection image */ gint proj_bytes; /* bpp in projection image */ gint proj_level; /* projection level */ diff --git a/app/core/gimpimage-resize.c b/app/core/gimpimage-resize.c index 4020f9d656..44ecae6ced 100644 --- a/app/core/gimpimage-resize.c +++ b/app/core/gimpimage-resize.c @@ -467,7 +467,7 @@ gimp_image_init (GimpImage *gimage) gimage->shadow = NULL; - gimage->construct_flag = -1; + gimage->construct_flag = FALSE; gimage->proj_type = RGBA_GIMAGE; gimage->projection = NULL; @@ -2260,7 +2260,7 @@ gimp_image_construct_layers (GimpImage *gimage, PixelRegion src1PR, src2PR, maskPR; PixelRegion * mask; GList *list; - GList *reverse_list = NULL; + GList *reverse_list; gint off_x; gint off_y; @@ -2268,36 +2268,8 @@ gimp_image_construct_layers (GimpImage *gimage, if ((layer = gimp_image_floating_sel (gimage))) floating_sel_composite (layer, x, y, w, h, FALSE); - /* Note added by Raph Levien, 27 Jan 1998 - This looks it was intended as an optimization, but it seems to - have correctness problems. In particular, if all channels are - turned off, the screen simply does not update the projected - image. It should be black. Turning off this optimization seems to - restore correct behavior. At some future point, it may be - desirable to turn the optimization back on. - - */ -#if 0 - /* If all channels are not visible, simply return */ - switch (gimp_image_base_type (gimage)) - { - case RGB: - if (! gimp_image_get_component_visible (gimage, RED_CHANNEL) && - ! gimp_image_get_component_visible (gimage, GREEN_CHANNEL) && - ! gimp_image_get_component_visible (gimage, BLUE_CHANNEL)) - return; - break; - case GRAY: - if (! gimp_image_get_component_visible (gimage, GRAY_CHANNEL)) - return; - break; - case INDEXED: - if (! gimp_image_get_component_visible (gimage, INDEXED_CHANNEL)) - return; - break; - } -#endif + reverse_list = NULL; for (list = GIMP_LIST (gimage->layers)->list; list; @@ -2323,8 +2295,10 @@ gimp_image_construct_layers (GimpImage *gimage, x1 = CLAMP (off_x, x, x + w); y1 = CLAMP (off_y, y, y + h); - x2 = CLAMP (off_x + gimp_drawable_width (GIMP_DRAWABLE (layer)), x, x + w); - y2 = CLAMP (off_y + gimp_drawable_height (GIMP_DRAWABLE (layer)), y, y + h); + x2 = CLAMP (off_x + gimp_drawable_width (GIMP_DRAWABLE (layer)), + x, x + w); + y2 = CLAMP (off_y + gimp_drawable_height (GIMP_DRAWABLE (layer)), + y, y + h); /* configure the pixel regions */ pixel_region_init (&src1PR, gimp_image_projection (gimage), @@ -2388,7 +2362,7 @@ gimp_image_construct_layers (GimpImage *gimage, } } - gimage->construct_flag = 1; /* something was projected */ + gimage->construct_flag = TRUE; /* something was projected */ } g_list_free (reverse_list); @@ -2433,7 +2407,7 @@ gimp_image_construct_channels (GimpImage *gimage, project_channel (gimage, channel, &src1PR, &src2PR); - gimage->construct_flag = 1; + gimage->construct_flag = TRUE; } } @@ -2535,7 +2509,7 @@ gimp_image_construct (GimpImage *gimage, /* set the construct flag, used to determine if anything * has been written to the gimage raw image yet. */ - gimage->construct_flag = 0; + gimage->construct_flag = FALSE; if (gimage->layers) { @@ -2544,17 +2518,19 @@ gimp_image_construct (GimpImage *gimage, } if ((gimage->layers) && /* There's a layer. */ - (! g_slist_next (gimage->layers)) && /* It's the only layer. */ - (gimp_layer_has_alpha ((GimpLayer *) (gimage->layers->data))) && /* It's !flat. */ - /* It's visible. */ + (! g_slist_next (gimage->layers)) && /* It's the only layer. */ + (gimp_layer_has_alpha ((GimpLayer *) (gimage->layers->data))) && + /* It's !flat. */ (gimp_drawable_get_visible (GIMP_DRAWABLE (gimage->layers->data))) && + /* It's visible. */ (gimp_drawable_width (GIMP_DRAWABLE (gimage->layers->data)) == gimage->width) && (gimp_drawable_height (GIMP_DRAWABLE (gimage->layers->data)) == gimage->height) && /* Covers all. */ - /* Not indexed. */ (!gimp_drawable_is_indexed (GIMP_DRAWABLE (gimage->layers->data))) && - (((GimpLayer *)(gimage->layers->data))->opacity == OPAQUE_OPACITY) /*opaq */ + /* Not indexed. */ + (((GimpLayer *)(gimage->layers->data))->opacity == OPAQUE_OPACITY) + /* Opaque */ ) { gint xoff; @@ -2585,14 +2561,14 @@ gimp_image_construct (GimpImage *gimage, destPR.curtile, srcPR.curtile); } - gimage->construct_flag = 1; + gimage->construct_flag = TRUE; gimp_image_construct_channels (gimage, x, y, w, h); return; } } #else - gimage->construct_flag = 0; + gimage->construct_flag = FALSE; #endif /* First, determine if the projection image needs to be diff --git a/app/core/gimpimage-resize.h b/app/core/gimpimage-resize.h index a07924d82b..cbd5f6ff98 100644 --- a/app/core/gimpimage-resize.h +++ b/app/core/gimpimage-resize.h @@ -53,7 +53,7 @@ struct _GimpImage { GimpViewable parent_instance; - Gimp *gimp; /* The GIMP we image belongs to */ + Gimp *gimp; /* the GIMP the image belongs to*/ gint ID; /* provides a unique ID */ @@ -79,7 +79,7 @@ struct _GimpImage TileManager *shadow; /* shadow buffer tiles */ /* Projection attributes */ - gint construct_flag; /* flag for construction */ + gboolean construct_flag; /* flag for construction */ GimpImageType proj_type; /* type of the projection image */ gint proj_bytes; /* bpp in projection image */ gint proj_level; /* projection level */ diff --git a/app/core/gimpimage-scale.c b/app/core/gimpimage-scale.c index 4020f9d656..44ecae6ced 100644 --- a/app/core/gimpimage-scale.c +++ b/app/core/gimpimage-scale.c @@ -467,7 +467,7 @@ gimp_image_init (GimpImage *gimage) gimage->shadow = NULL; - gimage->construct_flag = -1; + gimage->construct_flag = FALSE; gimage->proj_type = RGBA_GIMAGE; gimage->projection = NULL; @@ -2260,7 +2260,7 @@ gimp_image_construct_layers (GimpImage *gimage, PixelRegion src1PR, src2PR, maskPR; PixelRegion * mask; GList *list; - GList *reverse_list = NULL; + GList *reverse_list; gint off_x; gint off_y; @@ -2268,36 +2268,8 @@ gimp_image_construct_layers (GimpImage *gimage, if ((layer = gimp_image_floating_sel (gimage))) floating_sel_composite (layer, x, y, w, h, FALSE); - /* Note added by Raph Levien, 27 Jan 1998 - This looks it was intended as an optimization, but it seems to - have correctness problems. In particular, if all channels are - turned off, the screen simply does not update the projected - image. It should be black. Turning off this optimization seems to - restore correct behavior. At some future point, it may be - desirable to turn the optimization back on. - - */ -#if 0 - /* If all channels are not visible, simply return */ - switch (gimp_image_base_type (gimage)) - { - case RGB: - if (! gimp_image_get_component_visible (gimage, RED_CHANNEL) && - ! gimp_image_get_component_visible (gimage, GREEN_CHANNEL) && - ! gimp_image_get_component_visible (gimage, BLUE_CHANNEL)) - return; - break; - case GRAY: - if (! gimp_image_get_component_visible (gimage, GRAY_CHANNEL)) - return; - break; - case INDEXED: - if (! gimp_image_get_component_visible (gimage, INDEXED_CHANNEL)) - return; - break; - } -#endif + reverse_list = NULL; for (list = GIMP_LIST (gimage->layers)->list; list; @@ -2323,8 +2295,10 @@ gimp_image_construct_layers (GimpImage *gimage, x1 = CLAMP (off_x, x, x + w); y1 = CLAMP (off_y, y, y + h); - x2 = CLAMP (off_x + gimp_drawable_width (GIMP_DRAWABLE (layer)), x, x + w); - y2 = CLAMP (off_y + gimp_drawable_height (GIMP_DRAWABLE (layer)), y, y + h); + x2 = CLAMP (off_x + gimp_drawable_width (GIMP_DRAWABLE (layer)), + x, x + w); + y2 = CLAMP (off_y + gimp_drawable_height (GIMP_DRAWABLE (layer)), + y, y + h); /* configure the pixel regions */ pixel_region_init (&src1PR, gimp_image_projection (gimage), @@ -2388,7 +2362,7 @@ gimp_image_construct_layers (GimpImage *gimage, } } - gimage->construct_flag = 1; /* something was projected */ + gimage->construct_flag = TRUE; /* something was projected */ } g_list_free (reverse_list); @@ -2433,7 +2407,7 @@ gimp_image_construct_channels (GimpImage *gimage, project_channel (gimage, channel, &src1PR, &src2PR); - gimage->construct_flag = 1; + gimage->construct_flag = TRUE; } } @@ -2535,7 +2509,7 @@ gimp_image_construct (GimpImage *gimage, /* set the construct flag, used to determine if anything * has been written to the gimage raw image yet. */ - gimage->construct_flag = 0; + gimage->construct_flag = FALSE; if (gimage->layers) { @@ -2544,17 +2518,19 @@ gimp_image_construct (GimpImage *gimage, } if ((gimage->layers) && /* There's a layer. */ - (! g_slist_next (gimage->layers)) && /* It's the only layer. */ - (gimp_layer_has_alpha ((GimpLayer *) (gimage->layers->data))) && /* It's !flat. */ - /* It's visible. */ + (! g_slist_next (gimage->layers)) && /* It's the only layer. */ + (gimp_layer_has_alpha ((GimpLayer *) (gimage->layers->data))) && + /* It's !flat. */ (gimp_drawable_get_visible (GIMP_DRAWABLE (gimage->layers->data))) && + /* It's visible. */ (gimp_drawable_width (GIMP_DRAWABLE (gimage->layers->data)) == gimage->width) && (gimp_drawable_height (GIMP_DRAWABLE (gimage->layers->data)) == gimage->height) && /* Covers all. */ - /* Not indexed. */ (!gimp_drawable_is_indexed (GIMP_DRAWABLE (gimage->layers->data))) && - (((GimpLayer *)(gimage->layers->data))->opacity == OPAQUE_OPACITY) /*opaq */ + /* Not indexed. */ + (((GimpLayer *)(gimage->layers->data))->opacity == OPAQUE_OPACITY) + /* Opaque */ ) { gint xoff; @@ -2585,14 +2561,14 @@ gimp_image_construct (GimpImage *gimage, destPR.curtile, srcPR.curtile); } - gimage->construct_flag = 1; + gimage->construct_flag = TRUE; gimp_image_construct_channels (gimage, x, y, w, h); return; } } #else - gimage->construct_flag = 0; + gimage->construct_flag = FALSE; #endif /* First, determine if the projection image needs to be diff --git a/app/core/gimpimage-scale.h b/app/core/gimpimage-scale.h index a07924d82b..cbd5f6ff98 100644 --- a/app/core/gimpimage-scale.h +++ b/app/core/gimpimage-scale.h @@ -53,7 +53,7 @@ struct _GimpImage { GimpViewable parent_instance; - Gimp *gimp; /* The GIMP we image belongs to */ + Gimp *gimp; /* the GIMP the image belongs to*/ gint ID; /* provides a unique ID */ @@ -79,7 +79,7 @@ struct _GimpImage TileManager *shadow; /* shadow buffer tiles */ /* Projection attributes */ - gint construct_flag; /* flag for construction */ + gboolean construct_flag; /* flag for construction */ GimpImageType proj_type; /* type of the projection image */ gint proj_bytes; /* bpp in projection image */ gint proj_level; /* projection level */ diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index 4020f9d656..44ecae6ced 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -467,7 +467,7 @@ gimp_image_init (GimpImage *gimage) gimage->shadow = NULL; - gimage->construct_flag = -1; + gimage->construct_flag = FALSE; gimage->proj_type = RGBA_GIMAGE; gimage->projection = NULL; @@ -2260,7 +2260,7 @@ gimp_image_construct_layers (GimpImage *gimage, PixelRegion src1PR, src2PR, maskPR; PixelRegion * mask; GList *list; - GList *reverse_list = NULL; + GList *reverse_list; gint off_x; gint off_y; @@ -2268,36 +2268,8 @@ gimp_image_construct_layers (GimpImage *gimage, if ((layer = gimp_image_floating_sel (gimage))) floating_sel_composite (layer, x, y, w, h, FALSE); - /* Note added by Raph Levien, 27 Jan 1998 - This looks it was intended as an optimization, but it seems to - have correctness problems. In particular, if all channels are - turned off, the screen simply does not update the projected - image. It should be black. Turning off this optimization seems to - restore correct behavior. At some future point, it may be - desirable to turn the optimization back on. - - */ -#if 0 - /* If all channels are not visible, simply return */ - switch (gimp_image_base_type (gimage)) - { - case RGB: - if (! gimp_image_get_component_visible (gimage, RED_CHANNEL) && - ! gimp_image_get_component_visible (gimage, GREEN_CHANNEL) && - ! gimp_image_get_component_visible (gimage, BLUE_CHANNEL)) - return; - break; - case GRAY: - if (! gimp_image_get_component_visible (gimage, GRAY_CHANNEL)) - return; - break; - case INDEXED: - if (! gimp_image_get_component_visible (gimage, INDEXED_CHANNEL)) - return; - break; - } -#endif + reverse_list = NULL; for (list = GIMP_LIST (gimage->layers)->list; list; @@ -2323,8 +2295,10 @@ gimp_image_construct_layers (GimpImage *gimage, x1 = CLAMP (off_x, x, x + w); y1 = CLAMP (off_y, y, y + h); - x2 = CLAMP (off_x + gimp_drawable_width (GIMP_DRAWABLE (layer)), x, x + w); - y2 = CLAMP (off_y + gimp_drawable_height (GIMP_DRAWABLE (layer)), y, y + h); + x2 = CLAMP (off_x + gimp_drawable_width (GIMP_DRAWABLE (layer)), + x, x + w); + y2 = CLAMP (off_y + gimp_drawable_height (GIMP_DRAWABLE (layer)), + y, y + h); /* configure the pixel regions */ pixel_region_init (&src1PR, gimp_image_projection (gimage), @@ -2388,7 +2362,7 @@ gimp_image_construct_layers (GimpImage *gimage, } } - gimage->construct_flag = 1; /* something was projected */ + gimage->construct_flag = TRUE; /* something was projected */ } g_list_free (reverse_list); @@ -2433,7 +2407,7 @@ gimp_image_construct_channels (GimpImage *gimage, project_channel (gimage, channel, &src1PR, &src2PR); - gimage->construct_flag = 1; + gimage->construct_flag = TRUE; } } @@ -2535,7 +2509,7 @@ gimp_image_construct (GimpImage *gimage, /* set the construct flag, used to determine if anything * has been written to the gimage raw image yet. */ - gimage->construct_flag = 0; + gimage->construct_flag = FALSE; if (gimage->layers) { @@ -2544,17 +2518,19 @@ gimp_image_construct (GimpImage *gimage, } if ((gimage->layers) && /* There's a layer. */ - (! g_slist_next (gimage->layers)) && /* It's the only layer. */ - (gimp_layer_has_alpha ((GimpLayer *) (gimage->layers->data))) && /* It's !flat. */ - /* It's visible. */ + (! g_slist_next (gimage->layers)) && /* It's the only layer. */ + (gimp_layer_has_alpha ((GimpLayer *) (gimage->layers->data))) && + /* It's !flat. */ (gimp_drawable_get_visible (GIMP_DRAWABLE (gimage->layers->data))) && + /* It's visible. */ (gimp_drawable_width (GIMP_DRAWABLE (gimage->layers->data)) == gimage->width) && (gimp_drawable_height (GIMP_DRAWABLE (gimage->layers->data)) == gimage->height) && /* Covers all. */ - /* Not indexed. */ (!gimp_drawable_is_indexed (GIMP_DRAWABLE (gimage->layers->data))) && - (((GimpLayer *)(gimage->layers->data))->opacity == OPAQUE_OPACITY) /*opaq */ + /* Not indexed. */ + (((GimpLayer *)(gimage->layers->data))->opacity == OPAQUE_OPACITY) + /* Opaque */ ) { gint xoff; @@ -2585,14 +2561,14 @@ gimp_image_construct (GimpImage *gimage, destPR.curtile, srcPR.curtile); } - gimage->construct_flag = 1; + gimage->construct_flag = TRUE; gimp_image_construct_channels (gimage, x, y, w, h); return; } } #else - gimage->construct_flag = 0; + gimage->construct_flag = FALSE; #endif /* First, determine if the projection image needs to be diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h index a07924d82b..cbd5f6ff98 100644 --- a/app/core/gimpimage.h +++ b/app/core/gimpimage.h @@ -53,7 +53,7 @@ struct _GimpImage { GimpViewable parent_instance; - Gimp *gimp; /* The GIMP we image belongs to */ + Gimp *gimp; /* the GIMP the image belongs to*/ gint ID; /* provides a unique ID */ @@ -79,7 +79,7 @@ struct _GimpImage TileManager *shadow; /* shadow buffer tiles */ /* Projection attributes */ - gint construct_flag; /* flag for construction */ + gboolean construct_flag; /* flag for construction */ GimpImageType proj_type; /* type of the projection image */ gint proj_bytes; /* bpp in projection image */ gint proj_level; /* projection level */ diff --git a/app/core/gimpimagefile.c b/app/core/gimpimagefile.c index eb6c0b67e3..6d25ba553a 100644 --- a/app/core/gimpimagefile.c +++ b/app/core/gimpimagefile.c @@ -30,6 +30,7 @@ #endif #include +#include #include "core-types.h" diff --git a/app/core/gimpprojection-construct.c b/app/core/gimpprojection-construct.c index 4020f9d656..44ecae6ced 100644 --- a/app/core/gimpprojection-construct.c +++ b/app/core/gimpprojection-construct.c @@ -467,7 +467,7 @@ gimp_image_init (GimpImage *gimage) gimage->shadow = NULL; - gimage->construct_flag = -1; + gimage->construct_flag = FALSE; gimage->proj_type = RGBA_GIMAGE; gimage->projection = NULL; @@ -2260,7 +2260,7 @@ gimp_image_construct_layers (GimpImage *gimage, PixelRegion src1PR, src2PR, maskPR; PixelRegion * mask; GList *list; - GList *reverse_list = NULL; + GList *reverse_list; gint off_x; gint off_y; @@ -2268,36 +2268,8 @@ gimp_image_construct_layers (GimpImage *gimage, if ((layer = gimp_image_floating_sel (gimage))) floating_sel_composite (layer, x, y, w, h, FALSE); - /* Note added by Raph Levien, 27 Jan 1998 - This looks it was intended as an optimization, but it seems to - have correctness problems. In particular, if all channels are - turned off, the screen simply does not update the projected - image. It should be black. Turning off this optimization seems to - restore correct behavior. At some future point, it may be - desirable to turn the optimization back on. - - */ -#if 0 - /* If all channels are not visible, simply return */ - switch (gimp_image_base_type (gimage)) - { - case RGB: - if (! gimp_image_get_component_visible (gimage, RED_CHANNEL) && - ! gimp_image_get_component_visible (gimage, GREEN_CHANNEL) && - ! gimp_image_get_component_visible (gimage, BLUE_CHANNEL)) - return; - break; - case GRAY: - if (! gimp_image_get_component_visible (gimage, GRAY_CHANNEL)) - return; - break; - case INDEXED: - if (! gimp_image_get_component_visible (gimage, INDEXED_CHANNEL)) - return; - break; - } -#endif + reverse_list = NULL; for (list = GIMP_LIST (gimage->layers)->list; list; @@ -2323,8 +2295,10 @@ gimp_image_construct_layers (GimpImage *gimage, x1 = CLAMP (off_x, x, x + w); y1 = CLAMP (off_y, y, y + h); - x2 = CLAMP (off_x + gimp_drawable_width (GIMP_DRAWABLE (layer)), x, x + w); - y2 = CLAMP (off_y + gimp_drawable_height (GIMP_DRAWABLE (layer)), y, y + h); + x2 = CLAMP (off_x + gimp_drawable_width (GIMP_DRAWABLE (layer)), + x, x + w); + y2 = CLAMP (off_y + gimp_drawable_height (GIMP_DRAWABLE (layer)), + y, y + h); /* configure the pixel regions */ pixel_region_init (&src1PR, gimp_image_projection (gimage), @@ -2388,7 +2362,7 @@ gimp_image_construct_layers (GimpImage *gimage, } } - gimage->construct_flag = 1; /* something was projected */ + gimage->construct_flag = TRUE; /* something was projected */ } g_list_free (reverse_list); @@ -2433,7 +2407,7 @@ gimp_image_construct_channels (GimpImage *gimage, project_channel (gimage, channel, &src1PR, &src2PR); - gimage->construct_flag = 1; + gimage->construct_flag = TRUE; } } @@ -2535,7 +2509,7 @@ gimp_image_construct (GimpImage *gimage, /* set the construct flag, used to determine if anything * has been written to the gimage raw image yet. */ - gimage->construct_flag = 0; + gimage->construct_flag = FALSE; if (gimage->layers) { @@ -2544,17 +2518,19 @@ gimp_image_construct (GimpImage *gimage, } if ((gimage->layers) && /* There's a layer. */ - (! g_slist_next (gimage->layers)) && /* It's the only layer. */ - (gimp_layer_has_alpha ((GimpLayer *) (gimage->layers->data))) && /* It's !flat. */ - /* It's visible. */ + (! g_slist_next (gimage->layers)) && /* It's the only layer. */ + (gimp_layer_has_alpha ((GimpLayer *) (gimage->layers->data))) && + /* It's !flat. */ (gimp_drawable_get_visible (GIMP_DRAWABLE (gimage->layers->data))) && + /* It's visible. */ (gimp_drawable_width (GIMP_DRAWABLE (gimage->layers->data)) == gimage->width) && (gimp_drawable_height (GIMP_DRAWABLE (gimage->layers->data)) == gimage->height) && /* Covers all. */ - /* Not indexed. */ (!gimp_drawable_is_indexed (GIMP_DRAWABLE (gimage->layers->data))) && - (((GimpLayer *)(gimage->layers->data))->opacity == OPAQUE_OPACITY) /*opaq */ + /* Not indexed. */ + (((GimpLayer *)(gimage->layers->data))->opacity == OPAQUE_OPACITY) + /* Opaque */ ) { gint xoff; @@ -2585,14 +2561,14 @@ gimp_image_construct (GimpImage *gimage, destPR.curtile, srcPR.curtile); } - gimage->construct_flag = 1; + gimage->construct_flag = TRUE; gimp_image_construct_channels (gimage, x, y, w, h); return; } } #else - gimage->construct_flag = 0; + gimage->construct_flag = FALSE; #endif /* First, determine if the projection image needs to be diff --git a/app/core/gimpprojection-construct.h b/app/core/gimpprojection-construct.h index a07924d82b..cbd5f6ff98 100644 --- a/app/core/gimpprojection-construct.h +++ b/app/core/gimpprojection-construct.h @@ -53,7 +53,7 @@ struct _GimpImage { GimpViewable parent_instance; - Gimp *gimp; /* The GIMP we image belongs to */ + Gimp *gimp; /* the GIMP the image belongs to*/ gint ID; /* provides a unique ID */ @@ -79,7 +79,7 @@ struct _GimpImage TileManager *shadow; /* shadow buffer tiles */ /* Projection attributes */ - gint construct_flag; /* flag for construction */ + gboolean construct_flag; /* flag for construction */ GimpImageType proj_type; /* type of the projection image */ gint proj_bytes; /* bpp in projection image */ gint proj_level; /* projection level */ diff --git a/app/core/gimptoolinfo.h b/app/core/gimptoolinfo.h index 4bc2ea2539..374205f57f 100644 --- a/app/core/gimptoolinfo.h +++ b/app/core/gimptoolinfo.h @@ -20,6 +20,8 @@ #define __GIMP_TOOL_INFO_H__ +#include + #include "gimpdata.h" diff --git a/app/core/gimpunit.c b/app/core/gimpunit.c index 6e3a225198..903ed02cf8 100644 --- a/app/core/gimpunit.c +++ b/app/core/gimpunit.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include "libgimpbase/gimpbase.h" diff --git a/app/display/Makefile.am b/app/display/Makefile.am index b35760f942..48a706429e 100644 --- a/app/display/Makefile.am +++ b/app/display/Makefile.am @@ -50,10 +50,3 @@ INCLUDES = @STRIP_BEGIN@ \ $(GTK_CFLAGS) \ -I$(includedir) \ @STRIP_END@ - -.PHONY: files - -files: - @files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \ - echo $$p; \ - done diff --git a/app/main.c b/app/main.c index 726075c157..89a5eb544e 100644 --- a/app/main.c +++ b/app/main.c @@ -42,6 +42,8 @@ #include "core/core-types.h" +#include "config/gimpconfig.h" + #include "gui/gui.h" #include "appenv.h" @@ -143,6 +145,27 @@ main (int argc, gui_libs_init (&argc, &argv); } + /* test code for GimpConfig, will go away */ + { + GimpConfig *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); + + g_signal_connect_swapped (G_OBJECT (config), "notify", + G_CALLBACK (g_print), + "GimpConfig property changed\n"); + + gimp_config_serialize (config); + gimp_config_deserialize (config); + + g_object_unref (config); + } + #if defined (HAVE_SHM_H) || defined (G_OS_WIN32) use_shm = TRUE; #endif diff --git a/app/pdb/plug_in_cmds.c b/app/pdb/plug_in_cmds.c index 5d343962fa..e8db6841d2 100644 --- a/app/pdb/plug_in_cmds.c +++ b/app/pdb/plug_in_cmds.c @@ -414,7 +414,6 @@ plugin_domain_register_invoker (Gimp *gimp, gboolean success = TRUE; gchar *domain_name; gchar *domain_path; - PlugInDef *plug_in_def; domain_name = (gchar *) args[0].value.pdb_pointer; if (domain_name == NULL) @@ -472,7 +471,6 @@ plugin_help_register_invoker (Gimp *gimp, { gboolean success = TRUE; gchar *help_path; - PlugInDef *plug_in_def; help_path = (gchar *) args[0].value.pdb_pointer; if (help_path == NULL) diff --git a/app/widgets/widgets-types.h b/app/widgets/widgets-types.h index f7ae41e3a4..a9ca5fb475 100644 --- a/app/widgets/widgets-types.h +++ b/app/widgets/widgets-types.h @@ -33,20 +33,6 @@ typedef enum GIMP_VIEW_TYPE_LIST } GimpViewType; -typedef enum -{ - GIMP_PREVIEW_SIZE_NONE = 0, - GIMP_PREVIEW_SIZE_TINY = 16, - GIMP_PREVIEW_SIZE_EXTRA_SMALL = 24, - GIMP_PREVIEW_SIZE_SMALL = 32, - GIMP_PREVIEW_SIZE_MEDIUM = 48, - GIMP_PREVIEW_SIZE_LARGE = 64, - GIMP_PREVIEW_SIZE_EXTRA_LARGE = 96, - GIMP_PREVIEW_SIZE_HUGE = 128, - GIMP_PREVIEW_SIZE_ENORMOUS = 192, - GIMP_PREVIEW_SIZE_GIGANTIC = 256 -} GimpPreviewSize; - typedef enum { GIMP_DROP_NONE, diff --git a/configure.in b/configure.in index 8c7a9a3a89..7e19f0dcde 100644 --- a/configure.in +++ b/configure.in @@ -860,6 +860,7 @@ libgimpwidgets/makefile.mingw app/Makefile app/makefile.mingw app/base/Makefile +app/config/Makefile app/core/Makefile app/display/Makefile app/file/Makefile diff --git a/libgimp/Makefile.am b/libgimp/Makefile.am index c4376644fe..6a7f42201d 100644 --- a/libgimp/Makefile.am +++ b/libgimp/Makefile.am @@ -182,7 +182,3 @@ libgimpui_1_3_la_LDFLAGS = @STRIP_BEGIN@ \ @STRIP_END@ libgimpui_1_3_la_LIBADD = $(GTK_LIBS) - -## this is probably cruft, but may not be. -klm -## makefile.mingw: $(top_builddir)/config.status $(top_srcdir)/libgimp/makefile.mingw.in -## cd $(top_builddir) && CONFIG_FILES=libgimp/$@ CONFIG_HEADERS= $(SHELL) ./config.status diff --git a/libgimpbase/Makefile.am b/libgimpbase/Makefile.am index 84e80bff78..f1ea805698 100644 --- a/libgimpbase/Makefile.am +++ b/libgimpbase/Makefile.am @@ -69,7 +69,3 @@ libgimpbase_1_3_la_LDFLAGS = @STRIP_BEGIN@ \ @STRIP_END@ libgimpbase_1_3_la_LIBADD = $(GLIB_LIBS) - -## this is probably cruft, but may not be. -klm -## makefile.mingw: $(top_builddir)/config.status $(top_srcdir)/libgimpcolor/makefile.mingw.in -## cd $(top_builddir) && CONFIG_FILES=libgimpcolor/$@ CONFIG_HEADERS= $(SHELL) ./config.status diff --git a/libgimpcolor/Makefile.am b/libgimpcolor/Makefile.am index 6d25c1e677..3b95df0142 100644 --- a/libgimpcolor/Makefile.am +++ b/libgimpcolor/Makefile.am @@ -56,8 +56,3 @@ libgimpcolor_1_3_la_LDFLAGS = @STRIP_BEGIN@ \ @STRIP_END@ libgimpcolor_1_3_la_LIBADD = $(GLIB_LIBS) -lm - -## this is probably cruft, but may not be. -klm -## makefile.mingw: $(top_builddir)/config.status $(top_srcdir)/libgimpcolor/makefile.mingw.in -## cd $(top_builddir) && CONFIG_FILES=libgimpcolor/$@ CONFIG_HEADERS= $(SHELL) ./config.status -## \ No newline at end of file diff --git a/libgimpconfig/gimpconfig-deserialize.c b/libgimpconfig/gimpconfig-deserialize.c new file mode 100644 index 0000000000..d9bd4a082a --- /dev/null +++ b/libgimpconfig/gimpconfig-deserialize.c @@ -0,0 +1,223 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * Object properties deserialization routines + * Copyright (C) 2001 Sven Neumann + * + * 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 +#include + +#include + +#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; +} diff --git a/libgimpconfig/gimpconfig-deserialize.h b/libgimpconfig/gimpconfig-deserialize.h new file mode 100644 index 0000000000..81a39115c6 --- /dev/null +++ b/libgimpconfig/gimpconfig-deserialize.h @@ -0,0 +1,30 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * Object peoperties deserialization routines + * Copyright (C) 2001 Sven Neumann + * + * 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__ */ diff --git a/libgimpconfig/gimpconfig-iface.c b/libgimpconfig/gimpconfig-iface.c new file mode 100644 index 0000000000..058cc82af5 --- /dev/null +++ b/libgimpconfig/gimpconfig-iface.c @@ -0,0 +1,238 @@ +/* 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 +#include +#include +#include +#include + +#include + +#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) + { + 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); +} + +gboolean +gimp_config_deserialize (GimpConfig *config) +{ + gint fd; + GScanner *scanner; + gboolean success; + + g_return_val_if_fail (GIMP_CONFIG (config), FALSE); + g_return_val_if_fail (GIMP_OBJECT (config)->name != NULL, FALSE); + + fd = open (GIMP_OBJECT (config)->name, O_RDONLY); + + if (fd == -1) + return FALSE; + + scanner = g_scanner_new (NULL); + + 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_scanner_input_file (scanner, fd); + scanner->input_name = GIMP_OBJECT (config)->name; + + success = gimp_config_deserialize_properties (config, scanner); + + g_scanner_destroy (scanner); + close (fd); + + return success; +} diff --git a/libgimpconfig/gimpconfig-iface.h b/libgimpconfig/gimpconfig-iface.h new file mode 100644 index 0000000000..665d8a969a --- /dev/null +++ b/libgimpconfig/gimpconfig-iface.h @@ -0,0 +1,57 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995-1997 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_CONFIG_H__ +#define __GIMP_CONFIG_H__ + +#include "core/core-types.h" +#include "core/gimpobject.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)) + + +typedef struct _GimpConfig GimpConfig; +typedef struct _GimpConfigClass GimpConfigClass; + +struct _GimpConfig +{ + GimpObject parent_instance; + + guint marching_ants_speed; + GimpPreviewSize preview_size; +}; + +struct _GimpConfigClass +{ + GimpObjectClass parent_class; +}; + + +GType gimp_config_get_type (void) G_GNUC_CONST; + +void gimp_config_serialize (GimpConfig *config); +gboolean gimp_config_deserialize (GimpConfig *config); + + +#endif /* __GIMP_CONFIG_H__ */ diff --git a/libgimpconfig/gimpconfig-serialize.c b/libgimpconfig/gimpconfig-serialize.c new file mode 100644 index 0000000000..31164a8cdf --- /dev/null +++ b/libgimpconfig/gimpconfig-serialize.c @@ -0,0 +1,96 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * Object propoerties serialization routines + * Copyright (C) 2001 Sven Neumann + * + * 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 +#include + +#include + +#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); + } +} diff --git a/libgimpconfig/gimpconfig-serialize.h b/libgimpconfig/gimpconfig-serialize.h new file mode 100644 index 0000000000..80e4ff53bf --- /dev/null +++ b/libgimpconfig/gimpconfig-serialize.h @@ -0,0 +1,30 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * Object properties serialization routines + * Copyright (C) 2001 Sven Neumann + * + * 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__ */ diff --git a/libgimpmath/Makefile.am b/libgimpmath/Makefile.am index 91ca189b69..535825e957 100644 --- a/libgimpmath/Makefile.am +++ b/libgimpmath/Makefile.am @@ -47,7 +47,3 @@ libgimpmath_1_3_la_LDFLAGS = @STRIP_BEGIN@ \ @STRIP_END@ libgimpmath_1_3_la_LIBADD = $(GLIB_LIBS) -lm - -## this is probably cruft, but may not be. -klm -## makefile.mingw: $(top_builddir)/config.status $(top_srcdir)/libgimpmath/makefile.mingw.in -## cd $(top_builddir) && CONFIG_FILES=libgimpmath/$@ CONFIG_HEADERS= $(SHELL) ./config.status diff --git a/libgimpwidgets/Makefile.am b/libgimpwidgets/Makefile.am index 75e4e30ea8..8717182d8a 100644 --- a/libgimpwidgets/Makefile.am +++ b/libgimpwidgets/Makefile.am @@ -84,7 +84,3 @@ libgimpwidgets_1_3_la_LDFLAGS = @STRIP_BEGIN@ \ @STRIP_END@ libgimpwidgets_1_3_la_LIBADD = $(GLIB_LIBS) -lm - -## this is probably cruft, but may not be. -klm -##makefile.mingw: $(top_builddir)/config.status $(top_srcdir)/libgimpwidgets/makefile.mingw.in -## cd $(top_builddir) && CONFIG_FILES=libgimpwidgets/$@ CONFIG_HEADERS= $(SHELL) ./config.status diff --git a/plug-ins/Makefile.am b/plug-ins/Makefile.am index e46e7f88c0..eebdfd42cc 100644 --- a/plug-ins/Makefile.am +++ b/plug-ins/Makefile.am @@ -62,7 +62,3 @@ SUBDIRS = \ ## gap \ ## gdyntext \ - -## this is probably cruft, but may not be. -klm -## makefile.mingw: $(top_builddir)/config.status $(top_srcdir)/plug-ins/makefile.mingw.in -## cd $(top_builddir) && CONFIG_FILES=plug-ins/$@ CONFIG_HEADERS= $(SHELL) ./config.status diff --git a/tools/pdbgen/pdb/plug_in.pdb b/tools/pdbgen/pdb/plug_in.pdb index b4574e6bf4..4672df017a 100644 --- a/tools/pdbgen/pdb/plug_in.pdb +++ b/tools/pdbgen/pdb/plug_in.pdb @@ -279,7 +279,6 @@ HELP %invoke = ( success => 'TRUE', - vars => [ 'PlugInDef *plug_in_def' ], code => <<'CODE', { if (current_plug_in && current_plug_in->query) @@ -313,7 +312,6 @@ HELP %invoke = ( success => 'TRUE', - vars => [ 'PlugInDef *plug_in_def' ], code => <<'CODE', { if (current_plug_in && current_plug_in->query)