#dialog #native #windows #unix #display #bsd #macos #dialogs

native-dialog

A library to display dialogs. Supports GNU/Linux, BSD Unix, macOS and Windows.

18 releases (4 breaking)

0.5.5 Feb 19, 2021
0.5.2 Dec 21, 2020
0.4.3 Sep 9, 2020
0.4.1 Jul 29, 2020

#80 in macOS APIs

Download history 292/week @ 2020-12-22 283/week @ 2020-12-29 466/week @ 2021-01-05 506/week @ 2021-01-12 559/week @ 2021-01-19 495/week @ 2021-01-26 721/week @ 2021-02-02 838/week @ 2021-02-09 1610/week @ 2021-02-16 680/week @ 2021-02-23 547/week @ 2021-03-02 1103/week @ 2021-03-09 815/week @ 2021-03-16 1018/week @ 2021-03-23 729/week @ 2021-03-30 687/week @ 2021-04-06

2,724 downloads per month
Used in 3 crates

MIT license

61KB
1.5K SLoC

native-dialog

Crates.io Docs.rs License

A library to display file choosers and message boxes. Supports GNU/Linux, BSD Unix, macOS and Windows.

Installation

cargo add native-dialog

Usage

use native_dialog::{FileDialog, MessageDialog, MessageType};

fn main() {
    let path = FileDialog::new()
        .set_location("~/Desktop")
        .add_filter("PNG Image", &["png"])
        .add_filter("JPEG Image", &["jpg", "jpeg"])
        .show_open_single_file()
        .unwrap();

    let path = match path {
        Some(path) => path,
        None => return,
    };

    let yes = MessageDialog::new()
        .set_type(MessageType::Info)
        .set_title("Do you want to open the file?")
        .set_text(&format!("{:#?}", path))
        .show_confirm()
        .unwrap();

    if yes {
        do_something(path);
    }
}

Misc

Why the dialogs look ugly/blurry on Windows?

Turn on crate features or embed manifests into the .exe to enable visual styling and dpi awareness for your program. Check out examples/windows_manifest and examples/windows_features for example.

Why the program crashed when opening a dialog on macOS?

The UI framework of macOS (Cocoa) has a limitation that all UI operations must be performed on the main thread.

Dependencies

~0.4–1.1MB
~26K SLoC