diff options
| author | Pietro Gagliardi <[email protected]> | 2014-07-02 17:13:40 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-07-02 17:13:40 -0400 |
| commit | 5d339e656b66d00356960ae057969532d34245b4 (patch) | |
| tree | 01f00932aba2a4b996603beeda788995e0f0a382 /prevlib/dialog_darwin.go | |
| parent | 2d7e168e6a350a0cfb52970fbf74c9e37834eaec (diff) | |
Moved everything out of the way pending rewrite.
Diffstat (limited to 'prevlib/dialog_darwin.go')
| -rw-r--r-- | prevlib/dialog_darwin.go | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/prevlib/dialog_darwin.go b/prevlib/dialog_darwin.go new file mode 100644 index 0000000..421e838 --- /dev/null +++ b/prevlib/dialog_darwin.go @@ -0,0 +1,49 @@ +// 2 march 2014 + +package ui + +import ( + "fmt" + "unsafe" +) + +// #include "objc_darwin.h" +import "C" + +//export dialog_send +func dialog_send(pchan unsafe.Pointer, res C.intptr_t) { + rchan := (*chan int)(pchan) + go func() { // send it in a new goroutine like we do with everything else + *rchan <- int(res) + }() +} + +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 + } + panic(fmt.Errorf("unknown message box style %d\n", style)) +} + +func (w *Window) msgBox(primarytext string, secondarytext string) { + _msgBox(w, primarytext, secondarytext, 0) +} + +func (w *Window) msgBoxError(primarytext string, secondarytext string) { + _msgBox(w, primarytext, secondarytext, 1) +} |
