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).
32 lines
1.5 KiB
TOML
32 lines
1.5 KiB
TOML
[package]
|
|
name = "craft-appkit"
|
|
description = "The macOS menu-tracking observers and Save panel calls that need `unsafe`, behind a safe API, so no other crate allows `unsafe`."
|
|
version.workspace = true
|
|
edition.workspace = true
|
|
license.workspace = true
|
|
rust-version.workspace = true
|
|
repository.workspace = true
|
|
|
|
# `NSMenuDidBeginTrackingNotification` and `NSMenuDidEndTrackingNotification`, observed through
|
|
# `NSNotificationCenter` with a block. A Save panel made with `-init`, and the target of a pop-up menu's action.
|
|
[target.'cfg(target_os = "macos")'.dependencies]
|
|
block2 = "0.6.2"
|
|
objc2 = { version = "0.6.4", default-features = false, features = ["std"] }
|
|
objc2-app-kit = { version = "0.3.2", default-features = false, features = ["std", "NSButton", "NSControl", "NSMenu", "NSPanel", "NSPopUpButton", "NSResponder", "NSSavePanel", "NSView", "NSWindow"] }
|
|
objc2-foundation = { version = "0.3.2", default-features = false, features = ["std", "block2", "NSNotification", "NSObject", "NSOperation", "NSString"] }
|
|
|
|
# The workspace table with `unsafe_code` at `deny`: `lib.rs` allows it for this crate's FFI calls, and design-lint's
|
|
# `contract/unsafe-allow` rule names this crate's source as one of the places that may. Cargo cannot override one
|
|
# workspace lint.
|
|
[lints.rust]
|
|
unsafe_code = "deny"
|
|
missing_docs = "warn"
|
|
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(craft_pdf_unicode_fixtures)"] }
|
|
|
|
[lints.clippy]
|
|
cognitive_complexity = "deny"
|
|
too_many_arguments = "deny"
|
|
wildcard_imports = "deny"
|
|
dbg_macro = "warn"
|
|
todo = "warn"
|