Custom symbolic icons in gtk4

Can anybody help me with loading symbolic icons. Doing this doesn’t work:

    GtkIconTheme *theme = gtk_icon_theme_get_for_display(gdk_display_get_default());
    gtk_icon_theme_add_search_path(theme, "/home/zagor/code/kronomi/data/icons/scalable/actions");

followed by:

    GtkWidget *icon = gtk_image_new_from_icon_name("kronomi-alarm-symbolic");

You can see the full example here: GitHub - zagortenay333/kronomi

The icon shows up but doesn’t get colored

Is there something I have to do with the svg icons? I tried both setting fill to #000000 and currentColor.

Alright, I found the solution. The trick is to have the same directory structure as the hicolor fallback theme. So data/icons/hicolor/symbolic/apps and the call should be gtk_icon_theme_add_search_path("home/zagor/code/kronomi/data/icons")

For more information: Themed Icons - GNOME Developer Documentation

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