Repository navigation
Conversation
…sion The save dialog does not always change the extension of the name when another file type is selected, and `FileDialog` does not say which type was selected. A save dialog opened with `Untitled.psd` and PSD, PNG and JPEG types could therefore return `Untitled.psd` for the PNG type. After the dialog returns, ask it for the selected file type with `GetFileTypeIndex` and apply that type's first extension to the returned path when: - the name has no extension, or - it still has the extension of the name passed to `set_file_name`, and that extension is not one of the selected type's. A typed extension is kept, and so is any extension the type lists. A type whose first extension is `*` or empty changes nothing. If the renamed path already exists, the path the dialog returned is kept, since the dialog only asked to overwrite that one. The rule is a function of paths, with unit tests. It is the Windows counterpart of the XDG portal rule in PolyMeilex#341.
|
Superseded by #370: the branch moved to intergrado/rfd with the same commits. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Common Item Dialog doesn't always change the extension of the name when another file type is selected, and
FileDialogdoesn't say which type was selected. A save dialog opened withUntitled.psdand PSD, PNG and JPEG types can therefore returnUntitled.psdfor the PNG type.After the dialog returns, this asks it for the selected file type (
IFileDialog::GetFileTypeIndex, 1-based) and applies that type's first extension to the returned path when:set_file_name, and that extension isn't one of the selected type's.A typed extension is kept (
Untitled.pngtyped with the PSD type selected stays.png), and so is any extension the type lists, whatever its case. A type whose first extension is*or empty changes nothing. If the renamed path already exists, the path the dialog returned is kept, since the dialog only asked to overwrite that one. If the index can't be read, or names no type, the path is unchanged.The rule is a function of paths (
with_chosen_extension), and the lookup of the type by its index is another, so both have unit tests that don't need a dialog.This is the Windows counterpart of #341, which applies the same rules to the XDG portal. It is independent of #341 and of the macOS change in the same area.
Testing
*/empty types ignored, an index of 0, past the end, or with no types changes nothing.cargo checkandcargo clippy --all-targetsforx86_64-pc-windows-msvc, andcargo fmt --check.