Fedora環境下Gtk+開發環境配置


一、安裝必要組建:(在root權限下)yum install gtk2 gtk2-devel gtk2-devel-docs測試

二、可能還須要組建(可選,不行再裝):yum install gnome-devel gnome-devel-docsui

三、編寫測試程序:spa

  
#include < gtk / gtk.h > void hello(GtkWidget * widget,gpointer data) { g_print( " Hello Ubuntu!\n " ); } gint delete_event(GtkWidget * widget,GdkEvent * event ,gpointer data) { g_print ( " delete event occurred\n " ); return (TRUE); } void destroy(GtkWidget * widget,gpointer data) { gtk_main_quit(); } int main( int argc, char * argv[] ) { GtkWidget * window; GtkWidget * button; gtk_init ( & argc, & argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_signal_connect (GTK_OBJECT(window), " delete_event " ,GTK_SIGNAL_FUNC(delete_event),NULL); gtk_signal_connect (GTK_OBJECT (window), " destroy " ,GTK_SIGNAL_FUNC (destroy), NULL); gtk_container_set_border_width (GTK_CONTAINER (window), 10 ); button = gtk_button_new_with_label ( " Hello Ubuntu! " ); gtk_signal_connect (GTK_OBJECT (button), " clicked " ,GTK_SIGNAL_FUNC (hello), NULL); gtk_signal_connect_object (GTK_OBJECT (button), " clicked " ,GTK_SIGNAL_FUNC (gtk_widget_destroy),GTK_OBJECT (window)); gtk_container_add (GTK_CONTAINER (window), button); gtk_widget_show (button); gtk_widget_show (window); /* 顯示一個窗口 */ gtk_main(); /* 進入主循環 */ return ( ); }

四、編譯程序:code

終端命令:blog

  
$ gcc `pkg - config -- cflags -- libs gtk +- 2.0 ` gtktest.c - o gtktest $ . / gtktest
五、看到一個帶有hello world按鈕的小窗口就表示安裝成功了!假如你遇到問題,就本身去Google答案了, 或者給我留言,一塊兒看看。Good luck!!!!
相關文章
相關標籤/搜索