summaryrefslogtreecommitdiff
path: root/redo/uitask.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-07-08 12:04:51 -0400
committerPietro Gagliardi <[email protected]>2014-07-08 12:04:51 -0400
commit60d0953fe9f16726958f709007402ea4c8b89fc6 (patch)
treed3704828dad002c1144626aaec1f3e5cc5560041 /redo/uitask.go
parentbe56707c51a411c5e8228a78d663c91df4636128 (diff)
Implemented the Window OnClosing() event on GTK+. It works!
Diffstat (limited to 'redo/uitask.go')
-rw-r--r--redo/uitask.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/redo/uitask.go b/redo/uitask.go
index 76908fb..462a24b 100644
--- a/redo/uitask.go
+++ b/redo/uitask.go
@@ -45,10 +45,23 @@ type event struct {
lock sync.Mutex
}
+// do should never be nil; TODO should we make setters panic instead?
+
+func newEvent() *event {
+ return &event{
+ do: func(c Doer) bool {
+ return false
+ },
+ }
+}
+
func (e *event) set(f func(Doer)) {
e.lock.Lock()
defer e.lock.Unlock()
+ if f == nil {
+ f = func(c Doer) {}
+ }
e.do = func(c Doer) bool {
f(c)
return false
@@ -59,6 +72,11 @@ func (e *event) setbool(f func(Doer) bool) {
e.lock.Lock()
defer e.lock.Unlock()
+ if f == nil {
+ f = func(c Doer) bool {
+ return false
+ }
+ }
e.do = f
}