Re: float params of a gobject
- From: Christian Neumair <chris gnome-de org>
- To: Daniel Alonso <dalonso apanoia net>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: float params of a gobject
- Date: Mon, 10 Jul 2006 18:28:35 +0200
Am Montag, den 10.07.2006, 12:45 -0300 schrieb Daniel Alonso:
Hi, I'm trying to define a gobject class with a floating number
property. In the init class procedure I define the property the
following way:
param_spec = g_param_spec_float
("width" /* name */,
_("Icon Width") /* nick */,
_("The width of the svg icon") /* blurb */,
G_MINFLOAT /* minimum */,
G_MAXFLOAT /* maximum */,
0.0 /* default_value */,
(GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (g_object_class,
PROP_WIDTH,
param_spec);
This compiles fine, but when running the test program it raises a glib
exception:
(test:5073): GLib-GObject-CRITICAL **: g_param_spec_float: assertion
`default_value >= minimum && default_value <= maximum' failed
(test:5073): GLib-GObject-CRITICAL **: g_object_class_install_property:
assertion `G_IS_PARAM_SPEC (pspec)' failed
But default value 0.0 is equal G_MINFLOAT and lesser than G_MAXFLOAT,
isn't it?
From the API docs [1]:
"The minimum positive value which can be held in a gfloat.
If you are interested in the smallest value which can be held in a
gfloat, use -G_MAX_FLOAT."
0.0 is not considered positive in this case, I think it works like:
G_MINFLOAT is the smalles floating number f that satisfies f > 0.
Since icons may only have a positive width, 1.0 might be a good default
value.
[1]
http://developer.gnome.org/doc/API/2.0/glib/glib-Limits-of-Basic-Types.html#G-MINFLOAT:CAPS"
--
Christian Neumair <chris gnome-de org>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]