Custom symbolic icons not working on my GTK4 app

I want to use custom icons for the tabs of a adw::ViewStack, but I’m having trouble displaying them in my application, even though gtk::IconTheme::has_icon says it exists.

I’ve made this minimal example, which does, in summary:

// register the resources
gio::resources_register_include!("compiled.gresource").expect("Failed to register resources.");

// adds the icon theme
let icon_theme = gtk::IconTheme::for_display(&WidgetExt::display(&window));
icon_theme.add_resource_path("/io/github/santiagocezar/maniatic-launcher/icons/");
icon_theme.add_resource_path("/io/github/santiagocezar/maniatic-launcher/icons/scalable/actions/");

// and shows an image
let img = gtk::Image::from_icon_name("one-symbolic");
window.set_child(Some(&img));

Here’s the resources XML:

<?xml version="1.0" encoding="UTF-8"?>
<gresources>
    <gresource prefix="/io/github/santiagocezar/maniatic-launcher/icons/scalable/actions/">
        <file compressed="true" preprocess="xml-stripblanks">one-symbolic.svg</file>
        <file compressed="true" preprocess="xml-stripblanks">two-symbolic.svg</file>
        <file compressed="true" preprocess="xml-stripblanks">mania-symbolic.svg</file>
    </gresource>
</gresources>

But this is how it looks when I run it:

Made it work by installing librsvg, welp

1 Like

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