Re: GTK Queue Draw Subtle Question



Thomas,

You could implement a worker thread that you can monitor it's progress. Once it is done, you can update your display. There are some things to keep in mind when doing this though. You don't want to call GTK functions from your worker thread. If you are drawing your results to a cairo surface, you can draw with your worker thread and when it is all done, update the surface in your drawing area widget. If you need to keep other data you can use glib. Having a worker thread will keep your application responsive.

Some of these concepts are useful for drawing a Mandelbrot fractal so I put a little demo together if you are interested. It uses a timer to check when the drawing is done. When it is, it updates the drawing area. It is in GTK3 but the concepts should be the same for GTK2. Would have to make a few code changes though for GTK2.

https://github.com/cecashon/OrderedSetVelociRaptor/blob/master/Misc/cairo_drawings/mandelbrot1.c

Anyways, hope it is of some help.

Eric





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