summaryrefslogtreecommitdiff
path: root/dialog_darwin.go
blob: ef1cd6cfdc0a9139c2019f6d0336c36466629f11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// 2 march 2014

package ui

import (
	// ...
)

// #include "objc_darwin.h"
import "C"

func _msgBox(parent *Window, primarytext string, secondarytext string, style uintptr) {
	ret := make(chan struct{})
	defer close(ret)
	uitask <- func() {
		var pwin C.id = nil

		if parent != nil {
			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)
		case 1:		// error
			C.msgBoxError(pwin, primary, secondary)
		}
		ret <- struct{}{}
	}
	<-ret
}

func msgBox(parent *Window, primarytext string, secondarytext string) {
	_msgBox(parent, primarytext, secondarytext, 0)
}

func msgBoxError(parent *Window, primarytext string, secondarytext string) {
	_msgBox(parent, primarytext, secondarytext, 1)
}