From: John R. <jr...@ce...> - 2011-06-20 15:03:48
|
On Jun 20, 2011, at 12:04 AM, Benny Malengier wrote: > > > 2011/6/20 John Ralls <jr...@ce...> > > On Jun 19, 2011, at 2:06 PM, Benny Malengier wrote: > > > Nick, Gerald, or other Gtk experts, > > > > I have hit a wall in the Gtk 3 conversion, see http://www.gramps-project.org/bugs/view.php?id=5009 > > > > Please have a look at the problem: There is no more GenericTreeModel, and my attempts of creating a pure python one have failed. > > So we have 3 options: > > > > 1/I'm doing something wrong and it can work using Gtk.TreeModel, we just need to understand it better. > > 2/We need to write a C module as Generictreemode, then use ctypes and GObject to inherit from it and use in Gramps > > 3/we need to convert to Gtk.ListStore and Gtk.TreeStore > > > > Let's hope it is 1/! > > The file treeviewgramps.py shows the problem. When run, it shows: > > > > (treeviewgramps.py:2871): Gtk-CRITICAL **: gtk_tree_model_get_n_columns: assertion `iface->get_n_columns != NULL' failed > > (treeviewgramps.py:2871): Gtk-CRITICAL **: gtk_tree_model_get_iter: assertion `iface->get_iter != NULL' failed > > > > And the treeview holds no data. > > > > What I can say for now is that documentation is bad, no resources yet via the internet, and segmentation faults galore. > > > GenericTreeModel is an implementation of GtkTreeModel... GtkTreeStore is too. It looks like John Stowers has made some effort to make GenericTreeModel more python-like, but it doesn't look like he's extended GtkTreeModel. 1/ or 3/ should be feasible, but will require that you rewrite your code to use the GtkTreeModel functions directly. > > Yes, rewriting to GtkTreeModel is what I did, but it is an abstract class not allowing direct inheritence. I need to figure out the correct way to do it. > > I now do: > > class FlatBaseModel(GObject.GObject, Gtk.TreeModel): > __gtype_name__ = 'FlatBaseModel' > > def __init__(self): > GObject.GObject.__init__(self) > > Which already throws an assertion. > I think the error is in the needed implementation of > > http://developer.gnome.org/gtk3/stable/GtkTreeModel.html#GtkTreeModelIface > > I don't know if above init is sufficient to set this GInterface also... > > > After browsing the code in pygtktreemodel.c for a bit, it looks to me that it should port to Gtk3 with minimal pain, so 2/ might be the least amount of work. > > Yes, the only disadvantage is that we need to do some compiling in Gramps for install, raising the bar for a source install by users. > However, as so many resources on the net exist for GtkGenericTreeModel, and so many applications seem to use it, I would hope they create some support to make porting easier. > > I wrote a mail to John Stowers to ask if he has a git branch with port of his D-Feet application, as it uses GtkGenericTreeModel, if no reply, I'll subscribe to pygtk list and ask there. On IRC there was nobody with the knowledge to help. > All I need would be one example of how it is supposed to be set up :-) Benny, I'm not sufficiently familiar with pygi to know if you can implement a gtk interface directly in Python, or how to go about it. Are the Gtk-supplied implementations (GtkTreeStore, etc.) not adequate? Did you see http://developer.gnome.org/gtk3/stable/TreeWidget.html ? Regards, John Ralls |