How to use SVG files for icon-name property on .ui files?

Hi! I saved some SVG files and added its on my GResource:

<!-- Icons -->
    <file>icons/symbolic/item-missing-symbolic.svg</file>
    <file>icons/symbolic/list-compact-symbolic.svg</file>
    <file>icons/symbolic/plus-symbolic.svg</file>

I built my GResource:

gnome.compile_resources('kairos',
  'kairos.gresource.xml',
  gresource_bundle: true,
  install: true,
  install_dir: pkgdatadir,
)

But the icons are not available, and my app continue to shows the icon missing icon.

Did someone know how to make icons works? If you need any other informations, just ask me.

Thank you in advance!

Can you share the entire GResource file contents? It’s likely that you’re installing the icons to the wrong location.

Have you read the documentation?

Of course! Here it is:

<?xml version="1.0" encoding="UTF-8"?>
<gresources>
  <gresource prefix="/com/gitlab/mlorier/Kairos">

    <!-- UI Components -->
    <file preprocess="xml-stripblanks">ui/kairos-window.ui</file>
    <file preprocess="xml-stripblanks">ui/kairos-preferences-dialog.ui</file>
    <file preprocess="xml-stripblanks">ui/kairos-export-dialog.ui</file>
    <file preprocess="xml-stripblanks">ui/kairos-add-event-dialog.ui</file>
    <file preprocess="xml-stripblanks">ui/widgets/kairos-event-prefs.ui</file>
    <file preprocess="xml-stripblanks">ui/widgets/kairos-timetable-prefs.ui</file>
    <file preprocess="xml-stripblanks">ui/widgets/kairos-event-row.ui</file>
    <file preprocess="xml-stripblanks" alias="shortcuts-dialog.ui">ui/shortcuts-dialog.ui</file>

    <!-- Icons -->
    <file>icons/symbolic/item-missing-symbolic.svg</file>
    <file>icons/symbolic/list-compact-symbolic.svg</file>
    <file>icons/symbolic/plus-symbolic.svg</file>

    <!-- Others Resources -->
    <file>style.css</file>

  </gresource>
</gresources>

Yes, but I follow the instructions, right?

You’re installing the icons to /com/gitlab/mlorier/Kairos/icons/symbolic/, but they should be installed to /com/gitlab/mlorier/Kairos/icons/scalable/actions/ instead, as shown in the example of the documentation.

1 Like

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