-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.go
More file actions
147 lines (120 loc) · 3.13 KB
/
app.go
File metadata and controls
147 lines (120 loc) · 3.13 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
package main
import (
"context"
"github.com/wailsapp/wails/v2/pkg/runtime"
)
// App struct
type App struct {
ctx context.Context
manager *Manager
}
// NewApp creates a new App application struct
func NewApp() *App {
return &App{
manager: NewManager(),
}
}
// startup is called when the app starts. The context is saved
// so we can call the runtime methods
func (a *App) startup(ctx context.Context) {
a.ctx = ctx
}
// GetSupportedBrowsers returns the list of installed and supported browsers
func (a *App) GetSupportedBrowsers() []Browser {
return GetSupportedBrowsers()
}
// GetWebApps returns the list of installed web apps
func (a *App) GetWebApps() ([]WebApp, error) {
return a.manager.GetWebApps()
}
// CreateWebApp creates a new web app
// Note: We'll implement the actual logic in manager.go next
func (a *App) CreateWebApp(app WebApp) error {
return a.manager.CreateWebApp(app)
}
// EditWebApp edits an existing web app
func (a *App) EditWebApp(app WebApp) error {
return a.manager.EditWebApp(app)
}
// RunWebApp runs the web app
func (a *App) RunWebApp(app WebApp) error {
return a.manager.RunWebApp(app)
}
func (a *App) GetFavicons(url string) ([]string, error) {
return a.manager.GetFavicons(url)
}
// DeleteWebApp deletes a web app
func (a *App) DeleteWebApp(app WebApp) error {
return a.manager.DeleteWebApp(app)
}
func (a *App) GetPWAMetadata(url string) (PWAMetadata, error) {
return a.manager.GetPWAMetadata(url)
}
func (a *App) SelectIcon() (string, error) {
return runtime.OpenFileDialog(a.ctx, runtime.OpenDialogOptions{
Title: "Select Icon",
Filters: []runtime.FileFilter{
{
DisplayName: "Images",
Pattern: "*.png;*.jpg;*.jpeg;*.svg;*.ico;*.xpm",
},
},
})
}
func (a *App) ShowError(title, message string) {
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
Type: runtime.ErrorDialog,
Title: title,
Message: message,
})
}
func (a *App) ShowMessage(title, message string) {
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
Type: runtime.InfoDialog,
Title: title,
Message: message,
})
}
func (a *App) ShowQuestion(title, message string) (string, error) {
return runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
Type: runtime.QuestionDialog,
Title: title,
Message: message,
Buttons: []string{"Yes", "No"},
DefaultButton: "No",
CancelButton: "No",
})
}
// Window Controls
func (a *App) Quit() {
runtime.Quit(a.ctx)
}
func (a *App) WindowMinimise() {
runtime.WindowMinimise(a.ctx)
}
func (a *App) WindowMaximise() {
runtime.WindowMaximise(a.ctx)
}
func (a *App) WindowUnmaximise() {
runtime.WindowUnmaximise(a.ctx)
}
func (a *App) WindowClose() {
runtime.Quit(a.ctx)
}
func (a *App) WindowIsMaximised() bool {
return runtime.WindowIsMaximised(a.ctx)
}
func (a *App) WindowGetSize() (int, int) {
w, h := runtime.WindowGetSize(a.ctx)
return w, h
}
func (a *App) WindowSetSize(w, h int) {
runtime.WindowSetSize(a.ctx, w, h)
}
func (a *App) WindowGetPosition() (int, int) {
x, y := runtime.WindowGetPosition(a.ctx)
return x, y
}
func (a *App) WindowSetPosition(x, y int) {
runtime.WindowSetPosition(a.ctx, x, y)
}