Commit def233b4 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

app/config/Makefile.am new files with utility functions.

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

	* app/config/Makefile.am
	* app/config/gimpconfig-utils.[ch]: new files with utility functions.

	* app/config/gimpdisplayconfig.[ch]: new class with display config
	properties so GimpGuiConfig doesn't get too large.

	* app/config/gimpbaseconfig.c
	* app/config/gimpcoreconfig.[ch]
	* app/config/gimpguiconfig.[ch]: install path properties with
	useable defaults (substituted gimpdir and friends). Moved properties
	around.

	* app/gui/session.c: removed outdated comment.
parent e16e7643
2001-12-18 Sven Neumann <sven@gimp.org>
* app/config/Makefile.am
* app/config/gimpconfig-utils.[ch]: new files with utility functions.
* app/config/gimpdisplayconfig.[ch]: new class with display config
properties so GimpGuiConfig doesn't get too large.
* app/config/gimpbaseconfig.c
* app/config/gimpcoreconfig.[ch]
* app/config/gimpguiconfig.[ch]: install path properties with
useable defaults (substituted gimpdir and friends). Moved properties
around.
* app/gui/session.c: removed outdated comment.
2001-12-18 Michael Natterer <mitch@gimp.org>
* configure.in: added -DGDK_PIXBUF_DISABLE_DEPRECATED to CPPFLAGS.
......
......@@ -16,10 +16,14 @@ libappconfig_a_SOURCES = @STRIP_BEGIN@ \
gimpconfig-serialize.h \
gimpconfig-types.c \
gimpconfig-types.h \
gimpconfig-utils.c \
gimpconfig-utils.h \
gimpbaseconfig.c \
gimpbaseconfig.h \
gimpcoreconfig.c \
gimpcoreconfig.h \
gimpdisplayconfig.c \
gimpdisplayconfig.h \
gimpguiconfig.c \
gimpguiconfig.h \
@STRIP_END@
......
......@@ -101,11 +101,12 @@ gimp_base_config_class_init (GimpBaseConfigClass *klass)
object_class->get_property = gimp_base_config_get_property;
GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_TEMP_PATH,
"temp-path",
"${gimp_dir}" G_DIR_SEPARATOR_S "tmp");
"temp-path",
g_build_filename (gimp_directory (),
"tmp", NULL));
GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_SWAP_PATH,
"swap-path",
"${gimp_dir}");
"swap-path",
g_strdup (gimp_directory ()));
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_STINGY_MEMORY_USE,
"stingy-memory-use",
FALSE);
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* Utitility functions for GimpConfig.
* Copyright (C) 2001 Sven Neumann <sven@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib.h>
#include "libgimpbase/gimpenv.h"
#include "gimpconfig-utils.h"
gchar *
gimp_config_build_data_path (const gchar *name)
{
return g_strconcat (gimp_directory (), G_DIR_SEPARATOR_S, name,
G_SEARCHPATH_SEPARATOR_S,
gimp_data_directory (), G_DIR_SEPARATOR_S, name,
NULL);
}
gchar *
gimp_config_build_plug_in_path (const gchar *name)
{
return g_strconcat (gimp_directory (), G_DIR_SEPARATOR_S, name,
G_SEARCHPATH_SEPARATOR_S,
gimp_plug_in_directory (), G_DIR_SEPARATOR_S, name,
NULL);
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
*
* Utitility functions for GimpConfig.
* Copyright (C) 2001 Sven Neumann <sven@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_CONFIG_UTILS_H__
#define __GIMP_CONFIG_UTILS_H__
gchar * gimp_config_build_data_path (const gchar *name);
gchar * gimp_config_build_plug_in_path (const gchar *name);
#endif /* __GIMP_CONFIG_UTILS_H__ */
......@@ -31,18 +31,11 @@
#include "gimpconfig.h"
#include "gimpconfig-params.h"
#include "gimpconfig-types.h"
#include "gimpconfig-utils.h"
#include "gimpcoreconfig.h"
#define BUILD_PLUG_IN_PATH(name)\
("${gimp_dir}" G_DIR_SEPARATOR_S name G_SEARCHPATH_SEPARATOR_S \
"${gimp_plugin_dir}" G_DIR_SEPARATOR_S name)
#define BUILD_DATA_PATH(name)\
("${gimp_dir}" G_DIR_SEPARATOR_S name G_SEARCHPATH_SEPARATOR_S \
"${gimp_datadir}" G_DIR_SEPARATOR_S name)
static void gimp_core_config_class_init (GimpCoreConfigClass *klass);
static void gimp_core_config_set_property (GObject *object,
guint property_id,
......@@ -77,7 +70,11 @@ enum
PROP_UNDO_LEVELS,
PROP_PLUGINRC_PATH,
PROP_MODULE_LOAD_INHIBIT,
PROP_WRITE_THUMBNAILS
PROP_PREVIEW_SIZE,
PROP_WRITE_THUMBNAILS,
PROP_GAMMA_CORRECTION,
PROP_INSTALL_COLORMAP,
PROP_MIN_COLORS
};
......@@ -121,22 +118,22 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_PLUG_IN_PATH,
"plug-in-path",
BUILD_PLUG_IN_PATH ("plug-ins"));
gimp_config_build_plug_in_path ("plug-ins"));
GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_MODULE_PATH,
"module-path",
BUILD_PLUG_IN_PATH ("modules"));
gimp_config_build_plug_in_path ("modules"));
GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_BRUSH_PATH,
"brush-path",
BUILD_DATA_PATH ("brushes"));
gimp_config_build_data_path ("brushes"));
GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_PATTERN_PATH,
"pattern-path",
BUILD_DATA_PATH ("patterns"));
gimp_config_build_data_path ("patterns"));
GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_PALETTE_PATH,
"palette-path",
BUILD_DATA_PATH ("palettes"));
gimp_config_build_data_path ("palettes"));
GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_GRADIENT_PATH,
"gradient-path",
BUILD_DATA_PATH ("gradients"));
gimp_config_build_data_path ("gradients"));
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_DEFAULT_BRUSH,
"default-brush",
NULL);
......@@ -178,13 +175,26 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
0, G_MAXINT, 5);
GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_PLUGINRC_PATH,
"pluginrc-path",
"${gimp_dir}" G_DIR_SEPARATOR_S "pluginrc");
g_build_filename (gimp_directory (),
"pluginrc", NULL));
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_MODULE_LOAD_INHIBIT,
"module-load-inhibit",
NULL);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_PREVIEW_SIZE,
"preview-size",
GIMP_TYPE_PREVIEW_SIZE, GIMP_PREVIEW_SIZE_SMALL);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_WRITE_THUMBNAILS,
"write-thumbnails",
TRUE);
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_GAMMA_CORRECTION,
"gamma-correction",
0.0, 100.0, 1.0);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_INSTALL_COLORMAP,
"install-colormap",
FALSE);
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_MIN_COLORS,
"min-colors",
27, 256, 144);
}
static void
......@@ -275,9 +285,21 @@ gimp_core_config_set_property (GObject *object,
g_free (core_config->module_load_inhibit);
core_config->module_load_inhibit = g_value_dup_string (value);
break;
case PROP_PREVIEW_SIZE:
core_config->preview_size = g_value_get_enum (value);
break;
case PROP_WRITE_THUMBNAILS:
core_config->write_thumbnails = g_value_get_boolean (value);
break;
case PROP_GAMMA_CORRECTION:
core_config->gamma_val = g_value_get_double (value);
break;
case PROP_INSTALL_COLORMAP:
core_config->install_cmap = g_value_get_boolean (value);
break;
case PROP_MIN_COLORS:
core_config->min_colors = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......@@ -360,9 +382,21 @@ gimp_core_config_get_property (GObject *object,
case PROP_MODULE_LOAD_INHIBIT:
g_value_set_string (value, core_config->module_load_inhibit);
break;
case PROP_PREVIEW_SIZE:
g_value_set_enum (value, core_config->preview_size);
break;
case PROP_WRITE_THUMBNAILS:
g_value_set_boolean (value, core_config->write_thumbnails);
break;
case PROP_GAMMA_CORRECTION:
g_value_set_double (value, core_config->gamma_val);
break;
case PROP_INSTALL_COLORMAP:
g_value_set_boolean (value, core_config->install_cmap);
break;
case PROP_MIN_COLORS:
g_value_set_int (value, core_config->min_colors);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......
......@@ -67,7 +67,13 @@ struct _GimpCoreConfig
gchar *plug_in_rc_path;
gchar *module_load_inhibit;
GimpPreviewSize preview_size;
gboolean write_thumbnails;
gdouble gamma_val;
gboolean install_cmap;
gint min_colors;
};
struct _GimpCoreConfigClass
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* GimpDisplayConfig class
* Copyright (C) 2001 Sven Neumann <sven@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "base/base-enums.h"
#include "core/core-enums.h"
#include "gimpconfig.h"
#include "gimpconfig-params.h"
#include "gimpconfig-types.h"
#include "gimpconfig-utils.h"
#include "gimpdisplayconfig.h"
static void gimp_display_config_class_init (GimpDisplayConfigClass *klass);
static void gimp_display_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_display_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
enum
{
PROP_0,
PROP_MARCHING_ANTS_SPEED,
PROP_COLORMAP_CYCLING,
PROP_RESIZE_WINDOWS_ON_ZOOM,
PROP_RESIZE_WINDOWS_ON_RESIZE,
PROP_DEFAULT_DOT_FOR_DOT,
PROP_CURSOR_MODE,
PROP_CURSOR_UPDATING,
PROP_IMAGE_TITLE_FORMAT,
PROP_SHOW_RULERS,
PROP_SHOW_STATUSBAR,
PROP_CONFIRM_ON_CLOSE,
PROP_MONITOR_XRESOLUTION,
PROP_MONITOR_YRESOLUTION,
PROP_MONITOR_RES_FROM_GDK
};
GType
gimp_display_config_get_type (void)
{
static GType config_type = 0;
if (! config_type)
{
static const GTypeInfo config_info =
{
sizeof (GimpDisplayConfigClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gimp_display_config_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpDisplayConfig),
0, /* n_preallocs */
NULL /* instance_init */
};
config_type = g_type_register_static (GIMP_TYPE_CORE_CONFIG,
"GimpDisplayConfig",
&config_info, 0);
}
return config_type;
}
static void
gimp_display_config_class_init (GimpDisplayConfigClass *klass)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass);
object_class->set_property = gimp_display_config_set_property;
object_class->get_property = gimp_display_config_get_property;
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_MARCHING_ANTS_SPEED,
"marching-ants-speed",
50, G_MAXINT, 300);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_COLORMAP_CYCLING,
"colormap-cycling",
FALSE);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_RESIZE_WINDOWS_ON_ZOOM,
"resize-windows-on-zoom",
FALSE);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_RESIZE_WINDOWS_ON_RESIZE,
"resize-windows-on-resize",
FALSE);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_DEFAULT_DOT_FOR_DOT,
"default-dot-for-dot",
TRUE);
/* FIXME: insert cursor_mode and cursor_updating here */
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_IMAGE_TITLE_FORMAT,
"image-title-format",
"%f-%p.%i (%t)");
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_RULERS,
"show-rulers",
TRUE);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_STATUSBAR,
"show-statusbar",
TRUE);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_CONFIRM_ON_CLOSE,
"confirm-on-close",
TRUE);
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_MONITOR_XRESOLUTION,
"monitor-xresolution",
GIMP_MIN_RESOLUTION, G_MAXDOUBLE, 72.0);
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_MONITOR_YRESOLUTION,
"monitor-yresolution",
GIMP_MIN_RESOLUTION, G_MAXDOUBLE, 72.0);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_MONITOR_RES_FROM_GDK,
"monitor-resolution-from-windowing-system",
TRUE);
}
static void
gimp_display_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpDisplayConfig *display_config;
display_config = GIMP_DISPLAY_CONFIG (object);
switch (property_id)
{
case PROP_MARCHING_ANTS_SPEED:
display_config->marching_ants_speed = g_value_get_int (value);
break;
case PROP_COLORMAP_CYCLING:
display_config->colormap_cycling = g_value_get_boolean (value);
break;
case PROP_RESIZE_WINDOWS_ON_ZOOM:
display_config->resize_windows_on_zoom = g_value_get_boolean (value);
break;
case PROP_RESIZE_WINDOWS_ON_RESIZE:
display_config->resize_windows_on_resize = g_value_get_boolean (value);
break;
case PROP_DEFAULT_DOT_FOR_DOT:
display_config->default_dot_for_dot = g_value_get_boolean (value);
break;
case PROP_IMAGE_TITLE_FORMAT:
g_free (display_config->image_title_format);
display_config->image_title_format = g_value_dup_string (value);
break;
case PROP_SHOW_RULERS:
display_config->show_rulers = g_value_get_boolean (value);
break;
case PROP_SHOW_STATUSBAR:
display_config->show_statusbar = g_value_get_boolean (value);
break;
case PROP_CONFIRM_ON_CLOSE:
display_config->confirm_on_close = g_value_get_boolean (value);
break;
case PROP_MONITOR_XRESOLUTION:
display_config->monitor_xres = g_value_get_double (value);
break;
case PROP_MONITOR_YRESOLUTION:
display_config->monitor_yres = g_value_get_double (value);
break;
case PROP_MONITOR_RES_FROM_GDK:
display_config->monitor_res_from_gdk = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_display_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpDisplayConfig *display_config;
display_config = GIMP_DISPLAY_CONFIG (object);
switch (property_id)
{
case PROP_MARCHING_ANTS_SPEED:
g_value_set_int (value, display_config->marching_ants_speed);
break;
case PROP_COLORMAP_CYCLING:
g_value_set_boolean (value, display_config->colormap_cycling);
break;
case PROP_RESIZE_WINDOWS_ON_ZOOM:
g_value_set_boolean (value, display_config->resize_windows_on_zoom);
break;
case PROP_RESIZE_WINDOWS_ON_RESIZE:
g_value_set_boolean (value, display_config->resize_windows_on_resize);
break;
case PROP_DEFAULT_DOT_FOR_DOT:
g_value_set_boolean (value, display_config->default_dot_for_dot);
break;
case PROP_IMAGE_TITLE_FORMAT:
g_value_set_string (value, display_config->image_title_format);
break;
case PROP_SHOW_RULERS:
g_value_set_boolean (value, display_config->show_rulers);
break;
case PROP_SHOW_STATUSBAR:
g_value_set_boolean (value, display_config->show_statusbar);
break;
case PROP_CONFIRM_ON_CLOSE:
g_value_set_boolean (value, display_config->confirm_on_close);
break;
case PROP_MONITOR_XRESOLUTION:
g_value_set_double (value, display_config->monitor_xres);
break;
case PROP_MONITOR_YRESOLUTION:
g_value_set_double (value, display_config->monitor_yres);
break;
case PROP_MONITOR_RES_FROM_GDK:
g_value_set_boolean (value, display_config->monitor_res_from_gdk);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* GimpDisplayConfig class
* Copyright (C) 2001 Sven Neumann <sven@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_DISPLAY_CONFIG_H__
#define __GIMP_DISPLAY_CONFIG_H__
#include "gimpcoreconfig.h"
#define GIMP_TYPE_DISPLAY_CONFIG (gimp_display_config_get_type ())
#define GIMP_DISPLAY_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DISPLAY_CONFIG, GimpDisplayConfig))
#define GIMP_DISPLAY_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DISPLAY_CONFIG, GimpDisplayConfigClass))
#define GIMP_IS_DISPLAY_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_DISPLAY_CONFIG))
#define GIMP_IS_DISPLAY_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DISPLAY_CONFIG))
typedef struct _GimpDisplayConfig GimpDisplayConfig;
typedef struct _GimpDisplayConfigClass GimpDisplayConfigClass;
struct _GimpDisplayConfig
{
GimpCoreConfig parent_instance;
gint marching_ants_speed;
gboolean colormap_cycling;
gboolean resize_windows_on_zoom;
gboolean resize_windows_on_resize;
gboolean default_dot_for_dot;
gint cursor_mode;
gboolean cursor_updating;
gchar *image_title_format;
gboolean show_rulers;
gboolean show_statusbar;
gboolean confirm_on_close;
gdouble monitor_xres;
gdouble monitor_yres;
gboolean monitor_res_from_gdk;
};
struct _GimpDisplayConfigClass
{
GimpCoreConfigClass parent_class;
};
GType gimp_display_config_get_type (void) G_GNUC_CONST;
#endif /* GIMP_DISPLAY_CONFIG_H__ */
......@@ -31,15 +31,11 @@
#include "gimpconfig.h"
#include "gimpconfig-params.h"
#include "gimpconfig-types.h"
#include "gimpconfig-utils.h"
#include "gimpguiconfig.h"
#define BUILD_DATA_PATH(name)\
("${gimp_dir}" G_DIR_SEPARATOR_S name G_SEARCHPATH_SEPARATOR_S \
"${gimp_datadir}" G_DIR_SEPARATOR_S name)