Re: ListStore iteration



On Thu, 05 Oct 2006 23:12:02 -0500, Paul Davis wrote:

> Amadeus,
> 
> You're not allowing the update function to be run.  You change the selection
> which causes the image to be loaded and put into the pixbuf for display, but
> you don't return and let gtk iterate through the event loop and redraw the
> image.
> 
> The first way to accomplish this that comes to mind is to register an
> on_idle function.  Then you use a timeout that updates the selection.
> 
> Something like this:
> 
> bool MainWindow::on_idle()
> {
>    if( _iterating )
>    {
>       if( enough_time_has_passed() )
>       {
>            _row_iter++ ;
>            _selection->select( row_iter ) ;
>        }
>     }
> 
>    return true ;
> }
> 
> And connect it like so:
> 
> Glib::signal_idle().connect( sigc::mem_fun( *main_window_ptr,
> &MainWindow::on_idle ) ) ;
> 
> And then your button handler:
> 
> void
> MainWindow::on_SaveAllButton_clicked()
> {
>       _selection = ItemSelector->get_selection() ;
>       _row_iter = _selection->children()->begin() ;
>      _iterating = true ;
>      _selection->select( _row_iter ) ;
>      init_enough_time_passed_function() ;
> }
> 
> Paul
> 


So the idea is to have each iteration triggered by some sort of timer,
right? A simple sleep() won't do (because I tried that). Except that
unlike a timeout, with an on_idle() function, the update happens as
quickly as possible. As in Chapter 17 in the book.

What exactly is the enought_time_has_passed() function. Sorry, I'm a
little tired myself.







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