summaryrefslogtreecommitdiff
path: root/dialog_darwin.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-06-30 09:57:44 -0400
committerPietro Gagliardi <[email protected]>2014-06-30 09:57:44 -0400
commit33155f7496a818a1ed83fe49cccb63be7842bc81 (patch)
treebbb14af3d92becf7d5ca5abfb28630a2b413ad93 /dialog_darwin.go
parente032807546a96e6489d18a0e42ced51b7c31a55c (diff)
Reverted everything back to the old API.
Diffstat (limited to 'dialog_darwin.go')
-rw-r--r--dialog_darwin.go56
1 files changed, 33 insertions, 23 deletions
diff --git a/dialog_darwin.go b/dialog_darwin.go
index 421e838..038c640 100644
--- a/dialog_darwin.go
+++ b/dialog_darwin.go
@@ -3,7 +3,6 @@
package ui
import (
- "fmt"
"unsafe"
)
@@ -18,32 +17,43 @@ func dialog_send(pchan unsafe.Pointer, res C.intptr_t) {
}()
}
-func _msgBox(parent *Window, primarytext string, secondarytext string, style uintptr) Response {
- var pwin C.id = nil
+func _msgBox(parent *Window, primarytext string, secondarytext string, style uintptr) chan int {
+ ret := make(chan int)
+ uitask <- func() {
+ var pwin C.id = nil
- if parent != dialogWindow {
- pwin = parent.sysData.id
+ if parent != dialogWindow {
+ pwin = parent.sysData.id
+ }
+ primary := toNSString(primarytext)
+ secondary := C.id(nil)
+ if secondarytext != "" {
+ secondary = toNSString(secondarytext)
+ }
+ switch style {
+ case 0: // normal
+ C.msgBox(pwin, primary, secondary, unsafe.Pointer(&ret))
+ case 1: // error
+ C.msgBoxError(pwin, primary, secondary, unsafe.Pointer(&ret))
+ }
}
- primary := toNSString(primarytext)
- secondary := C.id(nil)
- if secondarytext != "" {
- secondary = toNSString(secondarytext)
- }
- switch style {
- case 0: // normal
- C.msgBox(pwin, primary, secondary)
- return OK
- case 1: // error
- C.msgBoxError(pwin, primary, secondary)
- return OK
- }
- panic(fmt.Errorf("unknown message box style %d\n", style))
+ return ret
}
-func (w *Window) msgBox(primarytext string, secondarytext string) {
- _msgBox(w, primarytext, secondarytext, 0)
+func (w *Window) msgBox(primarytext string, secondarytext string) (done chan struct{}) {
+ done = make(chan struct{})
+ go func() {
+ <-_msgBox(w, primarytext, secondarytext, 0)
+ done <- struct{}{}
+ }()
+ return done
}
-func (w *Window) msgBoxError(primarytext string, secondarytext string) {
- _msgBox(w, primarytext, secondarytext, 1)
+func (w *Window) msgBoxError(primarytext string, secondarytext string) (done chan struct{}) {
+ done = make(chan struct{})
+ go func() {
+ <-_msgBox(w, primarytext, secondarytext, 1)
+ done <- struct{}{}
+ }()
+ return done
}