mirror of
https://github.com/gen2brain/cbconvert
synced 2025-10-14 02:28:51 +02:00
Handle error
This commit is contained in:
@@ -284,13 +284,16 @@ func previewPost() {
|
|||||||
go func(opts cbconvert.Options) {
|
go func(opts cbconvert.Options) {
|
||||||
conv := cbconvert.New(opts)
|
conv := cbconvert.New(opts)
|
||||||
|
|
||||||
|
var s string
|
||||||
file := files[index]
|
file := files[index]
|
||||||
|
|
||||||
img, err := conv.Preview(file.Path, file.Stat, width, height)
|
img, err := conv.Preview(file.Path, file.Stat, width, height)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
s = err.Error()
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
iup.PostMessage(iup.GetHandle("Preview"), "", 0, img)
|
iup.PostMessage(iup.GetHandle("Preview"), s, 0, img)
|
||||||
}(opts)
|
}(opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,7 +315,9 @@ func preview() iup.Ihandle {
|
|||||||
SetCallback("POSTMESSAGE_CB", iup.PostMessageFunc(func(ih iup.Ihandle, s string, i int, p any) int {
|
SetCallback("POSTMESSAGE_CB", iup.PostMessageFunc(func(ih iup.Ihandle, s string, i int, p any) int {
|
||||||
img := p.(cbconvert.Image)
|
img := p.(cbconvert.Image)
|
||||||
|
|
||||||
if img.Image != nil {
|
iup.GetHandle("Loading").SetAttributes("VISIBLE=NO, STOP=YES")
|
||||||
|
|
||||||
|
if img.Image != nil && len(s) == 0 {
|
||||||
iup.Destroy(iup.GetHandle("cover"))
|
iup.Destroy(iup.GetHandle("cover"))
|
||||||
iup.ImageFromImage(img.Image).SetHandle("cover")
|
iup.ImageFromImage(img.Image).SetHandle("cover")
|
||||||
|
|
||||||
@@ -321,9 +326,12 @@ func preview() iup.Ihandle {
|
|||||||
} else {
|
} else {
|
||||||
ih.SetAttribute("IMAGE", "logo")
|
ih.SetAttribute("IMAGE", "logo")
|
||||||
iup.GetHandle("PreviewInfo").SetAttribute("TITLE", "")
|
iup.GetHandle("PreviewInfo").SetAttribute("TITLE", "")
|
||||||
}
|
|
||||||
|
|
||||||
iup.GetHandle("Loading").SetAttributes("VISIBLE=NO, STOP=YES")
|
sp := strings.Split(s, ": ")
|
||||||
|
if len(sp) > 1 {
|
||||||
|
iup.MessageError(ih, fmt.Sprintf("%s\n\n%s", sp[0], strings.Join(sp[1:], ": ")))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return iup.DEFAULT
|
return iup.DEFAULT
|
||||||
})),
|
})),
|
||||||
@@ -340,6 +348,8 @@ func tabs() iup.Ihandle {
|
|||||||
SetAttributes(`TIP="Do not convert images that have RGB colorspace"`),
|
SetAttributes(`TIP="Do not convert images that have RGB colorspace"`),
|
||||||
iup.Toggle(" Exclude Cover").SetHandle("NoCover").
|
iup.Toggle(" Exclude Cover").SetHandle("NoCover").
|
||||||
SetAttributes(`TIP="Do not convert the cover image"`),
|
SetAttributes(`TIP="Do not convert the cover image"`),
|
||||||
|
iup.Toggle(" Remove Non-Image Files from the Archive").SetHandle("NoNonImage").
|
||||||
|
SetAttribute("TIP", "Remove .nfo, .xml, .txt files from the archive"),
|
||||||
iup.Toggle(" Do not Transform or Convert Images").SetHandle("NoConvert").
|
iup.Toggle(" Do not Transform or Convert Images").SetHandle("NoConvert").
|
||||||
SetAttributes(`TIP="Copy images from archive or directory without modifications"`).
|
SetAttributes(`TIP="Copy images from archive or directory without modifications"`).
|
||||||
SetCallback("VALUECHANGED_CB", iup.ValueChangedFunc(func(ih iup.Ihandle) int {
|
SetCallback("VALUECHANGED_CB", iup.ValueChangedFunc(func(ih iup.Ihandle) int {
|
||||||
@@ -373,10 +383,6 @@ func tabs() iup.Ihandle {
|
|||||||
iup.Text().SetAttributes("VISIBLECOLUMNS=16, MINSIZE=100x").SetHandle("Suffix").
|
iup.Text().SetAttributes("VISIBLECOLUMNS=16, MINSIZE=100x").SetHandle("Suffix").
|
||||||
SetAttribute("TIP", "Add suffix to filename, i.e. filename_suffix.cbz"),
|
SetAttribute("TIP", "Add suffix to filename, i.e. filename_suffix.cbz"),
|
||||||
),
|
),
|
||||||
iup.Vbox(
|
|
||||||
iup.Toggle(" Remove Non-Image Files from the Archive").SetHandle("NoNonImage").
|
|
||||||
SetAttribute("TIP", "Remove .nfo, .xml, .txt files from the archive"),
|
|
||||||
),
|
|
||||||
iup.Vbox(
|
iup.Vbox(
|
||||||
iup.Label("Archive Format:"),
|
iup.Label("Archive Format:"),
|
||||||
iup.List().SetAttributes(map[string]string{
|
iup.List().SetAttributes(map[string]string{
|
||||||
|
Reference in New Issue
Block a user