gresource.xml
file and include it in your build system. Make sure to start with a Gtk.Application
as described in the previous sectiondata
directory, create a new file called gresource.xml
with the following contents:meson.build
, somewhere before the executable
step:executable
step:gresource.xml
file and have included it in the build system, we can add files and reference them in our app.GLib.Action
, GTK has a baked-in set of icon sizes defined under the namespace Gtk.IconSize
. When creating icons, it is important to know which of these sizes will be used and to design and hint the icon at that size. For more information about creating and hinting icons, check out the Human Interface Guidelines. Add your custom icon to the data
directory, and then update your gresource.xml
file to reference it:alias
the icon to paths in hicolor and GTK will automatically load the correct version when its size is referenced:Application
class' activate ()
function. This will let us reference the icon name without using long paths, and automatically handle icon sizing as previously mentioned Again, don't forget to use the same RDNN'd path that was defined in gresource.xml
:Gtk.Image
or Gtk.Button
using your custom icon and add it to the main window: