inserting model in a GtkTreeStore
- From: Carlos Pereira <jose carlos pereira ist utl pt>
- Cc: gtk-app-devel-list gnome org
- Subject: inserting model in a GtkTreeStore
- Date: Sun, 27 Apr 2008 17:10:27 +0100
Hi all!
To insert the various nodes in a GtkTreeStore, the code below works for me.
The problem is, this should not work, because I am handling a
GtkTreeIter as if it was some sort of integer, while it is in fact a
structure!
The current child node is the next parent node, so I would expect the
proper
way to do this would be to copy the current node iter to the parent
iter, and
because these are structures, I would have to copy their contents...
What is the standard way of doing this? I am confused!
Thanks!
Carlos
GtkTreeIter insert_row (GtkTreeStore *store, GtkTreeIter *parent, char
*label)
{
GtkTreeIter iter;
gtk_tree_store_append (store, &iter, parent);
gtk_tree_store_set (store, &iter, 0, label, -1);
return iter;
}
void insert_model (GtkWidget *treeview)
{
GtkTreeStore *store;
GtkTreeIter iter1, iter2, iter3;
store = gtk_tree_store_new (1, G_TYPE_STRING);
iter1 = insert_row (store, NULL, "Node 0");
iter2 = insert_row (store, &iter1, "Node 0:0");
insert_row (store, &iter2, "Node 0:0:0");
insert_row (store, &iter2, "Node 0:0:1");
gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (store));
g_object_unref (store);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]