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());
+2
View File
@@ -16,6 +16,7 @@ pub(super) const EN: &[(&str, &str)] = &[
"A conversion writes a new file; pick another name",
),
("office.error.changed", "The document changed meanwhile; try again"),
("office.print.failed", "Printing failed: {error}"),
("office.recovery.failed", "A recovery copy was not written: {error}"),
("office.recovery.off", "Recovery copies are off for this run: {error}"),
("office.recovery.lost", "{name} could not be recovered: {error}"),
@@ -101,6 +102,7 @@ pub(super) const ZH_CN: &[(&str, &str)] = &[
("office.error.conflict", "{name} 已在磁盘上改动,保存已停止"),
("office.error.convert", "格式转换要写成新文件,请换个名字"),
("office.error.changed", "文档在此间已改动,请重试"),
("office.print.failed", "打印失败:{error}"),
("office.recovery.failed", "恢复副本未能写入:{error}"),
("office.recovery.off", "本次运行不写恢复副本:{error}"),
("office.recovery.lost", "{name} 未能恢复:{error}"),