changeset 316:a07e08f708d6

Fixed icons in the tree control in GTK 2.x when loaded from a file.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 02 Apr 2003 11:31:38 +0000
parents 89eac0990c67
children 83edbd751da9
files gtk/dw.c
diffstat 1 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/dw.c	Wed Apr 02 10:55:08 2003 +0000
+++ b/gtk/dw.c	Wed Apr 02 11:31:38 2003 +0000
@@ -100,6 +100,9 @@
 	GdkBitmap *mask;
 	int used;
 	unsigned long width, height;
+#if GTK_MAJOR_VERSION > 1
+	GdkPixbuf *pixbuf;
+#endif
 } DWPrivatePixmap;
 
 static DWPrivatePixmap *_PixmapArray = NULL;
@@ -700,11 +703,21 @@
 }
 
 #if GTK_MAJOR_VERSION > 1
+static GdkPixbuf *_find_private_pixbuf(long id)
+{
+	if(id < _PixmapCount && _PixmapArray[id].used)
+		return _PixmapArray[id].pixbuf;
+	return NULL;
+}
+
 static GdkPixbuf *_find_pixbuf(long id)
 {
 	char *data = NULL;
 	int z;
 
+	if(id & (1 << 31))
+		return _find_private_pixbuf((id & 0xFFFFFF));
+
 	for(z=0;z<_resources.resource_max;z++)
 	{
 		if(_resources.resource_id[z] == id)
@@ -4350,11 +4363,11 @@
 
 	if(pixbuf)
 	{
+		_PixmapArray[found].pixbuf = pixbuf;
 		_PixmapArray[found].width = gdk_pixbuf_get_width(pixbuf);
 		_PixmapArray[found].height = gdk_pixbuf_get_height(pixbuf);
 
 		gdk_pixbuf_render_pixmap_and_mask(pixbuf, &_PixmapArray[found].pixmap, &_PixmapArray[found].mask, 1);
-		g_object_unref(pixbuf);
 	}
 #elif defined(USE_IMLIB)
 	image = gdk_imlib_load_image(file);
@@ -4400,6 +4413,13 @@
 
 		if(id < _PixmapCount && _PixmapArray[id].used)
 		{
+#if GTK_MAJOR_VERSION > 1
+			if(_PixmapArray[id].pixbuf)
+			{
+				g_object_unref(_PixmapArray[id].pixbuf);
+				_PixmapArray[id].pixbuf = NULL;
+			}
+#endif
 			if(_PixmapArray[id].mask)
 			{
 				gdk_bitmap_unref(_PixmapArray[id].mask);