From 48a61372189f9f86237ab2d555f610c1207cf651 Mon Sep 17 00:00:00 2001 From: Nuno Cruces Date: Sat, 14 Dec 2019 02:16:06 +0000 Subject: [PATCH] Fixes. --- dialog/dialog_darwin.go | 12 ++++++------ dialog/dialog_test.go | 22 +++++++++++----------- dialog/dialog_windows.go | 6 +++--- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/dialog/dialog_darwin.go b/dialog/dialog_darwin.go index a8d94c9..a6a0355 100644 --- a/dialog/dialog_darwin.go +++ b/dialog/dialog_darwin.go @@ -128,16 +128,16 @@ opts.multipleSelectionsAllowed = {{.Multiple}}; opts.ofType = {{.Filter}}; {{end}} -var ret; +var res; try { - ret = app[{{.Operation}}](opts); + res = app[{{.Operation}}](opts); } catch (e) { if (e.errorNumber !== -128) throw e; } -if (Array.isArray(ret)) { - ret.join('\0'); -} else if (ret != null) { - ret.toString(); +if (Array.isArray(res)) { + res.join('\0'); +} else if (res != null) { + res.toString(); } else { void 0; } diff --git a/dialog/dialog_test.go b/dialog/dialog_test.go index 62860a2..9b7f036 100644 --- a/dialog/dialog_test.go +++ b/dialog/dialog_test.go @@ -3,53 +3,53 @@ package dialog import "testing" func TestOpenFile(t *testing.T) { - ret, err := OpenFile("", "", []FileFilter{ + res, err := OpenFile("", "", []FileFilter{ {"Go files", []string{".go"}}, {"Web files", []string{".html", ".js", ".css"}}, - {"Image files", []string{".png", ".ico"}}, + {"Image files", []string{".png", ".gif", ".ico", ".jpg", ".webp"}}, }) if err != nil { t.Error(err) } else { - t.Logf("%#v", ret) + t.Logf("%#v", res) } } func TestOpenFiles(t *testing.T) { - ret, err := OpenFiles("", "", []FileFilter{ + res, err := OpenFiles("", "", []FileFilter{ {"Go files", []string{".go"}}, {"Web files", []string{".html", ".js", ".css"}}, - {"Image files", []string{".png", ".ico"}}, + {"Image files", []string{".png", ".gif", ".ico", ".jpg", ".webp"}}, }) if err != nil { t.Error(err) } else { - t.Logf("%#v", ret) + t.Logf("%#v", res) } } func TestSaveFile(t *testing.T) { - ret, err := SaveFile("", "", true, []FileFilter{ + res, err := SaveFile("", "", true, []FileFilter{ {"Go files", []string{".go"}}, {"Web files", []string{".html", ".js", ".css"}}, - {"Image files", []string{".png", ".ico"}}, + {"Image files", []string{".png", ".gif", ".ico", ".jpg", ".webp"}}, }) if err != nil { t.Error(err) } else { - t.Logf("%#v", ret) + t.Logf("%#v", res) } } func TestPickFolder(t *testing.T) { - ret, err := PickFolder("", "") + res, err := PickFolder("", "") if err != nil { t.Error(err) } else { - t.Logf("%#v", ret) + t.Logf("%#v", res) } } diff --git a/dialog/dialog_windows.go b/dialog/dialog_windows.go index a6637c9..888dee7 100644 --- a/dialog/dialog_windows.go +++ b/dialog/dialog_windows.go @@ -22,7 +22,7 @@ var ( func OpenFile(title, defaultPath string, filters []FileFilter) (string, error) { var args _OPENFILENAME args.StructSize = uint32(unsafe.Sizeof(args)) - args.Flags = 0x00080000 // OFN_EXPLORER + args.Flags = 0x00080008 // OFN_NOCHANGEDIR|OFN_EXPLORER if title != "" { args.Title = syscall.StringToUTF16Ptr(title) @@ -43,7 +43,7 @@ func OpenFile(title, defaultPath string, filters []FileFilter) (string, error) { func OpenFiles(title, defaultPath string, filters []FileFilter) ([]string, error) { var args _OPENFILENAME args.StructSize = uint32(unsafe.Sizeof(args)) - args.Flags = 0x00080200 // OFN_EXPLORER|OFN_ALLOWMULTISELECT + args.Flags = 0x00080208 // OFN_NOCHANGEDIR|OFN_ALLOWMULTISELECT|OFN_EXPLORER if title != "" { args.Title = syscall.StringToUTF16Ptr(title) @@ -89,7 +89,7 @@ func OpenFiles(title, defaultPath string, filters []FileFilter) ([]string, error func SaveFile(title, defaultPath string, confirmOverwrite bool, filters []FileFilter) (string, error) { var args _OPENFILENAME args.StructSize = uint32(unsafe.Sizeof(args)) - args.Flags = 0x00080000 // OFN_EXPLORER + args.Flags = 0x00080008 // OFN_NOCHANGEDIR|OFN_EXPLORER if title != "" { args.Title = syscall.StringToUTF16Ptr(title)