g_timeout handling, is this the best way?



I have a program that uses a g_timeout loop to control the display of a
sequence of plots (produced via plplot), and I need to be able to change
the delay between displaying the plots.

The method I am using is this:

   1. Use g_timeout_add_full to create the timeout, with the GSourceFunc as
   a routine that checks whether a termination flag has been set, and either
   displays the next frame and returns TRUE or just returns FALSE.
   2. Set up a GDestroyNotify function that checks if a restart flag is set
   and if it has then starts a new timeout loop.
   3. The callback that changes the speed, updates the delay and then sets
   both the termination and restart flags, so that on the next timeout call,
   the loop is destroyed and recreated with the new delay.

Is this the best way to do it or is there a more convenient way?



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