diff --git a/ChangeLog b/ChangeLog index 5436e6fcfd..98e72d5cc4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2001-12-16 Sven Neumann + + * app/config/gimpconfig-params.[ch] + * app/config/gimpconfig-types.[ch]: added support for GimpUnit type. + + * app/config/gimpbaseconfig.[ch] + * app/config/gimpcoreconfig.[ch] + * app/config/test-config.c: cleaned up includes. Added more properties + to GimpCoreConfig. + + * app/libgimp_glue.h + * libgimpbase/gimpunit.h: + declared gimp_unit_get_number_of_built_in_units() G_GNUC_CONST. + + * app/core/gimpunit.[ch]: internal GimpUnit functions return const + strings. + + * app/xcf/xcf-save.c: changed accordingly. + 2001-12-16 Sven Neumann * app/core/gimpscanconvert.c: merged fix for bug #66003 from stable diff --git a/app/config/gimpbaseconfig.c b/app/config/gimpbaseconfig.c index 059c805ac9..749e81929e 100644 --- a/app/config/gimpbaseconfig.c +++ b/app/config/gimpbaseconfig.c @@ -23,6 +23,8 @@ #include +#include "libgimpbase/gimpbase.h" + #include "base/base-enums.h" #include "gimpconfig.h" diff --git a/app/config/gimpbaseconfig.h b/app/config/gimpbaseconfig.h index 300b2aadc4..636a564bd0 100644 --- a/app/config/gimpbaseconfig.h +++ b/app/config/gimpbaseconfig.h @@ -22,8 +22,6 @@ #ifndef __GIMP_BASE_CONFIG_H__ #define __GIMP_BASE_CONFIG_H__ -#include "base/base-enums.h" - #define GIMP_TYPE_BASE_CONFIG (gimp_base_config_get_type ()) #define GIMP_BASE_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_BASE_CONFIG, GimpBaseConfig)) diff --git a/app/config/gimpconfig-params.c b/app/config/gimpconfig-params.c index e2e10d856c..2f29b5f9a7 100644 --- a/app/config/gimpconfig-params.c +++ b/app/config/gimpconfig-params.c @@ -23,6 +23,9 @@ #include +#include "libgimpbase/gimpbasetypes.h" +#include "libgimpbase/gimpunit.h" + #include "gimpconfig-params.h" #include "gimpconfig-types.h" @@ -131,3 +134,73 @@ gimp_param_spec_path (const gchar *name, return G_PARAM_SPEC (pspec); } + + +static void gimp_param_unit_class_init (GParamSpecClass *class); +static gboolean gimp_param_unit_value_validate (GParamSpec *pspec, + GValue *value); + +GType +gimp_param_unit_get_type (void) +{ + static GType spec_type = 0; + + if (!spec_type) + { + static const GTypeInfo type_info = + { + sizeof (GParamSpecClass), + NULL, NULL, + (GClassInitFunc) gimp_param_unit_class_init, + NULL, NULL, + sizeof (GParamSpecInt), + 0, NULL, NULL + }; + + spec_type = g_type_register_static (G_TYPE_PARAM_INT, + "GimpParamUnit", + &type_info, 0); + } + + return spec_type; +} + +static void +gimp_param_unit_class_init (GParamSpecClass *class) +{ + class->value_type = GIMP_TYPE_UNIT; + class->value_validate = gimp_param_unit_value_validate; +} + +static gboolean +gimp_param_unit_value_validate (GParamSpec *pspec, + GValue *value) +{ + GParamSpecInt *ispec = G_PARAM_SPEC_INT (pspec); + gint oval = value->data[0].v_int; + + value->data[0].v_int = CLAMP (value->data[0].v_int, + ispec->minimum, + gimp_unit_get_number_of_units () - 1); + + return value->data[0].v_int != oval; +} + +GParamSpec * +gimp_param_spec_unit (const gchar *name, + const gchar *nick, + const gchar *blurb, + GimpUnit default_value, + GParamFlags flags) +{ + GParamSpecInt *pspec; + + pspec = g_param_spec_internal (GIMP_TYPE_PARAM_UNIT, + name, nick, blurb, flags); + + pspec->default_value = default_value; + pspec->minimum = GIMP_UNIT_INCH; + pspec->maximum = G_MAXINT; + + return G_PARAM_SPEC (pspec); +} diff --git a/app/config/gimpconfig-params.h b/app/config/gimpconfig-params.h index ce9b983e2a..244bcaa93e 100644 --- a/app/config/gimpconfig-params.h +++ b/app/config/gimpconfig-params.h @@ -49,6 +49,18 @@ GParamSpec * gimp_param_spec_path (const gchar *name, GParamFlags flags); +#define GIMP_TYPE_PARAM_UNIT (gimp_param_unit_get_type ()) +#define GIMP_IS_PARAM_SPEC_UNIT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), GIMP_TYPE_PARAM_SPEC_UNIT)) + +GType gimp_param_unit_get_type (void) G_GNUC_CONST; + +GParamSpec * gimp_param_spec_unit (const gchar *name, + const gchar *nick, + const gchar *blurb, + GimpUnit default_value, + GParamFlags flags); + + /* some convenience macros to install object properties */ #define GIMP_CONFIG_INSTALL_PROP_BOOLEAN(class, id, name, default)\ @@ -56,6 +68,11 @@ GParamSpec * gimp_param_spec_path (const gchar *name, g_param_spec_boolean (name, NULL, NULL,\ default,\ G_PARAM_READWRITE | G_PARAM_CONSTRUCT)) +#define GIMP_CONFIG_INSTALL_PROP_DOUBLE(class, id, name, min, max, default)\ + g_object_class_install_property (class, id,\ + g_param_spec_double (name, NULL, NULL,\ + min, max, default,\ + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)) #define GIMP_CONFIG_INSTALL_PROP_ENUM(class, id, name, enum_type, default)\ g_object_class_install_property (class, id,\ g_param_spec_enum (name, NULL, NULL,\ @@ -86,6 +103,11 @@ GParamSpec * gimp_param_spec_path (const gchar *name, g_param_spec_uint (name, NULL, NULL,\ min, max, default,\ G_PARAM_READWRITE | G_PARAM_CONSTRUCT)) +#define GIMP_CONFIG_INSTALL_PROP_UNIT(class, id, name, default)\ + g_object_class_install_property (class, id,\ + gimp_param_spec_unit (name, NULL, NULL,\ + default,\ + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)) #endif /* __GIMP_CONFIG_PARAMS_H__ */ diff --git a/app/config/gimpconfig-types.c b/app/config/gimpconfig-types.c index 1437a4ff3f..ce1fb43659 100644 --- a/app/config/gimpconfig-types.c +++ b/app/config/gimpconfig-types.c @@ -26,6 +26,8 @@ #include +#include "libgimpbase/gimpbase.h" + #include "gimpconfig-types.h" @@ -34,6 +36,11 @@ static void memsize_to_string (const GValue *src_value, static void string_to_memsize (const GValue *src_value, GValue *dest_value); +static void unit_to_string (const GValue *src_value, + GValue *dest_value); +static void string_to_unit (const GValue *src_value, + GValue *dest_value); + GType gimp_memsize_get_type (void) @@ -72,22 +79,46 @@ gimp_path_get_type (void) return path_type; } +GType +gimp_unit_get_type (void) +{ + static GType unit_type = 0; + + if (!unit_type) + { + static const GTypeInfo type_info = { 0, }; + + unit_type = g_type_register_static (G_TYPE_INT, "GimpUnit", + &type_info, 0); + + g_value_register_transform_func (unit_type, G_TYPE_STRING, + unit_to_string); + g_value_register_transform_func (G_TYPE_STRING, unit_type, + string_to_unit); + } + + return unit_type; +} + static void memsize_to_string (const GValue *src_value, GValue *dest_value) { - guint size; + guint size; + gchar *str; + + size = g_value_get_uint (src_value); - size = src_value->data[0].v_uint; - if (size > (1 << 30) && size % (1 << 30) == 0) - dest_value->data[0].v_pointer = g_strdup_printf ("%uG", size >> 30); + str = g_strdup_printf ("%uG", size >> 30); else if (size > (1 << 20) && size % (1 << 20) == 0) - dest_value->data[0].v_pointer = g_strdup_printf ("%uM", size >> 20); + str = g_strdup_printf ("%uM", size >> 20); else if (size > (1 << 10) && size % (1 << 10) == 0) - dest_value->data[0].v_pointer = g_strdup_printf ("%uk", size >> 10); + str = g_strdup_printf ("%uk", size >> 10); else - dest_value->data[0].v_pointer = g_strdup_printf ("%u", size); + str = g_strdup_printf ("%u", size); + + g_value_set_string_take_ownership (dest_value, str); }; @@ -95,13 +126,16 @@ static void string_to_memsize (const GValue *src_value, GValue *dest_value) { - gchar *end; - guint size; + const gchar *str; + gchar *end; + guint size; - if (!src_value->data[0].v_pointer) + str = g_value_get_string (src_value); + + if (!str || !*str) goto error; - size = strtoul (src_value->data[0].v_pointer, &end, 0); + size = strtoul (str, &end, 0); if (size == ULONG_MAX) goto error; @@ -135,5 +169,45 @@ string_to_memsize (const GValue *src_value, return; error: - g_warning ("Can't convert string to memory size."); + g_warning ("Can't convert string to GimpMemsize."); +}; + +static void +unit_to_string (const GValue *src_value, + GValue *dest_value) +{ + GimpUnit unit; + + unit = (GimpUnit) g_value_get_int (src_value); + + g_value_set_string (dest_value, gimp_unit_get_identifier (unit)); +}; + +static void +string_to_unit (const GValue *src_value, + GValue *dest_value) +{ + const gchar *str; + gint num_units; + gint i; + + str = g_value_get_string (src_value); + + if (!str || !*str) + goto error; + + num_units = gimp_unit_get_number_of_units (); + + for (i = GIMP_UNIT_PIXEL; i < num_units; i++) + if (strcmp (str, gimp_unit_get_identifier (i)) == 0) + break; + + if (i == num_units) + goto error; + + g_value_set_int (dest_value, i); + return; + + error: + g_warning ("Can't convert string to GimpUnit."); }; diff --git a/app/config/gimpconfig-types.h b/app/config/gimpconfig-types.h index 1053c29602..675b08d508 100644 --- a/app/config/gimpconfig-types.h +++ b/app/config/gimpconfig-types.h @@ -35,4 +35,9 @@ GType gimp_memsize_get_type (void) G_GNUC_CONST; GType gimp_path_get_type (void) G_GNUC_CONST; +#define GIMP_TYPE_UNIT (gimp_unit_get_type ()) + +GType gimp_unit_get_type (void) G_GNUC_CONST; + + #endif /* __GIMP_CONFIG_TYPES_H__ */ diff --git a/app/config/gimpcoreconfig.c b/app/config/gimpcoreconfig.c index e89896b44a..4b492d212b 100644 --- a/app/config/gimpcoreconfig.c +++ b/app/config/gimpcoreconfig.c @@ -23,6 +23,9 @@ #include +#include "libgimpbase/gimpbase.h" + +#include "base/base-enums.h" #include "core/core-enums.h" #include "gimpconfig.h" @@ -66,7 +69,13 @@ enum PROP_DEFAULT_COMMENT, PROP_DEFAULT_IMAGE_TYPE, PROP_DEFAULT_IMAGE_WIDTH, - PROP_DEFAULT_IMAGE_HEIGHT, + PROP_DEFAULT_IMAGE_HEIGHT, + PROP_DEFAULT_UNIT, + PROP_DEFAULT_XRESOLUTION, + PROP_DEFAULT_YRESOLUTION, + PROP_DEFAULT_RESOLUTION_UNIT, + PROP_UNDO_LEVELS, + PROP_PLUGINRC_PATH, }; @@ -150,6 +159,24 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass) GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_DEFAULT_IMAGE_HEIGHT, "default-image-height", 1, 0x8000, 256); + GIMP_CONFIG_INSTALL_PROP_UNIT (object_class, PROP_DEFAULT_UNIT, + "default-unit", + GIMP_UNIT_INCH); + GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_DEFAULT_XRESOLUTION, + "default-xresolution", + GIMP_MIN_RESOLUTION, G_MAXDOUBLE, 72.0); + GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_DEFAULT_YRESOLUTION, + "default-yresolution", + GIMP_MIN_RESOLUTION, G_MAXDOUBLE, 72.0); + GIMP_CONFIG_INSTALL_PROP_UNIT (object_class, PROP_DEFAULT_RESOLUTION_UNIT, + "default-resolution-unit", + GIMP_UNIT_INCH); + GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_UNDO_LEVELS, + "undo-levels", + 0, G_MAXINT, 5); + GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_PLUGINRC_PATH, + "pluginrc-path", + "${gimp_dir}" G_DIR_SEPARATOR_S "pluginrc"); } static void @@ -217,6 +244,25 @@ gimp_core_config_set_property (GObject *object, case PROP_DEFAULT_IMAGE_HEIGHT: core_config->default_image_height = g_value_get_int (value); break; + case PROP_DEFAULT_UNIT: + core_config->default_unit = g_value_get_int (value); + break; + case PROP_DEFAULT_XRESOLUTION: + core_config->default_xresolution = g_value_get_double (value); + break; + case PROP_DEFAULT_YRESOLUTION: + core_config->default_yresolution = g_value_get_double (value); + break; + case PROP_DEFAULT_RESOLUTION_UNIT: + core_config->default_resolution_unit = g_value_get_int (value); + break; + case PROP_UNDO_LEVELS: + core_config->levels_of_undo = g_value_get_int (value); + break; + case PROP_PLUGINRC_PATH: + g_free (core_config->plug_in_rc_path); + core_config->plug_in_rc_path = g_value_dup_string (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -277,6 +323,24 @@ gimp_core_config_get_property (GObject *object, case PROP_DEFAULT_IMAGE_HEIGHT: g_value_set_int (value, core_config->default_image_height); break; + case PROP_DEFAULT_UNIT: + g_value_set_int (value, core_config->default_unit); + break; + case PROP_DEFAULT_XRESOLUTION: + g_value_set_double (value, core_config->default_xresolution); + break; + case PROP_DEFAULT_YRESOLUTION: + g_value_set_double (value, core_config->default_yresolution); + break; + case PROP_DEFAULT_RESOLUTION_UNIT: + g_value_set_int (value, core_config->default_resolution_unit); + break; + case PROP_UNDO_LEVELS: + g_value_set_int (value, core_config->levels_of_undo); + break; + case PROP_PLUGINRC_PATH: + g_value_set_string (value, core_config->plug_in_rc_path); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; diff --git a/app/config/gimpcoreconfig.h b/app/config/gimpcoreconfig.h index 6956b0d00d..4ba10eb80d 100644 --- a/app/config/gimpcoreconfig.h +++ b/app/config/gimpcoreconfig.h @@ -22,8 +22,6 @@ #ifndef __GIMP_CORE_CONFIG_H__ #define __GIMP_CORE_CONFIG_H__ -#include "core/core-enums.h" - #include "gimpbaseconfig.h" @@ -56,21 +54,20 @@ struct _GimpCoreConfig gchar *default_comment; - GimpImageBaseType default_image_type; - gint default_image_width; gint default_image_height; - /* the remaining fields are not yet implemented as properties - - GimpUnit default_units; + GimpUnit default_unit; gdouble default_xresolution; gdouble default_yresolution; - GimpUnit default_resolution_units; + GimpUnit default_resolution_unit; gint levels_of_undo; - gchar *pluginrc_path; + gchar *plug_in_rc_path; + + /* the remaining fields are not yet implemented as properties + gchar *module_db_load_inhibit; gint thumbnail_mode; diff --git a/app/config/test-config.c b/app/config/test-config.c index 52ed63599c..aba64028e9 100644 --- a/app/config/test-config.c +++ b/app/config/test-config.c @@ -23,6 +23,12 @@ #include +#include "libgimpbase/gimplimits.h" +#include "libgimpbase/gimpbasetypes.h" + +#include "base/base-enums.h" +#include "core/core-enums.h" + #include "gimpconfig.h" #include "gimpcoreconfig.h" @@ -132,3 +138,32 @@ output_unknown_token (const gchar *key, g_print (" %s \"%s\"\n", key, value); g_free (escaped); } + + +/* some dummy funcs so we can properly link this beast */ + +const gchar * +gimp_unit_get_identifier (GimpUnit unit) +{ + switch (unit) + { + case GIMP_UNIT_PIXEL: + return "pixels"; + case GIMP_UNIT_INCH: + return "inches"; + case GIMP_UNIT_MM: + return "millimeters"; + case GIMP_UNIT_POINT: + return "points"; + case GIMP_UNIT_PICA: + return "picas"; + default: + return NULL; + } +} + +gint +gimp_unit_get_number_of_units (void) +{ + return GIMP_UNIT_END; +} diff --git a/app/core/gimpunit.c b/app/core/gimpunit.c index cf5748f6dd..f71e2f0d2c 100644 --- a/app/core/gimpunit.c +++ b/app/core/gimpunit.c @@ -182,7 +182,7 @@ _gimp_unit_get_digits (Gimp *gimp, return _gimp_unit_get_user_unit (gimp, unit)->digits; } -gchar * +const gchar * _gimp_unit_get_identifier (Gimp *gimp, GimpUnit unit) { @@ -200,7 +200,7 @@ _gimp_unit_get_identifier (Gimp *gimp, return _gimp_unit_get_user_unit (gimp, unit)->identifier; } -gchar * +const gchar * _gimp_unit_get_symbol (Gimp *gimp, GimpUnit unit) { @@ -218,7 +218,7 @@ _gimp_unit_get_symbol (Gimp *gimp, return _gimp_unit_get_user_unit (gimp, unit)->symbol; } -gchar * +const gchar * _gimp_unit_get_abbreviation (Gimp *gimp, GimpUnit unit) { @@ -236,7 +236,7 @@ _gimp_unit_get_abbreviation (Gimp *gimp, return _gimp_unit_get_user_unit (gimp, unit)->abbreviation; } -gchar * +const gchar * _gimp_unit_get_singular (Gimp *gimp, GimpUnit unit) { @@ -254,7 +254,7 @@ _gimp_unit_get_singular (Gimp *gimp, return gettext (_gimp_unit_get_user_unit (gimp, unit)->singular); } -gchar * +const gchar * _gimp_unit_get_plural (Gimp *gimp, GimpUnit unit) { diff --git a/app/core/gimpunit.h b/app/core/gimpunit.h index 163bb22fa0..2bec25bdc0 100644 --- a/app/core/gimpunit.h +++ b/app/core/gimpunit.h @@ -20,47 +20,47 @@ #define __APP_GIMP_UNIT_H__ -void gimp_units_init (Gimp *gimp); -void gimp_units_exit (Gimp *gimp); +void gimp_units_init (Gimp *gimp); +void gimp_units_exit (Gimp *gimp); -void gimp_unitrc_load (Gimp *gimp); -void gimp_unitrc_save (Gimp *gimp); +void gimp_unitrc_load (Gimp *gimp); +void gimp_unitrc_save (Gimp *gimp); -gint _gimp_unit_get_number_of_units (Gimp *gimp); -gint _gimp_unit_get_number_of_built_in_units (Gimp *gimp); +gint _gimp_unit_get_number_of_units (Gimp *gimp); +gint _gimp_unit_get_number_of_built_in_units (Gimp *gimp) G_GNUC_CONST; -GimpUnit _gimp_unit_new (Gimp *gimp, - gchar *identifier, - gdouble factor, - gint digits, - gchar *symbol, - gchar *abbreviation, - gchar *singular, - gchar *plural); +GimpUnit _gimp_unit_new (Gimp *gimp, + gchar *identifier, + gdouble factor, + gint digits, + gchar *symbol, + gchar *abbreviation, + gchar *singular, + gchar *plural); -gboolean _gimp_unit_get_deletion_flag (Gimp *gimp, - GimpUnit unit); -void _gimp_unit_set_deletion_flag (Gimp *gimp, - GimpUnit unit, - gboolean deletion_flag); +gboolean _gimp_unit_get_deletion_flag (Gimp *gimp, + GimpUnit unit); +void _gimp_unit_set_deletion_flag (Gimp *gimp, + GimpUnit unit, + gboolean deletion_flag); -gdouble _gimp_unit_get_factor (Gimp *gimp, - GimpUnit unit); +gdouble _gimp_unit_get_factor (Gimp *gimp, + GimpUnit unit); -gint _gimp_unit_get_digits (Gimp *gimp, - GimpUnit unit); +gint _gimp_unit_get_digits (Gimp *gimp, + GimpUnit unit); -gchar * _gimp_unit_get_identifier (Gimp *gimp, - GimpUnit unit); +const gchar * _gimp_unit_get_identifier (Gimp *gimp, + GimpUnit unit); -gchar * _gimp_unit_get_symbol (Gimp *gimp, - GimpUnit unit); -gchar * _gimp_unit_get_abbreviation (Gimp *gimp, - GimpUnit unit); -gchar * _gimp_unit_get_singular (Gimp *gimp, - GimpUnit unit); -gchar * _gimp_unit_get_plural (Gimp *gimp, - GimpUnit unit); +const gchar * _gimp_unit_get_symbol (Gimp *gimp, + GimpUnit unit); +const gchar * _gimp_unit_get_abbreviation (Gimp *gimp, + GimpUnit unit); +const gchar * _gimp_unit_get_singular (Gimp *gimp, + GimpUnit unit); +const gchar * _gimp_unit_get_plural (Gimp *gimp, + GimpUnit unit); #endif /* __APP_GIMP_UNIT_H__ */ diff --git a/app/libgimp_glue.h b/app/libgimp_glue.h index fc8aaf8f75..2035d27ceb 100644 --- a/app/libgimp_glue.h +++ b/app/libgimp_glue.h @@ -32,7 +32,7 @@ gboolean gimp_palette_set_background (const GimpRGB *color); gboolean gimp_palette_get_background (GimpRGB *color); gint gimp_unit_get_number_of_units (void); -gint gimp_unit_get_number_of_built_in_units (void); +gint gimp_unit_get_number_of_built_in_units (void) G_GNUC_CONST; GimpUnit gimp_unit_new (gchar *identifier, gdouble factor, gint digits, diff --git a/app/xcf/xcf-save.c b/app/xcf/xcf-save.c index 29d503942f..80d52b29f4 100644 --- a/app/xcf/xcf-save.c +++ b/app/xcf/xcf-save.c @@ -770,10 +770,10 @@ xcf_save_prop (XcfInfo *info, break; case PROP_USER_UNIT: { - GimpUnit unit; - gchar *unit_strings[5]; - gfloat factor; - guint32 digits; + GimpUnit unit; + const gchar *unit_strings[5]; + gfloat factor; + guint32 digits; unit = va_arg (args, guint32); @@ -798,7 +798,7 @@ xcf_save_prop (XcfInfo *info, info->cp += xcf_write_int32 (info->fp, &size, 1); info->cp += xcf_write_float (info->fp, &factor, 1); info->cp += xcf_write_int32 (info->fp, &digits, 1); - info->cp += xcf_write_string (info->fp, unit_strings, 5); + info->cp += xcf_write_string (info->fp, (gchar **) unit_strings, 5); } break; } diff --git a/libgimpbase/gimpunit.h b/libgimpbase/gimpunit.h index 81159fd59e..b61b8ac33e 100644 --- a/libgimpbase/gimpunit.h +++ b/libgimpbase/gimpunit.h @@ -36,7 +36,7 @@ G_BEGIN_DECLS gint gimp_unit_get_number_of_units (void); -gint gimp_unit_get_number_of_built_in_units (void); +gint gimp_unit_get_number_of_built_in_units (void) G_GNUC_CONST; GimpUnit gimp_unit_new (gchar *identifier, gdouble factor, diff --git a/libgimpconfig/gimpconfig-params.h b/libgimpconfig/gimpconfig-params.h index ce9b983e2a..244bcaa93e 100644 --- a/libgimpconfig/gimpconfig-params.h +++ b/libgimpconfig/gimpconfig-params.h @@ -49,6 +49,18 @@ GParamSpec * gimp_param_spec_path (const gchar *name, GParamFlags flags); +#define GIMP_TYPE_PARAM_UNIT (gimp_param_unit_get_type ()) +#define GIMP_IS_PARAM_SPEC_UNIT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), GIMP_TYPE_PARAM_SPEC_UNIT)) + +GType gimp_param_unit_get_type (void) G_GNUC_CONST; + +GParamSpec * gimp_param_spec_unit (const gchar *name, + const gchar *nick, + const gchar *blurb, + GimpUnit default_value, + GParamFlags flags); + + /* some convenience macros to install object properties */ #define GIMP_CONFIG_INSTALL_PROP_BOOLEAN(class, id, name, default)\ @@ -56,6 +68,11 @@ GParamSpec * gimp_param_spec_path (const gchar *name, g_param_spec_boolean (name, NULL, NULL,\ default,\ G_PARAM_READWRITE | G_PARAM_CONSTRUCT)) +#define GIMP_CONFIG_INSTALL_PROP_DOUBLE(class, id, name, min, max, default)\ + g_object_class_install_property (class, id,\ + g_param_spec_double (name, NULL, NULL,\ + min, max, default,\ + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)) #define GIMP_CONFIG_INSTALL_PROP_ENUM(class, id, name, enum_type, default)\ g_object_class_install_property (class, id,\ g_param_spec_enum (name, NULL, NULL,\ @@ -86,6 +103,11 @@ GParamSpec * gimp_param_spec_path (const gchar *name, g_param_spec_uint (name, NULL, NULL,\ min, max, default,\ G_PARAM_READWRITE | G_PARAM_CONSTRUCT)) +#define GIMP_CONFIG_INSTALL_PROP_UNIT(class, id, name, default)\ + g_object_class_install_property (class, id,\ + gimp_param_spec_unit (name, NULL, NULL,\ + default,\ + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)) #endif /* __GIMP_CONFIG_PARAMS_H__ */