tour/
tour.rs

1use native_dialog::{FileDialog, MessageDialog, MessageType};
2
3fn echo<T: std::fmt::Debug>(name: &str, value: &T) {
4    MessageDialog::new()
5        .set_title("Result")
6        .set_text(&format!("{}:\n{:#?}", &name, &value))
7        .show_alert()
8        .unwrap();
9}
10
11fn main() {
12    let result = MessageDialog::new()
13        .set_title("Tour")
14        .set_text("Do you want to begin the tour?")
15        .set_type(MessageType::Warning)
16        .show_confirm()
17        .unwrap();
18    if !result {
19        return;
20    }
21    echo("show_confirm", &result);
22
23    let result = FileDialog::new()
24        .set_location("~")
25        .show_open_single_file()
26        .unwrap();
27    echo("show_open_single_file", &result);
28
29    let result = FileDialog::new()
30        .add_filter("Rust Source", &["rs"])
31        .add_filter("Image", &["png", "jpg", "gif"])
32        .show_open_multiple_file()
33        .unwrap();
34    echo("show_open_multiple_file", &result);
35
36    let result = FileDialog::new().show_open_single_dir().unwrap();
37    echo("show_open_single_dir", &result);
38
39    let result = FileDialog::new()
40        .add_filter("Rust Source", &["rs"])
41        .add_filter("Image", &["png", "jpg", "gif"])
42        .show_save_single_file()
43        .unwrap();
44    echo("show_save_single_file", &result);
45
46    MessageDialog::new()
47        .set_title("End")
48        .set_text("That's the end!")
49        .show_alert()
50        .unwrap();
51}