On Fri, Feb 09, 2007 at 01:42:19PM +0100, Stefan Kost wrote: > >Deriving from classes that implement interfaces and changing > >the implementation would worth an explanation and example. > > Huh, sounds scary. > ... > Do you have pointers to an example?
I must admit while I do this in some real world code and it works, I have never verified I do it right by analysing the gtype.c code (too scary). That's one of the reasons why I suggested it... A testing (non-real world) example is attached, of which only MyPrintable, MyParent and MyChild2 are interesting (MyChild does not change the implementation). If I attempt to summarize it: 1. Implement the interface *again* in the subclass (this is the controversial point): G_DEFINE_TYPE_EXTENDED (MyChild2, my_child2, MY_TYPE_PARENT, 0, G_IMPLEMENT_INTERFACE(MY_TYPE_PRINTABLE, my_child2_printable_init)) 2. Get the parent interface in the interface init function with g_type_interface_peek_parent() and override methods: static void my_child2_printable_init(MyPrintableIface *iface) { my_child2_parent_printable = g_type_interface_peek_parent(iface); iface->print = my_child2_print; } 3. Use thus obtained parent implementation to call it in the overriden method (if suitable): my_child2_parent_printable->print(printable); > While checking for an example, just noticed that the "Implemented > Interfaces" stuff in Gtkdoc seems quite borked. Need to fix that. In what sense? It seems to work for me -- though I should note I use svn trunk gtk-doc. Yeti -- Whatever. _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list