/** inputadd.c **/ #include #include gint eventDelete(GtkWidget *widget, GdkEvent *event,gpointer data); gint eventDestroy(GtkWidget *widget, GdkEvent *event,gpointer data); void inputSetup(); void inputCallback(gpointer data,gint fd, GdkInputCondition in); GtkWidget *button; int main(int argc,char *argv[]) { GtkWidget *window; gnome_init("inputadd","1.0",argc,argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size(GTK_WINDOW(window), 200,200); gtk_container_set_border_width(GTK_CONTAINER(window), 40); gtk_signal_connect(GTK_OBJECT(window),"delete_event", GTK_SIGNAL_FUNC(eventDelete),NULL); gtk_signal_connect(GTK_OBJECT(window),"destroy", GTK_SIGNAL_FUNC(eventDestroy),NULL); button = gtk_button_new_with_label("Button"); gtk_container_add(GTK_CONTAINER(window),button); gtk_widget_show_all(window); inputSetup(); gtk_main(); exit(0); } void inputSetup() { int fd; fd = 0; fcntl(fd,F_SETFL,O_NONBLOCK); gdk_input_add(fd,GDK_INPUT_READ, (GdkInputFunction)inputCallback,NULL); } void inputCallback(gpointer data,gint fd, GdkInputCondition in) { int i; gint count; gchar string[20]; while((count = read(fd,string,20)) > 0) { for(i=0; i