Re: program sleep question

On Fri, 25 Jun 1999, Fox, Kevin M wrote:
> Is there an equivalent gtk function to the sleep function that sleeps and
> still allows gtk to refresh itself, and if not, why not?
> I am working on a program that has an opening splash screen similar to the
> gimp's. I need to sleep(2) so that the user can have a chance to see the
> text before going to the next line in the function, but the program dosnt
> refresh itself for 2 seconds because of the sleep...

There may be an easier way, but one way is to install a 2-second timeout,
then call gtk_main(); in the timeout, gtk_main_quit(). This will work
independently of your main gtk_main(); gtk_main_quit() will only affect
the top gtk_main() on the stack.

So, something like:

static gint 
quit_timeout(gpointer data)
  return FALSE;   /* removes the timeout */

void sleep_milliseconds(guint msecs)
  gtk_timeout_add(msecs, quit_timeout, NULL);

Code is untested, may well be slightly busted.

Just make sure you don't let the user choose the "quit" menu item or
otherwise cause a gtk_main_quit() to be called before quit_timeout()
happens, or you'll get all sorts of confusion.


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