Re: tree_view

It is not an easy task to create and begin to populate a tree view.
You have to set a lot of others widgets, but I'll show you a short
code to help you.

GtkWidget *treeStore, *treeView
GtkTreeViewColumn *column1, *column2...;
GtkCellRenderer *renderer1,*renderer2...;

treeStore = GTK_TREE_MODEL(gtk_tree_store_new(2,G_TYPE_STRING,G_TYPE_STRING));

treeView =

/* optional settings */
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (treeView), TRUE);
gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW (treeView), TRUE);
gtk_tree_view_set_reorderable(GTK_TREE_VIEW (treeView), TRUE);
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW (treeView), TRUE);


/* setup the renderer */
renderer1 = gtk_cell_renderer_text_new();
gtk_cell_renderer_set_fixed_size (renderer1,100,-1);
column1 = gtk_tree_view_column_new_with_attributes("Name", renderer1,
"text", 0, NULL);
gtk_tree_view_column_set_resizable (column1, TRUE);


/* you could make the same for the others columns and renderer or just
use the same renderer for all of them */

gchar *text1= "any text";
GtkTreeIter *newIter, *parentIter;

/* now you can append your item. if newIter is NULL, it will be the
root of the tree */
gtk_tree_store_set(GTK_TREE_STORE(treeStore), newIter, 0,text1, -1);

So... it is just a begining... Look at the api and the following tutorial:

I hope I could help you!

On 6/24/05, srinivas <srinivas comodo com> wrote:
hi ;

      i have a pbm in populating the tree_view, i want to populate
tree_view using file path got from gtk_file_selection_get_filename(fs),
how could i populate tree_view. how to insert file selection path to the
tree_view widget.



gtk-app-devel-list mailing list
gtk-app-devel-list gnome org

André Pedralho
Bachelor in Computer Science
Instituto Nokia de Tecnologia

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