How to make listview scroll to active position?

The application uses a listview and works out current position in it, but the list does not scroll to it. The user have to do this manually, which is tedious if the active position is far down the list, say at position 5000.  

I am using the following fragment to set the selection at pos:

   GtkTreeView * tv = ...
   GtkTreeSelection * tsel = gtk_tree_view_get_selection (tv);
   GtkTreeIter iter ;
   GtkListStore * store = (GtkListStore *)gtk_tree_view_get_model ( tv ) ;
   if ( gtk_tree_model_iter_nth_child ( (GtkTreeModel *)store ,
                                                      &iter , NULL , pos ) )
      gtk_tree_selection_select_iter ( tsel , &iter ) ;

How can I make the list scroll to the current selection?

Are there better ways of doing this?

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