Re: understanding gtype and gobject



Le mercredi 20 avril 2011 à 06:13 -0400, abhishek desai a écrit :
> I am trying to understand the gtype system and the gobject system.
> http://developer.gnome.org/gobject/stable/
> 
> Unable to figure out the difference between the gobject constructor
> and the gtypes instance_init function. Why do we use a constructor
> function in gobject ? Can we not do the functionality in the
> instance_init itself ?
instance_init is the standard init function to use. constructor is
called later when the object has been initialized, and is only useful if
you need to rely on construction GObject properties having been set
already.

See
http://developer.gnome.org/gobject/stable/chapter-gobject.html#gobject-instantiation

For instance_init:
> Provide an instance_init function to initialize your object before its
> construction properties are set. This is the preferred way to
> initialize a GObject instance. This function is equivalent to C++
> constructors.

For constructor:
> If you need to complete the object initialization after all the
> construction properties are set, override the constructor method and
> make sure to chain up to the object's parent class before doing your
> own initialization. In doubt, do not override the constructor method.


But I'd like to understand why the table on the page shows constructor
before instance_init, while the former is actually called *after* the
latter...


Regards


PS: General questions like yours should rather be asked on
gtk-app-devel-list: the present list is for development of GTK+ itself.




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