gtk_foo_new() vs. gtk_foo_init()




	When creating a new object, what kind of initialization should
take place in _new(), and what kind of initialization should take place in
_init()?

	I was under the impression that the _new() function should do
nothing more than 

GtkFoo*
gtk_foo_new (void)
{
  return GTK_FOO (gtk_type_new (gtk_foo_get_type ()));
}

	...and that any pointer or variable initialization, memory
allocations, etc. would be handled by gtk_foo_init().

	But then I looked at (an admittedly old copy of) Havoc's
FrootTkxtBuffer source.  He does all of his initialization in _new(), and
his _init() is blank.

	I am creating a custom object (not a widget) which needs to set
some values and call some _new() functions of its own.  I've put all that
stuff into my _init() function.  Should that be put into _new() instead?
Is the _init() reserved for X resources (GdkFonts/GdkWindows etc.) or some
such thing?

	Is the _init() function even called on GtkObjects which are not
widgets?  (Obviously, I assumed that they were.)

	Please advise.


Thanks,
Derek Simkowiak
dereks@kd-dev.com



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