标签:des style c class blog code
1 #include<gtk/gtk.h> 2 3 /*从一个图象文件中生成 GdkPixbuf 类型数据*/ 4 GdkPixbuf * create_pixbuf(const gchar *filename) 5 { 6 GdkPixbuf *pixbuf; 7 GError *error = NULL; 8 pixbuf = gdk_pixbuf_new_from_file(filename, &error); 9 if(!pixbuf) 10 { 11 fprintf(stderr,"%s\n",error->message); 12 g_error_free(error); 13 } 14 return pixbuf; 15 } 16 17 int main(int argc, char **argv) 18 { 19 GtkWidget *window; 20 21 /*初始化gtk+程序*/ 22 gtk_init(&argc, &argv); 23 24 /*生成了一个构件-GtkWindow,种类是GTK_WINDOW_TOPLEVEL,他有一个标题栏和一个边框,同意由窗口管理器进行管理*/ 25 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); 26 27 /*设置标题*/ 28 gtk_window_set_title(GTK_WINDOW(window),"icon"); 29 30 /*默认大小为230*150 像素*/ 31 gtk_window_set_default_size(GTK_WINDOW(window),230,150); 32 33 /*窗口位置在中间*/ 34 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); 35 36 /*创建任务栏上的图标*/ 37 gtk_window_set_icon(GTK_WINDOW(window),create_pixbuf("window.ico")); 38 39 /*显示窗口*/ 40 gtk_widget_show(window); 41 42 /*连接上一个关闭的信号(the destroy signal),就是 gtk_main_quit() 这个函数*/ 43 g_signal_connect_swapped(G_OBJECT(window),"destroy",G_CALLBACK(gtk_main_quit),NULL); 44 45 gtk_main(); 46 47 return 0; 48 }
标签:des style c class blog code
原文地址:http://www.cnblogs.com/yongjiuzhizhen/p/3754530.html