Skip to content

Instantly share code, notes, and snippets.

Created Feb 5, 2022
What would you like to do?
A minimal web browser
(local lgi (require :lgi))
(local inspect (require :inspect))
(local Gtk lgi.Gtk)
(local WebKit2 lgi.WebKit2)
(let [current-url ""
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
url (doto (Gtk.Entry)
(: :set_text current-url))
webview (WebKit2.WebView {
(fn [self pspec c]
(if (= "uri")
(url:set_text self.uri)
(and (= "title")
(> (# self.title) 0))
(.. self.title " - Just browsing"))
back (doto
(Gtk.Button {
:on_clicked (fn [s]
(if (webview:can_go_back)
(: :set_image
(Gtk.Image.new_from_icon_name "go-previous" Gtk.IconSize.LARGE_TOOLBAR)))]
(tset url :on_activate (fn [self]
(webview:load_uri self.text)))
(nav-bar:pack_start back false false 2)
(nav-bar:pack_start url true true 2)
(container:pack_start nav-bar false false 5)
(container:pack_start webview true true 5)
(webview:load_uri current-url)
(window:add container)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment