GNOME Bugzilla – Bug 143270
GtkTreeView selection may be wrong on first display
Last modified: 2004-12-22 21:47:04 UTC
Select a row with gtk_selection_select_iter, then show the GtkTreeView. If it has the focus when displayed, the fisrt row is selected whatever you selected before. To make things work correctly, you need call gtk_tree_view_set_cursor before displaying the tree. I could track the problem in gtk_tree_view_focus_to_cursor: if (cursor_path == NULL) { cursor_path = gtk_tree_path_new_first (); I suggestit would be better to search if something is selected using gtk_tree_selection_get_selected before defaulting to the firs row.
Confirmed. Also affects GIMP in several places.
Created attachment 29001 [details] [review] A Patch to correct the problem. This is a patch to correct the problem, made against gtk+-2.4.3.
As mentioned on IRC, gtk_tree_selection_get_selected() is documented to not work in MULTIPLE mode.
Created attachment 29012 [details] [review] An updated Patch based on mclasen's commentary Thanks to Matthias Clasen, a problem with the patch was corrected and integrated into this new patch. He and other developers helped me on the IRC in choosing the right API routines.
*** Bug 145579 has been marked as a duplicate of this bug. ***
2004-09-14 Matthias Clasen <mclasen@redhat.com> * gtk/gtktreeview.c (gtk_tree_view_focus_to_cursor): Set the cursor to the first selected row instead of always to the first row if there is no cursor. (#143270, Jean Bréfort)
*** Bug 150614 has been marked as a duplicate of this bug. ***