cache scaled icons after loading
This commit is contained in:
parent
b84a8f5758
commit
48ffaa7695
@ -11,9 +11,8 @@ you are happy to exert that control in a Lua-based Lisp language.
|
|||||||
## Plan
|
## Plan
|
||||||
|
|
||||||
* [X] use gtk-layer-shell to put it in a layer
|
* [X] use gtk-layer-shell to put it in a layer
|
||||||
* [] update only at relevant intervals
|
* [X] update only at relevant intervals
|
||||||
* [] do we need file poll support? prolly not if we're calling every 200ms
|
* [X] cache icon pixbufs
|
||||||
* [] cache icon pixbufs
|
|
||||||
* [] update image/label widget instead of destroying
|
* [] update image/label widget instead of destroying
|
||||||
* [] allow height customisation
|
* [] allow height customisation
|
||||||
|
|
||||||
|
@ -29,13 +29,22 @@
|
|||||||
GdkPixbuf.InterpType.BILINEAR)))))
|
GdkPixbuf.InterpType.BILINEAR)))))
|
||||||
found)
|
found)
|
||||||
|
|
||||||
(fn find-icon [name]
|
(local found-icons {})
|
||||||
|
|
||||||
|
(fn load-icon [name]
|
||||||
(if (= (name:sub 1 1) "/")
|
(if (= (name:sub 1 1) "/")
|
||||||
;; From a direct path
|
;; From a direct path
|
||||||
(GdkPixbuf.Pixbuf.new_from_file_at_scale name HEIGHT -1 true)
|
(GdkPixbuf.Pixbuf.new_from_file_at_scale name HEIGHT -1 true)
|
||||||
;; From icon theme
|
;; From icon theme
|
||||||
(Gtk.Image.new_from_pixbuf (find-icon-pixbuf name))))
|
(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]
|
(fn update-button [button icon text]
|
||||||
(match (button:get_child) it (button:remove it))
|
(match (button:get_child) it (button:remove it))
|
||||||
(let [i (resolve icon)]
|
(let [i (resolve icon)]
|
||||||
|
Loading…
Reference in New Issue
Block a user