GNOME Bugzilla – Bug 70648
GTK+ stock icon sizes cannot be themed
Last modified: 2011-02-04 16:11:52 UTC
The existing GTK+ stock icon theming mechanism does not allow theming of the "standard" stock icon sizes. The current API only allows implicit sizing by specifying bitmaps for each stock icons at each size; otherwise the icons are rescaled to the "standard" sizes for various GTK+ components. There are several practical obstacles here: (1) the stock pixmaps aren't installed, so there is no way to reuse them in an RC-file theme this way (unless one manually installs the pixmaps from the GTK+ sources); (2) specifying a new stock icons for every size would require about 300 separate icon entries in the RC file; (3) the stock pixmaps don't provide all the sizes one would need in the previous case, and the standard rescaling technique can't be used since it would defeat the purpose of "theming the size". What would of course be a straightforward solution would be to allow theming of the icon size constants in gtkiconfactory.c. This breaks down for those icons which are specified in the default theme via "add_sized" but single stock icon entries in the RC file may be used to work around this, with a relatively compact result. A patch is attached which does this; however it also replaces occurrences of add_sized with add_sized_with_fallback. However this means that the original stock icons will *not* be resized for those built-in sizes for which they are added (i.e. if add_sized_with_fallback specified GTK_ICON_SIZE_BUTTON as the standard for the pixmap, the pixmap will be used "as-is" when rendered onto buttons, without regard for the themed "gtk-icon-button-size" property). This patch should probably be discussed before being applied, even though it does not alter the look and feel of the default theme. -Bill
Created attachment 6614 [details] [review] patch to provide themeability of icon sizes (when rescaling)
- we need to get rid of the ICONS_RESIZEABLE thing, just delete the old code - the way the settings are done doesn't really work, since new icon sizes can be registered. Suggest perhaps a single "gtk-icon-sizes" setting containing something like "menu 20,20:button 24,24" or along those lines. - need to handle dynamic notification on the setting, which means incrementing the GtkIconSet cache validity stamp and queuing a resize on all toplevel windows - it's possible this should really be part of the theme, though I don't know; some accessibility things require a specific theme already (e.g. high-contrast). Maybe if someone is providing an icon collection with their theme they would want to be able to specify the natural sizes of the icon collection.
Leaving this on 2.0.0 for now.
Created attachment 8844 [details] [review] Patch to implement theming of icon sizes, without interfering with non-wildcarded icons
2.0.0 is long gone, and this bug is still marked "LOW" priority. However it is a blocker for accessibility. If the one-line change to gtkstyle.c at line 1963 (or so) is backed out of the previous patch, it causes no changes to gtk+ default icon set behavior unless icon sizes are explicitly resized in the RC file. I attach a fresh version of the patch which should apply fine against HEAD.
Owen: I know this isn't an easy one ... but I agree with Bill that its a must have for accessibility. The panel now registers its own icon size for its menus, so allowing it to be themed would change the size of the icons on the panel menus. Cheers :)
Is it still on the 2.2 milestone? Then don't worry about it.
Created attachment 10732 [details] [review] new patch that resizes icons dynamically when themes are changed
I have updated this patch so that it dynamically resizes the icons whenever the theme changes. This corrects problems where the icon sizes would not properly update, especially for themes that did not specify gtk-icon-sizes in the gtkrc file. Without this newer patch you would have to quit & restart a program to see the changed icon size.
Created attachment 10737 [details] [review] updated patch that corrects null-pointer core dump error
updated patch. found it caused a null-pointer core dump with gnome-terminal. Now this is fixed.
Created attachment 10761 [details] [review] Updated patch that works with gtk_icon_size_register, like gnome-panel.
Sorry about updating the patch so much. The latest patch gets the icons to resize properly even if the size is non-default (e.g. registered with the gtk_icon_size_register function). This also fixes bugzilla bug #71700.
Created attachment 10784 [details] [review] one-liner fix to make patch work when program is started after theme with icon-sizes was specified
Updated the patch with a one-line fix. Due to bad testing I didn't notice that my previous patch only worked when the theme was changed after the program was started. If a theme was selected with non-default icon sizes and *then* the program started, the icons weren't sized properly. This is now fixed.
I'm also seeing another problem on RH7.2, which I'm not sure is due to Mark's recent panel icon work, Brian's updated icon sizing patch, or neither :) What I'm seeing is: 1. Choose HighContrastLargePrint theme. Stock panel menu icons get bigger, but other icons on Applications/Actions menu don't. Panel doesn't resize either (bug #91686). 2. Restart panel so it resizes to fit the bigger font. Now the icons on the top level of the Applications/Actions menu are still small, but the ones in the *submenus* are big, as they should be. (Also, the GNOME foot icon beside the Applications menu title is clipped). 3. Switch back to default theme. The font switches back to normal size, but the menu panel doesn't resize (as per bug #91686), and none of the icon sizes on the Applications/Action menus change. They're still small on the top level, big in the submenus. 4. Restart panel. Now everything is back to default as it should be :) Can anyone else confirm they see this behaviour (using Brian's latest patch above, and panel from head), or is it just me...?
I tested this running Gnome on my Solaris9 and on my RedHat 7.2 machines, and it works fine for me on both.
Can confirm it's working fine for me on Solaris now too (GNOME 2 build 6), other than the issue raised in bug #92852.
Tue Sep 24 16:40:14 2002 Owen Taylor <otaylor@redhat.com> Make icon sizes configurable (#70648, slightly based on a patch from Bill Haneman, Brian Cameron) * gtk/gtkiconfactory.[ch]: Add gtk_icon_size_lookup_for_settings(). * gtk/gtksettings.c: Add gtk-icon-sizes XSETTING * gtk/gtkiconfactory.c: Make icon sizes per-GtkSettings. * gtk/gtkstyle.c: Use gtk_icon_size_lookup_for_settings() * gtk/gtkrc.[ch]: Privately export _gtk_rc_reset_styles() to force all the widgets to recompute their appearance.
I'm seeing problems with Owen's fix on RH7.2 and Solaris, can somebody else confirm I don't just have two separate but identically-behaving dodgy builds? :) E.g. starting from default gtk theme: - Open gedit, select LargePrint theme (from gnome-themes); text gets bigger, toolbar icons don't. See also the problems in bug #92852.
Ok, both these problems are rectified by changing 'dnd=x,y' to 'gtk-dnd=x,y' in the gtkrc files, as Owen pointed out. Still have one problem: changing from a theme with icon sizes specified to one without doesn't change the icon size back to default until you restart the app. Have pinged Owen by email on whether this a bug or a feature :)