2014-03-02 17:37:25 -06:00
|
|
|
// 2 march 2014
|
2014-03-12 20:55:45 -05:00
|
|
|
|
2014-03-02 17:37:25 -06:00
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
2014-06-08 11:36:55 -05:00
|
|
|
"unsafe"
|
2014-03-02 17:37:25 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
// #include "objc_darwin.h"
|
|
|
|
import "C"
|
|
|
|
|
2014-06-08 11:36:55 -05:00
|
|
|
//export dialog_send
|
|
|
|
func dialog_send(pchan unsafe.Pointer, res C.intptr_t) {
|
|
|
|
rchan := (*chan int)(pchan)
|
2014-06-10 13:49:54 -05:00
|
|
|
go func() { // send it in a new goroutine like we do with everything else
|
2014-06-08 11:36:55 -05:00
|
|
|
*rchan <- int(res)
|
|
|
|
}()
|
|
|
|
}
|
|
|
|
|
|
|
|
func _msgBox(parent *Window, primarytext string, secondarytext string, style uintptr) chan int {
|
|
|
|
ret := make(chan int)
|
2014-03-02 17:37:25 -06:00
|
|
|
uitask <- func() {
|
2014-06-04 23:53:26 -05:00
|
|
|
var pwin C.id = nil
|
|
|
|
|
2014-06-08 11:36:55 -05:00
|
|
|
if parent != dialogWindow {
|
2014-06-04 23:53:26 -05:00
|
|
|
pwin = parent.sysData.id
|
|
|
|
}
|
2014-05-15 18:08:24 -05:00
|
|
|
primary := toNSString(primarytext)
|
|
|
|
secondary := C.id(nil)
|
2014-04-10 11:34:30 -05:00
|
|
|
if secondarytext != "" {
|
2014-05-15 18:08:24 -05:00
|
|
|
secondary = toNSString(secondarytext)
|
|
|
|
}
|
|
|
|
switch style {
|
2014-06-10 13:49:54 -05:00
|
|
|
case 0: // normal
|
2014-06-08 11:36:55 -05:00
|
|
|
C.msgBox(pwin, primary, secondary, unsafe.Pointer(&ret))
|
2014-06-10 13:49:54 -05:00
|
|
|
case 1: // error
|
2014-06-08 11:36:55 -05:00
|
|
|
C.msgBoxError(pwin, primary, secondary, unsafe.Pointer(&ret))
|
2014-04-10 11:34:30 -05:00
|
|
|
}
|
2014-03-02 17:37:25 -06:00
|
|
|
}
|
2014-06-08 11:36:55 -05:00
|
|
|
return ret
|
2014-03-02 17:37:25 -06:00
|
|
|
}
|
|
|
|
|
2014-06-08 11:36:55 -05:00
|
|
|
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
|
2014-03-02 17:37:25 -06:00
|
|
|
}
|
|
|
|
|
2014-06-08 11:36:55 -05:00
|
|
|
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
|
2014-03-02 17:37:25 -06:00
|
|
|
}
|