Re: Extending GParamSpec



On Thu, 11 Jan 2007, Laurent Marzullo wrote:

(Sorry if this mail appear twice, but It seems that my previous post 'bounced')

Hello,

I?m currently writing a library and I would like to ?extend? the property and
GParamSpec functionalities of the Glib (I?m currently writing my library in C++
but I would like to understand some Glib stuff first).

The main question I?ve Is about the best way to ?extend? GParamSpec.

I would like to add (to all GParamSpec* object so, GParamSpecInt,
GParamSpecUInt, GParamSpecInt64, etc ...) some new method and attributes.

you can derive new GParamSpecs from a GParamSpec and add fields along that way.

1) An attributes saying if the GValue could be null or not, and so, also
changing the 'validate' method to check if the GValue is null or not.
This should be for all GParamSpec*

2) I would also like to know how to retrieve the value of the 'default_value'
parameter specified at the construction time of the GParamSpec*. I do not find
any g_param_spec_get_default nor any field In the GParamSpecInt structure where
this information is stored.

you can use g_param_value_set_default() to store a param spec's default in a GValue, or you can access the individual param specs.

3) I would also like to add some new attributs as length, scale, precision or a
vector of allowed value (string value or integer, and then, checking Against
those values when affecting a new one).

i've done that for beast, some example code implementing param specs with min/
max/stepping can be found here:
  http://svn.gnome.org/viewcvs/beast/trunk/sfi/sfiparams.h?view=markup
  http://svn.gnome.org/viewcvs/beast/trunk/sfi/sfiparams.c?view=markup
and GUI generation code based on those param specs:
  http://svn.gnome.org/viewcvs/beast/trunk/beast-gtk/gxk/gxkparam.h?view=markup
  http://svn.gnome.org/viewcvs/beast/trunk/beast-gtk/gxk/gxkparam-scale.c?view=markup

The very first question is really how to extend the GParamSpec structure for my
extension may also be usable to the other GParamSpecInt, GParamSpecBool, etc
with the less code as possible.

Thanks for your help

+--------------------+
+ Laurent Marzullo
+

---
ciaoTJ


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