On Wed, 14 Nov 2012 09:42:16 -0800 (PST) Stefano Mtangoo (evstevemd) wrote:
SM> I have looked at file pointed above but I cannot understand how it is
SM> being done.
SM> may be you can help me understand how forwarding is done?
SM> Gtk objects are sometimes confusing when it comes to newbie with
SM> little background in Gtk/C
You need to read a GTK (GObject) tutorial to really understand this but
you actually can just copy the code in src/gtk/dataview.cpp after "define
new GTK+ class wxGtkTreeModel" comment without even understanding it fully.
Of course, it would still be better to understand it... Roughly speaking
you just define a bunch of C functions and then assign pointers to them to
the GTK C++ vtbl equivalent.
As for forwarding itself, it's pretty trivial, look at e.g.
wxgtk_tree_model_get_value() implementation. It is called by GTK+ to get a
value for the given cell and it in turn forwards to wxDataViewModel to get
it and then returns it to GTK+.
You should do something similar here except much simpler because you can
hard code a lot of things instead of having to forward them (e.g. you will
have only one column and there will be no hierarchy for the items so your
iterators would be just trivial indices) and you don't need to support any
extra interfaces so you don't need any g_type_add_interface_static() calls.