Related to thunar#966 (closed). It seems
GtkIconTheme's UI scaling support for looking up and loading icons isn't quite as broken as I thought (I was testing it on an icon theme that was broken through no fault of the icon theme author).
However, there are still ways in which it behaves undesirably (UI scaled or not), specifically when looking up icons that aren't a "normal" size (like 31 instead of 32, for example). Whenever you try to load an icon at an "abnormal" size,
GtkIconTheme will give up and use a SVG icon instead of taking the next-largest PNG and scaling it down.
This works, but doesn't give the best behavior, because icon theme authors generally design icons with less "visual complexity" as the icon sizes decrease, rather than simply scaling the icon as-is down to a smaller size. When you put that together with
GtkIconTheme's behavior, you end up loading icons that are "too visually complex" at smaller "abnormal" sizes.
This is especially weird in places where Xfce allows users to pick arbitrary sizes for icons. For example, in xfdesktop, as the user slowly increases the size of desktop icons, the "unnatural" sizes will often result in a SVG that's rendered at the target size. But then when the user hits a "natural" size (like 24 or 32), the icon could change dramatically, because the icon theme designer decided to draw the icon differently at those smaller sizes.
As an example, the
audio-volume-muted-symbolic icon in the Adwaita icon theme is rendered in all black at smaller sizes (PNGs), but the SVG is rendered as a sort of medium grey. This means that, as someone were to slowly change icon sizes, they would see this odd change in the icon:
- 30: grey
- 31: grey
- 32: black
- 33: grey
- 34: grey
But, in reality, the icon theme designer intended the icon to be black, and only render grey at much larger sizes.
The important bit of this PR is in
xfce_gtk_icon_theme_lookup_icon(), where it first tries to find matching icons without using SVG icons, and only falling back to SVG if a more-suitable icon can't be found. The other functions just "replace" similarly-named functionality in
GtkIconTheme that need to use
Alternatively, we could also just not care about this, and use the
GtkIconTheme functions as intended. This might create some undesirable situations (like the one above), but it appeas that icon theme authors can signal to
GtkIconTheme that icons can be scaled through a range of sizes (via entries in their
index.theme file). For whatever reason, Adwaita has chosen not to do that for its fixed-size PNGs.
WIP: still needs gtkdocs