forked from wailsapp/wails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dialogs_linux.go
72 lines (61 loc) · 1.58 KB
/
dialogs_linux.go
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package application
func (m *linuxApp) showAboutDialog(title string, message string, icon []byte) {
window := globalApplication.getWindowForID(m.getCurrentWindowID())
var parent uintptr
if window != nil {
parent, _ = window.(*WebviewWindow).NativeWindowHandle()
}
about := newMessageDialog(InfoDialogType)
about.SetTitle(title).
SetMessage(message).
SetIcon(icon)
runQuestionDialog(
pointer(parent),
about,
)
}
type linuxDialog struct {
dialog *MessageDialog
}
func (m *linuxDialog) show() {
windowId := getNativeApplication().getCurrentWindowID()
window := globalApplication.getWindowForID(windowId)
var parent uintptr
if window != nil {
parent, _ = window.(*WebviewWindow).NativeWindowHandle()
}
response := runQuestionDialog(pointer(parent), m.dialog)
if response >= 0 && response < len(m.dialog.Buttons) {
button := m.dialog.Buttons[response]
if button.Callback != nil {
go button.Callback()
}
}
}
func newDialogImpl(d *MessageDialog) *linuxDialog {
return &linuxDialog{
dialog: d,
}
}
type linuxOpenFileDialog struct {
dialog *OpenFileDialogStruct
}
func newOpenFileDialogImpl(d *OpenFileDialogStruct) *linuxOpenFileDialog {
return &linuxOpenFileDialog{
dialog: d,
}
}
func (m *linuxOpenFileDialog) show() (chan string, error) {
return runOpenFileDialog(m.dialog)
}
type linuxSaveFileDialog struct {
dialog *SaveFileDialogStruct
}
func newSaveFileDialogImpl(d *SaveFileDialogStruct) *linuxSaveFileDialog {
return &linuxSaveFileDialog{
dialog: d,
}
}
func (m *linuxSaveFileDialog) show() (chan string, error) {
return runSaveFileDialog(m.dialog)
}