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

dialog.New(File/Folder/...)Open() only works with "file" repository #5204

Open
2 tasks done
brucealthompson opened this issue Oct 16, 2024 · 4 comments
Open
2 tasks done
Labels
unverified A bug that has been reported but not verified

Comments

@brucealthompson
Copy link

brucealthompson commented Oct 16, 2024

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

I have written a new repository interface which is intended to allow dialog.New(File/Folder/...)Open() to work with remote filesystems in a similar manner as WebDav. I have found that the current implementation of dialog.New(File/Folder/...)Open() has
a number of ties to the operating system / filesystem that fyne is running on. This works fine when it is displaying content from the "file" repository. However, it pretty much breaks down when you try to use it with a different repository. Here is an example of code that looks like it is currently broken for anything other than the "file" repository:
fyne.io\fyne\[email protected]\dialog\file.go

func (f *fileDialog) loadFavorites() {
  favoriteLocations, err := getFavoriteLocations()
  if err != nil {
    fyne.LogError("Getting favorite locations", err)
  }
  favoriteIcons := getFavoriteIcons()
  favoriteOrder := getFavoriteOrder()

getFavoriteLocations() is platform (not repository) specific code.

Here is another snippet from the same file:

for _, file := range files {
		if !f.showHidden && isHidden(file) {
			continue
		}

isHidden() is platform (not repository) specific code.

I suspect that the file/folder dialog objects are going to need some pretty major work to get them to work with repositories other than "file".

How to reproduce

This is bug is not possible to reproduce with the current codebase as a new non "file" repository needs to be written to exercise the code. I have written a new repository called "httpfile" which supports a subset of webdav functionality.

Screenshots

No response

Example code

I would provide the package "httpfile" I have written but it looks like attaching go files is not supported.

Fyne version

2.5.2

Go compiler version

1.23.1

Operating system and version

Windows 11

Additional Information

No response

@brucealthompson brucealthompson added the unverified A bug that has been reported but not verified label Oct 16, 2024
@brucealthompson brucealthompson changed the title dialog.New(File/Folder/...)Open() only works with "file" respository dialog.New(File/Folder/...)Open() only works with "file" repository Oct 17, 2024
@brucealthompson
Copy link
Author

brucealthompson commented Oct 19, 2024

I have produced a fix for this issue on https://github.com/brucealthompson/fyne/blob/release/v2.5.x/dialog/file.go
The fix essentially removes the elements in the fyne file dialog if the scheme of the initial location is not "file". It works for me and I believe in general.
I am not going to push this fix as I it is not a long term solution to the issue.

@andydotxyz
Copy link
Member

Hmm, is it right that setting the starting location to non-file should remove the favourites? That is not how things like Windows file explorer or a macOS finder window work.

If we have to hide them because they are not supported on wasm then let's make that change instead.

@brucealthompson
Copy link
Author

Hmm, is it right that setting the starting location to non-file should remove the favourites? That is not how things like Windows file explorer or a macOS finder window work.

Definitely its not the right fix from a fyne point of view. You will want something more general. That's why I did not do a push request.

If we have to hide them because they are not supported on wasm then let's make that change instead.

I think it could be supported on wasm using a webdav repository. Unfortunately the correct fix is much more involved than what I did to get my application to work. I was thinking that there must be someone that maintains the dialog.NewFileOpen() code that could do the correct fix. Is that not the case?

@andydotxyz
Copy link
Member

Definitely its not the right fix from a fyne point of view. You will want something more general. That's why I did not do a push request.

Apologies I maybe misunderstood your earlier message "It works for me and I believe in general."

I was thinking that there must be someone that maintains the dialog.NewFileOpen() code that could do the correct fix. Is that not the case?

All of the repository is maintained by a team - none of the code is maintained by a specific person. Things may have been confused because the PRs/issues got overlapped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unverified A bug that has been reported but not verified
Projects
None yet
Development

No branches or pull requests

2 participants