Re: problems selecting a row in a gtktreestore



Quoting Mariano Suárez-Alvarez <msuarezalvarez arnet com ar>:

> On Mon, 2007-02-05 at 12:40 -0500, Michael L. Gualtieri wrote:
> > I'm having problems selecting a row in a GtkTreeStore.
> > 
> > I have a treestore with one element in it, that I'd like to select
> > when I hit a button.  The button signals are working fine, however the
> > row never is selected.  I have tried this with both
> > gtk_tree_selection_select_iter and gtk_tree_selection_select_path, and
> > neither are working.  I am also sure the path is "0", since I can
> > select it by clicking on it and print out the path. 
> > 
> > 
> > Some example code:
> > 
> > GtkTreeIter iter;
> > GtkTreePath * path = gtk_tree_path_new_from_string ("0");
> > gtk_tree_model_get_iter (GTK_TREE_MODEL (my_tree_store), &iter, path);
> > 
> > GtkTreeSelection *selection; 
> > selection =
> > gtk_tree_view_get_selection(GTK_TREE_VIEW(lookup_widget(window_main,
> > "my_treeview")));
> > 
> > 
> > To select I try either this line:
> > gtk_tree_selection_select_path(selection, path);
> > 
> > or this line: 
> > gtk_tree_selection_select_iter(selection, &iter);
> > 
> > 
> > 
> > When I call gtk_tree_selection_select_path nothing visible happens.
> > When calling gtk_tree_selection_select_iter I get this warning:
> > 
> > Gtk-CRITICAL **: gtk_list_store_get_path: assertion `iter->stamp ==
> > GTK_LIST_STORE (tree_model)->stamp' failed 
> > 
> > 
> > I have tried MANY different ways to make the selection happen, but I
> > am out of ideas.  I have similar code elsewhere in my app that works
> > fine, however it uses a GtkListStore instead.  What is the trick to
> > GtkTreeStores? 
> > 
> That warning means that the iter you are passing to
> gtk_tree_selection_select_iter was not gotten from the same tree model
> (a ListStore in your case, I guess) as the one your GtkTreeSelection was
> gotten from.

More accurately, it means that the iter timestamp is outdated with respect with
the timestamp on the model. This happens when you get the iter, do some
operation with the model, and then try to use the iter with the model, with the
implicated risk of the model having changed and the iter no longer being valid.

Maybe getting first the selection, and then the iter for the path could help.
Always get the iterator immediately before using it.

Claudio

--
Claudio Saavedra <csaavedra alumnos utalca cl>

-------------------------------------------------
Este correo fue enviado por http://alumnos.utalca.cl



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