GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
src/file_dialog.rs (659B)
1 use std::path::PathBuf;
2
3 /// Opens a portal file chooser dialog for selecting a file.
4 pub fn pick_file(title: &str, filters: &[(&str, &[&str])]) -> Option<PathBuf> {
5 let mut dialog = rfd::FileDialog::new().set_title(title);
6 for (name, exts) in filters {
7 dialog = dialog.add_filter(*name, *exts);
8 }
9 dialog.pick_file()
10 }
11
12 /// Opens a portal file chooser dialog for saving a file.
13 pub fn save_file(title: &str, filters: &[(&str, &[&str])]) -> Option<PathBuf> {
14 let mut dialog = rfd::FileDialog::new().set_title(title);
15 for (name, exts) in filters {
16 dialog = dialog.add_filter(*name, *exts);
17 }
18 dialog.save_file()
19 }