-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
options.go
121 lines (105 loc) · 2.57 KB
/
options.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package options
import (
"log"
"runtime"
wailsruntime "github.com/wailsapp/wails/v2/internal/runtime"
"github.com/wailsapp/wails/v2/pkg/menu"
"github.com/imdario/mergo"
"github.com/wailsapp/wails/v2/pkg/logger"
"github.com/wailsapp/wails/v2/pkg/options/mac"
)
// App contains options for creating the App
type App struct {
Title string
Width int
Height int
DisableResize bool
Fullscreen bool
MinWidth int
MinHeight int
MaxWidth int
MaxHeight int
StartHidden bool
HideWindowOnClose bool
DevTools bool
RGBA int
ContextMenus []*menu.ContextMenu
TrayMenus []*menu.TrayMenu
Menu *menu.Menu
Mac *mac.Options
Logger logger.Logger `json:"-"`
LogLevel logger.LogLevel
Startup func(*wailsruntime.Runtime) `json:"-"`
Shutdown func() `json:"-"`
Bind []interface{}
}
// MergeDefaults will set the minimum default values for an application
func MergeDefaults(appoptions *App) {
err := mergo.Merge(appoptions, Default)
if err != nil {
log.Fatal(err)
}
}
func GetTrayMenus(appoptions *App) []*menu.TrayMenu {
var result []*menu.TrayMenu
switch runtime.GOOS {
case "darwin":
if appoptions.Mac != nil {
result = appoptions.Mac.TrayMenus
}
//case "linux":
// if appoptions.Linux != nil {
// result = appoptions.Linux.TrayMenu
// }
//case "windows":
// if appoptions.Windows != nil {
// result = appoptions.Windows.TrayMenu
// }
}
if result == nil {
result = appoptions.TrayMenus
}
return result
}
func GetApplicationMenu(appoptions *App) *menu.Menu {
var result *menu.Menu
switch runtime.GOOS {
case "darwin":
if appoptions.Mac != nil {
result = appoptions.Mac.Menu
}
//case "linux":
// if appoptions.Linux != nil {
// result = appoptions.Linux.TrayMenu
// }
//case "windows":
// if appoptions.Windows != nil {
// result = appoptions.Windows.TrayMenu
// }
}
if result == nil {
result = appoptions.Menu
}
return result
}
func GetContextMenus(appoptions *App) []*menu.ContextMenu {
var result []*menu.ContextMenu
switch runtime.GOOS {
case "darwin":
if appoptions.Mac != nil {
result = appoptions.Mac.ContextMenus
}
//case "linux":
// if appoptions.Linux != nil {
// result = appoptions.Linux.TrayMenu
// }
//case "windows":
// if appoptions.Windows != nil {
// result = appoptions.Windows.TrayMenu
// }
}
if result == nil {
result = appoptions.ContextMenus
}
return result
}