Hi;

On 25 March 2015 at 14:49, Sergei Naumov <vo...@rambler.ru> wrote:
>
>> 25.03.2015, 18:09:41 пользователь Emmanuele Bassi (eba...@gmail.com)
>> написал:
>>
>> > This is going
>> > to be my setup draw (axes, tickmarks, etc). Then because I use
>> > g_timeout_add_seconds() to fire up the thread, I'd have to change it to
>> > something like that
>>
>> Why are you using a timeout to fire of a thread? Timeouts do not use a
>> separate thread: they are part of the main loop. Are you calling
>> g_thread_new() from a timeout callback?
>
>
> I did this some time ago but someone advised me to simply use g_timeout()
> because what I want is to simply call a function once per a certain amount
> of time. Does it change anything?

Yes, it does change things. :-)

All timeout and idle sources are called within the context of the main
loop, and they do not use threads. This simplifies the code, somewhat,
but does not save you from blocking the main loop by drawing — which
is one of the reasons why you would use threads.

It does not change much in the outline that I gave you, except that
now you can simply call gtk_widget_queue_draw() at the end of your
timeout callback without necessarily using another idle callback. You
will still need to ask the GdkWindow to create a similar Cairo
surface, and you will still need to use that surface as the source.

To be fair, though, if you're not going to offload drawing to a
separate thread, then why are you complicating things this much?

If you want your widget to be redrawn at periodic intervals, you can
call gtk_widget_queue_draw() at the end of your timeout callback.

Ciao,
 Emmanuele.

-- 
https://www.bassi.io
[@] ebassi [@gmail.com]
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to