Mercurial > dwindows
comparison gtk/dw.c @ 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 | ff8f23594b15 |
children | 83edbd751da9 |
comparison
equal
deleted
inserted
replaced
315:89eac0990c67 | 316:a07e08f708d6 |
---|---|
98 { | 98 { |
99 GdkPixmap *pixmap; | 99 GdkPixmap *pixmap; |
100 GdkBitmap *mask; | 100 GdkBitmap *mask; |
101 int used; | 101 int used; |
102 unsigned long width, height; | 102 unsigned long width, height; |
103 #if GTK_MAJOR_VERSION > 1 | |
104 GdkPixbuf *pixbuf; | |
105 #endif | |
103 } DWPrivatePixmap; | 106 } DWPrivatePixmap; |
104 | 107 |
105 static DWPrivatePixmap *_PixmapArray = NULL; | 108 static DWPrivatePixmap *_PixmapArray = NULL; |
106 static int _PixmapCount = 0; | 109 static int _PixmapCount = 0; |
107 | 110 |
698 } | 701 } |
699 return NULL; | 702 return NULL; |
700 } | 703 } |
701 | 704 |
702 #if GTK_MAJOR_VERSION > 1 | 705 #if GTK_MAJOR_VERSION > 1 |
706 static GdkPixbuf *_find_private_pixbuf(long id) | |
707 { | |
708 if(id < _PixmapCount && _PixmapArray[id].used) | |
709 return _PixmapArray[id].pixbuf; | |
710 return NULL; | |
711 } | |
712 | |
703 static GdkPixbuf *_find_pixbuf(long id) | 713 static GdkPixbuf *_find_pixbuf(long id) |
704 { | 714 { |
705 char *data = NULL; | 715 char *data = NULL; |
706 int z; | 716 int z; |
717 | |
718 if(id & (1 << 31)) | |
719 return _find_private_pixbuf((id & 0xFFFFFF)); | |
707 | 720 |
708 for(z=0;z<_resources.resource_max;z++) | 721 for(z=0;z<_resources.resource_max;z++) |
709 { | 722 { |
710 if(_resources.resource_id[z] == id) | 723 if(_resources.resource_id[z] == id) |
711 { | 724 { |
4348 #if GTK_MAJOR_VERSION > 1 | 4361 #if GTK_MAJOR_VERSION > 1 |
4349 pixbuf = gdk_pixbuf_new_from_file(file, NULL); | 4362 pixbuf = gdk_pixbuf_new_from_file(file, NULL); |
4350 | 4363 |
4351 if(pixbuf) | 4364 if(pixbuf) |
4352 { | 4365 { |
4366 _PixmapArray[found].pixbuf = pixbuf; | |
4353 _PixmapArray[found].width = gdk_pixbuf_get_width(pixbuf); | 4367 _PixmapArray[found].width = gdk_pixbuf_get_width(pixbuf); |
4354 _PixmapArray[found].height = gdk_pixbuf_get_height(pixbuf); | 4368 _PixmapArray[found].height = gdk_pixbuf_get_height(pixbuf); |
4355 | 4369 |
4356 gdk_pixbuf_render_pixmap_and_mask(pixbuf, &_PixmapArray[found].pixmap, &_PixmapArray[found].mask, 1); | 4370 gdk_pixbuf_render_pixmap_and_mask(pixbuf, &_PixmapArray[found].pixmap, &_PixmapArray[found].mask, 1); |
4357 g_object_unref(pixbuf); | |
4358 } | 4371 } |
4359 #elif defined(USE_IMLIB) | 4372 #elif defined(USE_IMLIB) |
4360 image = gdk_imlib_load_image(file); | 4373 image = gdk_imlib_load_image(file); |
4361 | 4374 |
4362 if(image) | 4375 if(image) |
4398 { | 4411 { |
4399 unsigned long id = handle & 0xFFFFFF; | 4412 unsigned long id = handle & 0xFFFFFF; |
4400 | 4413 |
4401 if(id < _PixmapCount && _PixmapArray[id].used) | 4414 if(id < _PixmapCount && _PixmapArray[id].used) |
4402 { | 4415 { |
4416 #if GTK_MAJOR_VERSION > 1 | |
4417 if(_PixmapArray[id].pixbuf) | |
4418 { | |
4419 g_object_unref(_PixmapArray[id].pixbuf); | |
4420 _PixmapArray[id].pixbuf = NULL; | |
4421 } | |
4422 #endif | |
4403 if(_PixmapArray[id].mask) | 4423 if(_PixmapArray[id].mask) |
4404 { | 4424 { |
4405 gdk_bitmap_unref(_PixmapArray[id].mask); | 4425 gdk_bitmap_unref(_PixmapArray[id].mask); |
4406 _PixmapArray[id].mask = NULL; | 4426 _PixmapArray[id].mask = NULL; |
4407 } | 4427 } |