[gtkmm] trouble with redrawing screen
- From: "B.Hakvoort" <bart hakvoort be>
- To: gtkmm-list gnome org
- Subject: [gtkmm] trouble with redrawing screen
- Date: Mon, 10 May 2004 18:44:18 +0200
Hi,
I'd like to show my impatient users a pulsebar when an application
performs a lenghty task. But somehow the "pulsing" doesn't show up in
the main screen. I've already tried several things like
queue_draw() and
while (Gtk::Main::events_pending()) Gtk::Main::iteration();
Can someone tell me what i'm doing wrong?
Bart
PS. Attached is a small example, i think its pretty straigthforward.
#include <gtkmm/box.h>
#include <gtkmm/progressbar.h>
#include <gtkmm/statusbar.h>
#include <gtkmm/button.h>
#include <gtkmm/window.h>
#include <gtkmm/main.h>
#include <sigc++/class_slot.h>
class Demo : public Gtk::Window
{
Gtk::VBox vbox_main;
Gtk::ProgressBar pulsebar;
Gtk::Statusbar statusbar;
Gtk::Button btnTask;
Glib::Thread *pulse_thread;
bool pulse;
public:
Demo()
{
set_default_size(300,150);
btnTask.set_label( "Perform some task");
btnTask.signal_clicked().connect( SigC::slot( *this, &Demo::btnTask_clicked ) );
vbox_main.pack_start(btnTask);
pulsebar.set_pulse_step(0.01);
statusbar.pack_start( pulsebar );
vbox_main.pack_end(statusbar, Gtk::PACK_SHRINK);
add(vbox_main);
show_all_children();
}
void btnTask_clicked()
{
pulse=true;
pulse_thread = Glib::Thread::create(SigC::slot_class(*this, &Demo::Pulse), true);
sleep(5);//do something which requires an unknown amount of time.....
pulse=false;
pulse_thread->join();
}
void Pulse()
{
while (pulse) {
pulsebar.pulse();
usleep(10000);
}
}
};
int main(int argc, char *argv[])
{
Glib::thread_init();
Gtk::Main kit(argc, argv);
Demo demo;
Gtk::Main::run(demo);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]