-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
92 lines (77 loc) · 2.1 KB
/
main.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
package main
import (
"embed"
"fmt"
"runtime"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/menu"
"github.com/wailsapp/wails/v2/pkg/menu/keys"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
"github.com/wailsapp/wails/v2/pkg/options/mac"
wailsconfigstore "github.com/AndreiTelteu/wails-configstore"
)
//go:embed all:frontend/dist
var assets embed.FS
//go:embed build/appicon.png
var icon []byte
func main() {
// Create an instance of the app structure
app := NewApp()
configStore, err := wailsconfigstore.NewConfigStore("PhotoImporter")
if err != nil {
fmt.Printf("could not initialize the config store: %v\n", err)
return
}
isMacOS := runtime.GOOS == "darwin"
customMenu := menu.NewMenu()
fileMenu := customMenu.AddSubmenu("File")
fileMenu.AddText("Import", keys.CmdOrCtrl("i"), func(_ *menu.CallbackData) {
app.importSelected()
})
fileMenu.AddText("Clear Cache", keys.CmdOrCtrl("c"), func(_ *menu.CallbackData) {
app.ClearCache()
})
customMenu.Append(menu.EditMenu())
selectMenu := customMenu.AddSubmenu("Select")
selectMenu.AddText("Select All", keys.CmdOrCtrl("a"), func(_ *menu.CallbackData) {
app.selectAll()
})
selectMenu.AddText("Select None", keys.CmdOrCtrl("d"), func(_ *menu.CallbackData) {
app.selectNone()
})
selectMenu.AddText("Invert", keys.CmdOrCtrl("i"), func(_ *menu.CallbackData) {
app.invert()
})
customMenu.Append(menu.WindowMenu())
if isMacOS {
customMenu.Prepend(menu.AppMenu())
}
// Create application with options
err = wails.Run(&options.App{
Title: "Photo Importer",
Width: 1024,
Height: 768,
AssetServer: &assetserver.Options{
Assets: assets,
},
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
OnStartup: app.startup,
OnShutdown: app.shutdown,
Menu: customMenu,
Bind: []interface{}{
app,
configStore,
},
Mac: &mac.Options{
About: &mac.AboutInfo{
Title: APP_NAME,
Message: "A modern photo importer application.",
Icon: icon,
},
},
})
if err != nil {
println("Error:", err.Error())
}
}