summaryrefslogtreecommitdiff
path: root/cmd/rescribe/gui.go
diff options
context:
space:
mode:
authorNick White <git@njw.name>2022-02-21 14:54:42 +0000
committerNick White <git@njw.name>2022-02-21 14:54:42 +0000
commit2c29e91bd98a1354d0cc4772ca629e3f1fc327b5 (patch)
tree12117de3210c795a4d407fb277f640221e327466 /cmd/rescribe/gui.go
parent69ac99da02988ad2ed675570ccaa5ff7777f0279 (diff)
rescribe: Add getgbook use to the GUI (not embedded yet)
Diffstat (limited to 'cmd/rescribe/gui.go')
-rw-r--r--cmd/rescribe/gui.go39
1 files changed, 30 insertions, 9 deletions
diff --git a/cmd/rescribe/gui.go b/cmd/rescribe/gui.go
index b8449b5..fde660a 100644
--- a/cmd/rescribe/gui.go
+++ b/cmd/rescribe/gui.go
@@ -26,6 +26,8 @@ import (
)
var progressPoints = map[float64]string{
+ 0.11: "Downloading",
+ 0.12: "Processing PDF",
0.2: "Preprocessing",
0.5: "OCRing",
0.9: "Analysing",
@@ -327,7 +329,7 @@ func startGui(log log.Logger, cmd string, training string, tessdir string) error
if dirEntry.Text == "" {
dirEntry.SetText(homeDir)
}
- dir.SetText(fmt.Sprintf("Google Book: %s Savedir: %s", id, dirEntry.Text))
+ dir.SetText(fmt.Sprintf("Google Book: %s Save to: %s", id, dirEntry.Text))
dirIcon.SetResource(theme.SearchIcon())
myWindow.SetContent(fullContent)
gobtn.Enable()
@@ -452,18 +454,37 @@ func startGui(log log.Logger, cmd string, training string, tessdir string) error
progressBar.SetValue(0.1)
- if strings.HasPrefix(dir.Text, "Google Book:") {
- // TODO
- dialog.ShowError(errors.New("Coming soon"), myWindow)
- progressBar.SetValue(0.0)
- for _, v := range []fyne.Disableable{folderBtn, pdfBtn, gbookBtn, trainingOpts, gobtn} {
- v.Enable()
+ if strings.HasPrefix(dir.Text, "Google Book: ") {
+ progressBar.SetValue(0.11)
+ start := len("Google Book: ")
+ bookname = dir.Text[start:start+12]
+
+ start = start + 12 + len(" Save to: ")
+ bookdir = dir.Text[start:]
+ savedir = bookdir
+
+ fmt.Printf("Downloading Google Book\n")
+ d, err := getGoogleBook(ctx, bookname, bookdir)
+ if err != nil {
+ if !strings.HasSuffix(err.Error(), "signal: killed") {
+ msg := fmt.Sprintf("Error downloading Google Book %s: %v\n", bookname, err)
+ dialog.ShowError(errors.New(msg), myWindow)
+ fmt.Fprintf(os.Stderr, msg)
+ }
+ progressBar.SetValue(0.0)
+ for _, v := range []fyne.Disableable{folderBtn, pdfBtn, gbookBtn, trainingOpts, gobtn} {
+ v.Enable()
+ }
+ abortbtn.Disable()
+ return
}
- abortbtn.Disable()
- return
+ bookdir = d
+ savedir = d
+ bookname = filepath.Base(d)
}
if strings.HasSuffix(dir.Text, ".pdf") && !f.IsDir() {
+ progressBar.SetValue(0.12)
bookdir, err = extractPdfImgs(ctx, bookdir)
if err != nil {
if !strings.HasSuffix(err.Error(), "context canceled") {