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

native-dialog

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

16 releases (4 breaking)

0.5.2 Dec 21, 2020
0.4.4 Dec 11, 2020
0.4.3 Sep 9, 2020
0.4.1 Jul 29, 2020
Download history 1371/week @ 2020-09-25 1947/week @ 2020-10-02 1384/week @ 2020-10-09 1372/week @ 2020-10-16 1130/week @ 2020-10-23 764/week @ 2020-10-30 733/week @ 2020-11-06 673/week @ 2020-11-13 724/week @ 2020-11-20 1119/week @ 2020-11-27 631/week @ 2020-12-04 628/week @ 2020-12-11 520/week @ 2020-12-18 167/week @ 2020-12-25 458/week @ 2021-01-01 531/week @ 2021-01-08

4,373 downloads per month
Used in 2 crates

MIT license

57KB
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 result = FileDialog::new()
        .set_location("~/Desktop")
        .add_filter("PNG Image", &["png"])
        .add_filter("JPEG Image", &["jpg", "jpeg"])
        .show_open_single_file()
        .unwrap();

    let message = format!("{:#?}", result);

    let result = MessageDialog::new()
        .set_type(MessageType::Info)
        .set_title("Do you want to open these files?")
        .set_text(&message)
        .show_confirm()
        .unwrap();

    assert_eq!(result, true);
}

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 API of macOS has a limitation that all UI operations must be performed on the main thread.

Dependencies

~0.5–1.1MB
~26K SLoC