Message dialogs improvements (linux).

This commit is contained in:
Nuno Cruces 2020-01-06 12:35:45 +00:00
parent 315a7804b9
commit 7fe6837b4f
3 changed files with 10 additions and 6 deletions

View file

@ -18,7 +18,7 @@ func SelectFile(options ...Option) (string, error) {
args = append(args, zenityFilters(opts.filters)...) args = append(args, zenityFilters(opts.filters)...)
cmd := exec.Command("zenity", args...) cmd := exec.Command("zenity", args...)
out, err := cmd.Output() out, err := cmd.Output()
if err, ok := err.(*exec.ExitError); ok && err.ExitCode() == 1 { if err, ok := err.(*exec.ExitError); ok && err.ExitCode() != 255 {
return "", nil return "", nil
} }
if err != nil { if err != nil {
@ -43,7 +43,7 @@ func SelectFileMutiple(options ...Option) ([]string, error) {
args = append(args, zenityFilters(opts.filters)...) args = append(args, zenityFilters(opts.filters)...)
cmd := exec.Command("zenity", args...) cmd := exec.Command("zenity", args...)
out, err := cmd.Output() out, err := cmd.Output()
if err, ok := err.(*exec.ExitError); ok && err.ExitCode() == 1 { if err, ok := err.(*exec.ExitError); ok && err.ExitCode() != 255 {
return nil, nil return nil, nil
} }
if err != nil { if err != nil {
@ -71,7 +71,7 @@ func SelectFileSave(options ...Option) (string, error) {
args = append(args, zenityFilters(opts.filters)...) args = append(args, zenityFilters(opts.filters)...)
cmd := exec.Command("zenity", args...) cmd := exec.Command("zenity", args...)
out, err := cmd.Output() out, err := cmd.Output()
if err, ok := err.(*exec.ExitError); ok && err.ExitCode() == 1 { if err, ok := err.(*exec.ExitError); ok && err.ExitCode() != 255 {
return "", nil return "", nil
} }
if err != nil { if err != nil {
@ -95,7 +95,7 @@ func SelectDirectory(options ...Option) (string, error) {
} }
cmd := exec.Command("zenity", args...) cmd := exec.Command("zenity", args...)
out, err := cmd.Output() out, err := cmd.Output()
if err, ok := err.(*exec.ExitError); ok && err.ExitCode() == 1 { if err, ok := err.(*exec.ExitError); ok && err.ExitCode() != 255 {
return "", nil return "", nil
} }
if err != nil { if err != nil {

1
internal/osa/osa.go Normal file
View file

@ -0,0 +1 @@
package osa

View file

@ -55,8 +55,11 @@ func message(arg, text string, options []Option) (bool, error) {
} }
cmd := exec.Command("zenity", args...) cmd := exec.Command("zenity", args...)
_, err := cmd.Output() out, err := cmd.Output()
if err, ok := err.(*exec.ExitError); ok && err.ExitCode() == 1 { if err, ok := err.(*exec.ExitError); ok && err.ExitCode() != 255 {
if len(out) > 0 && string(out[:len(out)-1]) == opts.extra {
return false, ErrExtraButton
}
return false, nil return false, nil
} }
if err != nil { if err != nil {