ubuntu gtk2.0 一个简单完整的窗口

时间:2024-01-20 13:00:39

//gtk_main();开了线程,关闭窗口并不能退出程序,需要手动添加

 //gtk2.0,window quit compelete example
#include <gtk/gtk.h>
void onQuitPro(GtkWidget* w,GdkEvent *event,gpointer data){
g_main_quit();
}
int main(int argc,char *argv){
gtk_init(&argc,&argv);
GtkWidget* window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
//g_signal_connect((GtkObject*)window,"delete_event",(GCallback)gtk_main_quit,NULL);
g_signal_connect((GtkObject*)window,"delete_event",(GCallback)onQuitPro,NULL);
//上面两句任选一
gtk_widget_show(window);
gtk_main();
return FALSE;
}