[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Newbie & timing issue
- From: Alf C Stockton <alf stockton co za>
- To: gtk-app-devel-list gnome org
- Subject: Re: Newbie & timing issue
- Date: Sun, 18 Jul 2004 17:51:59 +0200 (SAST)
Well guys after much reading and experimenting I am still having a problem.
Please look at the attached and help ?
Thought process in creating/modifying this program I used two variables,
EventOne and EventTwo.
EventOne is used to tell how often & when the function timeout_cb() is to be
called and within timeout_cb() EventTwo should tell when the display
should automatically disappear if the user has not killed the display with the
OK button.
Killing the display with the OK button works fine but the timeout does not.
---
Regards,
Alf Stockton www.stockton.co.za
You are wise, witty, and wonderful, but you spend too much time reading
this sort of trash.
/*
* Thought process in creating/modifying this program I used EventOne and EventTwo
* EventOne is used to tell how often & when timeout_cb is to be called and within
* timeout_cb() EventTwo should tell when the display disappears automatically if
* user has not killed the display with the OK button.
* Killing the display with the button works fine but the timeout does not.
*/
#include <gtk/gtk.h>
//#include <glib-2.0/glib.h>
#include <glib.h>
#include <time.h>
GtkWidget *dialog;
gint Count;
guint Event, EventOne, EventTwo;
void response_cb( GtkDialog *dialog )
{
if (EventTwo) g_source_remove(EventTwo);
gtk_widget_destroy( GTK_WIDGET( dialog ) );
}
gboolean timeout_cb()
{
struct tm *tm_ptr;
time_t the_time;
gchar Message[256];
time(&the_time);
tm_ptr = localtime(&the_time);
g_sprintf(Message,"%d It is now %02d:%02d:%02d\n", Count++, tm_ptr->tm_hour, tm_ptr->tm_min, tm_ptr->tm_sec);
dialog = gtk_message_dialog_new( NULL, 0, GTK_MESSAGE_INFO,
GTK_BUTTONS_OK, Message );
g_signal_connect( G_OBJECT( dialog ), "response",
G_CALLBACK( response_cb ), dialog );
gtk_widget_show( dialog );
if (EventTwo)
{
g_source_remove(EventTwo);
EventTwo = g_timeout_add(11000, (GSourceFunc) response_cb, NULL);
}
return( TRUE );
}
int main( int argc, char **argv )
{
gtk_init (&argc, &argv);
Count = 1;
EventOne = g_timeout_add(10000, (GSourceFunc) timeout_cb, NULL );
gtk_main();
return( 0 );
}
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]