extract function for webview properties handler

This commit is contained in:
Daniel Barlow 2022-02-06 14:08:42 +00:00
parent 184aefa4dc
commit 1cd2247e02

View File

@ -72,6 +72,28 @@ progress, trough {
)) ))
(fn handle-webview-properties [self pspec bus]
(if (= pspec.name "uri")
(bus:publish
:url-changed self.uri)
(and (= pspec.name "title")
(> (# self.title) 0))
(bus:publish
:title-changed
self.title)
(= pspec.name
"estimated-load-progress")
(bus:publish
:loading-progress
self.estimated_load_progress)
(= pspec.name "is-loading")
(bus:publish
:loading? self.is_loading)
))
(let [current-url "https://terse.telent.net/admin/stream" (let [current-url "https://terse.telent.net/admin/stream"
bus (event-bus) bus (event-bus)
r {} r {}
@ -108,27 +130,7 @@ progress, trough {
}) })
webview (WebKit2.WebView { webview (WebKit2.WebView {
:on_notify :on_notify
(fn [self pspec c] #(handle-webview-properties $1 $2 bus)
(if (= pspec.name "uri")
(bus:publish
:url-changed self.uri)
(and (= pspec.name "title")
(> (# self.title) 0))
(bus:publish
:title-changed
self.title)
(= pspec.name
"estimated-load-progress")
(bus:publish
:loading-progress
self.estimated_load_progress)
(= pspec.name "is-loading")
(bus:publish
:loading? self.is_loading)
))
}) })
back (doto back (doto
(Gtk.Button { (Gtk.Button {