I need to modify a GLib's time-out interval while it is in execution. Is that possible? I took a look to the source code and it seems possible to me, but is required use some non-public functions from GLib internals. Should I reimplement GTimeoutSource or there are a way to do it?
In your timeout function, you could re-add the function with the new timeout interval and then return FALSE
to remove the timeout with the old interval:
gboolean
my_timeout_function(gpointer data)
{
// do stuff
// ...
if(need_to_change_interval)
{
g_timeout_add(new_interval, (GSourceFunc)my_timeout_function, data);
return FALSE;
}
return TRUE;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With