-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
49 lines (41 loc) · 905 Bytes
/
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
//go:generate fyne bundle -o data.go img/Icon.png
package main
import (
"os"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/data/binding"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/storage"
)
func main() {
a := app.New()
a.SetIcon(resourceIconPng)
w := a.NewWindow("TextEdit")
edit := &textEdit{window: w, changed: binding.NewBool()}
ui := edit.makeUI()
w.SetContent(ui)
edit.changed.AddListener(binding.NewDataListener(func() {
edited, _ := edit.changed.Get()
if edited {
w.SetTitle("TextEdit *")
} else {
w.SetTitle("TextEdit")
}
}))
if len(os.Args) > 1 {
file := storage.NewFileURI(os.Args[1])
read, err := storage.Reader(file)
if err != nil {
dialog.ShowError(err, w)
} else {
err = edit.load(read)
if err != nil {
dialog.ShowError(err, w)
}
}
}
w.Canvas().Focus(edit.entry)
w.Resize(fyne.NewSize(480, 360))
w.ShowAndRun()
}