cache scaled icons after loading

phoen
Daniel Barlow 2022-03-24 12:14:08 +00:00
parent b84a8f5758
commit 48ffaa7695
2 changed files with 12 additions and 4 deletions

View File

@ -11,9 +11,8 @@ you are happy to exert that control in a Lua-based Lisp language.
## Plan
* [X] use gtk-layer-shell to put it in a layer
* [] update only at relevant intervals
* [] do we need file poll support? prolly not if we're calling every 200ms
* [] cache icon pixbufs
* [X] update only at relevant intervals
* [X] cache icon pixbufs
* [] update image/label widget instead of destroying
* [] allow height customisation

View File

@ -29,13 +29,22 @@
GdkPixbuf.InterpType.BILINEAR)))))
found)
(fn find-icon [name]
(local found-icons {})
(fn load-icon [name]
(if (= (name:sub 1 1) "/")
;; From a direct path
(GdkPixbuf.Pixbuf.new_from_file_at_scale name HEIGHT -1 true)
;; From icon theme
(Gtk.Image.new_from_pixbuf (find-icon-pixbuf name))))
(fn find-icon [name]
(let [icon (. found-icons name)]
(or icon
(let [icon (load-icon name)]
(tset found-icons name icon)
icon))))
(fn update-button [button icon text]
(match (button:get_child) it (button:remove it))
(let [i (resolve icon)]