forked from fyne-io/fyne
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This does open mobile pickers as well, though the lack of ListableURI in mobile means it does not return correctly. Fixes fyne-io#941
- Loading branch information
1 parent
41c8fe3
commit 970ef77
Showing
12 changed files
with
295 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package dialog | ||
|
||
import ( | ||
"fyne.io/fyne" | ||
"fyne.io/fyne/storage" | ||
) | ||
|
||
var folderFilter = storage.NewMimeTypeFileFilter([]string{"application/x-directory"}) | ||
|
||
// NewFolderOpen creates a file dialog allowing the user to choose a folder to open. | ||
// The dialog will appear over the window specified when Show() is called. | ||
func NewFolderOpen(callback func(fyne.ListableURI, error), parent fyne.Window) *FileDialog { | ||
dialog := &FileDialog{} | ||
dialog.callback = callback | ||
dialog.parent = parent | ||
dialog.filter = folderFilter | ||
return dialog | ||
} | ||
|
||
// ShowFolderOpen creates and shows a file dialog allowing the user to choose a folder to open. | ||
// The dialog will appear over the window specified. | ||
func ShowFolderOpen(callback func(fyne.ListableURI, error), parent fyne.Window) { | ||
dialog := NewFolderOpen(callback, parent) | ||
if fileOpenOSOverride(dialog) { | ||
return | ||
} | ||
dialog.Show() | ||
} | ||
|
||
func (f *FileDialog) isDirectory() bool { | ||
return f.filter == folderFilter | ||
} | ||
|
||
func isListable(u fyne.URI) bool { | ||
if _, ok := u.(fyne.ListableURI); ok { | ||
return true | ||
} | ||
|
||
_, err := storage.ListerForURI(u) | ||
return err == nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters