gtk_icon_theme_lookup_icon() prefers fallbacks over primary name
Steps to reproduce
- Put a specific icon name in the 'hicolor' directory
- Call
gtk_icon_theme_lookup_icon()
that specific name, but with"application-x-generic"
in thefallback
argument
Current behavior
The "application-x-generic"
icon is returned.
Expected outcome
The specific icon should be returned.
Version information
gtk4-4.10.5-1.fc38.x86_64
Additional information
The issue was found because Nautilus fails to show the correct icon for connection files for the ThinLinc client. This is unlike other file managers, e.g. Caja or Thunar. After some digging, the issue turned out to be deeper in Gtk, rather than in Nautilus.
This is a regression for Nautlius at least. No idea if that is because it used different APIs before, or if it's also a regression in Gtk.
This test program mimics what happens in Nautilus:
#!/usr/bin/python3
import gi
gi.require_version('Gdk', '4.0')
gi.require_version('Gtk', '4.0')
from gi.repository import Gdk
from gi.repository import Gtk
theme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default())
icon = theme.lookup_icon('application-vnd.cendio.thinlinc.clientconf', [], 48, 1, 0, 0)
print(icon.get_property('icon-name'))
icon = theme.lookup_icon('application-vnd.cendio.thinlinc.clientconf',
['application-x-generic',
'application-vnd.cendio.thinlinc.clientconf-symbolic',
'application-x-generic-symbolic'], 48, 1, 0, 0)
print(icon.get_property('icon-name'))
The output with the ThinLinc client installed is:
$ ./icon.py
application-vnd.cendio.thinlinc.clientconf
application-x-generic