Printing failures say printing failed, in every app (T-13)

This commit is contained in:
ZacharyZhang-NY committed 2026-10-09 19:49:08 -04:00
1 parent 18158a8282
commit 843657a6b3
9 files changed
+18 -20

No files matched your search

+7 -6
View File
@@ -242,11 +242,7 @@ pub fn in_window<H: Host, R>(
}
/// Opens the print panel after GPUI releases the app.
pub fn print_later<H: Host>(
pdf: std::path::PathBuf,
cx: &mut Context<H>,
failed: impl FnOnce(&mut H, String, &mut Context<H>) + 'static,
) {
pub fn print_later<H: Tabs>(pdf: std::path::PathBuf, cx: &mut Context<H>) {
// The panel's modal loop calls back into GPUI.
cx.spawn(async move |this, cx| {
let printed = ely_platform::print::print_pdf(&pdf);
@@ -258,7 +254,7 @@ pub fn print_later<H: Host>(
Ok(printed) => log::info!("office: print done, printed {printed}"),
Err(error) => {
if this
.update(cx, |host, cx| failed(host, error.to_string(), cx))
.update(cx, |host, cx| host.print_failed(&error.to_string(), cx))
.is_err()
{
log::error!("office: printing failed after its window closed: {error}");
@@ -293,6 +289,11 @@ pub trait Tabs: Host {
self.toast_unlogged(text, severity, cx);
}
fn print_failed(&self, error: &str, cx: &mut App) {
let text = text(cx, "office.print.failed", &[("error", error)]);
self.toast(text, Severity::Danger, cx);
}
/// A success toast with a button that opens `path`.
fn toast_output(&self, text: SharedString, path: std::path::PathBuf, cx: &mut App) {
log::info!("{}: {text}", Self::KIND.app.slug());