Re: ListStore iteration



I'm a bit tired, some translation:

update function = gtkmm calling passing an expose event to your drawing area.
redraw the image = processing the expose event to redraw the image to screen.
on_idle function = signal_idle()

Paul

On 10/5/06, Paul Davis <pjdavis engineering uiowa edu> 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


On 10/5/06, Amadeus W. M. <amadeus84 verizon net > wrote:
I have an application consisting of a DrawingArea, with a ListStore next
to it, in which I display the names of some image files, to be displayed
in the DrawingArea. I can select an image from the list, read it from disk
into a pixbuf and display it into the drawing area just fine.

What I want to do is to loop through all the images upon the click of a
button. I know how to do that too, but the images don't get displayed one
by one in the drawing area, as the iterator advances. This is how I'm
doing this:

void MainWindow::on_SaveAllButton_clicked()
{
    // Members:

    // class Gtk::TreeView * ItemSelector;
    // Glib::RefPtr<Gtk::ListStore> SelStore_;
    // Gtk::DrawingArea Darea1;


    // Get a pointer to selection.
    Glib::RefPtr<Gtk::TreeSelection> Selection_=ItemSelector->get_selection();

    // Get the rows.
    Gtk::TreeModel::Children rows=SelStore_->children();
    Gtk::TreeModel::iterator r;

    for(r=rows.begin(); r!=rows.end(); r++){

        // Doesn't seem necessary.
        Gtk::TreeModel::Row row=*r;

        // Load and DISPLAY the pixbuf, upon select().
        Selection_->select(row);

        // do something to the image.

    }
}

What am I doing wrong that the images don't get displayed? Thanks!



_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list




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