forked from kevin2li/PDF-Guru
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.go
69 lines (61 loc) · 1.41 KB
/
utils.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
package main
import (
"github.com/pkg/errors"
wails_runtime "github.com/wailsapp/wails/v2/pkg/runtime"
)
func (a *App) SelectFile() string {
d, err := wails_runtime.OpenFileDialog(a.ctx, wails_runtime.OpenDialogOptions{})
if err != nil {
logger.Errorln(err)
return ""
}
logger.Debugf("%v\n", d)
return d
}
func (a *App) SelectMultipleFiles() []string {
d, err := wails_runtime.OpenMultipleFilesDialog(a.ctx, wails_runtime.OpenDialogOptions{})
if err != nil {
logger.Errorln(err)
return nil
}
logger.Debugf("%v\n", d)
return d
}
func (a *App) SelectDir() string {
d, err := wails_runtime.OpenDirectoryDialog(a.ctx, wails_runtime.OpenDialogOptions{})
if err != nil {
logger.Errorln(err)
return ""
}
logger.Debugf("%v\n", d)
return d
}
func (a *App) SaveFile() string {
d, err := wails_runtime.SaveFileDialog(a.ctx, wails_runtime.SaveDialogOptions{})
if err != nil {
logger.Errorln(err)
return ""
}
logger.Debugf("%v\n", d)
return d
}
func (a *App) OpenUrl(url string) {
wails_runtime.BrowserOpenURL(a.ctx, url)
}
func (a *App) GetClipboard() string {
text, err := wails_runtime.ClipboardGetText(a.ctx)
if err != nil {
logger.Errorln(err)
return ""
}
return text
}
func (a *App) SetClipboard(content string) error {
err := wails_runtime.ClipboardSetText(a.ctx, content)
if err != nil {
logger.Errorln(err)
err = errors.Wrap(err, "set clipboard error")
return err
}
return nil
}