1#[cfg_attr(target_os = "macos", path = "macos/mod.rs")]
5#[cfg_attr(target_os = "linux", path = "linux/mod.rs")]
6#[cfg_attr(target_os = "windows", path = "windows/mod.rs")]
7mod os_dialog;
8
9use raw_window_handle::{HandleError, HasWindowHandle};
10use std::io;
11use thiserror::Error;
12
13#[derive(Error, Debug)]
14pub enum BlockingDialogError {
15 #[error("The dialog is not running on the main thread")]
16 NotOnMainThread,
17 #[error("IO error: {0}")]
18 Io(#[from] io::Error),
19 #[error("Handle error: {0}")]
20 Handle(HandleError),
21 #[error("Could not initialize COM")]
22 CouldNotInitializeCOM,
23}
24
25#[derive(Debug, Clone, Copy)]
26pub enum BlockingDialogLevel {
27 Info,
28 Warning,
29 Error,
30}
31
32#[derive(Debug, Clone)]
33pub struct BlockingAlertDialog<'a, W: HasWindowHandle> {
34 pub window: W,
35 pub title: &'a str,
36 pub message: &'a str,
37 pub level: BlockingDialogLevel,
38}
39
40#[derive(Debug, Clone)]
41pub struct BlockingConfirmDialog<'a, W: HasWindowHandle> {
42 pub window: W,
43 pub title: &'a str,
44 pub message: &'a str,
45 pub level: BlockingDialogLevel,
46}
47
48#[derive(Debug, Clone)]
49pub struct BlockingPickFilesDialogFilter<'a> {
50 pub name: &'a str,
51 pub extensions: &'a [&'a str],
52}
53
54#[derive(Debug, Clone)]
55pub struct BlockingPickFilesDialog<'a, W: HasWindowHandle> {
56 pub window: W,
57 pub title: &'a str,
58 pub multiple: bool,
59 pub filter: &'a [BlockingPickFilesDialogFilter<'a>],
60}
61
62#[derive(Debug, Clone)]
63pub struct BlockingPickDirectoryDialog<'a, W: HasWindowHandle> {
64 pub window: W,
65 pub title: &'a str,
66}
67
68#[derive(Debug, Clone)]
69pub struct BlockingSaveFileDialog<'a, W: HasWindowHandle> {
70 pub window: W,
71 pub title: &'a str,
72 pub default_filename: Option<&'a str>,
73 pub filter: &'a [BlockingPickFilesDialogFilter<'a>],
74}