Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added additional documentation and example code snippet. #2156

Merged
merged 9 commits into from May 22, 2021
24 changes: 19 additions & 5 deletions dialog/file.go
Expand Up @@ -559,21 +559,31 @@ func (f *FileDialog) SetFileName(fileName string) {
}

// NewFileOpen creates a file dialog allowing the user to choose a file to open.
// The callback function will run when the dialog closes. The URI will be nil
// when the user cancels or when nothing is selected.
//
// The dialog will appear over the window specified when Show() is called.
func NewFileOpen(callback func(fyne.URIReadCloser, error), parent fyne.Window) *FileDialog {
dialog := &FileDialog{callback: callback, parent: parent}
return dialog
}

// NewFileSave creates a file dialog allowing the user to choose a file to save to (new or overwrite).
// If the user chooses an existing file they will be asked if they are sure.
// NewFileSave creates a file dialog allowing the user to choose a file to save
// to (new or overwrite). If the user chooses an existing file they will be
// asked if they are sure. The callback function will run when the dialog
// closes. The URI will be nil when the user cancels or when nothing is
// selected.
//
// The dialog will appear over the window specified when Show() is called.
func NewFileSave(callback func(fyne.URIWriteCloser, error), parent fyne.Window) *FileDialog {
dialog := &FileDialog{callback: callback, parent: parent, save: true}
return dialog
}

// ShowFileOpen creates and shows a file dialog allowing the user to choose a file to open.
// ShowFileOpen creates and shows a file dialog allowing the user to choose a
// file to open. The callback function will run when the dialog closes. The URI
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// file to open. The callback function will run when the dialog closes. The URI
// file to open. The callback function will run when the dialog closes. The URI

It's grammatically incorrect with double spaces. There are a few more places where this occurs but I just made one comment about it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is actually a school of thinking that says double space is grammatically correct. However I agree that we have settled on single spacing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not know that. It is very, very forbidden in Swedish at least 😅

// will be nil when the user cancels or when nothing is selected.
//
// The dialog will appear over the window specified.
func ShowFileOpen(callback func(fyne.URIReadCloser, error), parent fyne.Window) {
dialog := NewFileOpen(callback, parent)
Expand All @@ -583,8 +593,12 @@ func ShowFileOpen(callback func(fyne.URIReadCloser, error), parent fyne.Window)
dialog.Show()
}

// ShowFileSave creates and shows a file dialog allowing the user to choose a file to save to (new or overwrite).
// If the user chooses an existing file they will be asked if they are sure.
// ShowFileSave creates and shows a file dialog allowing the user to choose a
// file to save to (new or overwrite). If the user chooses an existing file they
// will be asked if they are sure. The callback function will run when the
// dialog closes. The URI will be nil when the user cancels or when nothing is
// selected.
//
// The dialog will appear over the window specified.
func ShowFileSave(callback func(fyne.URIWriteCloser, error), parent fyne.Window) {
dialog := NewFileSave(callback, parent)
Expand Down
10 changes: 8 additions & 2 deletions dialog/folder.go
Expand Up @@ -7,7 +7,10 @@ import (

var folderFilter = storage.NewMimeTypeFileFilter([]string{"application/x-directory"})

// NewFolderOpen creates a file dialog allowing the user to choose a folder to open.
// NewFolderOpen creates a file dialog allowing the user to choose a folder to
// open. The callback function will run when the dialog closes. The URI will be
// nil when the user cancels or when nothing is selected.
//
// The dialog will appear over the window specified when Show() is called.
//
// Since: 1.4
Expand All @@ -19,7 +22,10 @@ func NewFolderOpen(callback func(fyne.ListableURI, error), parent fyne.Window) *
return dialog
}

// ShowFolderOpen creates and shows a file dialog allowing the user to choose a folder to open.
// ShowFolderOpen creates and shows a file dialog allowing the user to choose a
// folder to open. The callback function will run when the dialog closes. The
// URI will be nil when the user cancels or when nothing is selected.
//
// The dialog will appear over the window specified.
//
// Since: 1.4
Expand Down