You can call g_idle_add() and various related functions from a non-GTK
thread. This is easier and more reliable than using a timer. When your
other thread has finished some work, add an idle callback in the main
context. the idle callback should call gtk_queue_redraw() for the
appropriate window/widgets.

On Sat, Feb 18, 2017 at 12:47 AM, Eric Cashon via gtk-list <
gtk-list@gnome.org> wrote:

> 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
>
>
>
> _______________________________________________
> gtk-list mailing list
> gtk-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-list
>
>
_______________________________________________
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list

Reply via email to