commit 48286f52b02bfd792341fcd715cd25de40231348
parent be829d3cc0868f1b48209441336263ba9a8fab85
Author: Daniel Barlow <dan@telent.net>
Date: Tue, 8 Feb 2022 17:20:10 +0000
use user-supplied urls as autocomplete suggestions
Diffstat:
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/just/just.fnl b/just/just.fnl
@@ -24,7 +24,6 @@
(tset n v (or (. n v) []))
(. n v))]
{
- :subscriptions subscriptions
:subscribe (fn [self event-name handler]
(table.insert (vivify subscriptions event-name) handler))
:publish (fn [self sender event-name payload]
@@ -228,8 +227,14 @@ progress, trough {
:show-tab-overview #(widget:set_current_page 0)
}))
-(let [current-url "https://terse.telent.net"
- bus (event-bus)
+(local completions
+ (doto (Gtk.ListStore)
+ (: :set_column_types [lgi.GObject.Type.STRING])))
+
+(fn add-autocomplete-suggestion [url]
+ (completions:append [url]))
+
+(let [bus (event-bus)
window (Gtk.Window {
:title "Just browsing"
:default_width 360
@@ -248,6 +253,7 @@ progress, trough {
:margin 0
})
url (Gtk.Entry {
+ :completion (Gtk.EntryCompletion {:model completions :text_column 0 })
:on_activate
(fn [self] (bus:publish self :fetch self.text))
})
@@ -312,6 +318,8 @@ progress, trough {
(window:show_all)
+ (bus:subscribe :fetch #(add-autocomplete-suggestion $2))
+
(each [i url (ipairs arg)]
(lgi.GLib.timeout_add_seconds
0