comparison 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
comparison
equal deleted inserted replaced
1705:3fa0448d3a7e 1706:fb6807b0ab0d
5664 HICN dw_icon_load(unsigned long module, unsigned long id) 5664 HICN dw_icon_load(unsigned long module, unsigned long id)
5665 { 5665 {
5666 return (HICN)id; 5666 return (HICN)id;
5667 } 5667 }
5668 5668
5669 /* Internal function to keep HICNs from getting too big */
5670 GdkPixbuf *_icon_resize(GdkPixbuf *ret)
5671 {
5672 int pwidth = gdk_pixbuf_get_width(ret);
5673 int pheight = gdk_pixbuf_get_height(ret);
5674
5675 if(pwidth > 24 || pheight > 24)
5676 {
5677 GdkPixbuf *orig = ret;
5678 ret = gdk_pixbuf_scale_simple(ret, pwidth > 24 ? 24 : pwidth, pheight > 24 ? 24 : pheight, GDK_INTERP_BILINEAR);
5679 g_object_unref(G_OBJECT(orig));
5680 }
5681 return ret;
5682 }
5683
5669 /* 5684 /*
5670 * Obtains an icon from a file. 5685 * Obtains an icon from a file.
5671 * Parameters: 5686 * Parameters:
5672 * filename: Name of the file, omit extention to have 5687 * filename: Name of the file, omit extention to have
5673 * DW pick the appropriate file extension. 5688 * DW pick the appropriate file extension.
5704 return 0; 5719 return 0;
5705 } 5720 }
5706 } 5721 }
5707 5722
5708 DW_MUTEX_LOCK; 5723 DW_MUTEX_LOCK;
5709 ret = gdk_pixbuf_new_from_file(file, NULL); 5724 ret = _icon_resize(gdk_pixbuf_new_from_file(file, NULL));
5710 DW_MUTEX_UNLOCK; 5725 DW_MUTEX_UNLOCK;
5711 return ret; 5726 return ret;
5712 } 5727 }
5713 5728
5714 /* 5729 /*
5738 else 5753 else
5739 { 5754 {
5740 return 0; 5755 return 0;
5741 } 5756 }
5742 DW_MUTEX_LOCK; 5757 DW_MUTEX_LOCK;
5743 ret = gdk_pixbuf_new_from_file(file, NULL); 5758 ret = _icon_resize(gdk_pixbuf_new_from_file(file, NULL));
5744 DW_MUTEX_UNLOCK; 5759 DW_MUTEX_UNLOCK;
5745 return ret; 5760 return ret;
5746 } 5761 }
5747 5762
5748 /* 5763 /*