GNOME Bugzilla – Bug 340475
gtk.Treeview.set_select_function callback wrong
Last modified: 2006-07-19 01:04:26 UTC
The callback for gtk.Treeview.set_select_function is not consistent with the docs. It's also not consistent with the GTK+ docs. # set the select function from another method self.previews_treeview.get_selection().set_select_function(self.some_select_function) # define the select function def some_select_function(self, *args): print args Output is something like this: ((1,),) http://www.pygtk.org/pygtk2reference/class-gtktreeselection.html#method-gtktreeselection--set-select-function tells me the select function should also have model and is_selected parameters instead of just a path.
At a minimum the docs have to be changed. The current signature is really: def func(info): where info is a tuple containing a path or a path and user_data depending if user_data was passed to the set_select_function() method. The question is whether this is enough to be useful. I'm guessing that it isn't since it would be useful to know if the path is currently selected and convenient to have the model and selection info available.
Why not just follow the docs? GTK+ itself uses the same type of callback, which has all info available. A tuple argument looks like a hack to me: other methods use perfectly clean signatures... why shouldn't this one?
I agree that gtk.Treeview.set_select_function is broken. However, due to API stability concern, it's also unfixable in the current form. I propose the addition of a new method, with an alternative name which should be used instead of set_select_function, in which all arguments are passed into the callback.
An alternative would be to keep the same method but add a new optional kwarg, like: treeview.set_select_function(func, data, extended_signature=True)
Since it's just the callback that is broken, not the method, and since it would seem that no one has ever used this method I think that the callback could be fixed for 2.10 and the method left alone. I see no advantage to leaving it with a broken callback and adding more cruft.
Fixed following Gustavo's suggestion. (_wrap_gtk_tree_selection_set_select_function): Optionally provide full info to callback. #340475 (Wouter Bolsterlee) Checking in gtk/gtktreeview.override; /cvs/gnome/pygtk/gtk/gtktreeview.override,v <-- gtktreeview.override new revision: 1.71; previous revision: 1.70 done