-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathui.go
More file actions
82 lines (71 loc) · 2.09 KB
/
ui.go
File metadata and controls
82 lines (71 loc) · 2.09 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
package main
import (
"context"
"runtime"
"github.com/wailsapp/wails/v2/pkg/menu"
"github.com/wailsapp/wails/v2/pkg/menu/keys"
run "github.com/wailsapp/wails/v2/pkg/runtime"
)
func SetMenuItem(ctx context.Context, app *App) *menu.Menu {
AppMenu := menu.NewMenu()
FileMenu := AppMenu.AddSubmenu("File")
FileMenu.AddText("About", keys.CmdOrCtrl("a"), func(cd *menu.CallbackData) {
_, err := run.MessageDialog(ctx, run.MessageDialogOptions{
Type: run.InfoDialog,
Title: "Wallflex",
Message: "Get random wallpaper for your desktop. \n \n © 2024. Abiodun Azeez. \n All Right Reserved.",
DefaultButton: "No",
})
if err != nil {
println(err.Error())
}
})
FileMenu.AddSeparator()
FileMenu.AddText("Setting", keys.CmdOrCtrl("s"), func(cd *menu.CallbackData) {
run.EventsEmit(ctx, "shortcut.page.setting")
})
FileMenu.AddSeparator()
FileMenu.AddText("Quit", keys.CmdOrCtrl("q"), func(_ *menu.CallbackData) {
run.Quit(app.ctx)
})
if runtime.GOOS == "darwin" {
AppMenu.Append(menu.EditMenu()) // on macos platform, we should append EditMenu to enable Cmd+C,Cmd+V,Cmd+Z... shortcut
}
return AppMenu
}
func SettingPage(mn *menu.CallbackData) {
run.EventsOn(context.TODO(), "Hello world", func(optionalData ...interface{}) {
})
}
func OpenNativeDir(ctx context.Context) (string, error) {
return run.OpenDirectoryDialog(ctx, run.OpenDialogOptions{
DefaultDirectory: "",
Title: "Select directory",
Filters: []run.FileFilter{
{
DisplayName: "Images (*.png;*.jpg)",
Pattern: "*.png;*.jpg",
},
},
})
}
func OpenNativeSingleDir(ctx context.Context) (string, error) {
return run.OpenDirectoryDialog(ctx, run.OpenDialogOptions{
DefaultDirectory: "",
Title: "Select directory",
// Filters: []run.FileFilter{
// {
// DisplayName: "Images (*.png;*.jpg)",
// Pattern: "*.png;*.jpg",
// },
// },
})
}
func MessageBox(ctx context.Context, msg string) (string, error) {
return run.MessageDialog(ctx, run.MessageDialogOptions{
Title: "",
Message: msg,
Icon: nil,
Buttons: []string{"Ok"},
})
}