summaryrefslogtreecommitdiff
path: root/cmd/rescribe
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/rescribe')
-rw-r--r--cmd/rescribe/gui.go81
-rw-r--r--cmd/rescribe/makefile4
-rw-r--r--cmd/rescribe/xyz.rescribe.rescribe.appdata.xml5
-rw-r--r--cmd/rescribe/xyz.rescribe.rescribe.yml11
4 files changed, 55 insertions, 46 deletions
diff --git a/cmd/rescribe/gui.go b/cmd/rescribe/gui.go
index 73f1db2..e4560df 100644
--- a/cmd/rescribe/gui.go
+++ b/cmd/rescribe/gui.go
@@ -265,9 +265,11 @@ func start(ctx context.Context, log *log.Logger, cmd string, tessdir string, gbo
}
go func() {
for r := range stdout {
- logarea.SetText(logarea.Text + string(r))
- logarea.CursorRow = strings.Count(logarea.Text, "\n")
- updateProgress(logarea.Text, progressBar)
+ fyne.Do(func() {
+ logarea.SetText(logarea.Text + string(r))
+ logarea.CursorRow = strings.Count(logarea.Text, "\n")
+ updateProgress(logarea.Text, progressBar)
+ })
}
}()
@@ -280,8 +282,10 @@ func start(ctx context.Context, log *log.Logger, cmd string, tessdir string, gbo
}
go func() {
for r := range stderr {
- logarea.SetText(logarea.Text + string(r))
- logarea.CursorRow = strings.Count(logarea.Text, "\n")
+ fyne.Do(func() {
+ logarea.SetText(logarea.Text + string(r))
+ logarea.CursorRow = strings.Count(logarea.Text, "\n")
+ })
}
}()
@@ -292,6 +296,7 @@ func start(ctx context.Context, log *log.Logger, cmd string, tessdir string, gbo
}
// letsGo starts the core process
+// this is started from a goroutine, so all fyne calls need wrapping in fyne.Do()
func letsGo(ctx context.Context, log *log.Logger, cmd string, tessdir string, gbookcmd string, dir string, training string, win fyne.Window, logarea *widget.Entry, progressBar *widget.ProgressBar, abortbtn *widget.Button, wipe bool, bigpdf bool, disableWidgets []fyne.Disableable) {
bookdir := dir
savedir := dir
@@ -300,38 +305,38 @@ func letsGo(ctx context.Context, log *log.Logger, cmd string, tessdir string, gb
f, err := os.Stat(bookdir)
if err != nil && !strings.HasPrefix(bookdir, "Google Book: ") {
msg := fmt.Sprintf("Error opening %s: %v", bookdir, err)
- dialog.ShowError(errors.New(msg), win)
+ fyne.Do(func() { dialog.ShowError(errors.New(msg), win) })
fmt.Fprintf(os.Stderr, msg)
- progressBar.SetValue(0.0)
+ fyne.Do(func() { progressBar.SetValue(0.0) })
for _, v := range disableWidgets {
- v.Enable()
+ fyne.Do(func() { v.Enable() })
}
- abortbtn.Disable()
+ fyne.Do(func() { abortbtn.Disable() })
return
}
for _, v := range disableWidgets {
- v.Disable()
+ fyne.Do(func() { v.Disable() })
}
- abortbtn.Enable()
+ fyne.Do(func() { abortbtn.Enable() })
- progressBar.SetValue(0.1)
+ fyne.Do(func() { progressBar.SetValue(0.1) })
if strings.HasPrefix(dir, "Google Book: ") {
if gbookcmd == "" {
msg := fmt.Sprintf("No getgbook found, can't download Google Book. Either set -gbookcmd on the command line, or use the official build which includes an embedded copy of getgbook.\n")
- dialog.ShowError(errors.New(msg), win)
+ fyne.Do(func() { dialog.ShowError(errors.New(msg), win) })
fmt.Fprintf(os.Stderr, msg)
- progressBar.SetValue(0.0)
+ fyne.Do(func() { progressBar.SetValue(0.0) })
for _, v := range disableWidgets {
- v.Enable()
+ fyne.Do(func() { v.Enable() })
}
- abortbtn.Disable()
+ fyne.Do(func() { abortbtn.Disable() })
return
}
- progressBar.SetValue(0.11)
+ fyne.Do(func() { progressBar.SetValue(0.11) })
start := len("Google Book: ")
bookname = dir[start : start+12]
@@ -344,14 +349,14 @@ func letsGo(ctx context.Context, log *log.Logger, cmd string, tessdir string, gb
if err != nil {
if !strings.HasSuffix(err.Error(), "signal: killed") {
msg := fmt.Sprintf("Error downloading Google Book %s\n", bookname)
- dialog.ShowError(errors.New(msg), win)
+ fyne.Do(func() { dialog.ShowError(errors.New(msg), win) })
fmt.Fprintf(os.Stderr, msg)
}
progressBar.SetValue(0.0)
for _, v := range disableWidgets {
- v.Enable()
+ fyne.Do(func() { v.Enable() })
}
- abortbtn.Disable()
+ fyne.Do(func() { abortbtn.Disable() })
return
}
bookdir = d
@@ -360,20 +365,20 @@ func letsGo(ctx context.Context, log *log.Logger, cmd string, tessdir string, gb
}
if strings.HasSuffix(dir, ".pdf") && !f.IsDir() {
- progressBar.SetValue(0.12)
+ fyne.Do(func() { progressBar.SetValue(0.12) })
bookdir, err = extractPdfImgs(ctx, bookdir)
if err != nil {
if !strings.HasSuffix(err.Error(), "context canceled") {
msg := fmt.Sprintf("Error opening PDF %s: %v\n", bookdir, err)
- dialog.ShowError(errors.New(msg), win)
+ fyne.Do(func() { dialog.ShowError(errors.New(msg), win) })
fmt.Fprintf(os.Stderr, msg)
}
- progressBar.SetValue(0.0)
+ fyne.Do(func() { progressBar.SetValue(0.0) })
for _, v := range disableWidgets {
- v.Enable()
+ fyne.Do(func() { v.Enable() })
}
- abortbtn.Disable()
+ fyne.Do(func() { abortbtn.Disable() })
return
}
@@ -381,14 +386,14 @@ func letsGo(ctx context.Context, log *log.Logger, cmd string, tessdir string, gb
// which will occur if we encounter an image we can't decode
if bookdir == "" {
msg := fmt.Sprintf("Error opening PDF\nThe format of this PDF is not supported, extract the images to .jpg manually into a\nfolder first, using a tool like the PDF image extractor at https://pdfcandy.com/extract-images.html.\n")
- dialog.ShowError(errors.New(msg), win)
+ fyne.Do(func() { dialog.ShowError(errors.New(msg), win) })
fmt.Fprintf(os.Stderr, msg)
- progressBar.SetValue(0.0)
+ fyne.Do(func() { progressBar.SetValue(0.0) })
for _, v := range disableWidgets {
- v.Enable()
+ fyne.Do(func() { v.Enable() })
}
- abortbtn.Disable()
+ fyne.Do(func() { abortbtn.Disable() })
return
}
@@ -404,7 +409,7 @@ func letsGo(ctx context.Context, log *log.Logger, cmd string, tessdir string, gb
err = startProcess(ctx, log, cmd, bookdir, bookname, training, savedir, tessdir, wipe, bigpdf)
if err != nil && strings.HasSuffix(err.Error(), "context canceled") {
- progressBar.SetValue(0.0)
+ fyne.Do(func() { progressBar.SetValue(0.0) })
return
}
if err != nil {
@@ -412,26 +417,26 @@ func letsGo(ctx context.Context, log *log.Logger, cmd string, tessdir string, gb
if strings.HasSuffix(err.Error(), "No images found") && strings.HasSuffix(dir, ".pdf") && !f.IsDir() {
msg = fmt.Sprintf("Error opening PDF\nNo images found in the PDF. Most likely the format of this PDF is not supported,\nextract the images to .jpg manually into a folder first, using a tool like\nthe PDF image extractor at https://pdfcandy.com/extract-images.html.\n")
}
- dialog.ShowError(errors.New(msg), win)
+ fyne.Do(func() { dialog.ShowError(errors.New(msg), win) })
fmt.Fprintf(os.Stderr, msg)
- progressBar.SetValue(0.0)
+ fyne.Do(func() { progressBar.SetValue(0.0) })
for _, v := range disableWidgets {
- v.Enable()
+ fyne.Do(func() { v.Enable() })
}
- abortbtn.Disable()
+ fyne.Do(func() { abortbtn.Disable() })
return
}
- progressBar.SetValue(1.0)
+ fyne.Do(func() { progressBar.SetValue(1.0) })
for _, v := range disableWidgets {
- v.Enable()
+ fyne.Do(func() { v.Enable() })
}
- abortbtn.Disable()
+ fyne.Do(func() { abortbtn.Disable() })
msg := fmt.Sprintf("OCR process finished successfully.\n\nYour completed files have been saved in:\n%s", savedir)
- dialog.ShowInformation("OCR Complete", msg, win)
+ fyne.Do(func() { dialog.ShowInformation("OCR Complete", msg, win) })
}
// startGui starts the gui process
diff --git a/cmd/rescribe/makefile b/cmd/rescribe/makefile
index bc177a4..ea500b9 100644
--- a/cmd/rescribe/makefile
+++ b/cmd/rescribe/makefile
@@ -20,7 +20,7 @@ OSXCROSSBIN=$(HOME)/src/osxcross/target/bin
EMBEDS=embed_darwin.go embed_darwin_amd64.go embed_darwin_arm64.go embed_linux.go embed_windows.go embed_other.go
GODEPS=gui.go main.go $(EMBEDS)
-VERSION=1.3.0
+VERSION=1.4.0
all: dist/linux/rescribe dist/linux/wayland/rescribe dist/darwin/rescribe.zip dist/windows/rescribe.exe
@@ -31,7 +31,7 @@ dist/linux/rescribe: $(GODEPS)
dist/linux/wayland/rescribe: $(GODEPS)
go generate
- mkdir -p dist/linux
+ mkdir -p dist/linux/wayland
GOOS=linux GOARCH=amd64 go build -tags embed,wayland -o $@ .
build/darwin_amd64/rescribe: $(GODEPS)
diff --git a/cmd/rescribe/xyz.rescribe.rescribe.appdata.xml b/cmd/rescribe/xyz.rescribe.rescribe.appdata.xml
index 987e975..9a343bd 100644
--- a/cmd/rescribe/xyz.rescribe.rescribe.appdata.xml
+++ b/cmd/rescribe/xyz.rescribe.rescribe.appdata.xml
@@ -42,6 +42,11 @@
</branding>
<releases>
+ <release version="1.4.0" date="2025-12-02" type="stable">
+ <description>
+ <p>Ensure directories of PNGs are always binarised (thanks Alex Turton), updated GUI library, updated flatpak version to use xdg desktop portals for sandboxed file access.</p>
+ </description>
+ </release>
<release version="1.3.0" date="2024-04-10" type="stable">
<description>
<p>Added support for PDFs with embedded rotated images, created new icon, added version number to MacOS and Windows builds, fixed possible crash on Windows caused by temporary jpegs not being closed before removal, fixed issue where an invalid PDF could be created in some cases, fixed issue with flatpak where not all trainings were available.</p>
diff --git a/cmd/rescribe/xyz.rescribe.rescribe.yml b/cmd/rescribe/xyz.rescribe.rescribe.yml
index e98ebb6..e477835 100644
--- a/cmd/rescribe/xyz.rescribe.rescribe.yml
+++ b/cmd/rescribe/xyz.rescribe.rescribe.yml
@@ -1,6 +1,6 @@
app-id: xyz.rescribe.rescribe
runtime: org.freedesktop.Platform
-runtime-version: '23.08'
+runtime-version: '25.08'
sdk: org.freedesktop.Sdk
sdk-extensions: org.freedesktop.Sdk.Extension.golang
build-options:
@@ -11,7 +11,6 @@ finish-args:
- --socket=wayland
- --device=dri # OpenGL
- --share=network # Used for google book downloading
- - --filesystem=home
command: rescribe
modules:
- name: rescribe
@@ -30,11 +29,11 @@ modules:
sources:
- type: git
url: https://github.com/rescribe/bookpipeline
- tag: v1.3.0
- commit: 6230fc2cf55e2e330caa44f534209c9fba35daa0
+ tag: v1.4.0
+ commit: f559f9e7c709afa6dabfcd54c0660fdc72585fcc
- type: archive
- url: https://rescribe.xyz/rescribe/modules-20240409-1a4506.tar.xz
- sha256: 0452ec822b9c807d9710ec34ed65169ec342039620f614d483cf91443e7cfc5e
+ url: https://rescribe.xyz/rescribe/modules-20251211-f559f9.tar.xz
+ sha256: ae736d34f11498829c7f0ee1874b2874db98de5bf99bf717620e8f91f36083ca
strip-components: 0
- type: file
url: https://rescribe.xyz/rescribe/embeds/tessdata.20220322.zip