void closeApp(GtkWidget *window,gpointer data)
{
gtk_main_quit();
}
int main (int argc ,int *argv[])
{
GtkWidget *window;
GtkWidget *IP_label;
//GtkWidget *send_entry,*recive_entry,*IP_entry;
GtkWidget *hbox1,*hbox2,*hbox3;
GtkWidget *vbox;
GtkWidget *button1;
GtkWidget *button2;
GtkWidget *button3;
GtkWidget *button4;
GtkWidget *button5;
GtkWidget *button6;
GtkWidget *button7;
GtkWidget *button8;
GtkWidget *button9;
//GtkWidget *button10;
gtk_init(&argc,&argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window),"火烈鸟");
gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
gtk_window_set_default_size(GTK_WINDOW(window),500,500);
hbox1 = gtk_hbox_new ( TRUE, 5 );
hbox2 = gtk_hbox_new ( TRUE, 5 );
hbox3 = gtk_hbox_new ( TRUE, 5 );
vbox = gtk_vbox_new ( TRUE, 10);
button1 = gtk_button_new_with_label("文件传输");//创建按钮
gtk_widget_set_size_request(button1,60,30);//为按钮设置大小
button2 = gtk_button_new_with_label("历史记录");
gtk_widget_set_size_request(button2,60,30);
button3 = gtk_button_new_with_label("关于");
gtk_widget_set_size_request(button3,60,30);
gtk_box_pack_start(GTK_BOX(hbox1),button1,TRUE,FALSE,5);
gtk_box_pack_start(GTK_BOX(hbox1),button2,TRUE,FALSE,5);
gtk_box_pack_start(GTK_BOX(hbox1),button3,TRUE,FALSE,5);
button4 = gtk_button_new_with_label("字体");
gtk_widget_set_size_request(button4,60,30);
button5 = gtk_button_new_with_label("颜色");
gtk_widget_set_size_request(button5,60,30);
button6 = gtk_button_new_with_label("表情");
gtk_widget_set_size_request(button6,60,30);
gtk_box_pack_start(GTK_BOX(hbox2),button4,TRUE,FALSE,5);
gtk_box_pack_start(GTK_BOX(hbox2),button5,TRUE,FALSE,5);
gtk_box_pack_start(GTK_BOX(hbox2),button6,TRUE,FALSE,5);
IP_label = gtk_label_new("IP:");
button7 = gtk_button_new_with_label("连接");
gtk_widget_set_size_request(button7,60,30);
button8 = gtk_button_new_with_label("发送");
gtk_widget_set_size_request(button8,60,30);
button9 = gtk_button_new_with_label("退出");
gtk_widget_set_size_request(button9,60,30);
gtk_box_pack_start(GTK_BOX(hbox3),IP_label,TRUE,TRUE,5);
gtk_box_pack_start(GTK_BOX(hbox3),button7,TRUE,FALSE,5);
gtk_box_pack_start(GTK_BOX(hbox3),button8,TRUE,FALSE,5);
gtk_box_pack_start(GTK_BOX(hbox3),button9,TRUE,FALSE,5);
gtk_box_pack_start(GTK_BOX(vbox),hbox1,FALSE,TRUE,10);
gtk_box_pack_start(GTK_BOX(vbox),hbox2,FALSE,TRUE,10);
gtk_box_pack_start(GTK_BOX(vbox),hbox3,FALSE,TRUE,10);
gtk_container_add(GTK_CONTAINER(window),vbox);
g_signal_connect(GTK_OBJECT(window),"destroy",G_CALLBACK(closeApp),NULL);
g_signal_connect(GTK_OBJECT(button9),"clicked",G_CALLBACK(closeApp),NULL);
gtk_widget_show_all(window);
gtk_main();
return 0;
}[/color]
[color=Red]neusoft@neusoft-desktop:~/XM$ gcc -o exp exp.c `pkg-config --cflags --libs gtk+-2.0`
exp.c: In function ‘main’:
exp.c:24: warning: passing argument 2 of ‘gtk_init’ from incompatible pointer type
buweiwei 于 2012-07-16 17:08:35发表:
大哥,进错门了吧...表示关注!