Re: gobject - A few questinons



On Mon, 20 Dec 2004 12:45:28 +0100, Stefan Kost
<kost imn htwk-leipzig de> wrote:
[...]
When I have parent objects created by myselfe, where do I set default
values for variables?  Is it ok to do that in my_object_instance_init
()?
instance_init should be okay. question to the gurus. Should one chain-up here
like in dispose/finalize? - otherwise that would not be called?

Whether you derive from an object written by someone else or yourself,
you are only concerned with the initialization of MyObject members inside
my_object_init(). Rest assured that the members of MyParent have already
been taken care of in my_parent_init() during the life-cycle of g_object_new().

and "No" you should not chain up in the initialization function (class
or instance).

I have one parent which stores some simple information about my object.
The declaration for this is the struct for the parent instance.  When I
use that in a child object, do I have a copy of the parent there?  Or do
I have to cast with MY_PARENTOBJ (self) to get this variables, declared
there?
The cast does it. The struct of the parent is embedded in the beginning of you
child class. Anyway some developers prefer not to use public variables and
access such data vie g_object_get(self,"property-name-1",&property_1,...,NULL);
This methods automatically tries the parent classes up to G_OBJECT.

Essentially, (GTK_WIDGET (this) == G_OBJECT (this)) is always TRUE.

Can I use this variables more than one time?  Like:  child->data and
parent->data or are this variables equal, do they exist both or only
one?
Huh?

If your parent instance has a member with the same name as your
child instance, this does not imply any relation between the two ;-)

Cheers,
                                                     -Tristan



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