Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File dialog locations #1379

Merged
merged 41 commits into from Oct 10, 2020
Merged

Conversation

andydotxyz
Copy link
Member

Description:
Replaces PR #1108

Fixes #821

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.

Where applicable:

  • Public APIs match existing style.

charlesdaniels and others added 30 commits June 15, 2020 15:30
This swaps ~/ and ./ as the default directory.

I have also made / the failover if both of those error. That *shouldn't*
happen though.

Note that / should be safe even on Windows, since NT supports
POSIX-style paths. `/` should expand to NTFS's root, which is almost
always `C:\`.

XXX: might be worth setting the failover dir in the platform driver. `/`
is probably not a good failover choice for iOS, although I'm not sure
the file dialog even makes sense there, since they have their own system
one? I'm not an iOS dev, so I'm not sure.
This adds the concept of a "starting directory", which may be set with a
new setter method. If there is a problem with this directory, or it is
an empty string, then the CWD is preferred, followed by the user home,
followed by `/`.

This also adds two new utility methods, ShowFileOpenAt, and
ShowFileSaveAt which allow the starting directory to be explicitly set
as arguments.

This should not break the existing API.
Per @andydotxyz I have moved the logic to calculate the starting
directory for the file dialog widget to it's own function.
This implements just the effectiveStartingDir() and a basic test from PR fyne-io#1108.
It does provide the ability to set a custom starting dir.

Cherry picked from fyne-io#1111 to fyne-io#1108 to avoid future merge conflicts.
Fix some issues related to ListableURI and dialog
@andydotxyz andydotxyz mentioned this pull request Oct 9, 2020
4 tasks
charlesdaniels
charlesdaniels previously approved these changes Oct 10, 2020
dialog/file.go Outdated Show resolved Hide resolved
dialog/file.go Show resolved Hide resolved
@andydotxyz
Copy link
Member Author

OK that's all comments addressed.
I also added storage.NewFileURI because I didn't want that windows file path handling in the generic NewURI constructor...

I am not certain now if StartingLocation is right - should we instead use SetLocation (so it's not start specific) or make it a Location field that can be written or read...

@andydotxyz andydotxyz merged commit b093037 into fyne-io:develop Oct 10, 2020
@andydotxyz andydotxyz deleted the file_dialog_locations branch October 10, 2020 22:05
@andydotxyz
Copy link
Member Author

Thanks for your help on this @charlesdaniels and @PucklaMotzer09, I know it's been a long haul but we got there :).
I will spend a little time looking at making it not file-specific which I think will allow a little cleanup too - will open another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants