summaryrefslogtreecommitdiff
path: root/cmd/rescribe/gui.go
diff options
context:
space:
mode:
authorNick White <git@njw.name>2022-01-04 13:28:45 +0000
committerNick White <git@njw.name>2022-01-04 13:28:45 +0000
commitae44599a6af801e25d2ea64155df044c19d063db (patch)
tree6c0cda9348f526006b77330f2ebf282ba528b622 /cmd/rescribe/gui.go
parentddde021837f978a74f57cb988c5cd80bd4fe8f70 (diff)
rescribe: Restrict file types to select for .pdf and .traineddata file pickers
Diffstat (limited to 'cmd/rescribe/gui.go')
-rw-r--r--cmd/rescribe/gui.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/cmd/rescribe/gui.go b/cmd/rescribe/gui.go
index 2fed6e2..8458230 100644
--- a/cmd/rescribe/gui.go
+++ b/cmd/rescribe/gui.go
@@ -18,6 +18,7 @@ import (
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/layout"
+ "fyne.io/fyne/v2/storage"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
)
@@ -106,7 +107,7 @@ func trainingSelectOnChange(sel *widget.Select, parent fyne.Window) func(string)
if str != "Other..." {
return
}
- dialog.ShowFileOpen(func(uri fyne.URIReadCloser, err error) {
+ d := dialog.NewFileOpen(func(uri fyne.URIReadCloser, err error) {
if err != nil || uri == nil {
return
}
@@ -130,6 +131,8 @@ func trainingSelectOnChange(sel *widget.Select, parent fyne.Window) func(string)
sel.Options = opts
sel.SetSelectedIndex(0)
}, parent)
+ d.SetFilter(storage.NewExtensionFileFilter([]string{".traineddata"}))
+ d.Show()
}
}
@@ -181,7 +184,7 @@ func startGui(log log.Logger, cmd string, training string, tessdir string) error
})
pdfBtn := widget.NewButtonWithIcon("Choose PDF", theme.DocumentIcon(), func() {
- dialog.ShowFileOpen(func(uri fyne.URIReadCloser, err error) {
+ d := dialog.NewFileOpen(func(uri fyne.URIReadCloser, err error) {
if err == nil && uri != nil {
uri.Close()
dir.SetText(uri.URI().Path())
@@ -190,6 +193,8 @@ func startGui(log log.Logger, cmd string, training string, tessdir string) error
gobtn.Enable()
}
}, myWindow)
+ d.SetFilter(storage.NewExtensionFileFilter([]string{".pdf"}))
+ d.Show()
})
gbookBtn := widget.NewButtonWithIcon("Get Google Book", theme.SearchIcon(), func() {