comparison gtk/dw.c @ 1706:fb6807b0ab0d

Limit the size of an HICN to 24x24 on GTK... icons are used for Tree and Container controls which on other platforms have limited size.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 05 May 2012 21:18:32 +0000
parents e19b93a8229b
children 0b1be0a99f59
comparison
equal deleted inserted replaced
1705:3fa0448d3a7e 1706:fb6807b0ab0d
6957 HICN dw_icon_load(unsigned long module, unsigned long id) 6957 HICN dw_icon_load(unsigned long module, unsigned long id)
6958 { 6958 {
6959 return (HICN)id; 6959 return (HICN)id;
6960 } 6960 }
6961 6961
6962 #if GTK_MAJOR_VERSION > 1
6963 /* Internal function to keep HICNs from getting too big */
6964 GdkPixbuf *_icon_resize(GdkPixbuf *ret)
6965 {
6966 pwidth = gdk_pixbuf_get_width(ret);
6967 pheight = gdk_pixbuf_get_height(ret);
6968
6969 if(pwidth > 24 || pheight > 24)
6970 {
6971 GdkPixbuf *orig = ret;
6972 ret = gdk_pixbuf_scale_simple(ret, pwidth > 24 ? 24 : pwidth, pheight > 24 ? 24 : pheight, GDK_INTERP_BILINEAR);
6973 g_object_unref(G_OBJECT(orig));
6974 }
6975 return ret;
6976 }
6977 #endif
6978
6962 /* 6979 /*
6963 * Obtains an icon from a file. 6980 * Obtains an icon from a file.
6964 * Parameters: 6981 * Parameters:
6965 * filename: Name of the file, omit extention to have 6982 * filename: Name of the file, omit extention to have
6966 * DW pick the appropriate file extension. 6983 * DW pick the appropriate file extension.
7034 _PixmapArray[found].used = 1; 7051 _PixmapArray[found].used = 1;
7035 _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL; 7052 _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL;
7036 } 7053 }
7037 7054
7038 #if GTK_MAJOR_VERSION > 1 7055 #if GTK_MAJOR_VERSION > 1
7039 pixbuf = gdk_pixbuf_new_from_file(file, NULL); 7056 pixbuf = _icon_resize(gdk_pixbuf_new_from_file(file, NULL));
7040 if (pixbuf) 7057 if (pixbuf)
7041 { 7058 {
7042 _PixmapArray[found].pixbuf = pixbuf; 7059 _PixmapArray[found].pixbuf = pixbuf;
7043 _PixmapArray[found].width = gdk_pixbuf_get_width(pixbuf); 7060 _PixmapArray[found].width = gdk_pixbuf_get_width(pixbuf);
7044 _PixmapArray[found].height = gdk_pixbuf_get_height(pixbuf); 7061 _PixmapArray[found].height = gdk_pixbuf_get_height(pixbuf);
7135 _PixmapArray[found].used = 1; 7152 _PixmapArray[found].used = 1;
7136 _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL; 7153 _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL;
7137 } 7154 }
7138 7155
7139 #if GTK_MAJOR_VERSION > 1 7156 #if GTK_MAJOR_VERSION > 1
7140 pixbuf = gdk_pixbuf_new_from_file(file, NULL); 7157 pixbuf = _icon_resize(gdk_pixbuf_new_from_file(file, NULL));
7141 if (pixbuf) 7158 if (pixbuf)
7142 { 7159 {
7143 _PixmapArray[found].pixbuf = pixbuf; 7160 _PixmapArray[found].pixbuf = pixbuf;
7144 _PixmapArray[found].width = gdk_pixbuf_get_width(pixbuf); 7161 _PixmapArray[found].width = gdk_pixbuf_get_width(pixbuf);
7145 _PixmapArray[found].height = gdk_pixbuf_get_height(pixbuf); 7162 _PixmapArray[found].height = gdk_pixbuf_get_height(pixbuf);