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 (
|
|
|
|
// ...
|
|
|
|
)
|
|
|
|
|
|
|
|
// #cgo LDFLAGS: -lobjc -framework Foundation -framework AppKit
|
|
|
|
// #include "objc_darwin.h"
|
|
|
|
import "C"
|
|
|
|
|
2014-05-15 18:08:24 -05:00
|
|
|
func _msgBox(primarytext string, secondarytext string, style uintptr) {
|
2014-03-02 17:37:25 -06:00
|
|
|
ret := make(chan struct{})
|
|
|
|
defer close(ret)
|
|
|
|
uitask <- func() {
|
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 {
|
|
|
|
case 0: // normal
|
|
|
|
C.msgBox(primary, secondary)
|
|
|
|
case 1: // error
|
|
|
|
C.msgBoxError(primary, secondary)
|
2014-04-10 11:34:30 -05:00
|
|
|
}
|
2014-03-02 17:37:25 -06:00
|
|
|
ret <- struct{}{}
|
|
|
|
}
|
|
|
|
<-ret
|
|
|
|
}
|
|
|
|
|
2014-03-12 11:14:24 -05:00
|
|
|
func msgBox(primarytext string, secondarytext string) {
|
2014-05-15 18:08:24 -05:00
|
|
|
_msgBox(primarytext, secondarytext, 0)
|
2014-03-02 17:37:25 -06:00
|
|
|
}
|
|
|
|
|
2014-03-12 11:14:24 -05:00
|
|
|
func msgBoxError(primarytext string, secondarytext string) {
|
2014-05-15 18:08:24 -05:00
|
|
|
_msgBox(primarytext, secondarytext, 1)
|
2014-03-02 17:37:25 -06:00
|
|
|
}
|