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 Oct 31, 2014 3:02 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: [SOLVED]GtkList syncronize scroolbar
PostPosted: Tue Feb 28, 2012 7:38 am 
Offline
Familiar Face

Joined: Fri Mar 25, 2011 7:55 am
Posts: 35
Location: romania
thanks to @errol.


Hi,

I have created a GtkListStore.
Lots of elements.
After fill up the list i have selected the last row of the list.

Code:
for ( int i = 0; i<300;i++ ) {
     gtk_list_store_append( store, &iter );
     gtk_list_store_set(  store,  &iter, ......, -1 );
}
selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ));
gtk_tree_selection_select_iter( selection, &iter );
// .......add solving code !!!!! ............
gtk_tree_selection_get_selected( selection, &model, &iter );
path = gtk_tree_model_get_path( model, &iter );
gtk_tree_view_scroll_to_cell( GTK_TREE_VIEW( view ),  path, NULL, FALSE, 0, 0 );
gtk_tree_path_free( path );
// .................................................


Row is selected but is not show in the window of list.
If i drag the vertical scrollbar i can see the row selected.
How can i syncronize the scrollbar to see directly the row selected ?

_________________
c/c++ for ever


Last edited by perosoft on Thu Mar 01, 2012 6:44 am, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: GtkList syncronize scroolbar
PostPosted: Tue Feb 28, 2012 11:34 am 
Offline
Familiar Face

Joined: Thu Dec 15, 2011 6:23 pm
Posts: 36
Location: Hrvatska
interesting, it seems like gtk_tree_view_scroll_to_cell candidate, but couldn't get to work. only thing that does work
Code:
gtk_widget_grab_focus (GTK_WIDGET (view));
int i;
gboolean result;
for (i=0; i<10100; i++)
{
g_signal_emit_by_name (GTK_TREE_VIEW (view), "move-cursor", GTK_MOVEMENT_DISPLAY_LINES, 0, &result);
}

It is realy primitive hack. Put any number of record ( greater than 10100 ).
But it works !
Cheers !


Top
 Profile  
 
 Post subject: Re: GtkList syncronize scroolbar
PostPosted: Tue Feb 28, 2012 12:28 pm 
Offline
Familiar Face

Joined: Fri Mar 25, 2011 7:55 am
Posts: 35
Location: romania
thanks, but not working for me !


kepica wrote:
interesting, it seems like gtk_tree_view_scroll_to_cell candidate, but couldn't get to work. only thing that does work
Code:
gtk_widget_grab_focus (GTK_WIDGET (view));
int i;
gboolean result;
for (i=0; i<10100; i++)
{
g_signal_emit_by_name (GTK_TREE_VIEW (view), "move-cursor", GTK_MOVEMENT_DISPLAY_LINES, 0, &result);
}

It is realy primitive hack. Put any number of record ( greater than 10100 ).
But it works !
Cheers !

_________________
c/c++ for ever


Top
 Profile  
 
 Post subject: Re: GtkList syncronize scroolbar
PostPosted: Wed Feb 29, 2012 9:49 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 768
Location: UK
Hi,

What has happened is you have updated the list store but this is not realised until control is returned back to the GTK main loop and the actual Tree View is updated. The code to realise and display the data is done a number of calls via Glib idle call backs. What you need to do is add your data, and add a Glib idle call back function that calls gtk_tree_view_scroll_to_cell ().

What should be happening is you :
- Update list store
- Create Glib Idle call back at normal priority and to be called only once, this call back to call gtk_tree_view_scroll_to_cell ()
- return control back to the GTK main loop

The main loop
- A Glib Idle call back at a high priority is called to update the GtkTreeView
- Your Glib Idle call back at normal priority is called to scroll to your cell.
- Any other call backs are done to update the display

The reason GTK updates GtkTreeView via an Idle call back is for efficiency. You could be adding or removing large amounts of data to the store, but if you also updated the display at the same time it would slow things down greatly.

_________________
E.


Top
 Profile  
 
 Post subject: Re: GtkList syncronize scroolbar
PostPosted: Thu Mar 01, 2012 6:43 am 
Offline
Familiar Face

Joined: Fri Mar 25, 2011 7:55 am
Posts: 35
Location: romania
thanks @errol, is working now !

errol wrote:
Hi,

What has happened is you have updated the list store but this is not realised until control is returned back to the GTK main loop and the actual Tree View is updated. The code to realise and display the data is done a number of calls via Glib idle call backs. What you need to do is add your data, and add a Glib idle call back function that calls gtk_tree_view_scroll_to_cell ().

What should be happening is you :
- Update list store
- Create Glib Idle call back at normal priority and to be called only once, this call back to call gtk_tree_view_scroll_to_cell ()
- return control back to the GTK main loop

The main loop
- A Glib Idle call back at a high priority is called to update the GtkTreeView
- Your Glib Idle call back at normal priority is called to scroll to your cell.
- Any other call backs are done to update the display

The reason GTK updates GtkTreeView via an Idle call back is for efficiency. You could be adding or removing large amounts of data to the store, but if you also updated the display at the same time it would slow things down greatly.

_________________
c/c++ for ever


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: Google [Bot], Yahoo [Bot] and 2 guests


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