macos: Add save-dialog format picker for named filters - #328
Merged
PolyMeilex merged 3 commits intoJul 17, 2026
Conversation
NSSavePanel previously merged every registered filter into one flat, unnamed allowed-types list (via the deprecated setAllowedFileTypes), unlike Windows/Linux which already show filter names. When two or more filters are registered, save_file now shows a "Format:" accessory view (label configurable via set_format_label) that switches the panel's allowed content types live via the modern allowedContentTypes API. Open-panel filtering was also modernized off the deprecated API as part of the same cleanup.
add_filters is only used by the open-panel builders, which are unrelated to the save-dialog format-picker feature added in aee3582. Restore its original deprecated setAllowedFileTypes implementation to keep this branch scoped to the save dialog; behavior is unchanged either way (filters are still merged into one flat list).
The previous phrasing nested "0 or 1 filters registered" inside a "don't support filter names" parenthetical, which read awkwardly and implied the 0-filter case was somehow about unsupported names rather than there being nothing to name.
Contributor
Author
|
Hi @PolyMeilex I'm happy to close this PR, if you don't feel it match the purpose or the intent of this repo. |
PolyMeilex
approved these changes
Jul 17, 2026
Owner
|
Thanks |
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
NSSavePanelpreviously merged every filter registered viaadd_filterinto oneflat, unnamed allowed-types list (via the deprecated
setAllowedFileTypes), unlikeWindows and Linux, which already show filter names to the user. This PR adds a
"Format:" picker to the macOS save dialog, matching the native convention used by
apps like TextEdit/Safari.
save_filenow shows a "Format:"accessory view (an
NSPopUpButton) listing each filter's name. Selecting onelive-updates the panel's allowed content types (and the auto-appended extension)
via the modern
allowedContentTypesAPI.shown, since there's nothing to choose between.
FileDialog::set_format_label/AsyncFileDialog::set_format_labelsocallers can customize the picker's label (defaults to
"Format:").add_filter/save_filedoc comments to describe the newmacOS behavior.
Test plan
cargo build/cargo checkclean on macOSexamples/save.rswith two filters registered:auto-appended extension (
.txt→.rtf)set_format_labelrenders correctly at various lengthsbehavior
pick_file/pick_files) filtering unaffected