Trying to get a simple TreeView to display a list of strings I tried something like this:
g_ui = GTK2.GladeXML("some_ui.glade"); g_ui->get_widget("test_treeview")->set_model(GTK2.ListStore(({"string"})));
To my surprise, the following returns zero: g_ui->get_widget("test_treeview")->get_model();
After some digging I found out that the generated code for GTK2.TreeView set_model failes to get a GObject from argument when it does something like this (returns NULL):
GTK_TREE_MODEL(get_pg2object(<obj_on_stack>, pgtk2_tree_model_program));
For reference, the meat in get_pg2object does this:
o=(struct object_wrapper *)get_storage(from,type); return o->obj;
But the storage for pgtk2_tree_model_program is a 'struct mixin_wrapper' so the cast seems dubious in this case.
I suspect that the content of the mixin_wrapper (offset) should be used to pin-point the relevant 'object_wrapper' for a given program. Should some find of specialized function be introduced for this?
I have this in my source/support.c just to get my simple example to work:
GObject *get_pg2object_mixin(struct object *from, struct program *type) { struct object_wrapper * o; struct mixin_wrapper * m; if (!from) return NULL; m=(struct mixin_wrapper *)get_storage(from,type); o=(struct object_wrapper *)from->storage + m->offset; return o->obj; }
and then uses that in TreeView.set_model()
This requires the caller to know if an object is a mixin-object or not. Is it better so to mark mixin-programs in some way so that get_pg2object() knows better how to extract object_wrappers from storage? Or have I missed something fundamental?
pike-devel@lists.lysator.liu.se