Re: inherited properties



On Thu, 8 Nov 2001, Skip Montanaro wrote:

> 
>     Murray> Does something_set_property() need to handle the properties of
>     Murray> the base object too? That seems silly, but I can't think how
>     Murray> else those properties could be set.
> 
> Can't it (or shouldn't it) just chain up to the base class if the property
> name isn't one of the ones it knows about?

nope, as owen and jamesh correctly pointed out already, set_property and
get_property aren't normal virtual functions and can't be chained (e.g.
because the prop_id argument they switch() on are class specific already).
however, if in a BaseClass you introduce ::foobar and then create
DerivedClass that also introduces its own ::foobar property, people
calling g_object_set (o, "foobar", value, NULL); will call the
set_property() of DerivedClass. if that class needs to somehow "chain"
to the set_property() function of BaseClass, it can call
g_object_set (this, "BaseClass::foobar", value, NULL);

this is also the reason why the <ClassName>::<property> syntax
in g_object_set/gtk_object_set/gtk_widget_set is highly deprecated
for outside object use since gtk+1.2.

---
ciaoTJ




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