Skip to content

Commit

Permalink
Set up starting location for dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacalz committed Nov 19, 2023
1 parent 2e95449 commit 227a309
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
22 changes: 14 additions & 8 deletions dialog/file_xdg.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,16 @@ func getFavoriteLocations() (map[string]fyne.ListableURI, error) {

func fileOpenOSOverride(d *FileDialog) bool {
go func() {
folderCallback, folder := d.callback.(func(fyne.ListableURI, error))
options := &filechooser.OpenOptions{
Modal: true,
Directory: folder,

Check failure on line 83 in dialog/file_xdg.go

View workflow job for this annotation

GitHub Actions / static_analysis

undefined: folder

Check failure on line 83 in dialog/file_xdg.go

View workflow job for this annotation

GitHub Actions / platform_tests (1.17.x, ubuntu-latest)

undefined: folder

Check failure on line 83 in dialog/file_xdg.go

View workflow job for this annotation

GitHub Actions / platform_tests (1.17.x, ubuntu-latest)

undefined: folder

Check failure on line 83 in dialog/file_xdg.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.17.x)

undefined: folder

Check failure on line 83 in dialog/file_xdg.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.17.x)

undefined: folder

Check failure on line 83 in dialog/file_xdg.go

View workflow job for this annotation

GitHub Actions / mobile_tests (1.20.x)

undefined: folder

Check failure on line 83 in dialog/file_xdg.go

View workflow job for this annotation

GitHub Actions / platform_tests (1.20.x, ubuntu-latest)

undefined: folder
AcceptLabel: d.confirmText,
}
if d.startingLocation != nil {
options.Location = d.startingLocation.Path()
}

folderCallback, folder := d.callback.(func(fyne.ListableURI, error))
if folder {
uris, err := filechooser.OpenFile("", "Open Folder", options)
if err != nil {
Expand Down Expand Up @@ -131,14 +134,17 @@ func fileOpenOSOverride(d *FileDialog) bool {

func fileSaveOSOverride(d *FileDialog) bool {
go func() {
options := &filechooser.SaveSingleOptions{
Modal: true,
AcceptLabel: d.confirmText,
FileName: d.initialFileName,
}
if d.startingLocation != nil {
options.Location = d.startingLocation.Path()
}

callback := d.callback.(func(fyne.URIWriteCloser, error))
uris, err := filechooser.SaveFile("", "Open File",
&filechooser.SaveSingleOptions{
Modal: true,
AcceptLabel: d.confirmText,
FileName: d.initialFileName,
},
)
uris, err := filechooser.SaveFile("", "Open File", options)
if err != nil {
callback(nil, err)
return
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/lucor/goinfo v0.9.0
github.com/mcuadros/go-version v0.0.0-20190830083331-035f6764e8d2
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
github.com/rymdport/portal v0.0.0-20231119194321-d452ead565fd
github.com/rymdport/portal v0.0.0-20231119195719-fb11153c815d
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef
github.com/stretchr/testify v1.8.4
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/rymdport/portal v0.0.0-20231119194321-d452ead565fd h1:nHVuLKAtBcunYBBiuclbtYllz+gW9TB3uHR8e1uMoM0=
github.com/rymdport/portal v0.0.0-20231119194321-d452ead565fd/go.mod h1:RYYAnv4sssTQ7ceErKl7UD8auER/0yFV7CgmfS/uAD8=
github.com/rymdport/portal v0.0.0-20231119195719-fb11153c815d h1:q+VIAL+ZpA2fP/9k6dn+720s4YJGVATDTj35L2CWsIA=
github.com/rymdport/portal v0.0.0-20231119195719-fb11153c815d/go.mod h1:RYYAnv4sssTQ7ceErKl7UD8auER/0yFV7CgmfS/uAD8=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/shurcooL/go v0.0.0-20200502201357-93f07166e636/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk=
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
Expand Down

0 comments on commit 227a309

Please sign in to comment.