- 论坛徽章:
- 0
|
环境 ----------------------- #uname -i x86_64
64位 fedora 12
安装和window一样的版本:gtk2 #yum install gtk2 gtk2-devel* 测试 代码 t_hello.c - #include<gtk/gtk.h>
-
void hello(GtkWidget *widget,gpointer data)
-
{
-
g_print("Hello,welcome!\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 ("Welcome!");
-
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(0);
-
}
编译 - # gcc `pkg-config --cflags --libs gtk+-2.0` t_hello.c -o t_hello
-
# ./t_hello
出现了Welcome的按钮。ok,环境配好了。 真是一试即成冲豪迈,万里征途从今始。耶~~~ |
|