Mercurial > dwindows
diff gtk3/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 | de49c1f284b2 |
line wrap: on
line diff
--- a/gtk3/dw.c Sat May 05 20:13:43 2012 +0000 +++ b/gtk3/dw.c Sat May 05 21:18:32 2012 +0000 @@ -5666,6 +5666,21 @@ return (HICN)id; } +/* Internal function to keep HICNs from getting too big */ +GdkPixbuf *_icon_resize(GdkPixbuf *ret) +{ + int pwidth = gdk_pixbuf_get_width(ret); + int pheight = gdk_pixbuf_get_height(ret); + + if(pwidth > 24 || pheight > 24) + { + GdkPixbuf *orig = ret; + ret = gdk_pixbuf_scale_simple(ret, pwidth > 24 ? 24 : pwidth, pheight > 24 ? 24 : pheight, GDK_INTERP_BILINEAR); + g_object_unref(G_OBJECT(orig)); + } + return ret; +} + /* * Obtains an icon from a file. * Parameters: @@ -5706,7 +5721,7 @@ } DW_MUTEX_LOCK; - ret = gdk_pixbuf_new_from_file(file, NULL); + ret = _icon_resize(gdk_pixbuf_new_from_file(file, NULL)); DW_MUTEX_UNLOCK; return ret; } @@ -5740,7 +5755,7 @@ return 0; } DW_MUTEX_LOCK; - ret = gdk_pixbuf_new_from_file(file, NULL); + ret = _icon_resize(gdk_pixbuf_new_from_file(file, NULL)); DW_MUTEX_UNLOCK; return ret; }