summaryrefslogtreecommitdiff
path: root/cmd/rescribe
diff options
context:
space:
mode:
authorNick White <git@njw.name>2021-12-20 14:17:37 +0000
committerNick White <git@njw.name>2021-12-20 14:17:37 +0000
commit7764cb2204f45dff66c97611a84faa41ed4ca206 (patch)
tree0bede7596478ff9419fb79bbbf369127ee3c50a3 /cmd/rescribe
parent59573b1fb8e5a47f924a636f0f46bd64ed19747e (diff)
rescribe: add "Choose PDF" button, and make chosen dir/file section a label rather than an entry
Diffstat (limited to 'cmd/rescribe')
-rw-r--r--cmd/rescribe/gui.go34
1 files changed, 21 insertions, 13 deletions
diff --git a/cmd/rescribe/gui.go b/cmd/rescribe/gui.go
index 36d9b3a..eb91a49 100644
--- a/cmd/rescribe/gui.go
+++ b/cmd/rescribe/gui.go
@@ -103,21 +103,27 @@ func startGui(log log.Logger, cmd string, training string, systess bool, tessdir
var gobtn *widget.Button
- dir := widget.NewEntry()
- dir.SetPlaceHolder("Folder to process")
- dir.OnChanged = func(s string) {
- // TODO: also check if string is a directory, and only enable if so
- if dir.Text != "" {
- gobtn.Enable()
- } else {
- gobtn.Disable()
- }
- }
+ dir := widget.NewLabel("")
- openbtn := widget.NewButtonWithIcon("Choose folder", theme.FolderOpenIcon(), func() {
+ dirIcon := widget.NewIcon(theme.FolderIcon())
+
+ folderBtn := widget.NewButtonWithIcon("Choose folder", theme.FolderOpenIcon(), func() {
dialog.ShowFolderOpen(func(uri fyne.ListableURI, err error) {
if err == nil && uri != nil {
dir.SetText(uri.Path())
+ dirIcon.SetResource(theme.FolderIcon())
+ gobtn.Enable()
+ }
+ }, myWindow)
+ })
+
+ pdfBtn := widget.NewButtonWithIcon("Choose PDF", theme.FileTextIcon(), func() {
+ dialog.ShowFileOpen(func(uri fyne.URIReadCloser, err error) {
+ if err == nil && uri != nil {
+ uri.Close()
+ dir.SetText(uri.URI().Path())
+ dirIcon.SetResource(theme.FileTextIcon())
+ gobtn.Enable()
}
}, myWindow)
})
@@ -187,9 +193,11 @@ func startGui(log log.Logger, cmd string, training string, systess bool, tessdir
})
gobtn.Disable()
- diropener := container.New(layout.NewGridLayout(2), dir, openbtn)
+ choices := container.New(layout.NewGridLayout(2), folderBtn, pdfBtn)
+
+ chosen := container.New(layout.NewBorderLayout(nil, nil, dirIcon, nil), dirIcon, dir)
- content := container.NewVBox(diropener, gobtn, progressBar, logarea)
+ content := container.NewVBox(choices, chosen, gobtn, progressBar, logarea)
myWindow.SetContent(content)