eufon

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 48ffaa7695fc8cc9a393fe7baeb23db862d25066
parent b84a8f5758840e462305b74348d9bc2ce683aea6
Author: Daniel Barlow <dan@telent.net>
Date:   Thu, 24 Mar 2022 12:14:08 +0000

cache scaled icons after loading

Diffstat:
Mblinkenlicht/README.md | 5++---
Mblinkenlicht/blinkenlicht.fnl | 11++++++++++-
2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/blinkenlicht/README.md b/blinkenlicht/README.md @@ -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 diff --git a/blinkenlicht/blinkenlicht.fnl b/blinkenlicht/blinkenlicht.fnl @@ -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)]