From a98306ef208f8a94a83ddac130ca49679fc0e560 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Tue, 28 May 2002 17:53:51 +0000 Subject: [PATCH] derive GIMP_TYPE_MEMSIZE from G_TYPE_ULONG. Should probably be even 2002-05-28 Sven Neumann * app/config/gimpconfig-types.c: derive GIMP_TYPE_MEMSIZE from G_TYPE_ULONG. Should probably be even G_TYPE_UINT64 but we use strtol which can only handles unsigned long int. * app/config/gimpbaseconfig.[ch] * app/config/gimpguiconfig.[ch]: changed accordingly. * app/config/test-config.c: use gimp_config_serialize_value() to dump changed values to stdout. --- ChangeLog | 12 ++++++++++++ app/config/gimpbaseconfig.c | 6 +++--- app/config/gimpbaseconfig.h | 2 +- app/config/gimpconfig-types.c | 20 ++++++++++---------- app/config/gimpguiconfig.c | 6 +++--- app/config/gimpguiconfig.h | 2 +- app/config/test-config.c | 34 +++++++++++++++++----------------- 7 files changed, 47 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index ec0d6896ba..86d4b01256 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2002-05-28 Sven Neumann + + * app/config/gimpconfig-types.c: derive GIMP_TYPE_MEMSIZE from + G_TYPE_ULONG. Should probably be even G_TYPE_UINT64 but we use + strtol which can only handles unsigned long int. + + * app/config/gimpbaseconfig.[ch] + * app/config/gimpguiconfig.[ch]: changed accordingly. + + * app/config/test-config.c: use gimp_config_serialize_value() to + dump changed values to stdout. + 2002-05-28 Michael Natterer * app/core/gimpcontext.c: override GObjectClass->constructor() and diff --git a/app/config/gimpbaseconfig.c b/app/config/gimpbaseconfig.c index 3d31cbeab5..e1d2451b19 100644 --- a/app/config/gimpbaseconfig.c +++ b/app/config/gimpbaseconfig.c @@ -112,7 +112,7 @@ gimp_base_config_class_init (GimpBaseConfigClass *klass) 1, 30, 1); GIMP_CONFIG_INSTALL_PROP_MEMSIZE (object_class, PROP_TILE_CACHE_SIZE, "tile-cache-size", - 0, G_MAXUINT, 1 << 25); + 0, G_MAXULONG, 1 << 25); } static void @@ -155,7 +155,7 @@ gimp_base_config_set_property (GObject *object, base_config->num_processors = g_value_get_uint (value); break; case PROP_TILE_CACHE_SIZE: - base_config->tile_cache_size = g_value_get_uint (value); + base_config->tile_cache_size = g_value_get_ulong (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -188,7 +188,7 @@ gimp_base_config_get_property (GObject *object, g_value_set_uint (value, base_config->num_processors); break; case PROP_TILE_CACHE_SIZE: - g_value_set_uint (value, base_config->tile_cache_size); + g_value_set_ulong (value, base_config->tile_cache_size); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); diff --git a/app/config/gimpbaseconfig.h b/app/config/gimpbaseconfig.h index 236f140e0b..babbd169b8 100644 --- a/app/config/gimpbaseconfig.h +++ b/app/config/gimpbaseconfig.h @@ -43,7 +43,7 @@ struct _GimpBaseConfig gchar *swap_path; gboolean stingy_memory_use; guint num_processors; - guint tile_cache_size; + gulong tile_cache_size; }; struct _GimpBaseConfigClass diff --git a/app/config/gimpconfig-types.c b/app/config/gimpconfig-types.c index d0a73488ce..9af9b037ba 100644 --- a/app/config/gimpconfig-types.c +++ b/app/config/gimpconfig-types.c @@ -68,7 +68,7 @@ gimp_memsize_get_type (void) { static const GTypeInfo type_info = { 0, }; - memsize_type = g_type_register_static (G_TYPE_UINT, "GimpMemsize", + memsize_type = g_type_register_static (G_TYPE_ULONG, "GimpMemsize", &type_info, 0); g_value_register_transform_func (memsize_type, G_TYPE_STRING, @@ -135,19 +135,19 @@ static void memsize_to_string (const GValue *src_value, GValue *dest_value) { - guint size; - gchar *str; + gulong size; + gchar *str; - size = g_value_get_uint (src_value); + size = g_value_get_ulong (src_value); if (size > (1 << 30) && size % (1 << 30) == 0) - str = g_strdup_printf ("%uG", size >> 30); + str = g_strdup_printf ("%luG", size >> 30); else if (size > (1 << 20) && size % (1 << 20) == 0) - str = g_strdup_printf ("%uM", size >> 20); + str = g_strdup_printf ("%luM", size >> 20); else if (size > (1 << 10) && size % (1 << 10) == 0) - str = g_strdup_printf ("%uk", size >> 10); + str = g_strdup_printf ("%luk", size >> 10); else - str = g_strdup_printf ("%u", size); + str = g_strdup_printf ("%lu", size); g_value_set_string_take_ownership (dest_value, str); }; @@ -158,7 +158,7 @@ string_to_memsize (const GValue *src_value, { const gchar *str; gchar *end; - guint size; + gulong size; str = g_value_get_string (src_value); @@ -194,7 +194,7 @@ string_to_memsize (const GValue *src_value, size <<= shift; } - g_value_set_uint (dest_value, size); + g_value_set_ulong (dest_value, size); return; diff --git a/app/config/gimpguiconfig.c b/app/config/gimpguiconfig.c index 5210cb4a45..9b3cbd2932 100644 --- a/app/config/gimpguiconfig.c +++ b/app/config/gimpguiconfig.c @@ -155,7 +155,7 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass) TRUE); GIMP_CONFIG_INSTALL_PROP_MEMSIZE (object_class, PROP_MAX_NEW_IMAGE_SIZE, "max-new-image-size", - 0, G_MAXUINT, 1 << 25); + 0, G_MAXULONG, 1 << 25); GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_THEME_PATH, "theme-path", gimp_config_build_data_path ("themes")); @@ -239,7 +239,7 @@ gimp_gui_config_set_property (GObject *object, gui_config->tearoff_menus = g_value_get_boolean (value); break; case PROP_MAX_NEW_IMAGE_SIZE: - gui_config->max_new_image_size = g_value_get_uint (value); + gui_config->max_new_image_size = g_value_get_ulong (value); break; case PROP_THEME_PATH: g_free (gui_config->theme_path); @@ -317,7 +317,7 @@ gimp_gui_config_get_property (GObject *object, g_value_set_boolean (value, gui_config->tearoff_menus); break; case PROP_MAX_NEW_IMAGE_SIZE: - g_value_set_uint (value, gui_config->max_new_image_size); + g_value_set_ulong (value, gui_config->max_new_image_size); break; case PROP_THEME_PATH: g_value_set_string (value, gui_config->theme_path); diff --git a/app/config/gimpguiconfig.h b/app/config/gimpguiconfig.h index d274cea88a..236687668f 100644 --- a/app/config/gimpguiconfig.h +++ b/app/config/gimpguiconfig.h @@ -55,7 +55,7 @@ struct _GimpGuiConfig gboolean show_tips; gboolean show_tool_tips; gboolean tearoff_menus; - guint max_new_image_size; + gulong max_new_image_size; gchar *theme_path; gchar *theme; gboolean use_help; diff --git a/app/config/test-config.c b/app/config/test-config.c index 2016d50b83..9ef1a959fb 100644 --- a/app/config/test-config.c +++ b/app/config/test-config.c @@ -33,6 +33,7 @@ #include "core/core-enums.h" #include "gimpconfig.h" +#include "gimpconfig-serialize.h" #include "gimprc.h" @@ -173,34 +174,33 @@ main (int argc, return EXIT_SUCCESS; } - -void +static void notify_callback (GObject *object, GParamSpec *pspec) { + GString *str; + GValue value = { 0, }; + g_return_if_fail (G_IS_OBJECT (object)); g_return_if_fail (G_IS_PARAM_SPEC (pspec)); - if (g_value_type_transformable (pspec->value_type, G_TYPE_STRING)) + g_value_init (&value, pspec->value_type); + g_object_get_property (object, pspec->name, &value); + + str = g_string_new (NULL); + + if (gimp_config_serialize_value (&value, str, TRUE)) { - GValue src = { 0, }; - GValue dest = { 0, }; - - g_value_init (&src, pspec->value_type); - g_object_get_property (object, pspec->name, &src); - - g_value_init (&dest, G_TYPE_STRING); - g_value_transform (&src, &dest); - - g_print (" %s -> %s\n", pspec->name, g_value_get_string (&dest)); - - g_value_unset (&dest); - g_value_unset (&src); + g_print (" %s -> %s\n", pspec->name, str->str); } else { - g_print (" %s changed\n", pspec->name); + g_print (" %s changed but we failed to serialize its value!\n", + pspec->name); } + + g_string_free (str, TRUE); + g_value_unset (&value); } static void