GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Fri Dec 19, 2014 3:17 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Show selected row in GtkTreeView
PostPosted: Tue Feb 12, 2008 6:33 am 
Offline
GTK+ Guru

Joined: Tue Feb 05, 2008 8:39 am
Posts: 130
Hi!

Is there any easy way to scroll GtkTreeView to make selected row visible? GtkTreeView is on GtkScrolledWindow.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 12, 2008 5:44 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
Check out the function gtk_tree_view_scroll_to_cell ()

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 13, 2008 12:31 pm 
Offline
GTK+ Guru

Joined: Tue Feb 05, 2008 8:39 am
Posts: 130
I tried that, but gtk_tree_view_scroll_to_cell(buffer, &iter, NULL, FALSE, FALSE) doesn't take effect!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 13, 2008 1:51 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
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:
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);
}

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 14, 2008 4:56 am 
Offline
GTK+ Guru

Joined: Tue Feb 05, 2008 8:39 am
Posts: 130
Thank you! I just didn't get path correctly. Now it's OK


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group