make entry widget a file-scoped local
This commit is contained in:
parent
6efbc34576
commit
bbd67b3a16
22
command.fnl
22
command.fnl
@ -111,19 +111,16 @@
|
||||
|
||||
(local prompt (Gtk.Label { :label ""}))
|
||||
|
||||
(fn update-widget-state [w result]
|
||||
(set prompt.label (or result.prompt ""))
|
||||
(set w.sensitive result.active)
|
||||
(set w.text
|
||||
(or result.default result.error "")))
|
||||
|
||||
(local widget
|
||||
(let [w (Gtk.Entry {
|
||||
:sensitive false
|
||||
})]
|
||||
(tset w :on_activate
|
||||
(fn [event]
|
||||
(update-widget-state w (on-input event.text))))
|
||||
(let [result (on-input event.text)]
|
||||
(set prompt.label (or result.prompt ""))
|
||||
(set w.sensitive result.active)
|
||||
(set w.text (or result.default result.error "")))))
|
||||
w))
|
||||
|
||||
(local box
|
||||
@ -136,6 +133,11 @@
|
||||
(box:pack_start widget true true 5)
|
||||
box))
|
||||
|
||||
(fn update-widget-state [result]
|
||||
(set prompt.label (or result.prompt ""))
|
||||
(set widget.sensitive result.active)
|
||||
(set widget.text (or result.default result.error "")))
|
||||
|
||||
(fn activate []
|
||||
(tset state :active true)
|
||||
(set widget.sensitive true)
|
||||
@ -153,15 +155,15 @@
|
||||
}]
|
||||
(set state s)
|
||||
(let [r (on-input nil)]
|
||||
(update-widget-state widget r)
|
||||
(update-widget-state r)
|
||||
(widget:grab_focus)
|
||||
r)))
|
||||
|
||||
(fn active? [] state.active)
|
||||
|
||||
|
||||
{
|
||||
: activate
|
||||
: active?
|
||||
:active? (fn [] state.active)
|
||||
: define-command
|
||||
: on-input
|
||||
: invoke-interactively
|
||||
|
Loading…
Reference in New Issue
Block a user