progressbar updates



hi,

I want to update a progressbar while reading large XML-files.  Now when I
do this all in load_button.clicked event-handler (in the main gtk+ thread?),
then the progressbar display won't be updated when I use set_fraction.

For example, the following will not work:
void MainWindow::OnLoadXMLClicked()
{
  progressbar->set_fraction(0.2);
  sleep(1);
  progressbar->set_fraction(0.3);
  sleep(1);
  progressbar->set_fraction(0.4);
  sleep(1);
  progressbar->set_fraction(0.5);
  sleep(1);
  progressbar->set_fraction(0.6);
  sleep(1);
  progressbar->set_fraction(0.7);
  sleep(1);
  progressbar->set_fraction(0.8);
  sleep(1);
  progressbar->set_fraction(0.9);
  sleep(1);
  progressbar->set_fraction(1.0);
}
(I only see 0% and 100% but nothing in between)

Next I tried to create a thread for this task:

void MainWindow::OnLoadXMLClicked()
{

  Glib::Thread::create
    (sigc::bind(sigc::mem_fun(*this, &MainWindow::loadXML), 
                tbxFilename->get_text()), 
     false);
}

But when I try to modify statusbar and progressbar from this
(loadXML-)thread, the gtk thread gets into trouble
(a button remains pushed, no display updates...).

I guess I need to synchronize something, but how can I do this?

thanks,

-- 
Felix Natter





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