Lists in a GtkTreeView



I am trying to figure out how to build a list out of GtkTreeView,
GtkListStore and friends.

I have two things which I can't figure out:
   How do I set the initial selection
   How do I make it respond to a double-click (to activate the OK
         button)

>From looking at the docs I thought I should be able to set the selection
by:
    select = gtk_tree_view_get_selection( GTK_TREE_VIEW( list ));
    if ( initial_sel>=0 ) {
        GtkTreePath *path =
gtk_tree_path_new_from_indices(initial_sel,-1);
        gtk_tree_selection_select_path(select,path);
        gtk_tree_path_free(path);
    }
But that doesn't seem to work. I always end up with the first item in
the list selected. (I'm attaching a little test program containing this
code, which does not work...). What am I doing wrong?
   (Note this does work if I set GTK_SELECTION_MULTIPLE, but not for
SINGLE, and I want only one thing selected).

I didn't see any signal in GtkTreeView that looked like "activate", I
could signal on a "button-press-event" and look for GDK_2BUTTON_PRESS,
but I assume there is a better way somewhere...




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