Skip to content

Commit 8707cba

Browse files
authored
Merge pull request #91 from ncruces/winfile
Use IFileDialog where available.
2 parents 44dd9f7 + 649da24 commit 8707cba

12 files changed

+338
-103
lines changed

date_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (dlg *calendarDialog) setup(text string, opts options) (time.Time, error) {
102102
win.SetFocus(dlg.dateCtl)
103103
win.ShowWindow(dlg.wnd, win.SW_NORMAL)
104104

105-
if opts.ctx != nil {
105+
if opts.ctx != nil && opts.ctx.Done() != nil {
106106
wait := make(chan struct{})
107107
defer close(wait)
108108
go func() {

entry_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (dlg *entryDialog) setup(text string, opts options) (string, error) {
9797
win.ShowWindow(dlg.wnd, win.SW_NORMAL)
9898
win.SendMessage(dlg.editCtl, win.EM_SETSEL, 0, intptr(-1))
9999

100-
if opts.ctx != nil {
100+
if opts.ctx != nil && opts.ctx.Done() != nil {
101101
wait := make(chan struct{})
102102
defer close(wait)
103103
go func() {

file_test.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package zenity_test
33
import (
44
"context"
55
"errors"
6-
"fmt"
76
"os"
87
"path/filepath"
98
"testing"
@@ -124,7 +123,7 @@ func TestSelectFile_script(t *testing.T) {
124123
}
125124

126125
t.Run("Cancel", func(t *testing.T) {
127-
zenity.Info(fmt.Sprintf("In the file selection dialog, cancel."))
126+
zenity.Info("In the file selection dialog, cancel.")
128127
str, err := zenity.SelectFile()
129128
if skip, err := skip(err); skip {
130129
t.Skip("skipping:", err)
@@ -134,7 +133,7 @@ func TestSelectFile_script(t *testing.T) {
134133
}
135134
})
136135
t.Run("File", func(t *testing.T) {
137-
zenity.Info(fmt.Sprintf("In the file selection dialog, pick any file."))
136+
zenity.Info("In the file selection dialog, pick any file.")
138137
str, err := zenity.SelectFile()
139138
if skip, err := skip(err); skip {
140139
t.Skip("skipping:", err)
@@ -147,7 +146,7 @@ func TestSelectFile_script(t *testing.T) {
147146
}
148147
})
149148
t.Run("Directory", func(t *testing.T) {
150-
zenity.Info(fmt.Sprintf("In the file selection dialog, pick any directory."))
149+
zenity.Info("In the file selection dialog, pick any directory.")
151150
str, err := zenity.SelectFile(zenity.Directory())
152151
if skip, err := skip(err); skip {
153152
t.Skip("skipping:", err)
@@ -169,7 +168,7 @@ func TestSelectFileMultiple_script(t *testing.T) {
169168
}
170169

171170
t.Run("Cancel", func(t *testing.T) {
172-
zenity.Info(fmt.Sprintf("In the file selection dialog, cancel."))
171+
zenity.Info("In the file selection dialog, cancel.")
173172
lst, err := zenity.SelectFileMultiple()
174173
if skip, err := skip(err); skip {
175174
t.Skip("skipping:", err)
@@ -179,7 +178,7 @@ func TestSelectFileMultiple_script(t *testing.T) {
179178
}
180179
})
181180
t.Run("Files", func(t *testing.T) {
182-
zenity.Info(fmt.Sprintf("In the file selection dialog, pick two files."))
181+
zenity.Info("In the file selection dialog, pick two files.")
183182
lst, err := zenity.SelectFileMultiple()
184183
if skip, err := skip(err); skip {
185184
t.Skip("skipping:", err)
@@ -194,7 +193,7 @@ func TestSelectFileMultiple_script(t *testing.T) {
194193
}
195194
})
196195
t.Run("Directories", func(t *testing.T) {
197-
zenity.Info(fmt.Sprintf("In the file selection dialog, pick two directories."))
196+
zenity.Info("In the file selection dialog, pick two directories.")
198197
lst, err := zenity.SelectFileMultiple(zenity.Directory())
199198
if skip, err := skip(err); skip {
200199
t.Skip("skipping:", err)
@@ -221,7 +220,7 @@ func TestSelectFileSave_script(t *testing.T) {
221220
}
222221

223222
t.Run("Cancel", func(t *testing.T) {
224-
zenity.Info(fmt.Sprintf("In the file save dialog, cancel."))
223+
zenity.Info("In the file save dialog, cancel.")
225224
str, err := zenity.SelectFileSave()
226225
if skip, err := skip(err); skip {
227226
t.Skip("skipping:", err)
@@ -231,7 +230,7 @@ func TestSelectFileSave_script(t *testing.T) {
231230
}
232231
})
233232
t.Run("Name", func(t *testing.T) {
234-
zenity.Info(fmt.Sprintf("In the file save dialog, press OK."))
233+
zenity.Info("In the file save dialog, press OK.")
235234
str, err := zenity.SelectFileSave(
236235
zenity.ConfirmOverwrite(),
237236
zenity.Filename("Χρτο.go"),

0 commit comments

Comments
 (0)