Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1136205
  • 博文数量: 309
  • 博客积分: 6093
  • 博客等级: 准将
  • 技术积分: 3038
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-03 17:14
个人简介

linux学习记录

文章分类

全部博文(309)

文章存档

2014年(2)

2012年(37)

2011年(41)

2010年(87)

2009年(54)

2008年(88)

分类:

2009-06-04 13:17:19

v
oid
update_widget_bg(GtkWidget *widget, 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);
}
阅读(759) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~