Re: CellRendererSpinButton and negative values




On Sep 30, 2004, at 1:45 AM, Daniel Kasak wrote:

Is it possible to get negative values supported?
Where is the data type set in the source of CellRendererSpinButton?

(assuming you're looking at Gtk2-1.061/examples/cellrenderer-spinbutton.pl)

the "value" property is a GObject property. this is created in the Glib::Object::Subclass 'use' starting at line 37. specifically, the 'properties' key is a reference to a list of Glib::ParamSpec objects, and the one named 'value' is created as part of the map statement from line 49 to line 60. a map is used there because we have four properties of the same type with common values, and the map removes some duplicated code. the array reference at line 57 is

   ['value', 'Value', 'How much is the fish', 0.0],

and the Glib::ParamSpec::double call places those values respectively in the "name", "nickname", "blurb", and "default_value" parameters. three other parameters are hard-coded there --- "minimum" ('0.0' at line 53), "maximum" (DBL_MAX at line 54), and "flags" (readable & writable, at line 56).

thus, this defines those four parameters to be doubles with legal values being the set [0.0, DBL_MAX].

if you want to change the legal range, you'll want to pull 'step' out of the map statement (negative values are not sensible for the 'step' parameter, which is passed to the SpinButton's step parameter to determine the increment used by the arrow buttons), and change the min & max to taste.

(Glib::ParamSpec::double is documented in the Glib::ParamSpec manpage, and the stuff you pass through Glib::Object::Subclass is documented in the Glib::Object::Subclass manpage.)

--
I think it worked on the Wiley Coyote model of project management - if
at any point you looked down and realised what you were doing was
impossible then you'd instantly fail.
  -- Simon Wistow




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]