eufon/just/just.fnl

53 lines
1.8 KiB
Plaintext
Raw Normal View History

2022-02-04 23:47:14 +00:00
(local lgi (require :lgi))
(local inspect (require :inspect))
(local Gtk lgi.Gtk)
(local WebKit2 lgi.WebKit2)
2022-02-05 00:13:47 +00:00
(let [current-url "https://terse.telent.net"
2022-02-04 23:47:14 +00:00
window (Gtk.Window {
:title "Just browsing"
:default_width 800
:default_height 600
:on_destroy Gtk.main_quit
})
container (Gtk.Box {
:orientation Gtk.Orientation.VERTICAL
})
nav-bar (Gtk.Box {
:orientation Gtk.Orientation.HORIZONTAL
})
2022-02-05 00:13:47 +00:00
url (doto (Gtk.Entry) (: :set_text current-url))
webview (WebKit2.WebView {
:on_notify
(fn [self pspec c]
(if (= pspec.name "uri")
(url:set_text self.uri)
2022-02-05 12:35:28 +00:00
(and (= pspec.name "title")
(> (# self.title) 0))
(window:set_title
(.. self.title " - Just browsing"))
2022-02-05 00:13:47 +00:00
))
})
2022-02-04 23:47:14 +00:00
back (Gtk.Button {
:label "<-"
2022-02-05 12:35:42 +00:00
:on_clicked (fn [s]
(if (webview:can_go_back)
(webview:go_back)))
2022-02-05 00:13:47 +00:00
})]
2022-02-04 23:47:14 +00:00
(nav-bar:pack_start back false false 5)
(nav-bar:pack_start url true true 5)
(container:pack_start nav-bar false false 5)
(container:pack_start webview true true 5)
(webview:load_uri current-url)
(window:add container)
(window:show_all))
(Gtk.main)