File Descriptor Input



//I am trying to get an input from a socket. But
before I implement the socket,
//I thought I should try the input from keyboard. I
tried to do that But I am 
//not successful. Here is the code. Can anyone help?
How to get the input 
//from a file descriptor, for example keyboard.

#include <gtk/gtk.h>
#include <stdio.h>

void myfunc()
{
 g_print("Got something.\n");
}

/****************/
void button_clicked(GtkWidget *widget, gpointer gdata)
{
 g_print("Button was clicked.\n");
}

/****************/
int main(int argc, char *argv[])
{
 GtkWidget *window;
 GtkWidget *button;
 char data[10];

 gtk_init(&argc, &argv);

 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 gtk_signal_connect(GTK_OBJECT (window),
"delete_event",
                   GTK_SIGNAL_FUNC(gtk_exit), NULL);
 gtk_container_border_width(GTK_CONTAINER(window),
15); 

 button = gtk_button_new_with_label("Click me"); 
 gtk_signal_connect(GTK_OBJECT(button), "clicked", 
                   GTK_SIGNAL_FUNC (button_clicked),
NULL); 
 gtk_container_add (GTK_CONTAINER(window), button); 
 gtk_widget_show(button);

 gtk_widget_show(window);

 gdk_input_add(fileno(stdin), GDK_INPUT_READ, 
               (GdkInputFunction) myfunc, (gpointer)
data);
 
 gtk_main();  
 return 0;
}
shiraz

__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com



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