On Sun, 06 Apr 2003 16:53:41 -0400 "A B" <alvinbeach hotmail com> wrote:
Hello, I am experimenting with GTK+. I am creating an app that does a lot of processing. What I am having problems with is having the application redraw itself. I thought that if I put all the processing in a pthread that would help. But, this isn't the case. What do GTK+ programmers do to work around this?
There are a couple of alternatives. Using threads is one of them (but not the
best IMHO). GTK+ depends on a regular flow of events. That means you should:
1 - split you calculation in little pieces that can be invoked via timeouts or
idle functions.
2 - allow GTK+ to process events from within your calculation
3 - use a separate calculation program, that communicates with the GUI via pipes
4 - use threads. But do not issue gTK+ calls from the thread that does the
processing.
For 1 see gtk_timeout_add() and gtk_idle_add().
for 2 use something like:
/* computation going on */
while (gtk_events_pending ())
gtk_main_iteration ();
/* computation continued */
For 3 see g_spawn_async_with_pipes()
Roland
--
R.F. Smith /"\ ASCII Ribbon Campaign
r s m i t h @ x s 4 a l l . n l \ / No HTML/RTF in email
http://www.xs4all.nl/~rsmith/ X No Word docs in email
/ \ Respect for open standards
Attachment:
pgpc910I9OGVA.pgp
Description: PGP signature