diff --git a/ChangeLog b/ChangeLog index 17549c8989..b4db86f844 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2001-12-18 Sven Neumann + + * app/config/Makefile.am: don't build test-config by default. + + * app/config/gimprc.[ch]: new files for the GimpRc implementation. + + * app/config/gimpcoreconfig.h + * app/config/gimpdisplayconfig.h + * app/config/gimpguiconfig.h: include the necessary enum headers + here and prefix local includes with config so the files can be safely + included from almost everywhere. + + * app/config/test-config.c: instantiate and test GimpRc. + 2001-12-18 DindinX * app/base/boundary.c: diff --git a/app/config/Makefile.am b/app/config/Makefile.am index 608a35c6f4..d4809f3480 100644 --- a/app/config/Makefile.am +++ b/app/config/Makefile.am @@ -26,6 +26,8 @@ libappconfig_a_SOURCES = @STRIP_BEGIN@ \ gimpdisplayconfig.h \ gimpguiconfig.c \ gimpguiconfig.h \ + gimprc.c \ + gimprc.h \ @STRIP_END@ AM_CPPFLAGS = @STRIP_BEGIN@ \ @@ -42,9 +44,9 @@ INCLUDES = @STRIP_BEGIN@ \ @STRIP_END@ # -# test programs, not to be installed +# test programs, not to be built by default and never installed # -noinst_PROGRAMS = test-config +EXTRA_PROGRAMS = test-config test_config_DEPENDENCIES = @STRIP_BEGIN@ \ libappconfig.a \ diff --git a/app/config/gimpcoreconfig.h b/app/config/gimpcoreconfig.h index 31d7dc1288..f81a5045ec 100644 --- a/app/config/gimpcoreconfig.h +++ b/app/config/gimpcoreconfig.h @@ -24,7 +24,7 @@ #include "core/core-enums.h" -#include "gimpbaseconfig.h" +#include "config/gimpbaseconfig.h" #define GIMP_TYPE_CORE_CONFIG (gimp_core_config_get_type ()) diff --git a/app/config/gimpdisplayconfig.h b/app/config/gimpdisplayconfig.h index ba32fb1de9..38c920b770 100644 --- a/app/config/gimpdisplayconfig.h +++ b/app/config/gimpdisplayconfig.h @@ -24,7 +24,7 @@ #include "display/display-enums.h" -#include "gimpcoreconfig.h" +#include "config/gimpcoreconfig.h" #define GIMP_TYPE_DISPLAY_CONFIG (gimp_display_config_get_type ()) diff --git a/app/config/gimpguiconfig.h b/app/config/gimpguiconfig.h index 23a7b7f88c..e72a3ce3c3 100644 --- a/app/config/gimpguiconfig.h +++ b/app/config/gimpguiconfig.h @@ -22,7 +22,7 @@ #ifndef __GIMP_GUI_CONFIG_H__ #define __GIMP_GUI_CONFIG_H__ -#include "gimpdisplayconfig.h" +#include "config/gimpdisplayconfig.h" #define GIMP_TYPE_GUI_CONFIG (gimp_gui_config_get_type ()) diff --git a/app/config/gimprc.c b/app/config/gimprc.c new file mode 100644 index 0000000000..b71b83a552 --- /dev/null +++ b/app/config/gimprc.c @@ -0,0 +1,102 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * GimpRc + * 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 "libgimpbase/gimpbase.h" + +#include "gimpconfig.h" +#include "gimpconfig-serialize.h" +#include "gimprc.h" + + +static void gimp_rc_config_iface_init (gpointer iface, + gpointer iface_data); +static void gimp_rc_serialize (GObject *object, + gint fd); + + +GType +gimp_rc_get_type (void) +{ + static GType rc_type = 0; + + if (! rc_type) + { + static const GTypeInfo rc_info = + { + sizeof (GimpRcClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + NULL, /* class_init */ + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GimpRc), + 0, /* n_preallocs */ + NULL /* instance_init */ + }; + static const GInterfaceInfo rc_iface_info = + { + gimp_rc_config_iface_init, + NULL, /* iface_finalize */ + NULL /* iface_data */ + }; + + rc_type = g_type_register_static (GIMP_TYPE_GUI_CONFIG, + "GimpRc", + &rc_info, 0); + + g_type_add_interface_static (rc_type, + GIMP_TYPE_CONFIG_INTERFACE, + &rc_iface_info); + } + + return rc_type; +} + +static void +gimp_rc_config_iface_init (gpointer iface, + gpointer iface_data) +{ + GimpConfigInterface *config_iface = (GimpConfigInterface *) iface; + + config_iface->serialize = gimp_rc_serialize; +} + +static void +gimp_rc_serialize (GObject *object, + gint fd) +{ + gimp_config_serialize_properties (object, fd); + gimp_config_serialize_unknown_tokens (object, fd); +} + +GimpRc * +gimp_rc_new (void) +{ + GimpRc *gimprc; + + gimprc = GIMP_RC (g_object_new (GIMP_TYPE_RC, NULL)); + + return gimprc; +} diff --git a/app/config/gimprc.h b/app/config/gimprc.h new file mode 100644 index 0000000000..ab45699389 --- /dev/null +++ b/app/config/gimprc.h @@ -0,0 +1,53 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * GimpRc + * 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 __GIMP_RC_H__ +#define __GIMP_RC_H__ + +#include "config/gimpguiconfig.h" + + +#define GIMP_TYPE_RC (gimp_rc_get_type ()) +#define GIMP_RC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_RC, GimpRc)) +#define GIMP_RC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_RC, GimpRcClass)) +#define GIMP_IS_RC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_RC)) +#define GIMP_IS_RC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_RC)) + + +typedef struct _GimpRc GimpRc; +typedef struct _GimpRcClass GimpRcClass; + +struct _GimpRc +{ + GimpGuiConfig parent_instance; +}; + +struct _GimpRcClass +{ + GimpGuiConfigClass parent_class; +}; + + +GType gimp_rc_get_type (void) G_GNUC_CONST; +GimpRc * gimp_rc_new (void); + + +#endif /* GIMP_RC_H__ */ diff --git a/app/config/test-config.c b/app/config/test-config.c index 06e1ca9555..557b075b9a 100644 --- a/app/config/test-config.c +++ b/app/config/test-config.c @@ -30,7 +30,7 @@ #include "core/core-enums.h" #include "gimpconfig.h" -#include "gimpguiconfig.h" +#include "gimprc.h" static void notify_callback (GObject *object, @@ -44,7 +44,7 @@ int main (int argc, char *argv[]) { - GObject *config; + GimpRc *gimprc; const gchar *filename = "foorc"; gchar *header; gint i; @@ -65,26 +65,27 @@ main (int argc, g_print ("Testing GimpConfig ...\n\n"); - config = g_object_new (GIMP_TYPE_GUI_CONFIG, NULL); + gimprc = gimp_rc_new (); g_print (" Serializing %s to '%s' ... ", - g_type_name (G_TYPE_FROM_INSTANCE (config)), filename); - gimp_config_serialize (config, filename); + g_type_name (G_TYPE_FROM_INSTANCE (gimprc)), filename); + gimp_config_serialize (G_OBJECT (gimprc), filename); g_print ("done.\n\n"); - g_signal_connect (config, "notify", + g_signal_connect (G_OBJECT (gimprc), "notify", G_CALLBACK (notify_callback), NULL); g_print (" Deserializing from '%s' ...\n", filename); - gimp_config_deserialize (config, filename, TRUE); + gimp_config_deserialize (G_OBJECT (gimprc), filename, TRUE); header = "\n Unknown string tokens:\n"; - gimp_config_foreach_unknown_token (config, output_unknown_token, &header); + gimp_config_foreach_unknown_token (G_OBJECT (gimprc), + output_unknown_token, &header); g_print ("\n"); - g_object_unref (config); + g_object_unref (G_OBJECT (gimprc)); g_print ("Done.\n");