GNOME Bugzilla – Bug 63305
GtkImage doesn't gray image when insensitive
Last modified: 2011-02-04 16:09:32 UTC
GnomeImage did. At least an option to do so would be nice.
One way to achieve this effect currently is to create a new stock item for your image.
OK, easier way to get the effect: GtkIconSet *icon_set = gtk_icon_set_new_from_pixbuf (pixbuf); gtk_image_new_from_icon_set (icon_set); gtk_icon_set_unref (icon_set); Graying things out generically is a pain (imagine doing it for GtkImage), so I think we should skip it for now. In the future, we can add a convenience function: gtk_image_new_from_icon_pixbuf() That does the above. Or a property ::build_insensitive, or just implement insensitivation always. (Though that might be a incompatible API change, I guess)
Currently this is what we have to do to get images that do insensitive without scaling them to random stock sizes: source = gtk.IconSource() source.set_pixbuf(pixbuf) source.set_size(gtk.ICON_SIZE_DIALOG) source.set_size_wildcarded(gtk.FALSE) iconset = gtk.IconSet() iconset.add_source(source) p = gtk.image_new_from_icon_set(iconset, gtk.ICON_SIZE_DIALOG) Note that this would be a lot more code in C...
I think we can trivially implement the build_insensitive thing, if we're willing to be slow (we can get a pixbuf from a GdkImage, or a GdkPixmap). Do we desensitize animations? ;-)
I'd like to find out soon whether we're going to fix this in GtkImage, or if I need to change Bonobo and Nautilus to make an icon set. I'm also unclear on whether the simple code Owen posted will work, or if I have to do something more complicated like what Matt alluded to.
Tue Jan 29 18:50:59 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkimage.c (gtk_image_expose): Optimize exposes of partial insensitive images. 2002-01-24 Havoc Pennington <hp@redhat.com> * gtk/gtkimage.c (gtk_image_expose): create insensitive version of the image regardless of storage type, #63305 * demos/gtk-demo/images.c: add toggle button to demonstrate that GtkImage makes its contents insensitive