forked from wailsapp/wails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
context_application_event.go
62 lines (51 loc) · 1.17 KB
/
context_application_event.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
package application
var blankApplicationEventContext = &ApplicationEventContext{}
const (
openedFiles = "openedFiles"
)
type ApplicationEventContext struct {
// contains filtered or unexported fields
data map[string]any
}
func (c ApplicationEventContext) OpenedFiles() []string {
files, ok := c.data[openedFiles]
if !ok {
return nil
}
result, ok := files.([]string)
if !ok {
return nil
}
return result
}
func (c ApplicationEventContext) setOpenedFiles(files []string) {
c.data[openedFiles] = files
}
func (c ApplicationEventContext) setIsDarkMode(mode bool) {
c.data["isDarkMode"] = mode
}
func (c ApplicationEventContext) getBool(key string) bool {
mode, ok := c.data[key]
if !ok {
return false
}
result, ok := mode.(bool)
if !ok {
return false
}
return result
}
func (c ApplicationEventContext) IsDarkMode() bool {
return c.getBool("isDarkMode")
}
func (c ApplicationEventContext) HasVisibleWindows() bool {
return c.getBool("hasVisibleWindows")
}
func (c ApplicationEventContext) setData(data map[string]any) {
c.data = data
}
func newApplicationEventContext() *ApplicationEventContext {
return &ApplicationEventContext{
data: make(map[string]any),
}
}