How to share a gtk.TreeSelection between two gtk.TreeView ?



Hello to everyone,

This is my first post in this mailing list. I am Gonzalo, and I am
working on a (quite specific) collection manager for the GNOME Desktop,
written in Python (PyGTK). That is for my introduction.

I am currently working on a list of tags. There are two kind of tags:
some are called "Tags" and the other "Collections". From a developer
point of view, there is no difference between them (both are (type,
name, color) tuples). From the user point of view, they are different
enough to display them as two _different_ lists (gtk.TreeView). However,
both lists should share a single tool bar, it's why I wish they could
share the same selection (gtk.TreeSelection). (That is not the default
behavior, since selections are done completely on the view side, each
view has its own selection.)

1.
I tried first to display them as a single gtk.TreeView , but from an
user interface point of view that did not made any sense for me.

2.
I played then (unsuccessfully) with the
gtk.TreeSelection.set_select_function() method. My idea was to modify
the second list selection (let's say the selection of the list of
collections) each time a node was selected in the first list (let's say
the tags list).

 The "select function"  must decide if a tag which was clicked should or
should not be selected. Once solved the recurrent calls issues (each
time a tag was un-selected from inside the "select function", the
function was called again), I realized that I had needed to re-write (a
probably worse version of) the GTK+ implementation of the "select
function"  in order to make that decision and simulate the
gtk.SELECTION_MULTIPLE (or gtk.SELECTION_SINGLE) behavior. That makes me
think I was on the wrong way, unless there is a way to make the custom
"select function" transparent for some calls (in which case it should be
possible to rely on the GTK+ "select function" decisions).

3.
I have also tried to use the same gtk.TreeModelFilter to create both
gtk.TreeView and set a different "set_visible" function for each of them
(in order to show only the collections (resp. tags) in the collections
(resp. tags) list). Sadly that is not possible because only one
"set_visible" function can be set to a gtk.TreeModelFilter ( GtkWarning:
IA__gtk_tree_model_filter_set_visible_func: assertion
`filter->priv->visible_method_set == FALSE' failed ).


Any advice is very welcome ; )

Best regards,
-- 
Gonzalo Bulnes Guilpain
www.infusion-project.org





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]