How to install icons with GTK4

I am trying to understand how to add my png icons to my buttons in GTK4.

From

I see that I should be using an IconTheme. OK, so what’s that?

OK, so it seems that I need to add the directory where my icons are.

Let’s presume I want them to be in the standard/“canonical” place, I don’t know what that actually means, so I’m guessing at

$HOME/install-myapp/share/my-app/icons
(where the installation prefix is $HOME/install-myapp)

From the above page, it seems that I need to add a resource path:

but what actually goes in there? - I don’t see.

I presume that I can set the icon-name property in the ui file:

<property name="icon-name">flip-horizontal.png</property>

I don’t see how this is connected to the directory I set for the resource path.

Maybe this is documented somewhere? I couldn’t find it.

Thanks.

The GNOME developers documentation has a tutorial on themed icons.

The recommended way to ship assets with your app is to use GResources, instead of installing files, except for the application icon, as that one has to be accessible by your desktop.

1 Like

Thank you @ebassi - that was the documentation I needed to read many days ago.

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