From af8627dee28b8269ab625048e11fd270d2381863 Mon Sep 17 00:00:00 2001 From: Nuno Cruces Date: Thu, 19 May 2022 14:09:21 +0100 Subject: [PATCH] Fix #29. --- cmd/zenity/main.go | 2 +- file.go | 9 +++++++-- file_darwin.go | 2 +- file_test.go | 36 ++++++++++++++++++------------------ file_unix.go | 2 +- file_windows.go | 2 +- 6 files changed, 29 insertions(+), 24 deletions(-) diff --git a/cmd/zenity/main.go b/cmd/zenity/main.go index 4d2ac04..ec5b5a2 100644 --- a/cmd/zenity/main.go +++ b/cmd/zenity/main.go @@ -168,7 +168,7 @@ func main() { case save: strResult(egestPath(zenity.SelectFileSave(opts...))) case multiple: - lstResult(egestPaths(zenity.SelectFileMutiple(opts...))) + lstResult(egestPaths(zenity.SelectFileMultiple(opts...))) } case colorSelectionDlg: diff --git a/file.go b/file.go index f2dd8ce..9f682d7 100644 --- a/file.go +++ b/file.go @@ -15,13 +15,18 @@ func SelectFile(options ...Option) (string, error) { return selectFile(applyOptions(options)) } -// SelectFileMutiple displays the multiple file selection dialog. +// SelectFileMultiple displays the multiple file selection dialog. // // Valid options: Title, Directory, Filename, ShowHidden, FileFilter(s). // // May return: ErrCanceled, ErrUnsupported. +func SelectFileMultiple(options ...Option) ([]string, error) { + return selectFileMultiple(applyOptions(options)) +} + +// Deprecated: use SelectFileMultiple. func SelectFileMutiple(options ...Option) ([]string, error) { - return selectFileMutiple(applyOptions(options)) + return SelectFileMultiple(options...) } // SelectFileSave displays the save file selection dialog. diff --git a/file_darwin.go b/file_darwin.go index 92cc4cb..0b6edb8 100644 --- a/file_darwin.go +++ b/file_darwin.go @@ -19,7 +19,7 @@ func selectFile(opts options) (string, error) { return strResult(opts, out, err) } -func selectFileMutiple(opts options) ([]string, error) { +func selectFileMultiple(opts options) ([]string, error) { var data zenutil.File data.Options.Prompt = opts.title data.Options.Invisibles = opts.showHidden diff --git a/file_test.go b/file_test.go index 931c28e..9aef10d 100644 --- a/file_test.go +++ b/file_test.go @@ -26,8 +26,8 @@ func ExampleSelectFile() { }) } -func ExampleSelectFileMutiple() { - zenity.SelectFileMutiple( +func ExampleSelectFileMultiple() { + zenity.SelectFileMultiple( zenity.Filename(defaultPath), zenity.FileFilters{ {"Go files", []string{"*.go"}}, @@ -53,8 +53,8 @@ func ExampleSelectFile_directory() { zenity.Directory()) } -func ExampleSelectFileMutiple_directory() { - zenity.SelectFileMutiple( +func ExampleSelectFileMultiple_directory() { + zenity.SelectFileMultiple( zenity.Filename(defaultPath), zenity.Directory()) } @@ -68,12 +68,12 @@ var fileFuncs = []struct { {"Directory", func(o ...zenity.Option) (string, error) { return zenity.SelectFile(append(o, zenity.Directory())...) }}, - {"Mutiple", func(o ...zenity.Option) (string, error) { - _, err := zenity.SelectFileMutiple(append(o, zenity.Directory())...) + {"Multiple", func(o ...zenity.Option) (string, error) { + _, err := zenity.SelectFileMultiple(append(o, zenity.Directory())...) return "", err }}, - {"MutipleDirectory", func(o ...zenity.Option) (string, error) { - _, err := zenity.SelectFileMutiple(o...) + {"MultipleDirectory", func(o ...zenity.Option) (string, error) { + _, err := zenity.SelectFileMultiple(o...) return "", err }}, } @@ -162,38 +162,38 @@ func TestSelectFile_script(t *testing.T) { }) } -func TestSelectFileMutiple_script(t *testing.T) { +func TestSelectFileMultiple_script(t *testing.T) { if testing.Short() { t.Skip("skipping test in short mode.") } t.Run("Cancel", func(t *testing.T) { zenity.Info(fmt.Sprintf("In the file selection dialog, cancel.")) - lst, err := zenity.SelectFileMutiple() + lst, err := zenity.SelectFileMultiple() if skip, err := skip(err); skip { t.Skip("skipping:", err) } if lst != nil || err != zenity.ErrCanceled { - t.Errorf("SelectFileMutiple() = %v, %v; want nil, %v", lst, err, zenity.ErrCanceled) + t.Errorf("SelectFileMultiple() = %v, %v; want nil, %v", lst, err, zenity.ErrCanceled) } }) t.Run("Files", func(t *testing.T) { zenity.Info(fmt.Sprintf("In the file selection dialog, pick two files.")) - lst, err := zenity.SelectFileMutiple() + lst, err := zenity.SelectFileMultiple() if skip, err := skip(err); skip { t.Skip("skipping:", err) } if lst == nil || err != nil { - t.Errorf("SelectFileMutiple() = %v, %v; want [path, path], nil", lst, err) + t.Errorf("SelectFileMultiple() = %v, %v; want [path, path], nil", lst, err) } for _, str := range lst { if _, serr := os.Stat(str); serr != nil { - t.Errorf("SelectFileMutiple() = %q, %v; %v", lst, err, serr) + t.Errorf("SelectFileMultiple() = %q, %v; %v", lst, err, serr) } } }) t.Run("Directories", func(t *testing.T) { zenity.Info(fmt.Sprintf("In the file selection dialog, pick two directories.")) - lst, err := zenity.SelectFileMutiple(zenity.Directory()) + lst, err := zenity.SelectFileMultiple(zenity.Directory()) if skip, err := skip(err); skip { t.Skip("skipping:", err) } @@ -201,13 +201,13 @@ func TestSelectFileMutiple_script(t *testing.T) { t.Skip("was not unsupported:", err) } if lst == nil || err != nil { - t.Errorf("SelectFileMutiple() = %v, %v; want [path, path], nil", lst, err) + t.Errorf("SelectFileMultiple() = %v, %v; want [path, path], nil", lst, err) } for _, str := range lst { if s, serr := os.Stat(str); serr != nil { - t.Errorf("SelectFileMutiple() = %q, %v; %v", str, err, serr) + t.Errorf("SelectFileMultiple() = %q, %v; %v", str, err, serr) } else if !s.IsDir() { - t.Errorf("SelectFileMutiple() = %q, %v; not a directory", str, err) + t.Errorf("SelectFileMultiple() = %q, %v; not a directory", str, err) } } }) diff --git a/file_unix.go b/file_unix.go index 1094057..077efa4 100644 --- a/file_unix.go +++ b/file_unix.go @@ -17,7 +17,7 @@ func selectFile(opts options) (string, error) { return strResult(opts, out, err) } -func selectFileMutiple(opts options) ([]string, error) { +func selectFileMultiple(opts options) ([]string, error) { args := []string{"--file-selection", "--multiple", "--separator", zenutil.Separator} args = appendTitle(args, opts) args = appendFileArgs(args, opts) diff --git a/file_windows.go b/file_windows.go index f120f89..1a5361b 100644 --- a/file_windows.go +++ b/file_windows.go @@ -62,7 +62,7 @@ func selectFile(opts options) (string, error) { return syscall.UTF16ToString(res[:]), nil } -func selectFileMutiple(opts options) ([]string, error) { +func selectFileMultiple(opts options) ([]string, error) { if opts.directory { _, res, err := pickFolders(opts, true) return res, err