Uninstalled icon theme icons in tests

With my quests to repair my screenshots I also like to get my icons back.

In my builddir I have:

tree icons/
icons/
├── gnome
│   ├── 16x16
│   │   └── ...
│   ├── 22x22
│   │   └── ...
│   ├── 24x24
│   │   └── ...
│   ├── 32x32
│   │   └── ...
│   ├── 48x48
│   │   └── ...
│   ├── 64x64
│   │   └── ...
│   └── scalable
│       └── ...
└── hicolor
    ├── 16x16
    │   └── ...
    ├── 24x24
    │   └── ...
    ├── 256x256
    │   └── ...
    ├── 48x48
    │   └── ...
    └── scalable
        └── ...

Those get installed when installing (and then also show up in the UI), but I’d like to access them from the tests already. For that so far I was just setting:

	XDG_CACHE_HOME=$(abs_top_builddir)
	XDG_DATA_HOME=$(abs_top_builddir)

and it was good. This does not work anymore :/. I added some debug logging:

theme is "Adwaita", icon-theme is "Adwaita", "(null)"
...
dk_pixbuf_new_from_theme: Couldn't load buzztrax_menu_source_machine 16x16 icon: Icon 'buzztrax_menu_source_machine' not present in theme Adwaita

but

find icons/ -name "buzztrax_menu_source_machine*"
icons/gnome/24x24/buzztrax_menu_source_machine.png
icons/gnome/16x16/buzztrax_menu_source_machine.png
icons/hicolor/24x24/buzztrax_menu_source_machine.png
icons/hicolor/16x16/buzztrax_menu_source_machine.png

I’ve tried a bunch of things:

    if ((display_manager = gdk_display_manager_get ())) {
      GdkScreen *default_screen;
      GtkSettings *default_settings;
      gchar *theme_name, *icon_theme_name, *fallback_icon_theme_name;

      default_display = gdk_display_manager_get_default_display (display_manager);
      if ((default_screen = gdk_display_get_default_screen (default_display))) {

        if ((default_settings = gtk_settings_get_for_screen (default_screen))) {
          g_object_get (default_settings, "gtk-theme-name", &theme_name,
              "gtk-icon-theme-name", &icon_theme_name,
              "gtk-fallback-icon-theme", &fallback_icon_theme_name, NULL);
          LOG_INFO ("theme is \"%s\", icon-theme is \"%s\", \"%s\"", theme_name,
              icon_theme_name, fallback_icon_theme_name);

          g_object_set (default_settings, "gtk-icon-theme-name", "gnome",
              "gtk-fallback-icon-theme", "hicolor",  NULL);
         ....

Setting the icon-theme or fallback-icon-theme has no effect. When loading the icon it still claims that ‘Adwaita’ is the icon-theme. What changed that this is not honored in gtk-3 anymore and whats the new way to achieve this?

I also looked at gtk_icon_theme_prepend_search_path and the docs for gtk_icon_theme_set_search_path() hint that it looks for an index.theme file.
So this is not what I cam looking for (I need a path for the icons and not for the icon-theme).

When I run with GTK_DEBUG=“icontheme” and redirect output to a log and then:

> grep /home/ensonic/ /tmp/gtk.log
Gtk-Message: 12:19:56.312: look for icon cache in /home/ensonic/projects/buzztrax/buzztrax/icons
Gtk-Message: 12:19:58.476: look for icon cache in /home/ensonic/projects/buzztrax/buzztrax/icons
Gtk-Message: 12:20:00.791: look for icon cache in /home/ensonic/projects/buzztrax/buzztrax/icons
Gtk-Message: 12:20:03.304: look for icon cache in /home/ensonic/projects/buzztrax/buzztrax/icons
Gtk-Message: 12:20:06.756: look for icon cache in /home/ensonic/projects/buzztrax/buzztrax/icons

Then I see that it checks the icon-dir I mentioned at the start of my post. There is no cache, but a cache is optional, right?

Also if I create a cache there (gtk-update-icon-cache -f -t icons/) it finds it, but still does not consider the icons.

Shouldn’t they be in a subdirectory below the size dir?

Usually app icons are in ${datadir}/icons/${theme}/${size}/apps, then icons used inside apps would go in ${datadir}/icons/${theme}/${size}/actions, ${datadir}/icons/${theme}/${size}/status, etc…