Re: Default values for properties
- From: Havoc Pennington <hp redhat com>
- To: Martin Baulig <martin home-of-linux org>
- Cc: gtk-devel-list gnome org, timj gtk org
- Subject: Re: Default values for properties
- Date: 05 Mar 2001 16:48:12 -0500
Havoc Pennington <hp redhat com> writes:
> Why are construct properties different from regular properties in this
> respect? i.e. why are we setting them to their default value at all?
>
> Normal properties have their defaults filled in _init(), construct
> properties could work the same way.
Discussing this around the Labs, we can't figure out the intended
semantics of construct properties at all - a naive theory which turns
out to be totally false but makes sense to me:
- G_PARAM_CONSTRUCT means "user must specify this property at
construct time"
- G_PARAM_CONSTRUCT_ONLY means "user can only specify this property
at construct time, not later"
So G_PARAM_CONSTRUCT would cause an error if the property wasn't
explicitly set by g_object_new(), and G_PARAM_CONSTRUCT_ONLY would
cause an error if you tried to set the property after g_object_new().
The two would be orthogonal; some properties have a sane default and
don't always need to be set, but can't be changed later, and some
always have to be provided on construct since there's no good default,
but can be changed dynamically at a later time. Others must be set
initially but can also be changed later. etc.
However this isn't at all what the current code
does. G_PARAM_CONSTRUCT and G_PARAM_CONSTRUCT_ONLY aren't handled
orthogonally, either flag makes the property a "construct property";
the only feature I can find of construct properties is that they
always get set on object construction (i.e. they are always passed in
to the "constructor" virtual method which by default calls
set_property for each property).
As far as I can tell, at the moment CONSTRUCT and CONSTRUCT_ONLY are
synonyms and have no effect beyond this "always passed to the
constructor" thing. I don't see where g_object_set() even prevents
setting a CONSTRUCT_ONLY property.
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]