Adventures with Gtk.TreeModelFilter

These days I’ve been involved in setting up a filter for a Gtk.TreeStore based TreeView, so that when you write in a Gtk.Entry, automatically the view is updated to show only the matching nodes with the text you are writing.

First of all, I had some troubles cause I’m using custom TreeDataFunc methods to extract treeview columns from instance of a class with around 9 fields (So i keep in the TreeStore all the information I want about an object, but only show two columns: a Gdk.Pixbuf Icon and a Title string). It gave me some headaches, as you can see.

But finally I managed to get it running. The problem with filtering a treeview using a VisibleFunc method to guess which rows should be visible, is that, even if a child node is visible (because it match with your entry text), if the father did not match, then you get as a result that the child isn’t visible either.

¿The solution? a recursive method called HasVisibleChilds that, given a node, explore the tree branch corresponding that node looking for visibility of the child nodes.

Update: Watch a nifty screencast of how is going (don’t forget to click on *Next* every time a text box is displayed ;-))


3 comentarios en “Adventures with Gtk.TreeModelFilter


Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s