mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-29 17:55:45 +01:00
A Save on macOS that offers two or more file types showed rfd's panel,
which allows every type's extension but has no menu to pick one, and
answered without a picked type. A document saved from such a panel kept
the suggested extension unless the user typed another one.
- macos.rs: such a Save is a sheet made with a Format menu (the panel's
accessory view, set before the sheet begins). The menu lists each type
by name with the suggested name's type chosen. Choosing a type puts its
extensions first in the allowed types and changes the extension in the
name field. The answer is `Saved` with the chosen type in `filter`, so
the save flow's picked-type rules apply as they do for the portal.
- format_menu.rs: the rules, tested on every platform: which types the
menu lists, distinct item titles, the renamed name, the allowed
extensions, and the type an answer reports (an extension the user typed
for another listed type wins; a name the panel kept with the suggested
extension keeps the chosen type).
- craft-appkit: `save_panel::new_save_panel` (nil from AppKit is `None`)
and `save_panel::on_choose` (a pop-up menu's action as a closure).
- `FileDialog::format_label` and `FilePanels::set_format_label` set the
menu's label in the app's language ("Format:" when unset).
64 lines
3.3 KiB
TOML
64 lines
3.3 KiB
TOML
[package]
|
|
name = "craft-dialogs"
|
|
description = "Native file and message dialogs that never block the event loop: queued requests, shown at the end of the frame, answered on a later frame."
|
|
version.workspace = true
|
|
edition.workspace = true
|
|
license.workspace = true
|
|
rust-version.workspace = true
|
|
repository.workspace = true
|
|
autotests = false
|
|
|
|
[lib]
|
|
# The lib's test target is the crate's one test executable: its trials and, with `screen-testing`, the
|
|
# screen tests in tests/it.
|
|
harness = false
|
|
|
|
# Versions the apps already pin (rfd 0.17.2, raw-window-handle 0.6.2), so adopting the crate adds
|
|
# nothing new to their Cargo.lock. rfd without its `wayland` feature, which links libwayland-client
|
|
# through pkg-config unless winit's `dlopen` is in the build too; the apps' own rfd keeps it on.
|
|
[dependencies]
|
|
craft-atomic = { workspace = true }
|
|
craft-host = { workspace = true }
|
|
craft-i18n = { workspace = true }
|
|
craft-platform = { workspace = true }
|
|
craft-behavior = { workspace = true, optional = true }
|
|
craft-browse = { workspace = true, optional = true }
|
|
craft-ui = { workspace = true, optional = true }
|
|
egui = { workspace = true, optional = true }
|
|
raw-window-handle = "0.6.2"
|
|
# `ui`: the file chooser's automation fields are JSON (craft-ui does not re-export serde_json).
|
|
serde_json = { workspace = true, optional = true }
|
|
rfd = { version = "0.17.2", default-features = false, features = ["xdg-portal"] }
|
|
|
|
# The file-dialog probe asks the session bus whether the desktop portal offers a file chooser.
|
|
# The free-standing Open and Folder panel (`beginWithCompletionHandler:`), and the Save sheet with a
|
|
# Format menu (`beginSheetModalForWindow:completionHandler:`). rfd and winit already use these.
|
|
[target.'cfg(target_os = "macos")'.dependencies]
|
|
block2 = "0.6.2"
|
|
craft-appkit = { workspace = true }
|
|
objc2 = { version = "0.6.4", default-features = false, features = ["std"] }
|
|
objc2-app-kit = { version = "0.3.2", default-features = false, features = ["std", "block2", "NSAccessibilityProtocols", "NSApplication", "NSButton", "NSControl", "NSOpenPanel", "NSPanel", "NSPopUpButton", "NSResponder", "NSSavePanel", "NSText", "NSTextField", "NSView", "NSWindow", "objc2-core-foundation"] }
|
|
objc2-foundation = { version = "0.3.2", default-features = false, features = ["std", "NSArray", "NSGeometry", "NSString", "NSURL", "objc2-core-foundation"] }
|
|
|
|
# The Linux and BSD Save panel asks the desktop portal itself, which reports the file type picked.
|
|
# The versions craft-platform already builds (zbus with async-io and blocking-api), so adopting the
|
|
# crate adds nothing new to the apps' Cargo.lock. The cfg is the one on `mod portal` in `lib.rs`.
|
|
[target.'cfg(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
|
|
futures-lite = "2"
|
|
log = "0.4"
|
|
zbus = { version = "5", default-features = false, features = ["async-io", "blocking-api"] }
|
|
|
|
[features]
|
|
suite = ["screen-testing", "craft-ui/suite"]
|
|
default = []
|
|
# `craft_dialogs::ui`: `PathField` and the other egui parts of the file service.
|
|
ui = ["dep:craft-behavior", "dep:craft-browse", "dep:craft-ui", "dep:egui", "dep:serde_json"]
|
|
# The stories and the integration binary of the file service's UI parts.
|
|
screen-testing = ["ui", "craft-ui/testing"]
|
|
|
|
[dev-dependencies]
|
|
craft-ui = { workspace = true, features = ["suite"] }
|
|
|
|
[lints]
|
|
workspace = true
|