fixes
This commit is contained in:
3
build.sh
3
build.sh
@@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
GOOS=windows GOARCH=amd64 go build -o bin/cpms.exe main.go
|
||||
92
main.go
92
main.go
@@ -11,6 +11,7 @@ import (
|
||||
"fyne.io/fyne/v2/app"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/dialog"
|
||||
"fyne.io/fyne/v2/storage"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"gopkg.in/yaml.v3"
|
||||
@@ -65,39 +66,73 @@ func main() {
|
||||
wp.Resize(fyne.NewSize(1024, 768))
|
||||
wp.CenterOnScreen()
|
||||
|
||||
grid := container.NewAdaptiveGrid(4)
|
||||
grid := container.NewVBox()
|
||||
scroll := container.NewVScroll(grid)
|
||||
scroll.SetMinSize(fyne.NewSize(-1, 768))
|
||||
|
||||
//load grid
|
||||
fillGrid(grid, wp)
|
||||
|
||||
profilesrootentry := widget.NewEntry()
|
||||
profilesrootentry.Text = cfg.ProfilesRoot
|
||||
archiverootentry := widget.NewEntry()
|
||||
archiverootentry.Text = cfg.ArchiveRoot
|
||||
profilesrootentry.SetText(cfg.ProfilesRoot)
|
||||
profilesrootentry.Disable()
|
||||
|
||||
container := container.NewBorder(nil, nil, nil, nil,
|
||||
widget.NewButtonWithIcon("", ap.Settings().Theme().Icon(theme.IconNameSettings), func() {
|
||||
dialog.NewForm("Settings", "Confirm", "Cancel", []*widget.FormItem{
|
||||
widget.NewFormItem("Profiles Root Folder", profilesrootentry),
|
||||
widget.NewFormItem("Archive Root Folder", archiverootentry),
|
||||
}, func(b bool) {
|
||||
if b {
|
||||
cfg.ArchiveRoot = archiverootentry.Text
|
||||
cfg.ProfilesRoot = profilesrootentry.Text
|
||||
saveConfig(*cfg)
|
||||
fillGrid(grid, wp)
|
||||
} else {
|
||||
cfg.ArchiveRoot = archiverootentry.Text
|
||||
cfg.ProfilesRoot = profilesrootentry.Text
|
||||
fillGrid(grid, wp)
|
||||
archiverootentry := widget.NewEntry()
|
||||
archiverootentry.SetText(cfg.ArchiveRoot)
|
||||
archiverootentry.Disable()
|
||||
|
||||
container := container.NewVBox(
|
||||
widget.NewForm(widget.NewFormItem("Profiles Directory", profilesrootentry)),
|
||||
widget.NewButtonWithIcon("Select", theme.FolderIcon(), func() {
|
||||
d := dialog.NewFolderOpen(func(lu fyne.ListableURI, err error) {
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}, wp).Show()
|
||||
if lu == nil {
|
||||
return
|
||||
}
|
||||
profilesrootentry.SetText(lu.Path())
|
||||
cfg.ProfilesRoot = lu.Path()
|
||||
saveConfig(*cfg)
|
||||
fillGrid(grid, wp)
|
||||
}, wp)
|
||||
l, err := storage.ListerForURI(storage.NewFileURI("."))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
if l != nil {
|
||||
d.SetLocation(l)
|
||||
}
|
||||
d.Show()
|
||||
}),
|
||||
widget.NewButton("Reload", func() {
|
||||
//reload grid
|
||||
widget.NewForm(widget.NewFormItem("Archive Directory", archiverootentry)),
|
||||
widget.NewButtonWithIcon("Select", theme.FolderIcon(), func() {
|
||||
d := dialog.NewFolderOpen(func(lu fyne.ListableURI, err error) {
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
if lu == nil {
|
||||
return
|
||||
}
|
||||
archiverootentry.SetText(lu.Path())
|
||||
cfg.ArchiveRoot = lu.Path()
|
||||
saveConfig(*cfg)
|
||||
fillGrid(grid, wp)
|
||||
}, wp)
|
||||
l, err := storage.ListerForURI(storage.NewFileURI("."))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
if l != nil {
|
||||
d.SetLocation(l)
|
||||
}
|
||||
d.Show()
|
||||
}),
|
||||
widget.NewSeparator(),
|
||||
widget.NewButton("Reload Profiles", func() {
|
||||
fillGrid(grid, wp)
|
||||
}),
|
||||
container.NewHScroll(grid),
|
||||
scroll,
|
||||
)
|
||||
wp.SetContent(container)
|
||||
wp.ShowAndRun()
|
||||
@@ -121,14 +156,25 @@ func scanProfiles(profilesroot string) []string {
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func makeIFunc(profile, archive string, parent fyne.Window) func() {
|
||||
return func() {
|
||||
if cfg.ArchiveRoot == "" || cfg.ProfilesRoot == "" {
|
||||
d := dialog.NewInformation("Notice", "you must select a archive root and profiles root before", parent)
|
||||
d.Show()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
dialog.NewConfirm("Are You Sure?", fmt.Sprintf("the current contents of %s will be lost", archive), func(b bool) {
|
||||
if b {
|
||||
err := walk(archive, func(path string, info fs.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.Remove(path)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
|
||||
Reference in New Issue
Block a user