Skip to content

Commit

Permalink
Merge pull request ncruces#91 from ncruces/winfile
Browse files Browse the repository at this point in the history
Use IFileDialog where available.
  • Loading branch information
ncruces authored Feb 23, 2024
2 parents 44dd9f7 + 649da24 commit 8707cba
Show file tree
Hide file tree
Showing 12 changed files with 338 additions and 103 deletions.
2 changes: 1 addition & 1 deletion date_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (dlg *calendarDialog) setup(text string, opts options) (time.Time, error) {
win.SetFocus(dlg.dateCtl)
win.ShowWindow(dlg.wnd, win.SW_NORMAL)

if opts.ctx != nil {
if opts.ctx != nil && opts.ctx.Done() != nil {
wait := make(chan struct{})
defer close(wait)
go func() {
Expand Down
2 changes: 1 addition & 1 deletion entry_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (dlg *entryDialog) setup(text string, opts options) (string, error) {
win.ShowWindow(dlg.wnd, win.SW_NORMAL)
win.SendMessage(dlg.editCtl, win.EM_SETSEL, 0, intptr(-1))

if opts.ctx != nil {
if opts.ctx != nil && opts.ctx.Done() != nil {
wait := make(chan struct{})
defer close(wait)
go func() {
Expand Down
17 changes: 8 additions & 9 deletions file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package zenity_test
import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -124,7 +123,7 @@ func TestSelectFile_script(t *testing.T) {
}

t.Run("Cancel", func(t *testing.T) {
zenity.Info(fmt.Sprintf("In the file selection dialog, cancel."))
zenity.Info("In the file selection dialog, cancel.")
str, err := zenity.SelectFile()
if skip, err := skip(err); skip {
t.Skip("skipping:", err)
Expand All @@ -134,7 +133,7 @@ func TestSelectFile_script(t *testing.T) {
}
})
t.Run("File", func(t *testing.T) {
zenity.Info(fmt.Sprintf("In the file selection dialog, pick any file."))
zenity.Info("In the file selection dialog, pick any file.")
str, err := zenity.SelectFile()
if skip, err := skip(err); skip {
t.Skip("skipping:", err)
Expand All @@ -147,7 +146,7 @@ func TestSelectFile_script(t *testing.T) {
}
})
t.Run("Directory", func(t *testing.T) {
zenity.Info(fmt.Sprintf("In the file selection dialog, pick any directory."))
zenity.Info("In the file selection dialog, pick any directory.")
str, err := zenity.SelectFile(zenity.Directory())
if skip, err := skip(err); skip {
t.Skip("skipping:", err)
Expand All @@ -169,7 +168,7 @@ func TestSelectFileMultiple_script(t *testing.T) {
}

t.Run("Cancel", func(t *testing.T) {
zenity.Info(fmt.Sprintf("In the file selection dialog, cancel."))
zenity.Info("In the file selection dialog, cancel.")
lst, err := zenity.SelectFileMultiple()
if skip, err := skip(err); skip {
t.Skip("skipping:", err)
Expand All @@ -179,7 +178,7 @@ func TestSelectFileMultiple_script(t *testing.T) {
}
})
t.Run("Files", func(t *testing.T) {
zenity.Info(fmt.Sprintf("In the file selection dialog, pick two files."))
zenity.Info("In the file selection dialog, pick two files.")
lst, err := zenity.SelectFileMultiple()
if skip, err := skip(err); skip {
t.Skip("skipping:", err)
Expand All @@ -194,7 +193,7 @@ func TestSelectFileMultiple_script(t *testing.T) {
}
})
t.Run("Directories", func(t *testing.T) {
zenity.Info(fmt.Sprintf("In the file selection dialog, pick two directories."))
zenity.Info("In the file selection dialog, pick two directories.")
lst, err := zenity.SelectFileMultiple(zenity.Directory())
if skip, err := skip(err); skip {
t.Skip("skipping:", err)
Expand All @@ -221,7 +220,7 @@ func TestSelectFileSave_script(t *testing.T) {
}

t.Run("Cancel", func(t *testing.T) {
zenity.Info(fmt.Sprintf("In the file save dialog, cancel."))
zenity.Info("In the file save dialog, cancel.")
str, err := zenity.SelectFileSave()
if skip, err := skip(err); skip {
t.Skip("skipping:", err)
Expand All @@ -231,7 +230,7 @@ func TestSelectFileSave_script(t *testing.T) {
}
})
t.Run("Name", func(t *testing.T) {
zenity.Info(fmt.Sprintf("In the file save dialog, press OK."))
zenity.Info("In the file save dialog, press OK.")
str, err := zenity.SelectFileSave(
zenity.ConfirmOverwrite(),
zenity.Filename("Χρτο.go"),
Expand Down
Loading

0 comments on commit 8707cba

Please sign in to comment.