[gtk-win32] Updating a progress bar from a worker thread
- From: "John Emmas" <johne53 tiscali co uk>
- To: <gtk-win32-list gnome org>
- Subject: [gtk-win32] Updating a progress bar from a worker thread
- Date: Sat, 19 Dec 2009 10:01:33 -0000
Recently, I downloaded the gtk-win32 tools that I found here:-
http://www.gtk.org/download-windows.html
including the recommended dependencies, such as 'win_iconv', 'libpng' and
'gettext' etc. Having got through the stage of building a simple "Hello
World" app, I thought it was time to try my hand at something a bit more
adventurous (not *too* adventurous - but maybe another stage forward).
I built an app whose main window is derived from Gtk::Window. It holds a
Vbox which contains a progress bar at the top, then a horizontal separator,
and finally, a button at the bottom. The basic idea is that when the user
presses the button, it starts a worker thread which periodically signals the
main GUI thread to update the progress bar. I've used pthread_win32 for the
threading and libsigc for the signals.
When I click on the button, the progress bar does indeed update - but with a
strange problem.... the updates only occur (visually) if:-
1) I keep my mouse cursor positioned over the GTK app, and
2) If I physically move the mouse.
If I hold the mouse stationary (or move it outside of the GTK main window)
the visual updates just don't happen (although I can tell that the update
function must be getting called).
Since yesterday I've tried several different strategies for implementing the
updates. For example, I started off by sending a signal from the worker
thread to the GUI thread. When that didn't work, I passed the worker thread
a pointer to the GTK main window, so that the worker thread could update the
progress bar directly. I tried a tight loop (with very fine updates) and a
"looser" loop (which uses coarser updates but sleeps for a second, in
between them). However, I see exactly the same problem, no matter what
strategy I use.
A couple of things occured to me... firstly, I'm building using Visual
Studio 2005 (VC++8). The documentation says not to use anything higher than
VC++6 (which has been obsolete for 10 years). I could probably dig out
VC++6 though, if anyone thinks that might help.
The second thing is that I've based my main window on Gtk::Window. If I'd
been using MFC I would probably have needed to base it on a CDialog. Should
I have used Gtk::Dialog as my base class, instead of Gtk::Window?
If all else fails, can anyone point me in the direction of a sample app
that shows how to implement a progress bar using gtk-win32?
Thanks,
John
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]