我是靠谱客的博主 凶狠宝马,这篇文章主要介绍GTK+设置控件背景图片,现在分享给大家,希望可以做个参考。


复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
void update_widget_bg(GtkWidget *widget, const gchar *img_file) { GtkStyle *style; GdkPixbuf *pixbuf; GdkPixmap *pixmap; gint width, height; pixbuf = gdk_pixbuf_new_from_file(img_file, NULL); width = gdk_pixbuf_get_width(pixbuf); height = gdk_pixbuf_get_height(pixbuf); pixmap = gdk_pixmap_new(NULL, width, height, 24); gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap, NULL, 0); style = gtk_style_copy(GTK_WIDGET (widget)->style); if (style->bg_pixmap[GTK_STATE_NORMAL]) g_object_unref(style->bg_pixmap[GTK_STATE_NORMAL]); style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref(pixmap); style->bg_pixmap[GTK_STATE_ACTIVE] = g_object_ref(pixmap); style->bg_pixmap[GTK_STATE_PRELIGHT] = g_object_ref(pixmap); style->bg_pixmap[GTK_STATE_SELECTED] = g_object_ref(pixmap); style->bg_pixmap[GTK_STATE_INSENSITIVE] = g_object_ref(pixmap); gtk_widget_set_style(GTK_WIDGET (widget), style); g_object_unref(style); }


最后

以上就是凶狠宝马最近收集整理的关于GTK+设置控件背景图片的全部内容,更多相关GTK+设置控件背景图片内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(58)

评论列表共有 0 条评论

立即
投稿
返回
顶部