From ffa1bbe0b91a8c812ddcea5c5d65e55f60d07f33 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 30 Jun 2014 22:48:12 -0400 Subject: Restored the previous new API. I'm going to change it so that events are callbacks rather than using a window handler, but other than that... yeah. --- dialog_darwin.go | 58 +++++++++++++++++++++++--------------------------------- 1 file changed, 24 insertions(+), 34 deletions(-) (limited to 'dialog_darwin.go') diff --git a/dialog_darwin.go b/dialog_darwin.go index 038c640..421e838 100644 --- a/dialog_darwin.go +++ b/dialog_darwin.go @@ -3,6 +3,7 @@ package ui import ( + "fmt" "unsafe" ) @@ -17,43 +18,32 @@ func dialog_send(pchan unsafe.Pointer, res C.intptr_t) { }() } -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 - } - 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)) - } +func _msgBox(parent *Window, primarytext string, secondarytext string, style uintptr) Response { + var pwin C.id = nil + + 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) + return OK + case 1: // error + C.msgBoxError(pwin, primary, secondary) + return OK } - return ret + panic(fmt.Errorf("unknown message box style %d\n", style)) } -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) msgBox(primarytext string, secondarytext string) { + _msgBox(w, primarytext, secondarytext, 0) } -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 +func (w *Window) msgBoxError(primarytext string, secondarytext string) { + _msgBox(w, primarytext, secondarytext, 1) } -- cgit v1.2.3