From 346292910bd28372cd7ec1ff7d27b49741b94310 Mon Sep 17 00:00:00 2001 From: maruu <2047922+maruu@users.noreply.github.com> Date: Thu, 1 Feb 2024 13:21:30 +0000 Subject: [PATCH] GH-4595: add method to set view of filedialog --- dialog/file.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dialog/file.go b/dialog/file.go index d06520a8e3..3d27cc0b59 100644 --- a/dialog/file.go +++ b/dialog/file.go @@ -84,6 +84,8 @@ type FileDialog struct { startingLocation fyne.ListableURI // this will be the initial filename in a FileDialog in save mode initialFileName string + // this will be the initial view in a FileDialog + initialView ViewLayout } // Declare conformity to Dialog interface @@ -774,6 +776,17 @@ func (f *FileDialog) SetFileName(fileName string) { } } +// SetView changes the default display view of the FileDialog +// This is normally called before the dialog is shown. +// +// Since: 2.5 +func (f *FileDialog) SetView(v ViewLayout) { + f.initialView = v + if f.dialog != nil { + f.dialog.setView(v) + } +} + // 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.