1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use native_dialog::{FileDialog, MessageDialog, MessageType};

fn echo<T: std::fmt::Debug>(name: &str, value: &T) {
    MessageDialog::new()
        .set_title("Result")
        .set_text(&format!("{}:\n{:#?}", &name, &value))
        .show_alert()
        .unwrap();
}

fn main() {
    let result = MessageDialog::new()
        .set_title("Tour")
        .set_text("Do you want to begin the tour?")
        .set_type(MessageType::Warning)
        .show_confirm()
        .unwrap();
    if !result {
        return;
    }
    echo("show_confirm", &result);

    let result = FileDialog::new()
        .set_location("~")
        .show_open_single_file()
        .unwrap();
    echo("show_open_single_file", &result);

    let result = FileDialog::new()
        .add_filter("Rust Source", &["rs"])
        .add_filter("Image", &["png", "jpg", "gif"])
        .show_open_multiple_file()
        .unwrap();
    echo("show_open_multiple_file", &result);

    let result = FileDialog::new().show_open_single_dir().unwrap();
    echo("show_open_single_dir", &result);

    let result = FileDialog::new()
        .add_filter("Rust Source", &["rs"])
        .add_filter("Image", &["png", "jpg", "gif"])
        .show_save_single_file()
        .unwrap();
    echo("show_save_single_file", &result);

    MessageDialog::new()
        .set_title("End")
        .set_text("That's the end!")
        .show_alert()
        .unwrap();
}