Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GTK: cancel timeout

Tags:

gtk

glib

GTK allows you to set a timeout with g_timeout_add. Just like g_signal_connect, the g_timeout_add function returns an id representing the timeout. So, is there a way to cancel a timeout using the id? Looking through the documentation, I don't see any way to cancel a timeout event, but I would assume there must be some way, otherwise what is the point of the id value returned by g_timeout_add?

So, is there any way to cancel a timeout event, or is this just something that needs to be handled manually by setting a "cancellation flag" which can be checked within the user-provided timeout handler function?

like image 487
Channel72 Avatar asked Aug 14 '12 15:08

Channel72


1 Answers

There are two ways to remove a callback registered through g_timeout_add():

  • Have the callback function return FALSE,
  • Call g_source_remove() with the identifier returned by g_timeout_add().
like image 136
Frédéric Hamidi Avatar answered Oct 09 '22 00:10

Frédéric Hamidi