summaryrefslogtreecommitdiff
path: root/dialog_darwin.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-07-02 22:53:03 -0400
committerPietro Gagliardi <[email protected]>2014-07-02 22:53:03 -0400
commit8a81650b3da7ce00725336df9e03b38e935c5a65 (patch)
tree08af843f0460e7226f305cf7162021ef54e8c3f7 /dialog_darwin.go
parent4dd5ceb11d62bd6b9af4847936314a9d8c45707f (diff)
Moved it all back; the preemptive multitaksing during an event handler kills us on all platforms. Going to have to restrict ALL GUI accss to happening from one t hread, so going to need to drop uitask entirely and have just a start() callback for startup code and a post() function for posting requests to windows (like channel sends but into a perpetual buffer).
Diffstat (limited to 'dialog_darwin.go')
-rw-r--r--dialog_darwin.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/dialog_darwin.go b/dialog_darwin.go
new file mode 100644
index 0000000..421e838
--- /dev/null
+++ b/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)
+}