pub enum FileDialogType {
Open,
Save,
}
#[derive(Debug, Clone, Default)]
pub struct FileDialogOptions {
pub show_hidden: bool,
pub allowed_types: Option<Vec<FileSpec>>,
}
#[derive(Debug, Clone, Copy)]
pub struct FileSpec {
pub name: &'static str,
pub extensions: &'static [&'static str],
}
impl FileDialogOptions {
pub fn new() -> FileDialogOptions {
FileDialogOptions::default()
}
pub fn show_hidden(mut self) -> Self {
self.show_hidden = true;
self
}
pub fn allowed_types(mut self, types: Vec<FileSpec>) -> Self {
self.allowed_types = Some(types);
self
}
}
impl FileSpec {
pub const TEXT: FileSpec = FileSpec::new("Text", &["txt"]);
pub const JPG: FileSpec = FileSpec::new("Jpeg", &["jpg", "jpeg"]);
pub const GIF: FileSpec = FileSpec::new("Gif", &["gif"]);
pub const PDF: FileSpec = FileSpec::new("PDF", &["pdf"]);
pub const HTML: FileSpec = FileSpec::new("Web Page", &["htm", "html"]);
pub const fn new(name: &'static str, extensions: &'static [&'static str]) -> Self {
FileSpec { name, extensions }
}
}