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

Fix Gtk open file dialog returns folder #17500

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

zii-dmg
Copy link
Contributor

@zii-dmg zii-dmg commented Nov 13, 2024

What does the pull request do?

Gtk open file dialog shows folders in recent list. User can select folder and Gtk will return its path. Avalonia open file dialog should return only files. Fix is checking if Gtk path is real file.

What is the current behavior?

Gtk open file dialog returns folder path. Avalonia creates FileInfo from this path and returns IStorageFile to user. Then user can call IStorageFile.Open* methods or manually call any .NET file API and will get exception because path is folder.

What is the updated/expected behavior with this PR?

Avalonia checks if path is file and returns only files.

How was the solution implemented (if it's not obvious)?

Fix is checking if Gtk path is real file by File.Exists().

Checklist

Breaking changes

Obsoletions / Deprecations

Fixed issues

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0053270-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6
Copy link
Member

maxkatz6 commented Nov 14, 2024

According to their documentation, GTK_FILE_CHOOSER_ACTION_OPEN should only allow picking files.
While I don't see issues with current File.Exist approach, are we sure something else is not broken? Just double checking.

@maxkatz6 maxkatz6 added bug os-linux backport-candidate-11.2.x Consider this PR for backporting to 11.2 branch labels Nov 14, 2024
@zii-dmg
Copy link
Contributor Author

zii-dmg commented Nov 14, 2024

I don't see other problems with Gtk dialog. With select folder recent list contains only folders. With save file there is no recent list.

GTK_FILE_CHOOSER_ACTION_OPEN should only allow picking files

I think it's bug in Gtk. To reproduce user must select folder from recent list but not double click it. Then click "open" button. Double click will go to folder in dialog but not accept it.

@maxkatz6 maxkatz6 merged commit ec7e68c into AvaloniaUI:master Nov 14, 2024
11 checks passed
maxkatz6 pushed a commit that referenced this pull request Nov 14, 2024
@maxkatz6 maxkatz6 added backported-11.2.x and removed backport-candidate-11.2.x Consider this PR for backporting to 11.2 branch labels Nov 14, 2024
@zii-dmg zii-dmg deleted the gtk-dialog-folder-fix branch November 15, 2024 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants