I have a GTK layout with a widget on the left of an HBox deciding the maximum height I want, and a VBox on the right containing three buttons, each containing only an image and no text. The images are a GTK stock icon, and so have the stock storage type.
Using expand=True, fill=True packing the buttons without images are exactly the height I want - some arbitrary small width, and 1/3 each the height of the left half of the HBox. However with an image, they are either too tall - 3 * ICON_SIZE_MENU is too tall in many themes - or if I force the button's height request, they get clipped. I would rather scale them to the size of the parent button.
Do I have to make my own pixbufs for each of the stock icons I'm using (and regenerate them if the size changes)? Or can GTK automatically size the image to fit the button, rather than the other way around? Since the images are only a few pixels off from fitting in every theme I've tried, is there a way to just disable the button's clipping?
This application is written in Python using PyGTK, but solutions in any language are appreciated.
(I tried just making it an icon name storage type, but one of the icons is REVERT_TO_SAVED, which turned into the broken stock image when I tried to force it to a particular pixel height. Plus, I'd rather not force it to any fixed pixel height.)
There's no way to automatically do you want you want. You might want to subclass gtk.Image and in your subclass, scale a pixbuf to your widget's allocation size. The advantage of this is that you'll have a reusable widget and you'll be able to have it resize your image on the fly.
The downside is that you'll have an ugly, scaled up pixmap. You may want to look into scalable vector graphics.
Scaling an image to its parent button size in GTK?