Documentation
¶
Overview ¶
Package gofiledialog provides Explorer-style Open, Save, and Select Folder dialogs for Fyne applications.
The dialogs are built from Fyne primitives instead of wrapping Fyne's built-in file dialog, which allows gofiledialog to provide switchable views, sortable/configurable Details columns, persistent shared settings, filters, New Folder support, and asynchronous image thumbnails.
Index ¶
- func ShowFolder(onChosen func(paths []string, err error), parent fyne.Window, opts ...Option) error
- func ShowOpen(onChosen func(paths []string, err error), parent fyne.Window, opts ...Option) error
- func ShowSave(onChosen func(paths []string, err error), parent fyne.Window, opts ...Option) error
- type Browser
- func (b *Browser) ActivateSelected()
- func (b *Browser) Back() error
- func (b *Browser) CanGoBack() bool
- func (b *Browser) CanGoForward() bool
- func (b *Browser) Close()
- func (b *Browser) Columns() []Column
- func (b *Browser) Content() fyne.CanvasObject
- func (b *Browser) CurrentDir() string
- func (b *Browser) Forward() error
- func (b *Browser) MoveSelection(delta int)
- func (b *Browser) MultiSelect() bool
- func (b *Browser) NavigateTo(dir string) error
- func (b *Browser) Refresh() error
- func (b *Browser) Selected() (FileEntry, bool)
- func (b *Browser) SelectedEntries() []FileEntry
- func (b *Browser) SetColumnVisible(id ColumnID, visible bool)
- func (b *Browser) SetFilter(filter func(FileEntry) bool) error
- func (b *Browser) SetMultiSelect(enabled bool)
- func (b *Browser) SetSort(id ColumnID)
- func (b *Browser) SetViewMode(mode ViewMode)
- func (b *Browser) ShowHidden() bool
- func (b *Browser) SortAscending() bool
- func (b *Browser) SortColumn() ColumnID
- func (b *Browser) ToggleShowHidden(show bool) error
- func (b *Browser) TypeAhead(prefix string) bool
- func (b *Browser) Up() error
- func (b *Browser) ViewMode() ViewMode
- func (b *Browser) VisibleColumns() []Column
- type Column
- type ColumnID
- type ColumnSetting
- type FileEntry
- type Filter
- type FolderDialog
- type OpenDialog
- type Option
- type Place
- type SaveDialog
- type Settings
- type Store
- type ViewMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ShowFolder ¶
ShowFolder is a convenience wrapper that builds and immediately shows a folder-selection dialog. parent is accepted for API compatibility but is not used for placement.
Types ¶
type Browser ¶
type Browser struct {
// OnActivate fires when the user activates a file row. Directories are
// navigated into as soon as they are selected because Fyne's collection
// widgets do not emit a second OnSelected event for the already-selected
// item.
OnActivate func(entry FileEntry)
// OnDirChanged fires whenever the browser finishes navigating to a new
// directory, so a toolbar/breadcrumb can refresh its state.
OnDirChanged func(dir string)
// OnSelectionChanged fires when the selected entry set changes.
OnSelectionChanged func()
// OnError fires when a navigation attempt (double-click, Back/Forward/Up,
// or a path typed into a breadcrumb) fails, e.g. permission denied.
OnError func(err error)
// OnSettingsChanged fires whenever persisted dialog state (sort, column
// visibility/width, show-hidden) changes, so a caller can save it.
OnSettingsChanged func()
// contains filtered or unexported fields
}
Browser is the core directory-browsing widget shared by the Open, Save and Folder dialogs. It supports Details, List, and Small/Medium/Large icon views over the same underlying entries.
func NewBrowser ¶
NewBrowser creates a Browser listing startDir.
func (*Browser) ActivateSelected ¶
func (b *Browser) ActivateSelected()
ActivateSelected opens the selected directory or activates the selected file through OnActivate.
func (*Browser) CanGoForward ¶
CanGoForward reports whether Forward would move to a different directory.
func (*Browser) Close ¶ added in v0.1.2
func (b *Browser) Close()
Close releases background resources owned by the browser. A closed browser must not be reused.
func (*Browser) Columns ¶
Columns returns every registered column (visible or not), for building a "choose columns" menu.
func (*Browser) Content ¶
func (b *Browser) Content() fyne.CanvasObject
Content returns the canvas object to embed in a dialog window.
func (*Browser) CurrentDir ¶
CurrentDir returns the directory currently being browsed.
func (*Browser) MoveSelection ¶
MoveSelection moves the current row highlight by delta, clamped to the current listing. It is used by keyboard navigation.
func (*Browser) MultiSelect ¶ added in v0.1.2
MultiSelect reports whether the browser permits more than one selected file.
func (*Browser) NavigateTo ¶
NavigateTo lists dir, replaces the browser's current contents, and pushes dir onto the navigation history (discarding any forward history).
func (*Browser) SelectedEntries ¶
SelectedEntries returns selected files in display order. Directories are intentionally excluded for Open dialogs; Folder dialogs use CurrentDir.
func (*Browser) SetColumnVisible ¶
SetColumnVisible shows or hides a column. Name cannot be hidden.
func (*Browser) SetFilter ¶
SetFilter sets a display filter for files and refreshes the current directory. Directories are always shown so users can keep navigating.
func (*Browser) SetMultiSelect ¶
SetMultiSelect controls whether selected files accumulate. Directory activation still navigates immediately.
func (*Browser) SetSort ¶
SetSort sorts the Details view by column id, toggling direction if id is already the active sort column. Unknown column IDs are ignored.
func (*Browser) SetViewMode ¶
SetViewMode switches the active view.
func (*Browser) ShowHidden ¶
ShowHidden reports whether hidden files/directories are currently listed.
func (*Browser) SortAscending ¶
func (*Browser) SortColumn ¶
SortColumn and SortAscending report the current Details-view sort state.
func (*Browser) ToggleShowHidden ¶
ToggleShowHidden sets whether hidden files/directories are listed and re-lists the current directory.
func (*Browser) TypeAhead ¶
TypeAhead selects the next entry whose name begins with prefix, wrapping around from the current selection.
func (*Browser) VisibleColumns ¶
VisibleColumns returns the currently visible columns in display order.
type Column ¶
type Column struct {
ID ColumnID
Title string
Width float32
Visible bool
Text func(e FileEntry) string
Less func(a, b FileEntry) bool
}
Column describes one Details-view column: how to render a cell and how to compare two entries for sorting.
type ColumnSetting ¶
type ColumnSetting struct {
ID ColumnID `json:"id"`
Visible bool `json:"visible"`
Width float32 `json:"width"`
}
ColumnSetting is the persisted state of a single Details-view column.
type FileEntry ¶
type FileEntry struct {
Name string
Path string
IsDir bool
Hidden bool
Size int64
ModTime time.Time
CreatedTime time.Time
}
FileEntry describes a single file or directory shown in the browser.
type Filter ¶
Filter describes one file-type option in the dialog's Type dropdown. Extensions are case-insensitive and may be written with or without a leading dot. A nil or empty Extensions slice matches all files.
func (Filter) DefaultExtension ¶
type FolderDialog ¶
type FolderDialog struct {
// contains filtered or unexported fields
}
FolderDialog is a folder-selection dialog window.
func NewFolder ¶
func NewFolder(parent fyne.Window, opts ...Option) (*FolderDialog, error)
NewFolder builds a folder-selection dialog. The currently displayed folder is returned when the user chooses Select Folder. parent is accepted for API compatibility with Fyne's dialog helpers; gofiledialog currently creates a top-level window and centers it on screen because fyne.Window does not expose portable parent-relative placement.
func (*FolderDialog) SetOnChosen ¶
func (d *FolderDialog) SetOnChosen(f func(paths []string, err error))
SetOnChosen sets the callback invoked when the Folder dialog closes.
func (*FolderDialog) Show ¶
func (d *FolderDialog) Show()
Show displays the Folder dialog window, centered on screen.
type OpenDialog ¶
type OpenDialog struct {
// contains filtered or unexported fields
}
OpenDialog is a file-open dialog window.
func NewOpen ¶
func NewOpen(parent fyne.Window, opts ...Option) (*OpenDialog, error)
NewOpen builds an Open-file dialog. The dialog is not shown until Show is called. parent is accepted for API compatibility with Fyne's dialog helpers; gofiledialog currently creates a top-level window and centers it on screen because fyne.Window does not expose portable parent-relative placement.
func (*OpenDialog) SetOnChosen ¶
func (d *OpenDialog) SetOnChosen(f func(paths []string, err error))
SetOnChosen sets the callback invoked when the dialog closes. paths is nil if the user cancelled.
func (*OpenDialog) Show ¶
func (d *OpenDialog) Show()
Show displays the dialog window, centered on screen.
type Option ¶
type Option func(*options)
Option configures a dialog created by NewOpen (and, in later phases, NewSave / NewFolder).
func WithFileName ¶
WithFileName pre-fills the Save dialog filename entry.
func WithFilters ¶
WithFilters sets the file-type choices shown in the Type dropdown. The first filter is selected initially. Directories are never filtered out.
func WithMultiSelect ¶
WithMultiSelect allows Open dialogs to accumulate multiple selected files. Fyne's built-in collection widgets do not expose modifier-key selection, so selections accumulate as files are clicked.
func WithStartDir ¶
WithStartDir sets the directory the dialog opens to.
type SaveDialog ¶
type SaveDialog struct {
// contains filtered or unexported fields
}
SaveDialog is a file-save dialog window.
func NewSave ¶
func NewSave(parent fyne.Window, opts ...Option) (*SaveDialog, error)
NewSave builds a Save-file dialog. The chosen path is returned without creating the file; callers decide how to write it. parent is accepted for API compatibility with Fyne's dialog helpers; gofiledialog currently creates a top-level window and centers it on screen because fyne.Window does not expose portable parent-relative placement.
func (*SaveDialog) SetOnChosen ¶
func (d *SaveDialog) SetOnChosen(f func(paths []string, err error))
SetOnChosen sets the callback invoked when the Save dialog closes.
func (*SaveDialog) Show ¶
func (d *SaveDialog) Show()
Show displays the Save dialog window, centered on screen.
type Settings ¶
type Settings struct {
// LastDir is used when Fyne has no remembered file-dialog location.
LastDir string `json:"lastDir"`
ViewMode string `json:"viewMode"`
ShowHidden bool `json:"showHidden"`
SortColumn ColumnID `json:"sortColumn"`
SortAscending bool `json:"sortAscending"`
Columns []ColumnSetting `json:"columns"`
WindowWidth float32 `json:"windowWidth"`
WindowHeight float32 `json:"windowHeight"`
}
Settings is the dialog state that persists across processes: the last folder, view mode, sort, visible columns and their widths, the hidden-files toggle, and window size. It is shared by every app that imports gofiledialog and uses the default Store (see WithStore to opt out).
type Store ¶
Store loads and saves Settings. Dialog persistence is best-effort: Load errors fall back to defaults, and Save errors are intentionally ignored so a settings backend cannot break user interaction.
The default, used unless an app supplies its own via WithStore, is a JSON file shared across every app on the machine that uses gofiledialog with its default settings. The default store serializes in-process saves, coordinates writes with other processes through a lock file, and replaces the settings file atomically.
Source Files
¶
- browser.go
- columns.go
- columns_menu.go
- ctime_other.go
- dialog.go
- doc.go
- entry.go
- filters.go
- foldername_other.go
- format.go
- hidden_other.go
- icons.go
- list_dir.go
- navigation.go
- places.go
- places_other.go
- settings.go
- settings_atomic_other.go
- settings_lock_other.go
- sidebar.go
- sort.go
- thumbnail.go
- view_details.go
- view_icons.go
- view_list.go
- viewmode.go
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
demo
command
Command demo exercises the gofiledialog dialogs.
|
Command demo exercises the gofiledialog dialogs. |
|
internal
|
|
|
lru
Package lru implements a small, fixed-capacity, concurrency-safe least-recently-used cache.
|
Package lru implements a small, fixed-capacity, concurrency-safe least-recently-used cache. |