GNOME Bugzilla – Bug 59377
gtk_tree_selection_unselect_iter () actually doesn't unselect the specifiediterator.
Last modified: 2011-02-04 16:09:32 UTC
gtk_tree_selection_unselect_iter () actually doesn't unselect the specified iterator. Test case: #include <gtk/gtk.h> int main (int argc, char** argv) { GtkWidget *tree_view; GtkTreeStore *tree_store; GtkTreeSelection *selection; GtkTreePath *path; GtkTreeIter iter; GtkTreeIter child_iter; gboolean val; gint indices[] = {5,7,3}; guint i; guint j; gboolean result; gtk_init (&argc, &argv); tree_store = gtk_tree_store_new (1,G_TYPE_INT); path = gtk_tree_path_new_from_string ("5:7:3"); for (i = 0; i < 3; i++) { for (j = 0; j <= indices[i]; j++) { if (i == 0) { gtk_tree_store_append (tree_store, &iter, NULL); } else { gtk_tree_store_append (tree_store, &child_iter, &iter); } } if (i != 0) { iter = child_iter; } } tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (tree_store)); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); gtk_tree_selection_set_mode (GTK_TREE_SELECTION (selection),GTK_TREE_SELECTION_SINGLE); result = gtk_tree_selection_get_selected (selection,NULL,NULL); printf ("result = %d\n",result); gtk_tree_selection_unselect_iter (selection,&iter); printf ("\n gtk_tree_selection_unselect_iter() is called\n"); result = gtk_tree_selection_get_selected (selection,NULL,NULL); printf ("result = %d\n",result); } Output of the compiled code: result = 0 gtk_tree_selection_unselect_iter() is called result = 1
One problem with the current design of the tree is that you cannot select rows that aren't currently on the screen. In this case, you are selecting a child before you have expanded to that point. It would be nice to be able to cache this information, but that's too big a change to the tree right now. *** This bug has been marked as a duplicate of 50054 ***