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 #[cfg(target_os = "linux")]
25 #[error("Native dialog error: {0}")]
26 NativeDialog(native_dialog::Error),
27}
28
29#[derive(Debug, Clone, Copy)]
30pub enum BlockingDialogLevel {
31 Info,
32 Warning,
33 Error,
34}
35
36#[derive(Debug, Clone)]
37pub struct BlockingAlertDialog<'a, W: HasWindowHandle> {
38 pub window: W,
39 pub title: &'a str,
40 pub message: &'a str,
41 pub level: BlockingDialogLevel,
42}
43
44#[derive(Debug, Clone)]
45pub struct BlockingConfirmDialog<'a, W: HasWindowHandle> {
46 pub window: W,
47 pub title: &'a str,
48 pub message: &'a str,
49 pub level: BlockingDialogLevel,
50}
51
52#[derive(Debug, Clone)]
53pub struct BlockingPickFilesDialogFilter<'a> {
54 pub name: &'a str,
55 pub extensions: &'a [&'a str],
56}
57
58#[derive(Debug, Clone)]
59pub struct BlockingPickFilesDialog<'a, W: HasWindowHandle> {
60 pub window: W,
61 pub title: &'a str,
62 pub multiple: bool,
63 pub filter: &'a [BlockingPickFilesDialogFilter<'a>],
64}
65
66#[derive(Debug, Clone)]
67pub struct BlockingPickDirectoryDialog<'a, W: HasWindowHandle> {
68 pub window: W,
69 pub title: &'a str,
70}
71
72#[derive(Debug, Clone)]
73pub struct BlockingSaveFileDialog<'a, W: HasWindowHandle> {
74 pub window: W,
75 pub title: &'a str,
76 pub default_filename: Option<&'a str>,
77 pub filter: &'a [BlockingPickFilesDialogFilter<'a>],
78}