Row selection in treestore
- From: Burcu Can <burcucana yahoo com>
- To: gtk-app-devel-list gnome org
- Subject: Row selection in treestore
- Date: Thu, 24 Jun 2004 04:09:25 -0700 (PDT)
Hi, that's a part of my program. How can i provide the
third row (third element) to be selected instead of
first row at the beginning of the program? I used
gtk_tree_selection_select_iter(selection,&iter);
function to make the selection but it doesn't work.
enum
{
COL_DIR=0,
NUM_COLS
};
GtkWidget* create_view(GtkWidget* window)
{
GtkWidget *view;
GtkTreeStore *treestore;
GtkTreeIter iter,child;
GtkCellRenderer *renderer;
GtkTreeSelection *selection;
view=lookup_widget(GTK_WIDGET(window), "treeview1");
renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW
(view),
-1,
"Directories",
renderer,
"text",
COL_DIR,
NULL);
treestore= gtk_tree_store_new(NUM_COLS ,
G_TYPE_STRING);
gtk_tree_view_set_model(GTK_TREE_VIEW(view),
GTK_TREE_MODEL(treestore));
g_object_unref(GTK_TREE_MODEL(treestore));
gtk_tree_store_append(treestore,&iter,NULL);
gtk_tree_store_set (treestore, &iter,
COL_DIR,"mnt",
-1);
gtk_tree_store_append(treestore,&child,&iter);
gtk_tree_store_set (treestore, &child,
COL_DIR,"cdrom",
-1);
gtk_tree_store_append(treestore,&iter,NULL);
gtk_tree_store_set (treestore, &iter,
COL_DIR,"bin",
-1);
gtk_tree_store_append(treestore,&iter,NULL);
gtk_tree_store_set (treestore, &iter,
COL_DIR,"usr",
-1);
selection=gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
gtk_tree_selection_select_iter(selection,&iter);
return view;
}
Thanks...
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]