From ee0a305972fa6482313589e75ac676f63d4649bd Mon Sep 17 00:00:00 2001 From: Leonid Nikitin Date: Sat, 10 Feb 2024 20:11:26 +0600 Subject: [PATCH 1/4] I made sure that the current folder was saved. --- src/convertor/view.go | 21 +++++++++++++++++++-- src/convertor/view_setting.go | 18 ++++++++++++++++-- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/convertor/view.go b/src/convertor/view.go index 0ef751f..7a18160 100644 --- a/src/convertor/view.go +++ b/src/convertor/view.go @@ -6,11 +6,13 @@ import ( "fyne.io/fyne/v2/canvas" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/dialog" + "fyne.io/fyne/v2/storage" "fyne.io/fyne/v2/widget" "git.kor-elf.net/kor-elf/gui-for-ffmpeg/src/helper" "git.kor-elf.net/kor-elf/gui-for-ffmpeg/src/localizer" "github.com/nicksnyder/go-i18n/v2/i18n" "image/color" + "path/filepath" ) type ViewContract interface { @@ -78,14 +80,14 @@ func (v View) Main( Widget: fileVideoForConversion, }, { - Widget: fileVideoForConversionMessage, + Widget: container.NewHScroll(fileVideoForConversionMessage), }, { Text: v.localizerService.GetMessage(&i18n.LocalizeConfig{MessageID: "buttonForSelectedDirTitle"}), Widget: buttonForSelectedDir, }, { - Widget: buttonForSelectedDirMessage, + Widget: container.NewHScroll(buttonForSelectedDirMessage), }, { Widget: checkboxOverwriteOutputFiles, @@ -147,6 +149,8 @@ func (v View) getButtonFileVideoForConversion(form *widget.Form, progress *widge MessageID: "choose", }) + var locationURI fyne.ListableURI + button := widget.NewButton(buttonTitle, func() { fileDialog := dialog.NewFileOpen( func(r fyne.URIReadCloser, err error) { @@ -170,9 +174,15 @@ func (v View) getButtonFileVideoForConversion(form *widget.Form, progress *widge progress.Value = 0 progress.Refresh() conversionMessage.Text = "" + + listableURI := storage.NewFileURI(filepath.Dir(r.URI().Path())) + locationURI, err = storage.ListerForURI(listableURI) }, v.w) helper.FileDialogResize(fileDialog, v.w) fileDialog.Show() + if locationURI != nil { + fileDialog.SetLocation(locationURI) + } }) return button, fileVideoForConversionMessage, fileInput @@ -190,6 +200,8 @@ func (v View) getButtonForSelectingDirectoryForSaving() (button *widget.Button, MessageID: "choose", }) + var locationURI fyne.ListableURI + button = widget.NewButton(buttonTitle, func() { fileDialog := dialog.NewFolderOpen( func(r fyne.ListableURI, err error) { @@ -206,9 +218,14 @@ func (v View) getButtonForSelectingDirectoryForSaving() (button *widget.Button, buttonMessage.Text = r.Path() setStringSuccessStyle(buttonMessage) + locationURI, _ = storage.ListerForURI(r) + }, v.w) helper.FileDialogResize(fileDialog, v.w) fileDialog.Show() + if locationURI != nil { + fileDialog.SetLocation(locationURI) + } }) return diff --git a/src/convertor/view_setting.go b/src/convertor/view_setting.go index 813c8ea..c09acba 100644 --- a/src/convertor/view_setting.go +++ b/src/convertor/view_setting.go @@ -5,11 +5,13 @@ import ( "fyne.io/fyne/v2/canvas" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/dialog" + "fyne.io/fyne/v2/storage" "fyne.io/fyne/v2/widget" "git.kor-elf.net/kor-elf/gui-for-ffmpeg/src/helper" "github.com/nicksnyder/go-i18n/v2/i18n" "image/color" "net/url" + "path/filepath" ) func (v View) SelectFFPath( @@ -47,7 +49,7 @@ func (v View) SelectFFPath( Widget: buttonFFmpeg, }, { - Widget: buttonFFmpegMessage, + Widget: container.NewHScroll(buttonFFmpegMessage), }, { Text: v.localizerService.GetMessage(&i18n.LocalizeConfig{ @@ -56,7 +58,7 @@ func (v View) SelectFFPath( Widget: buttonFFprobe, }, { - Widget: buttonFFprobeMessage, + Widget: container.NewHScroll(buttonFFprobeMessage), }, { Widget: errorMessage, @@ -99,6 +101,12 @@ func (v View) getButtonSelectFile(path string) (filePath *string, button *widget MessageID: "choose", }) + var locationURI fyne.ListableURI + if len(path) > 0 { + listableURI := storage.NewFileURI(filepath.Dir(path)) + locationURI, _ = storage.ListerForURI(listableURI) + } + button = widget.NewButton(buttonTitle, func() { fileDialog := dialog.NewFileOpen( func(r fyne.URIReadCloser, err error) { @@ -115,9 +123,15 @@ func (v View) getButtonSelectFile(path string) (filePath *string, button *widget buttonMessage.Text = r.URI().Path() setStringSuccessStyle(buttonMessage) + + listableURI := storage.NewFileURI(filepath.Dir(r.URI().Path())) + locationURI, _ = storage.ListerForURI(listableURI) }, v.w) helper.FileDialogResize(fileDialog, v.w) fileDialog.Show() + if locationURI != nil { + fileDialog.SetLocation(locationURI) + } }) return -- 2.45.2 From 48f8c577c0f3a0a83ce3557216894f6a59cf30cc Mon Sep 17 00:00:00 2001 From: Leonid Nikitin Date: Sat, 10 Feb 2024 20:13:17 +0600 Subject: [PATCH 2/4] Fixed a buffer overflow error when converting videos when the video is more than 2 hours long. --- src/handler/convertor.go | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/handler/convertor.go b/src/handler/convertor.go index db2f7e2..e878665 100644 --- a/src/handler/convertor.go +++ b/src/handler/convertor.go @@ -178,19 +178,30 @@ func (p Progress) Run(stdOut io.ReadCloser, stdErr io.ReadCloser) error { progress := 0.0 go func() { - scannerErr := bufio.NewScanner(stdErr) - for scannerErr.Scan() { - errorText = scannerErr.Text() - } - if err := scannerErr.Err(); err != nil { - errorText = err.Error() + scannerErr := bufio.NewReader(stdErr) + for { + line, _, err := scannerErr.ReadLine() + if err != nil { + if err == io.EOF { + break + } + continue + } + data := strings.TrimSpace(string(line)) + errorText = data } }() - scannerOut := bufio.NewScanner(stdOut) - for scannerOut.Scan() { - data := scannerOut.Text() - + scannerOut := bufio.NewReader(stdOut) + for { + line, _, err := scannerOut.ReadLine() + if err != nil { + if err == io.EOF { + break + } + continue + } + data := strings.TrimSpace(string(line)) if strings.Contains(data, "progress=end") { p.progressbar.Value = p.totalDuration p.progressbar.Refresh() -- 2.45.2 From a617635911e30e25211cca562992f25d836db95b Mon Sep 17 00:00:00 2001 From: Leonid Nikitin Date: Sat, 10 Feb 2024 20:23:41 +0600 Subject: [PATCH 3/4] Changed the version to 0.3.1. --- src/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.go b/src/main.go index ed4ce92..f992a23 100644 --- a/src/main.go +++ b/src/main.go @@ -20,7 +20,7 @@ import ( "os" ) -const appVersion string = "0.3.0" +const appVersion string = "0.3.1" func main() { a := app.New() -- 2.45.2 From 154cd1c7ddf2769f9d1357d42a81e09905ae0b1c Mon Sep 17 00:00:00 2001 From: Leonid Nikitin Date: Sat, 10 Feb 2024 20:32:29 +0600 Subject: [PATCH 4/4] Fixed convertor_windows.go. Changed "git.kor-elf.net/kor-elf/gui-for-ffmpeg/convertor" to "git.kor-elf.net/kor-elf/gui-for-ffmpeg/src/convertor". --- src/handler/convertor_windows.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handler/convertor_windows.go b/src/handler/convertor_windows.go index 3453a40..79732c5 100644 --- a/src/handler/convertor_windows.go +++ b/src/handler/convertor_windows.go @@ -8,7 +8,7 @@ import ( "errors" "fyne.io/fyne/v2/canvas" "fyne.io/fyne/v2/widget" - "git.kor-elf.net/kor-elf/gui-for-ffmpeg/convertor" + "git.kor-elf.net/kor-elf/gui-for-ffmpeg/src/convertor" "github.com/nicksnyder/go-i18n/v2/i18n" "io" "net/http" -- 2.45.2