|
|
@ -53,14 +53,8 @@ impl<R: Runtime> Dialog<R> {
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(not(target_os = "linux"))]
|
|
|
|
#[cfg(not(target_os = "linux"))]
|
|
|
|
macro_rules! run_dialog {
|
|
|
|
macro_rules! run_dialog {
|
|
|
|
($e:expr, $h: ident) => {{
|
|
|
|
($e:expr, $h: expr) => {{
|
|
|
|
std::thread::spawn(move || {
|
|
|
|
std::thread::spawn(move || $h(tauri::async_runtime::block_on($e)));
|
|
|
|
let response = tauri::async_runtime::block_on($e);
|
|
|
|
|
|
|
|
$h(!matches!(
|
|
|
|
|
|
|
|
response,
|
|
|
|
|
|
|
|
rfd::MessageDialogResult::No | rfd::MessageDialogResult::Cancel
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}};
|
|
|
|
}};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -69,13 +63,7 @@ macro_rules! run_dialog {
|
|
|
|
($e:expr, $h: ident) => {{
|
|
|
|
($e:expr, $h: ident) => {{
|
|
|
|
std::thread::spawn(move || {
|
|
|
|
std::thread::spawn(move || {
|
|
|
|
let context = glib::MainContext::default();
|
|
|
|
let context = glib::MainContext::default();
|
|
|
|
context.invoke_with_priority(glib::PRIORITY_HIGH, move || {
|
|
|
|
context.invoke_with_priority(glib::PRIORITY_HIGH, move || $h($e));
|
|
|
|
let response = $e;
|
|
|
|
|
|
|
|
$h(!matches!(
|
|
|
|
|
|
|
|
response,
|
|
|
|
|
|
|
|
rfd::MessageDialogResult::No | rfd::MessageDialogResult::Cancel
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}};
|
|
|
|
}};
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -83,10 +71,7 @@ macro_rules! run_dialog {
|
|
|
|
#[cfg(not(target_os = "linux"))]
|
|
|
|
#[cfg(not(target_os = "linux"))]
|
|
|
|
macro_rules! run_file_dialog {
|
|
|
|
macro_rules! run_file_dialog {
|
|
|
|
($e:expr, $h: ident) => {{
|
|
|
|
($e:expr, $h: ident) => {{
|
|
|
|
std::thread::spawn(move || {
|
|
|
|
std::thread::spawn(move || $h(tauri::async_runtime::block_on($e)));
|
|
|
|
let response = tauri::async_runtime::block_on($e);
|
|
|
|
|
|
|
|
$h(response);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}};
|
|
|
|
}};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -95,10 +80,7 @@ macro_rules! run_file_dialog {
|
|
|
|
($e:expr, $h: ident) => {{
|
|
|
|
($e:expr, $h: ident) => {{
|
|
|
|
std::thread::spawn(move || {
|
|
|
|
std::thread::spawn(move || {
|
|
|
|
let context = glib::MainContext::default();
|
|
|
|
let context = glib::MainContext::default();
|
|
|
|
context.invoke_with_priority(glib::PRIORITY_HIGH, move || {
|
|
|
|
context.invoke_with_priority(glib::PRIORITY_HIGH, move || $h($e));
|
|
|
|
let response = $e;
|
|
|
|
|
|
|
|
$h(response);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}};
|
|
|
|
}};
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -226,5 +208,16 @@ pub fn show_message_dialog<R: Runtime, F: FnOnce(bool) + Send + 'static>(
|
|
|
|
dialog: MessageDialogBuilder<R>,
|
|
|
|
dialog: MessageDialogBuilder<R>,
|
|
|
|
f: F,
|
|
|
|
f: F,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
|
|
|
|
use rfd::MessageDialogResult;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let ok_label = dialog.ok_button_label.clone();
|
|
|
|
|
|
|
|
let f = move |res| {
|
|
|
|
|
|
|
|
f(match res {
|
|
|
|
|
|
|
|
MessageDialogResult::Ok | MessageDialogResult::Yes => true,
|
|
|
|
|
|
|
|
MessageDialogResult::Custom(s) => ok_label.map_or(s == OK, |ok_label| ok_label == s),
|
|
|
|
|
|
|
|
_ => false,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
run_dialog!(MessageDialog::from(dialog).show(), f);
|
|
|
|
run_dialog!(MessageDialog::from(dialog).show(), f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|