I am totally new to Gtk+ and in order to get a first overview of these libraries I am trying to understand some basic examples taken by the net. I have a problem about the following example code:
Code:
/* compile using:
cc -Wall -g `pkg-config --cflags --libs gtk+-2.0` -o example main.c
*/
#include <gtk/gtk.h>
void on_window_map (GtkWidget*, gpointer);
void on_window_realize (GtkWidget*, gpointer);
void on_window_show (GtkWidget*, gpointer);
int
main (int argc, char *argv[])
{
GtkWidget *window;
int a;
/* initialize the GTK+ library */
gtk_init (&argc, &argv);
/* create main window */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Example");
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
gtk_widget_set_size_request (window, 200, 100);
/* connect signals */
g_signal_connect (G_OBJECT(window), "destroy",
G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (G_OBJECT(window), "realize",
G_CALLBACK (on_window_realize), NULL);
g_signal_connect (G_OBJECT(window), "map",
G_CALLBACK (on_window_map), NULL);
g_signal_connect (G_OBJECT(window), "show",
G_CALLBACK (on_window_show), NULL);
/* show the main window */
gtk_widget_show (window);
gtk_main ();
return 0;
}
void
on_window_map (GtkWidget *w,gpointer user_data)
{
g_print("Window was mapped.\n");
}
void
on_window_realize (GtkWidget *w,gpointer user_data)
{
g_print("Window was realized.\n");
}
void
on_window_show (GtkWidget *w,gpointer user_data)
{
int x;
g_print("Window was shown.\n");
printf("Insert x : ");
scanf("%d",&x);
}
In the function
on_window_show I added the request to insert an integer via terminal, I would like to be asked for it after the window has been showed, what am I missing?
Can you suggest me some good tutorials?
Thanks in advance
Roscarby
[/code]