Re: GProperty -- a proposal on top of GParamSpec (with code)

On Sat, 2011-03-26 at 14:53 +0200, Stefan Kost wrote:
> Hi Rob,
> Am 06.12.2010 11:46, schrieb Rob Staudinger:
> > Hello,
> > 
> > I've written out so many gobject property handlers in the last few
> > years, and they are always looking similar, so the desire to prune some
> > boilerplate code has been growing. The idea behind GProperty (actually
> > G<Foo>Property) is to subclass a GParamSpec<Foo> and add data and code
> > so the property can update the object it applies to itself. For e.g. a
> > string property this would of course include freeing the previous value.
> > 
> You should also post this to bugzilla. I have been looking for this in bugzilla
> now for quite some time. I am not sure yet, how much it will help. I small
> benefit could be that it allows to supress notifies if the value has not changed
> on a g_object_set.

Properties are not overwritten if they are re-set with the current
value, notifications aren't emitted either in that case.

Anyway I think it might be preferable to re-do the code, so there are
separate classes for accessor-based property implementations, and "auto"
properties that manage the value based on struct-offset:

GParamSpec<Type> ⇽ G<Type>Property ⇽ G<Type>AutoProperty

G<Type>Property     ... takes accessors in the constructor
G<Type>AutoProperty ... takes struct offset and manages the property
                        value and notifiction behind the scenes.

I'll try to get that done some time and open a bug then.

- Rob

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