#include
#include
void label1(GtkWidget *button1,gpointer data)
{
printf("label1 %s pressed\n",(char *)data);
}
void label2(GtkWidget *button2,gpointer data)
{
printf("%label2 %s pressed\n",(char *)data);
}
void label3(GtkWidget *button3,gpointer data)
{
printf("%label3 %s pressed\n",(char *)data);
}
int main(int argc,char *argv[])
{
GtkWidget *window;
GtkWidget *hbox;
GtkWidget *vbox;
GtkWidget *button1;
GtkWidget *button2;
GtkWidget *button3;
gtk_init(&argc,&argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "The Window Title");
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_window_set_default_size(GTK_WINDOW(window), 300, 200);
button1 = gtk_button_new_with_label("Hello Button One");
button2 = gtk_button_new_with_label("Hello Button Two");
button3 = gtk_button_new_with_label("Hello Button Three");
g_signal_connect(GTK_OBJECT(button1),"clicked",GTK_SIGNAL_FUNC(label1),"Button 1");
g_signal_connect(GTK_OBJECT(button2),"clicked",GTK_SIGNAL_FUNC(label2),"Button 2");
g_signal_connect(GTK_OBJECT(button3),"clicked",GTK_SIGNAL_FUNC(label3),"Button 3");
hbox = gtk_hbox_new(TRUE,5);
vbox = gtk_vbox_new(FALSE,10);
gtk_box_pack_start(GTK_BOX(hbox),vbox,FALSE,FALSE,5);
gtk_box_pack_start(GTK_BOX(hbox),button3,FALSE,FALSE,5);
gtk_box_pack_start(GTK_BOX(vbox),button1,TRUE,FALSE,5);
gtk_box_pack_start(GTK_BOX(vbox),button2,TRUE,FALSE,5);
gtk_container_add(GTK_CONTAINER(window),hbox);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
阅读(923) | 评论(0) | 转发(0) |