I decided to rewrite the program taking into account the experience gained.
40 lines
857 B
Go
40 lines
857 B
Go
package view
|
|
|
|
import (
|
|
"fyne.io/fyne/v2"
|
|
"fyne.io/fyne/v2/container"
|
|
"fyne.io/fyne/v2/lang"
|
|
"fyne.io/fyne/v2/widget"
|
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application/setting"
|
|
)
|
|
|
|
func StartWithError(err error, languages []setting.Lang, funcSelected func(lang setting.Lang)) fyne.CanvasObject {
|
|
messageHead := lang.L("error")
|
|
|
|
listView := widget.NewList(
|
|
func() int {
|
|
return len(languages)
|
|
},
|
|
func() fyne.CanvasObject {
|
|
return widget.NewLabel("template")
|
|
},
|
|
func(i widget.ListItemID, o fyne.CanvasObject) {
|
|
block := o.(*widget.Label)
|
|
block.SetText(languages[i].Title)
|
|
})
|
|
listView.OnSelected = func(id widget.ListItemID) {
|
|
funcSelected(languages[id])
|
|
}
|
|
|
|
return container.NewBorder(
|
|
container.NewVBox(
|
|
widget.NewLabel(messageHead),
|
|
widget.NewLabel(err.Error()),
|
|
),
|
|
nil,
|
|
nil,
|
|
nil,
|
|
listView,
|
|
)
|
|
}
|