dunlin

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

commit 64d4dfe2ffff075dc216787480390bc48e4e22dd
parent 39735be89129364258769f865538892d4fd157e5
Author: Daniel Barlow <dan@telent.net>
Date:   Sun,  1 Jan 2023 00:11:01 +0000

hook up progress-bar, uri display

the road to callback hell is plagued with good intentions:
I am not unwilling to revisit this code if it gets any more gnarly

Diffstat:
Mbuffer.fnl | 10++++++++--
Mcommand.fnl | 3+++
Mframe.fnl | 14+++++++++++++-
3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/buffer.fnl b/buffer.fnl @@ -2,6 +2,7 @@ (local { : view } (require :fennel)) (fn new-buffer [name] + (var property-change-listener nil) (let [props {} widget (WebKit2.WebView { ;; :on_decide_policy @@ -19,11 +20,16 @@ (when (not (= pspec.name :parent)) (let [val (. self pspec.name)] (tset props pspec.name val) - ;(listeners:notify pspec.name val) - ))) + (when property-change-listener + (property-change-listener + pspec.name val))) + )) })] {:webview widget :name name + :subscribe-property-changes + (fn [self cb] + (set property-change-listener cb)) :location #(widget:get_uri) :visit (fn [_ u] (widget:load_uri u)) :properties props})) diff --git a/command.fnl b/command.fnl @@ -183,6 +183,9 @@ :widget box : prompt : frame + :set-inactive-text (fn [self text] + (when (not self.state.active) + (tset entry :text text))) :completions-widget completions }] (hbox:pack_start prompt false false 15) diff --git a/frame.fnl b/frame.fnl @@ -30,7 +30,14 @@ contentwidget (Gtk.Box { :orientation Gtk.Orientation.VERTICAL }) - ] + update-prop (fn [name value] + (match name + :estimated-load-progress + (tset progress-bar :fraction value) + :uri + (commander:set-inactive-text value) + n + (comment (print "prop change" n value))))] (tset window :on_key_release_event (fn [window event] @@ -58,6 +65,11 @@ (w:hide)) (tset self :buffer b) (contentwidget:pack_start b.webview true true 0) + (b:subscribe-property-changes + (fn [name val] + (if (= b self.buffer) + (update-prop name val) + (print "ignore props from background" b)))) (b.webview:show)) }] (lume.extend self f)