about_dialog/
about-dialog.rs

1use nvdialog_rs::{AboutDialog, FileDialog, FileDialogType, Image, Object};
2use std::process::abort;
3
4fn main() {
5    nvdialog_rs::init().expect("failed to initialize libnvdialog");
6    let extensions = ["png", "jpeg", "jpg", "ico", "webp"];
7    let filedlg = FileDialog::new(
8        "Choose the icon for the dialog",
9        FileDialogType::OpenFile,
10        Some(extensions),
11    );
12    let filename = filedlg.retrieve_filename().unwrap_or_else(|| {
13        eprintln!("No filename given!");
14        abort()
15    });
16    let img = Image::from_filename(filename).unwrap_or_else(|e| {
17        eprintln!("Failed to read image! {}", e.to_string());
18        abort();
19    });
20
21    let dialog = AboutDialog::new()
22        .name("NvDialog Example")
23        .description(
24            "An example of using nvdialog-rs and NvdAboutDialog, with a custom user-picked icon",
25        )
26        .icon(img)
27        .build();
28
29    dialog.show();
30}