diff --git a/build.bat b/build.bat deleted file mode 100644 index a1c11a9..0000000 --- a/build.bat +++ /dev/null @@ -1 +0,0 @@ -go build -ldflags="-H windowsgui" -o bin/cpms.exe main.go \ No newline at end of file diff --git a/build.sh b/build.sh deleted file mode 100644 index 83d06b3..0000000 --- a/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -GOOS=windows GOARCH=amd64 go build -o bin/cpms.exe main.go \ No newline at end of file diff --git a/cpms.exe b/cpms.exe new file mode 100644 index 0000000..0b32780 Binary files /dev/null and b/cpms.exe differ diff --git a/cpms.png b/cpms.png new file mode 100644 index 0000000..689b5d1 Binary files /dev/null and b/cpms.png differ diff --git a/main.go b/main.go index b6523af..023835c 100644 --- a/main.go +++ b/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)