mirror of https://github.com/GNOME/gimp.git
app/config/gimpconfig-params.[ch] added support for GimpUnit type.
2001-12-16 Sven Neumann <sven@gimp.org> * 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.
This commit is contained in:
parent
851f0d8475
commit
efe8f6dbdc
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
||||||
|
2001-12-16 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* 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 <sven@gimp.org>
|
2001-12-16 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* app/core/gimpscanconvert.c: merged fix for bug #66003 from stable
|
* app/core/gimpscanconvert.c: merged fix for bug #66003 from stable
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "libgimpbase/gimpbase.h"
|
||||||
|
|
||||||
#include "base/base-enums.h"
|
#include "base/base-enums.h"
|
||||||
|
|
||||||
#include "gimpconfig.h"
|
#include "gimpconfig.h"
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
#ifndef __GIMP_BASE_CONFIG_H__
|
#ifndef __GIMP_BASE_CONFIG_H__
|
||||||
#define __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_TYPE_BASE_CONFIG (gimp_base_config_get_type ())
|
||||||
#define GIMP_BASE_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_BASE_CONFIG, GimpBaseConfig))
|
#define GIMP_BASE_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_BASE_CONFIG, GimpBaseConfig))
|
||||||
|
|
|
@ -23,6 +23,9 @@
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "libgimpbase/gimpbasetypes.h"
|
||||||
|
#include "libgimpbase/gimpunit.h"
|
||||||
|
|
||||||
#include "gimpconfig-params.h"
|
#include "gimpconfig-params.h"
|
||||||
#include "gimpconfig-types.h"
|
#include "gimpconfig-types.h"
|
||||||
|
|
||||||
|
@ -131,3 +134,73 @@ gimp_param_spec_path (const gchar *name,
|
||||||
|
|
||||||
return G_PARAM_SPEC (pspec);
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -49,6 +49,18 @@ GParamSpec * gimp_param_spec_path (const gchar *name,
|
||||||
GParamFlags flags);
|
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 */
|
/* some convenience macros to install object properties */
|
||||||
|
|
||||||
#define GIMP_CONFIG_INSTALL_PROP_BOOLEAN(class, id, name, default)\
|
#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,\
|
g_param_spec_boolean (name, NULL, NULL,\
|
||||||
default,\
|
default,\
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT))
|
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)\
|
#define GIMP_CONFIG_INSTALL_PROP_ENUM(class, id, name, enum_type, default)\
|
||||||
g_object_class_install_property (class, id,\
|
g_object_class_install_property (class, id,\
|
||||||
g_param_spec_enum (name, NULL, NULL,\
|
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,\
|
g_param_spec_uint (name, NULL, NULL,\
|
||||||
min, max, default,\
|
min, max, default,\
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT))
|
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__ */
|
#endif /* __GIMP_CONFIG_PARAMS_H__ */
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "libgimpbase/gimpbase.h"
|
||||||
|
|
||||||
#include "gimpconfig-types.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,
|
static void string_to_memsize (const GValue *src_value,
|
||||||
GValue *dest_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
|
GType
|
||||||
gimp_memsize_get_type (void)
|
gimp_memsize_get_type (void)
|
||||||
|
@ -72,22 +79,46 @@ gimp_path_get_type (void)
|
||||||
return path_type;
|
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
|
static void
|
||||||
memsize_to_string (const GValue *src_value,
|
memsize_to_string (const GValue *src_value,
|
||||||
GValue *dest_value)
|
GValue *dest_value)
|
||||||
{
|
{
|
||||||
guint size;
|
guint size;
|
||||||
|
gchar *str;
|
||||||
|
|
||||||
size = src_value->data[0].v_uint;
|
size = g_value_get_uint (src_value);
|
||||||
|
|
||||||
if (size > (1 << 30) && size % (1 << 30) == 0)
|
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)
|
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)
|
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
|
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,
|
string_to_memsize (const GValue *src_value,
|
||||||
GValue *dest_value)
|
GValue *dest_value)
|
||||||
{
|
{
|
||||||
|
const gchar *str;
|
||||||
gchar *end;
|
gchar *end;
|
||||||
guint size;
|
guint size;
|
||||||
|
|
||||||
if (!src_value->data[0].v_pointer)
|
str = g_value_get_string (src_value);
|
||||||
|
|
||||||
|
if (!str || !*str)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
size = strtoul (src_value->data[0].v_pointer, &end, 0);
|
size = strtoul (str, &end, 0);
|
||||||
if (size == ULONG_MAX)
|
if (size == ULONG_MAX)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -135,5 +169,45 @@ string_to_memsize (const GValue *src_value,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
error:
|
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.");
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,4 +35,9 @@ GType gimp_memsize_get_type (void) G_GNUC_CONST;
|
||||||
GType gimp_path_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__ */
|
#endif /* __GIMP_CONFIG_TYPES_H__ */
|
||||||
|
|
|
@ -23,6 +23,9 @@
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "libgimpbase/gimpbase.h"
|
||||||
|
|
||||||
|
#include "base/base-enums.h"
|
||||||
#include "core/core-enums.h"
|
#include "core/core-enums.h"
|
||||||
|
|
||||||
#include "gimpconfig.h"
|
#include "gimpconfig.h"
|
||||||
|
@ -67,6 +70,12 @@ enum
|
||||||
PROP_DEFAULT_IMAGE_TYPE,
|
PROP_DEFAULT_IMAGE_TYPE,
|
||||||
PROP_DEFAULT_IMAGE_WIDTH,
|
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,
|
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_DEFAULT_IMAGE_HEIGHT,
|
||||||
"default-image-height",
|
"default-image-height",
|
||||||
1, 0x8000, 256);
|
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
|
static void
|
||||||
|
@ -217,6 +244,25 @@ gimp_core_config_set_property (GObject *object,
|
||||||
case PROP_DEFAULT_IMAGE_HEIGHT:
|
case PROP_DEFAULT_IMAGE_HEIGHT:
|
||||||
core_config->default_image_height = g_value_get_int (value);
|
core_config->default_image_height = g_value_get_int (value);
|
||||||
break;
|
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:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -277,6 +323,24 @@ gimp_core_config_get_property (GObject *object,
|
||||||
case PROP_DEFAULT_IMAGE_HEIGHT:
|
case PROP_DEFAULT_IMAGE_HEIGHT:
|
||||||
g_value_set_int (value, core_config->default_image_height);
|
g_value_set_int (value, core_config->default_image_height);
|
||||||
break;
|
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:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
#ifndef __GIMP_CORE_CONFIG_H__
|
#ifndef __GIMP_CORE_CONFIG_H__
|
||||||
#define __GIMP_CORE_CONFIG_H__
|
#define __GIMP_CORE_CONFIG_H__
|
||||||
|
|
||||||
#include "core/core-enums.h"
|
|
||||||
|
|
||||||
#include "gimpbaseconfig.h"
|
#include "gimpbaseconfig.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,21 +54,20 @@ struct _GimpCoreConfig
|
||||||
|
|
||||||
gchar *default_comment;
|
gchar *default_comment;
|
||||||
|
|
||||||
|
|
||||||
GimpImageBaseType default_image_type;
|
GimpImageBaseType default_image_type;
|
||||||
|
|
||||||
gint default_image_width;
|
gint default_image_width;
|
||||||
gint default_image_height;
|
gint default_image_height;
|
||||||
|
|
||||||
/* the remaining fields are not yet implemented as properties
|
GimpUnit default_unit;
|
||||||
|
|
||||||
GimpUnit default_units;
|
|
||||||
gdouble default_xresolution;
|
gdouble default_xresolution;
|
||||||
gdouble default_yresolution;
|
gdouble default_yresolution;
|
||||||
GimpUnit default_resolution_units;
|
GimpUnit default_resolution_unit;
|
||||||
|
|
||||||
gint levels_of_undo;
|
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;
|
gchar *module_db_load_inhibit;
|
||||||
gint thumbnail_mode;
|
gint thumbnail_mode;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,12 @@
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "libgimpbase/gimplimits.h"
|
||||||
|
#include "libgimpbase/gimpbasetypes.h"
|
||||||
|
|
||||||
|
#include "base/base-enums.h"
|
||||||
|
#include "core/core-enums.h"
|
||||||
|
|
||||||
#include "gimpconfig.h"
|
#include "gimpconfig.h"
|
||||||
#include "gimpcoreconfig.h"
|
#include "gimpcoreconfig.h"
|
||||||
|
|
||||||
|
@ -132,3 +138,32 @@ output_unknown_token (const gchar *key,
|
||||||
g_print (" %s \"%s\"\n", key, value);
|
g_print (" %s \"%s\"\n", key, value);
|
||||||
g_free (escaped);
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -182,7 +182,7 @@ _gimp_unit_get_digits (Gimp *gimp,
|
||||||
return _gimp_unit_get_user_unit (gimp, unit)->digits;
|
return _gimp_unit_get_user_unit (gimp, unit)->digits;
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
const gchar *
|
||||||
_gimp_unit_get_identifier (Gimp *gimp,
|
_gimp_unit_get_identifier (Gimp *gimp,
|
||||||
GimpUnit unit)
|
GimpUnit unit)
|
||||||
{
|
{
|
||||||
|
@ -200,7 +200,7 @@ _gimp_unit_get_identifier (Gimp *gimp,
|
||||||
return _gimp_unit_get_user_unit (gimp, unit)->identifier;
|
return _gimp_unit_get_user_unit (gimp, unit)->identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
const gchar *
|
||||||
_gimp_unit_get_symbol (Gimp *gimp,
|
_gimp_unit_get_symbol (Gimp *gimp,
|
||||||
GimpUnit unit)
|
GimpUnit unit)
|
||||||
{
|
{
|
||||||
|
@ -218,7 +218,7 @@ _gimp_unit_get_symbol (Gimp *gimp,
|
||||||
return _gimp_unit_get_user_unit (gimp, unit)->symbol;
|
return _gimp_unit_get_user_unit (gimp, unit)->symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
const gchar *
|
||||||
_gimp_unit_get_abbreviation (Gimp *gimp,
|
_gimp_unit_get_abbreviation (Gimp *gimp,
|
||||||
GimpUnit unit)
|
GimpUnit unit)
|
||||||
{
|
{
|
||||||
|
@ -236,7 +236,7 @@ _gimp_unit_get_abbreviation (Gimp *gimp,
|
||||||
return _gimp_unit_get_user_unit (gimp, unit)->abbreviation;
|
return _gimp_unit_get_user_unit (gimp, unit)->abbreviation;
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
const gchar *
|
||||||
_gimp_unit_get_singular (Gimp *gimp,
|
_gimp_unit_get_singular (Gimp *gimp,
|
||||||
GimpUnit unit)
|
GimpUnit unit)
|
||||||
{
|
{
|
||||||
|
@ -254,7 +254,7 @@ _gimp_unit_get_singular (Gimp *gimp,
|
||||||
return gettext (_gimp_unit_get_user_unit (gimp, unit)->singular);
|
return gettext (_gimp_unit_get_user_unit (gimp, unit)->singular);
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
const gchar *
|
||||||
_gimp_unit_get_plural (Gimp *gimp,
|
_gimp_unit_get_plural (Gimp *gimp,
|
||||||
GimpUnit unit)
|
GimpUnit unit)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,7 +27,7 @@ void gimp_unitrc_load (Gimp *gimp);
|
||||||
void gimp_unitrc_save (Gimp *gimp);
|
void gimp_unitrc_save (Gimp *gimp);
|
||||||
|
|
||||||
gint _gimp_unit_get_number_of_units (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_built_in_units (Gimp *gimp) G_GNUC_CONST;
|
||||||
|
|
||||||
GimpUnit _gimp_unit_new (Gimp *gimp,
|
GimpUnit _gimp_unit_new (Gimp *gimp,
|
||||||
gchar *identifier,
|
gchar *identifier,
|
||||||
|
@ -50,16 +50,16 @@ gdouble _gimp_unit_get_factor (Gimp *gimp,
|
||||||
gint _gimp_unit_get_digits (Gimp *gimp,
|
gint _gimp_unit_get_digits (Gimp *gimp,
|
||||||
GimpUnit unit);
|
GimpUnit unit);
|
||||||
|
|
||||||
gchar * _gimp_unit_get_identifier (Gimp *gimp,
|
const gchar * _gimp_unit_get_identifier (Gimp *gimp,
|
||||||
GimpUnit unit);
|
GimpUnit unit);
|
||||||
|
|
||||||
gchar * _gimp_unit_get_symbol (Gimp *gimp,
|
const gchar * _gimp_unit_get_symbol (Gimp *gimp,
|
||||||
GimpUnit unit);
|
GimpUnit unit);
|
||||||
gchar * _gimp_unit_get_abbreviation (Gimp *gimp,
|
const gchar * _gimp_unit_get_abbreviation (Gimp *gimp,
|
||||||
GimpUnit unit);
|
GimpUnit unit);
|
||||||
gchar * _gimp_unit_get_singular (Gimp *gimp,
|
const gchar * _gimp_unit_get_singular (Gimp *gimp,
|
||||||
GimpUnit unit);
|
GimpUnit unit);
|
||||||
gchar * _gimp_unit_get_plural (Gimp *gimp,
|
const gchar * _gimp_unit_get_plural (Gimp *gimp,
|
||||||
GimpUnit unit);
|
GimpUnit unit);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ gboolean gimp_palette_set_background (const GimpRGB *color);
|
||||||
gboolean gimp_palette_get_background (GimpRGB *color);
|
gboolean gimp_palette_get_background (GimpRGB *color);
|
||||||
|
|
||||||
gint gimp_unit_get_number_of_units (void);
|
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,
|
GimpUnit gimp_unit_new (gchar *identifier,
|
||||||
gdouble factor,
|
gdouble factor,
|
||||||
gint digits,
|
gint digits,
|
||||||
|
|
|
@ -771,7 +771,7 @@ xcf_save_prop (XcfInfo *info,
|
||||||
case PROP_USER_UNIT:
|
case PROP_USER_UNIT:
|
||||||
{
|
{
|
||||||
GimpUnit unit;
|
GimpUnit unit;
|
||||||
gchar *unit_strings[5];
|
const gchar *unit_strings[5];
|
||||||
gfloat factor;
|
gfloat factor;
|
||||||
guint32 digits;
|
guint32 digits;
|
||||||
|
|
||||||
|
@ -798,7 +798,7 @@ xcf_save_prop (XcfInfo *info,
|
||||||
info->cp += xcf_write_int32 (info->fp, &size, 1);
|
info->cp += xcf_write_int32 (info->fp, &size, 1);
|
||||||
info->cp += xcf_write_float (info->fp, &factor, 1);
|
info->cp += xcf_write_float (info->fp, &factor, 1);
|
||||||
info->cp += xcf_write_int32 (info->fp, &digits, 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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ G_BEGIN_DECLS
|
||||||
|
|
||||||
|
|
||||||
gint gimp_unit_get_number_of_units (void);
|
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,
|
GimpUnit gimp_unit_new (gchar *identifier,
|
||||||
gdouble factor,
|
gdouble factor,
|
||||||
|
|
|
@ -49,6 +49,18 @@ GParamSpec * gimp_param_spec_path (const gchar *name,
|
||||||
GParamFlags flags);
|
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 */
|
/* some convenience macros to install object properties */
|
||||||
|
|
||||||
#define GIMP_CONFIG_INSTALL_PROP_BOOLEAN(class, id, name, default)\
|
#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,\
|
g_param_spec_boolean (name, NULL, NULL,\
|
||||||
default,\
|
default,\
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT))
|
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)\
|
#define GIMP_CONFIG_INSTALL_PROP_ENUM(class, id, name, enum_type, default)\
|
||||||
g_object_class_install_property (class, id,\
|
g_object_class_install_property (class, id,\
|
||||||
g_param_spec_enum (name, NULL, NULL,\
|
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,\
|
g_param_spec_uint (name, NULL, NULL,\
|
||||||
min, max, default,\
|
min, max, default,\
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT))
|
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__ */
|
#endif /* __GIMP_CONFIG_PARAMS_H__ */
|
||||||
|
|
Loading…
Reference in New Issue