Compare commits

..

No commits in common. "359db74251ae7fb5d0fcb17d69de078326dd5231" and "3dc59344cb9a6b5b0e0a615149b9a2b89b8ccd40" have entirely different histories.

5 changed files with 16 additions and 58 deletions

View File

@ -6,13 +6,11 @@ import (
"fyne.io/fyne/v2/canvas" "fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container" "fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/dialog" "fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/storage"
"fyne.io/fyne/v2/widget" "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/helper"
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/src/localizer" "git.kor-elf.net/kor-elf/gui-for-ffmpeg/src/localizer"
"github.com/nicksnyder/go-i18n/v2/i18n" "github.com/nicksnyder/go-i18n/v2/i18n"
"image/color" "image/color"
"path/filepath"
) )
type ViewContract interface { type ViewContract interface {
@ -80,14 +78,14 @@ func (v View) Main(
Widget: fileVideoForConversion, Widget: fileVideoForConversion,
}, },
{ {
Widget: container.NewHScroll(fileVideoForConversionMessage), Widget: fileVideoForConversionMessage,
}, },
{ {
Text: v.localizerService.GetMessage(&i18n.LocalizeConfig{MessageID: "buttonForSelectedDirTitle"}), Text: v.localizerService.GetMessage(&i18n.LocalizeConfig{MessageID: "buttonForSelectedDirTitle"}),
Widget: buttonForSelectedDir, Widget: buttonForSelectedDir,
}, },
{ {
Widget: container.NewHScroll(buttonForSelectedDirMessage), Widget: buttonForSelectedDirMessage,
}, },
{ {
Widget: checkboxOverwriteOutputFiles, Widget: checkboxOverwriteOutputFiles,
@ -149,8 +147,6 @@ func (v View) getButtonFileVideoForConversion(form *widget.Form, progress *widge
MessageID: "choose", MessageID: "choose",
}) })
var locationURI fyne.ListableURI
button := widget.NewButton(buttonTitle, func() { button := widget.NewButton(buttonTitle, func() {
fileDialog := dialog.NewFileOpen( fileDialog := dialog.NewFileOpen(
func(r fyne.URIReadCloser, err error) { func(r fyne.URIReadCloser, err error) {
@ -174,15 +170,9 @@ func (v View) getButtonFileVideoForConversion(form *widget.Form, progress *widge
progress.Value = 0 progress.Value = 0
progress.Refresh() progress.Refresh()
conversionMessage.Text = "" conversionMessage.Text = ""
listableURI := storage.NewFileURI(filepath.Dir(r.URI().Path()))
locationURI, err = storage.ListerForURI(listableURI)
}, v.w) }, v.w)
helper.FileDialogResize(fileDialog, v.w) helper.FileDialogResize(fileDialog, v.w)
fileDialog.Show() fileDialog.Show()
if locationURI != nil {
fileDialog.SetLocation(locationURI)
}
}) })
return button, fileVideoForConversionMessage, fileInput return button, fileVideoForConversionMessage, fileInput
@ -200,8 +190,6 @@ func (v View) getButtonForSelectingDirectoryForSaving() (button *widget.Button,
MessageID: "choose", MessageID: "choose",
}) })
var locationURI fyne.ListableURI
button = widget.NewButton(buttonTitle, func() { button = widget.NewButton(buttonTitle, func() {
fileDialog := dialog.NewFolderOpen( fileDialog := dialog.NewFolderOpen(
func(r fyne.ListableURI, err error) { func(r fyne.ListableURI, err error) {
@ -218,14 +206,9 @@ func (v View) getButtonForSelectingDirectoryForSaving() (button *widget.Button,
buttonMessage.Text = r.Path() buttonMessage.Text = r.Path()
setStringSuccessStyle(buttonMessage) setStringSuccessStyle(buttonMessage)
locationURI, _ = storage.ListerForURI(r)
}, v.w) }, v.w)
helper.FileDialogResize(fileDialog, v.w) helper.FileDialogResize(fileDialog, v.w)
fileDialog.Show() fileDialog.Show()
if locationURI != nil {
fileDialog.SetLocation(locationURI)
}
}) })
return return

View File

@ -5,13 +5,11 @@ import (
"fyne.io/fyne/v2/canvas" "fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container" "fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/dialog" "fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/storage"
"fyne.io/fyne/v2/widget" "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/helper"
"github.com/nicksnyder/go-i18n/v2/i18n" "github.com/nicksnyder/go-i18n/v2/i18n"
"image/color" "image/color"
"net/url" "net/url"
"path/filepath"
) )
func (v View) SelectFFPath( func (v View) SelectFFPath(
@ -49,7 +47,7 @@ func (v View) SelectFFPath(
Widget: buttonFFmpeg, Widget: buttonFFmpeg,
}, },
{ {
Widget: container.NewHScroll(buttonFFmpegMessage), Widget: buttonFFmpegMessage,
}, },
{ {
Text: v.localizerService.GetMessage(&i18n.LocalizeConfig{ Text: v.localizerService.GetMessage(&i18n.LocalizeConfig{
@ -58,7 +56,7 @@ func (v View) SelectFFPath(
Widget: buttonFFprobe, Widget: buttonFFprobe,
}, },
{ {
Widget: container.NewHScroll(buttonFFprobeMessage), Widget: buttonFFprobeMessage,
}, },
{ {
Widget: errorMessage, Widget: errorMessage,
@ -101,12 +99,6 @@ func (v View) getButtonSelectFile(path string) (filePath *string, button *widget
MessageID: "choose", 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() { button = widget.NewButton(buttonTitle, func() {
fileDialog := dialog.NewFileOpen( fileDialog := dialog.NewFileOpen(
func(r fyne.URIReadCloser, err error) { func(r fyne.URIReadCloser, err error) {
@ -123,15 +115,9 @@ func (v View) getButtonSelectFile(path string) (filePath *string, button *widget
buttonMessage.Text = r.URI().Path() buttonMessage.Text = r.URI().Path()
setStringSuccessStyle(buttonMessage) setStringSuccessStyle(buttonMessage)
listableURI := storage.NewFileURI(filepath.Dir(r.URI().Path()))
locationURI, _ = storage.ListerForURI(listableURI)
}, v.w) }, v.w)
helper.FileDialogResize(fileDialog, v.w) helper.FileDialogResize(fileDialog, v.w)
fileDialog.Show() fileDialog.Show()
if locationURI != nil {
fileDialog.SetLocation(locationURI)
}
}) })
return return

View File

@ -178,30 +178,19 @@ func (p Progress) Run(stdOut io.ReadCloser, stdErr io.ReadCloser) error {
progress := 0.0 progress := 0.0
go func() { go func() {
scannerErr := bufio.NewReader(stdErr) scannerErr := bufio.NewScanner(stdErr)
for { for scannerErr.Scan() {
line, _, err := scannerErr.ReadLine() errorText = scannerErr.Text()
if err != nil { }
if err == io.EOF { if err := scannerErr.Err(); err != nil {
break errorText = err.Error()
}
continue
}
data := strings.TrimSpace(string(line))
errorText = data
} }
}() }()
scannerOut := bufio.NewReader(stdOut) scannerOut := bufio.NewScanner(stdOut)
for { for scannerOut.Scan() {
line, _, err := scannerOut.ReadLine() data := scannerOut.Text()
if err != nil {
if err == io.EOF {
break
}
continue
}
data := strings.TrimSpace(string(line))
if strings.Contains(data, "progress=end") { if strings.Contains(data, "progress=end") {
p.progressbar.Value = p.totalDuration p.progressbar.Value = p.totalDuration
p.progressbar.Refresh() p.progressbar.Refresh()

View File

@ -8,7 +8,7 @@ import (
"errors" "errors"
"fyne.io/fyne/v2/canvas" "fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/widget" "fyne.io/fyne/v2/widget"
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/src/convertor" "git.kor-elf.net/kor-elf/gui-for-ffmpeg/convertor"
"github.com/nicksnyder/go-i18n/v2/i18n" "github.com/nicksnyder/go-i18n/v2/i18n"
"io" "io"
"net/http" "net/http"

View File

@ -20,7 +20,7 @@ import (
"os" "os"
) )
const appVersion string = "0.3.1" const appVersion string = "0.3.0"
func main() { func main() {
a := app.New() a := app.New()