gimp/libgimpconfig/gimpconfig-params.h

151 lines
7.6 KiB
C
Raw Normal View History

/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* ParamSpecs for config objects
* 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_PARAMS_H__
#define __GIMP_CONFIG_PARAMS_H__
/*
* GIMP_PARAM_SERIALIZE - A property that can and should be
* serialized and deserialized.
* GIMP_PARAM_AGGREGATE - The object property is to be treated as
* part of the parent object.
* GIMP_PARAM_RESTART - Changes to this property take effect only
* after a restart.
* GIMP_PARAM_CONFIRM - Changes to this property should be
* confirmed by the user before being applied.
* GIMP_PARAM_DEFAULTS - Don't serialize this property if it has the
* default value.
* GIMP_PARAM_IGNORE - This property exists for obscure reasons
* and is needed for backward compatibility.
* Ignore the value read and don't serialize it.
*/
#define GIMP_PARAM_SERIALIZE (1 << (0 + G_PARAM_USER_SHIFT))
made object properties G_PARAM_READWRITE by default. Added flag 2003-04-12 Michael Natterer <mitch@gimp.org> * app/config/gimpconfig-params.h: made object properties G_PARAM_READWRITE by default. Added flag GIMP_PARAM_AGGREGATE which indicates that an object property is not a reference but a real part of its owner. * app/config/gimpconfig-deserialize.c: g_object_set_property() object properties only if they are not GIMP_PARAM_AGGREGATE. * app/config/gimpconfig-utils.c (gimp_config_copy_properties, gimp_config_reset_properties): copy and reset GIMP_PARAM_AGGREGATE object properties correctly. * app/config/gimpconfig-serialize.c: don't call gimp_config_writer_open/close() for properties which are handled by a GimpConfigIface::serialize_property() implementation. * app/core/gimpcontext.c: removed exlicit G_PARAM_WRITABLE from object properties since that's the default now. Call gimp_config_writer_open/close() when serializing properties. * app/core/gimpviewable.c (gimp_viewable_get_property): use gimp_viewable_get_stock_id(). (gimp_viewable_set_stock_id): set stock_id to NULL if the new stock_id is the same as viewable_class->default_stock_id. Added serialize_property() which skips stock_id serialization if it is NULL. * app/tools/gimptextoptions.c: made the "text" property GIMP_PARAM_AGGREGATE. Added gimp_text_options_set_property() (which does nothing). * app/widgets/gimptemplateeditor.[ch]: added an optional GimpViewableButton to change the template's icon. * app/gui/file-new-dialog.c: create it with the icon button so it gets some testing.
2003-04-12 19:06:25 +00:00
#define GIMP_PARAM_AGGREGATE (1 << (1 + G_PARAM_USER_SHIFT))
#define GIMP_PARAM_RESTART (1 << (2 + G_PARAM_USER_SHIFT))
#define GIMP_PARAM_CONFIRM (1 << (3 + G_PARAM_USER_SHIFT))
#define GIMP_PARAM_DEFAULTS (1 << (4 + G_PARAM_USER_SHIFT))
#define GIMP_PARAM_IGNORE (1 << (5 + G_PARAM_USER_SHIFT))
#define GIMP_CONFIG_PARAM_FLAGS (G_PARAM_READWRITE | \
G_PARAM_CONSTRUCT | \
GIMP_PARAM_SERIALIZE)
/* some convenience macros to install object properties */
#define GIMP_CONFIG_INSTALL_PROP_BOOLEAN(class, id,\
name, blurb, default, flags)\
g_object_class_install_property (class, id,\
g_param_spec_boolean (name, NULL, blurb,\
2001-12-11 15:58:07 +00:00
default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_INSTALL_PROP_RGB(class, id,\
name, blurb, default, flags)\
g_object_class_install_property (class, id,\
gimp_param_spec_rgb (name, NULL, blurb,\
default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_INSTALL_PROP_DOUBLE(class, id,\
name, blurb, min, max, default, flags)\
g_object_class_install_property (class, id,\
g_param_spec_double (name, NULL, blurb,\
min, max, default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_INSTALL_PROP_RESOLUTION(class, id,\
name, blurb, default, flags)\
g_object_class_install_property (class, id,\
g_param_spec_double (name, NULL, blurb,\
GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION, \
default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_INSTALL_PROP_ENUM(class, id,\
name, blurb, enum_type, default, flags)\
g_object_class_install_property (class, id,\
g_param_spec_enum (name, NULL, blurb,\
enum_type, default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_INSTALL_PROP_INT(class, id,\
name, blurb, min, max, default, flags)\
g_object_class_install_property (class, id,\
g_param_spec_int (name, NULL, blurb,\
2001-12-11 15:58:07 +00:00
min, max, default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_INSTALL_PROP_MATRIX2(class, id,\
name, blurb, default, flags)\
g_object_class_install_property (class, id,\
gimp_param_spec_matrix2 (name, NULL, blurb,\
default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_INSTALL_PROP_MEMSIZE(class, id,\
name, blurb, min, max, default, flags)\
g_object_class_install_property (class, id,\
gimp_param_spec_memsize (name, NULL, blurb,\
min, max, default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_INSTALL_PROP_PATH(class, id,\
name, blurb, type, default, flags)\
g_object_class_install_property (class, id,\
gimp_param_spec_path (name, NULL, blurb,\
type, default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_INSTALL_PROP_STRING(class, id,\
name, blurb, default, flags)\
2001-12-11 15:58:07 +00:00
g_object_class_install_property (class, id,\
g_param_spec_string (name, NULL, blurb,\
2001-12-11 15:58:07 +00:00
default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_INSTALL_PROP_UINT(class, id,\
name, blurb, min, max, default, flags)\
2001-12-11 15:58:07 +00:00
g_object_class_install_property (class, id,\
g_param_spec_uint (name, NULL, blurb,\
2001-12-11 15:58:07 +00:00
min, max, default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
#define GIMP_CONFIG_INSTALL_PROP_UNIT(class, id,\
name, blurb, pixels, percent, default, flags)\
g_object_class_install_property (class, id,\
gimp_param_spec_unit (name, NULL, blurb,\
pixels, percent, default,\
flags | GIMP_CONFIG_PARAM_FLAGS))
/* object and pointer properties are _not_ G_PARAM_CONSTRUCT */
#define GIMP_CONFIG_INSTALL_PROP_OBJECT(class, id,\
name, blurb, object_type, flags)\
g_object_class_install_property (class, id,\
g_param_spec_object (name, NULL, blurb,\
object_type,\
flags |\
made object properties G_PARAM_READWRITE by default. Added flag 2003-04-12 Michael Natterer <mitch@gimp.org> * app/config/gimpconfig-params.h: made object properties G_PARAM_READWRITE by default. Added flag GIMP_PARAM_AGGREGATE which indicates that an object property is not a reference but a real part of its owner. * app/config/gimpconfig-deserialize.c: g_object_set_property() object properties only if they are not GIMP_PARAM_AGGREGATE. * app/config/gimpconfig-utils.c (gimp_config_copy_properties, gimp_config_reset_properties): copy and reset GIMP_PARAM_AGGREGATE object properties correctly. * app/config/gimpconfig-serialize.c: don't call gimp_config_writer_open/close() for properties which are handled by a GimpConfigIface::serialize_property() implementation. * app/core/gimpcontext.c: removed exlicit G_PARAM_WRITABLE from object properties since that's the default now. Call gimp_config_writer_open/close() when serializing properties. * app/core/gimpviewable.c (gimp_viewable_get_property): use gimp_viewable_get_stock_id(). (gimp_viewable_set_stock_id): set stock_id to NULL if the new stock_id is the same as viewable_class->default_stock_id. Added serialize_property() which skips stock_id serialization if it is NULL. * app/tools/gimptextoptions.c: made the "text" property GIMP_PARAM_AGGREGATE. Added gimp_text_options_set_property() (which does nothing). * app/widgets/gimptemplateeditor.[ch]: added an optional GimpViewableButton to change the template's icon. * app/gui/file-new-dialog.c: create it with the icon button so it gets some testing.
2003-04-12 19:06:25 +00:00
G_PARAM_READWRITE | GIMP_PARAM_SERIALIZE))
#define GIMP_CONFIG_INSTALL_PROP_POINTER(class, id,\
name, blurb, flags)\
g_object_class_install_property (class, id,\
g_param_spec_pointer (name, NULL, blurb,\
flags |\
G_PARAM_READWRITE | GIMP_PARAM_SERIALIZE))
#endif /* __GIMP_CONFIG_PARAMS_H__ */