Re: still on treeview



Ottavio Campana wrote:
> I've created the treeview with all the columns I need.
> 
> Now I  need to  know how to  add rows to  it e  how to remove  them.

If you've created a GtkTreeView, you have also created a 
GtkTreeModel which will hold the data (or at least you should 
have :) and done either a gtj_tree_new_with_model() or a 
gtk_tree_new() followed by a gtk_tree_view_set_model().  

A GtkTreeModel is either a GtkTreeStore or a GtkListStore -
GtkListStore is used for old GtkCList type data, and GtkTreeList
for hierarchical tree type data.

You can get the model back by gtk_tree_view_get_model(), and
depending on the model you can add or remove rows in a variety of
ways, depending on the underlying store type.

To set data, we use gtk_list_store_set() or gtk_tree_store_set()
after using a GtkTreeIter to get to the right place in the list
to insert it. To delete a row we use gtk_list_store_remove() or
gtk_tree_store_remove() with a GtkTreeIter pointing at the 
appropriate row.

There are various methods of setting a GtkTreeIter to the
appropriate value - there are _append and _prepend methods to
insert at the end or start of the store, _insert_before and
_insert_after methods to insert data before or after a certain
node, and gtk_tree_model_iter_next() and
gtk_tree_model_iter_children() methods for tree traversal.

Documentation on all of this is available in the API docs at
http://developer.gnome.org/doc/API/2.0/gtk/TreeWidgetObjects.html

Hope this all helps,

Cheers,
Dave.

-- 
David Neary,
E-Mail: dneary wanadoo fr
Tél: 04 91 72 46 84
CV: http://www.redbrick.dcu.ie/~bolsh/CV/



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