Skip to content

Commit

Permalink
Improve doc strings for file dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikKalkoken committed Sep 28, 2024
1 parent 119d2f8 commit eedc766
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions dialog/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -831,33 +831,40 @@ func (f *FileDialog) SetView(v ViewLayout) {
}

// 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 callback function will run when the dialog closes and provide a reader for the chosen file.
// The reader must be closed by the callback.
// The reader 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 {
func NewFileOpen(callback func(reader fyne.URIReadCloser, err 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. The callback function will run when the dialog
// closes. The URI will be nil when the user cancels or when nothing is
// selected.
// asked if they are sure.
//
// The callback function will run when the dialog closes and provide a writer for the chosen file.
// The writer must be closed by the callback.
// The writer 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 {
func NewFileSave(callback func(writer fyne.URIWriteCloser, err 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. The callback function will run when the dialog closes. The URI
// will be nil when the user cancels or when nothing is selected.
// file to open.
//
// The callback function will run when the dialog closes and provide a reader for the chosen file.
// The reader must be closed by the callback.
// The reader 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) {
func ShowFileOpen(callback func(reader fyne.URIReadCloser, err error), parent fyne.Window) {
dialog := NewFileOpen(callback, parent)
if fileOpenOSOverride(dialog) {
return
Expand All @@ -867,12 +874,14 @@ func ShowFileOpen(callback func(fyne.URIReadCloser, error), parent fyne.Window)

// 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.
// will be asked if they are sure.
//
// The callback function will run when the dialog closes and provide a writer for the chosen file.
// The writer must be closed by the callback.
// The writer 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) {
func ShowFileSave(callback func(writer fyne.URIWriteCloser, err error), parent fyne.Window) {
dialog := NewFileSave(callback, parent)
if fileSaveOSOverride(dialog) {
return
Expand Down

0 comments on commit eedc766

Please sign in to comment.