I know that the usual way of giving an application an icon is via its desktop file. However, there are situations where this does not really apply:
Development builds
On Windows
AppImage
How can I get custom window icons to work in these situations? I’ve both used window.set_icon_name and gtk::Window::set_default_icon_name to the AppID, but it does not work. I’m pretty sure the icon itself works though, because it is shown fine in the About dialog and the logs with GTK_DEBUG set confirm this.
(As as side question: is it possible for an application to have multiple windows with different icons?)
There are a few Gtk applications that are commonly distributed across all platforms (Gimp, Xournal++, Xournal) and they window icons working just fine. So there somehow must be another way? (I think those are all still Gtk 3 so at least there must have been some way in the past)
Okay, so a custom icon for development and non-packaged builds on Wayland is off the table. This is unfortunate, but not really Gtk’s fault.
Which leaves open the Windows issue. There must be some mechanism already implemented because it worked at least in Gtk 3 and even my Gtk 4 application has an icon (the Gtk logo). One thing to note is that set_icon_name was previously set_icon in Gtk 3, maybe this is a relevant change somehow.