print error when failing to load image

phoen
Daniel Barlow 2022-04-07 23:39:56 +01:00
parent 2ec7bfc78a
commit a39a752b15
1 changed files with 7 additions and 1 deletions

View File

@ -60,11 +60,17 @@
(local found-icons {})
(macro check-err [form]
`(let [(result# err#) ,form]
(or result#
(error err#))))
(fn load-icon [name]
(let [pixbuf
(if (= (name:sub 1 1) "/")
;; From a direct path
(GdkPixbuf.Pixbuf.new_from_file_at_scale name HEIGHT -1 true)
(check-err
(GdkPixbuf.Pixbuf.new_from_file_at_scale name HEIGHT -1 true))
;; From icon theme
(find-icon-pixbuf name))]
(Gtk.Image.new_from_pixbuf pixbuf)))