On Sat, Jan 03, 2004 at 10:23:51PM -0800, Daniel Rogers wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Manish Singh wrote: > | Actually, the common idiom is to define: > | > | parent_class = g_type_class_peek_parent (class); > | > | in class_init, with parent_class being a static at file scope. Then > you just > | use it as Calvin did whenever you need to chain up. Less code clutter that > | way. > > so this: > "The problem here is how we can find the parent constructor. An approach > (used in GTK+ source code) would be to save the original constructor in > a static variable from maman_bar_class_init and then to re-use it from > maman_bar_constructor. This is clearly possible and very simple but I > was told it was not nice and the prefered way is to use the > g_type_class_peek and g_type_class_peek_parent functions." > > from this: > http://www.le-hacker.org/papers/gobject/ch04.html#gobject-instanciation > > is wrong? Well, all the real world GObject code I've seen uses the idiom I detailed above. And it's much less clutter to my eyes. I wonder what reasoning whoever told Mathieu that it was "not nice" used.. apart from needing a global variable (only rigid style freaks would care) I can't think of any reason why. -Manish