Finding available icons across platforms

I develop on Ubuntu 18 and when testing my application on Windows and macOS I noticed some icons were shown as broken images. The ones failing are Gtk.STOCK_PROPERTIES and Gtk.STOCK_FIND. Created as following:

Gtk.Button.new_from_icon_name(Gtk.STOCK_PROPERTIES, Gtk.IconSize.BUTTON)

I used these because the code was ported from GTK2 where new_from_stock was used and the names sound like they come with GTK.

The difference is both Windows and macOS use Adwaita, while I have another icon theme on Ubuntu. Using the inspector and setting Adwaita on the Ubuntu machine shows the icons without problems.

Is there a list of icons available on all platforms for example?

Does Icon Naming Specification help?

You have to ship the Adwaita Icon Theme on Windows and Mac. I can’t really say much about Mac because I don’t use it. For Windows you can download the package from MSYS2:

http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-adwaita-icon-theme-3.34.3-1-any.pkg.tar.xz

Yes, thanks. I just noticed gtk3-icon-browser comes installed which is a visual representation of that link you provided. Looks like this is the way to go and only use icons from this list.

1 Like

I should have mentioned this in the opening post, but yes, the Adwaita icon theme is installed on all systems. It’s just that other stock icons (Gtk.STOCK_APPLY and Gtk.STOCK_NO to just name a few) seems to be working without issues and some don’t anymore.

The stock items API was deprecated precisely because it’s not possible to maintain a 1:1 mapping between stock items and named icons.

Don’t use the stock items API with the named icons API: they are not the same thing, and you should never mix them; please, follow the named icons or use the Icon browser tool that is shipped by GTK—in some Linux distributions it may live in a separate package, like gtk-3-examples in Debian.

On Windows and macOS you may need to install the Adwaita icon theme within your application’s root; you can find an archive available on download.gnome.org. If the icon theme is too big for you, you can remove the assets you’re not using—but you still need to maintain the directory structure to allow the icon theme machinery to load the icons using the correct size.

Ok, got it! Thanks. Will make sure everything will be named icons.

This app provides some additional icons you might find useful, which you can include via gresource: https://flathub.org/apps/details/org.gnome.design.IconLibrary

It can also be used to search the built-in icons instead of gtk-icon-browser (which is missing some icons).

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.