Adding custom icon without gresource, icon lookup fails

I’ve just added the fire-symbolic icon in a local folder, at ./data/icons/hicolor/scalable/actions/fire-symbolic.svg

I’ve added the icon path to the global Gtk.IconTheme. The Gtk.IconTheme recognizes there’s an icon named fire-symbolic, but the icon lookup fails. Using the icon in a Gtk.Image also fails.

The relative code is here. (I’m using ClojureScript, so the following code gets compiled to javascript and then runs on the GJS runtime)

(let [icon-theme
          (Gtk/IconTheme.get_for_display (.get_display win))]
      (.add_search_path icon-theme "./data/icons")

       ;; Returns true
       (.has_icon icon-theme "fire-symbolic")

       ;; Returns [-1], so the icon is scalable
       (.get_icon_sizes icon-theme "fire-symbolic")

       ;; The lookup fails and returns "image-missing"
       (.-icon-name (.lookup_icon icon-theme "fire-symbolic" nil 128 1 Gtk/TextDirection.NONE 0))))

Any idea on how I could debug this?


I believe you should create an appropriate index.theme file in ./data/icons/hicolor. You can copy /usr/share/icons/hicolor/index.theme and tailor that to your needs.

Otherwise you can just call .add_search_path("./data/icons/hicolor/scalable/actions") as: (link)

if an icon found isn’t found either in the current icon theme or the default icon theme, and an image file with the right name is found directly in one of the elements of path , then that image will be used for the icon name. (This is legacy feature, and new icons should be put into the fallback icon theme, which is called hicolor, rather than directly on the icon path.)

You can run your application with the environment variable GTK_DEBUG=icontheme to get informational messages (requires a debug build of GTK). (link)

See also Icon Theme Specification

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