GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Show selected row in GtkTreeView

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
Wolfgang
Familiar Face


Joined: 05 Feb 2008
Posts: 45

PostPosted: Tue Feb 12, 2008 6:33 am    Post subject: Show selected row in GtkTreeView Reply with quote

Hi!

Is there any easy way to scroll GtkTreeView to make selected row visible? GtkTreeView is on GtkScrolledWindow.
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 496
Location: Portland, OR USA

PostPosted: Tue Feb 12, 2008 5:44 pm    Post subject: Reply with quote

Check out the function gtk_tree_view_scroll_to_cell ()
Back to top
Wolfgang
Familiar Face


Joined: 05 Feb 2008
Posts: 45

PostPosted: Wed Feb 13, 2008 12:31 pm    Post subject: Reply with quote

I tried that, but gtk_tree_view_scroll_to_cell(buffer, &iter, NULL, FALSE, FALSE) doesn't take effect!
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 496
Location: Portland, OR USA

PostPosted: Wed Feb 13, 2008 1:51 pm    Post subject: Reply with quote

From the documentation:

Quote:
If column is NULL, then no horizontal scrolling occurs. Likewise, if path is NULL no vertical scrolling occurs. At a minimum,


I haven't tested this, but perhaps something like this:

Code: (C)
1
2
3
4
5
6
7
8
9
10
11
12
13
void show_selected_row (GtkWidget *tree_view)
{
    GtkTreeModel *model;
    GtkTreeSelection *sel;
    GtkTreePath *path;
   
    model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
    sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
    gtk_tree_selection_get_selected (sel, *model, &iter);
    path = gtk_tree_model_get_path (model, &iter);
    gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (tree_view),
                                  path, NULL, FALSE, 0, 0);
}
Back to top
Wolfgang
Familiar Face


Joined: 05 Feb 2008
Posts: 45

PostPosted: Thu Feb 14, 2008 4:56 am    Post subject: Reply with quote

Thank you! I just didn't get path correctly. Now it's OK
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP