Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/saurvs/nfd-rs
OS-native file dialogs on Linux, OS X and Windows
https://github.com/saurvs/nfd-rs
cross-platform dialog-box
Last synced: 7 days ago
JSON representation
OS-native file dialogs on Linux, OS X and Windows
- Host: GitHub
- URL: https://github.com/saurvs/nfd-rs
- Owner: saurvs
- License: mit
- Created: 2016-03-03T14:13:23.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-03-14T22:24:19.000Z (over 1 year ago)
- Last Synced: 2024-10-08T14:06:14.307Z (26 days ago)
- Topics: cross-platform, dialog-box
- Language: Rust
- Homepage:
- Size: 272 KB
- Stars: 156
- Watchers: 6
- Forks: 21
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-rust-cn - saurvs/nfd-rs
- awesome-rust - saurvs/nfd-rs
- awesome-rust - saurvs/nfd-rs
- awesome-rust-cn - saurvs/nfd-rs
- awesome-rust-zh - saurvs/nfd-rs - [nativefiledialog](https://github.com/mlabbe/nativefiledialog)绑定 (库 / GUI)
README
# nfd-rs [![](http://meritbadge.herokuapp.com/nfd)](https://crates.io/crates/nfd) [![](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/saurvs/nfd-rs/blob/master/LICENSE.md)
`nfd-rs` is a Rust binding to the library [nativefiledialog](https://github.com/mlabbe/nativefiledialog), that provides a convenient cross-platform interface to opening file dialogs on Linux, OS X and Windows.
This crate has been tested on Mac, Window and Linux (Ubuntu 14.04) and supports single/mutliple and save dialogs, notice APIs may break with newer versions.
## Usage
* Add the dependency `nfd` in your ```Cargo.toml```
```toml
[dependencies]
nfd = "0.0.4"
```* Open a single file dialog
```rust
extern crate nfd;use nfd::Response;
fn main() {
let result = nfd::open_file_dialog(None, None).unwrap_or_else(|e| {
panic!(e);
});match result {
Response::Okay(file_path) => println!("File path = {:?}", file_path),
Response::OkayMultiple(files) => println!("Files {:?}", files),
Response::Cancel => println!("User canceled"),
}
}
```* Open a multi file dialog using builder with jpg files as filter
```rust
extern crate nfd;use nfd::Response;
fn main() {
let result = nfd::dialog_multiple().filter("jpg").open().unwrap_or_else(|e| {
panic!(e);
});match result {
Response::Okay(file_path) => println!("File path = {:?}", file_path),
Response::OkayMultiple(files) => println!("Files {:?}", files),
Response::Cancel => println!("User canceled"),
}
}
```## Screenshot
![Cocoa on El Capitan](screenshots/cocoa_el_capitan.png?raw=true)