Re: GtkTreeModel question



Archit Baweja <bighead users sourceforge net> writes:

Hi

Yeah I know I have to get an iter first. But how do I get that iter, if I
only have a pointer to the struct I have added to the model. That is the problem.

Here's a quick example showing three ways to find the row "3:2:5"

{
  GtkTreePath *path;
  GtkTreeIter iter;
  GtkTreeIter parent_iter;

  /* method one */
  path = gtk_tree_path_new_from_string ("3:2:5");
  gtk_tree_model_get_iter (model, &iter, path);
  gtk_tree_path_free (path);

  /* An even simpler away to do the above */
  gtk_tree_model_get_iter_from_string (model, &iter, "3:2:5");

  /* another way */
  gtk_tree_model_get_nth_child (model, &iter, NULL, 3);
  parent_iter = iter;
  gtk_tree_model_get_nth_child (model, &iter, &parent_iter, 2);
  parent_iter = iter;
  gtk_tree_model_get_nth_child (model, &iter, NULL, 5);
}

I'll add this to the docs right now.
-Jonathan



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