On Wed, Jul 21, 2010 at 12:53 PM, Ken Resander <[email protected]> wrote:
> 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:
>
> [code]
> 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 ) ;
> }
> [/code]
>
> How can I make the list scroll to the current selection?
>
>
You need to get the path of the selected cell and then use
gtk_tree_view_scroll_to_cell
http://library.gnome.org/devel/gtk/stable/GtkTreeView.html#gtk-tree-view-scroll-to-cell
/jk
> Are there better ways of doing this?
>
>
>
> _______________________________________________
> gtk-list mailing list
> [email protected]
> http://mail.gnome.org/mailman/listinfo/gtk-list
>
>
_______________________________________________
gtk-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtk-list