Re: Newbie & timing issue
- From: John Cupitt <jcupitt gmail com>
- To: Alf C Stockton <alf stockton co za>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Newbie & timing issue
- Date: Fri, 9 Jul 2004 11:50:10 +0000
On Fri, 9 Jul 2004 07:47:00 +0200 (SAST), Alf C Stockton
<alf stockton co za> wrote:
Now for my next trick I would like to restart the display after receiving a
interrupt rather than take up memory & cycles while counting down.
Is there a way that my program could instigate/initiate an interrupt to occur at
some time in the future?
Sure, that's what g_timeout_add() does. This hypnotic program pops up
a dialog box every 2 seconds:
#include <gtk/gtk.h>
void
response_cb( GtkDialog *dialog )
{
gtk_widget_destroy( GTK_WIDGET( dialog ) );
}
gboolean
timeout_cb()
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new( NULL, 0, GTK_MESSAGE_INFO,
GTK_BUTTONS_OK, "You are feeling sleeeepy ..." );
g_signal_connect( G_OBJECT( dialog ), "response",
G_CALLBACK( response_cb ), dialog );
gtk_widget_show( dialog );
return( TRUE );
}
int
main( int argc, char **argv )
{
gtk_init (&argc, &argv);
g_timeout_add( 2000, (GSourceFunc) timeout_cb, NULL );
gtk_main();
return( 0 );
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]