5. timer
5. timer #include <stdio.h> #include <string.h> #include <gtk/gtk.h> /* Determines if to continue the timer or not */ static gboolean continue_timer = FALSE; /* Determines if the timer has started */ static gboolean start_timer = FALSE; /* Display seconds expired */ static int sec_expired = 0; static gboolean _label_update(gpointer data) { GtkLabel *label = (GtkLabel*)data; char buf[256]; memset(&buf, 0x0, 256); snprintf(buf, 255, "Time elapsed: %d secs", ++sec_expired); gtk_label_set_label(label, buf); return continue_timer; } int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *frame; GtkWidget *quit_button; GtkWidget *label; gtk_init(NULL, NULL); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window),...
ความคิดเห็น
แสดงความคิดเห็น