GTK4: How to get a pixbuf from an icon now that gtk_icon_theme_load_icon is gone?

In GTK3, I was able to get pixbufs from an icon theme by using gtk_icon_theme_load_icon(). At a later time, they were, if needed, resized by using gdk_pixbuf_scale_simple() and put into a tree view. In GTK4, gtk_icon_theme_load_icon() is gone. There is gtk_icon_theme_lookup_icon() now, but this one returns a GtkIconPaintable. As shown in the documentation, I can get a GdkPaintable from it. But the crucial thing for me is that in the past I had a pixbuf that I could resize at a later time. How could I achieve the same now, getting a pixbuf from an icon and resize it so I can put it inside a tree view, or is there something else equivalent which I can do now instead?

I think I’ve sorted it out, though I have not yet attempted to use the created pixbuf. The solution is a bit verbose. The functions to use after gtk_icon_theme_lookup_icon() are in the following order:


That should do for getting the same pixbuf as I had with GTK3. I’ll mark this posting as solution after a successful test with a GtkTreeView (edit: done).

GtkCellRendererPixbuf::texture should let you avoid the detour through pixbufs.

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