-
Notifications
You must be signed in to change notification settings - Fork 21
/
about.go
75 lines (65 loc) · 2.03 KB
/
about.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
package main
import (
"bufio"
"bytes"
"embed"
_ "embed"
"fmt"
"strings"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
)
//go:embed metadata
var metadata embed.FS
//go:embed LICENSE
var crocguiLicense string
//go:embed third-party-licenses.txt
var thirdPartyLicenses string
func aboutTabItem() *container.TabItem {
longdescbytes, _ := metadata.ReadFile(fmt.Sprintf("metadata/%s/full_description.txt", langCode))
longdesc := string(longdescbytes)
longdesc = strings.ReplaceAll(longdesc, "<b>", "")
longdesc = strings.ReplaceAll(longdesc, "</b>", "")
aboutInfo := widget.NewLabel(longdesc)
aboutInfo.Wrapping = fyne.TextWrapWord
acLicense := widget.NewAccordion()
licenseReader := bytes.NewBufferString(crocguiLicense + thirdPartyLicenses)
currentLicense := ""
currentLibrary := "croc"
scanner := bufio.NewScanner(licenseReader)
for scanner.Scan() {
line := scanner.Text()
if strings.HasPrefix(line, "-----") {
acLicense.Append(widget.NewAccordionItem(currentLibrary, widget.NewLabel(currentLicense)))
currentLicense = ""
scanner.Scan()
scanner.Scan()
currentLibrary = scanner.Text()
scanner.Scan()
continue
}
currentLicense += fmt.Sprintln(line)
}
// Add font licenses
fontEntries, _ := fsFonts.ReadDir("internal/fonts")
for _, fe := range fontEntries {
if fbase, remain, split := strings.Cut(fe.Name(), "-"); split && remain == "OFL.txt" {
bfontLicense, rerr := fsFonts.ReadFile(fmt.Sprintf("internal/fonts/%s", fe.Name()))
if rerr == nil {
strLicense := string(bfontLicense)
acLicense.Append(widget.NewAccordionItem(fmt.Sprintf("Font: %s", fbase), widget.NewLabel(strLicense)))
}
}
}
licenseToggle := widget.NewButton(lp("License Info"), func() {
w := fyne.CurrentApp().NewWindow(lp("License Info"))
w.SetContent(container.NewScroll(acLicense))
w.Resize(fyne.NewSize(450, 800))
w.Show()
})
return container.NewTabItemWithIcon(lp("About"), theme.InfoIcon(),
container.NewVScroll(container.NewVBox(aboutInfo, licenseToggle)),
)
}