Compare commits

...
Author SHA1 Message Date
Martin Ball 95bea6a1da Merge remote-tracking branch 'origin/main' into fix/print-page-clears-old-job-message
; Conflicts:
;	docs/ui-parity.md
2026-11-04 21:01:17 +00:00
Martin BallandClaude Opus 5.5 6384a47b3b Print page: the last job's marker is kept per window, since egui counts passes per viewport
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FypgCYPZSei56X4AGFPSu5
2026-11-04 16:56:51 +00:00
Martin BallandClaude Opus 5.5 860f695108 File › Print: opened again, the page doesn't repeat the last job's message
"Print job submitted…" (or a failure) stayed on the Print page the next
time it was opened. The job's outcome is said once in the status bar, so a
fresh open drops it; a failure arriving while the page is open stays, and
printer status (finding printers, none found) still shows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FypgCYPZSei56X4AGFPSu5
2026-11-04 16:47:26 +00:00
6 changed files with 65 additions and 1 deletions
+2
View File
@@ -55,6 +55,7 @@ impl WordApp {
seen_full_screen,
escape_free,
word_count,
print_page_pass,
missing_fonts,
last_autosave,
equation_prev_tab,
@@ -170,6 +171,7 @@ impl WordApp {
seen_full_screen,
escape_free,
word_count,
print_page_pass,
missing_fonts,
last_autosave,
equation_prev_tab,
+3
View File
@@ -588,6 +588,9 @@ pub struct WordApp {
/// layout they were read from.
pub missing_fonts: crate::chrome::MissingFontsMemo,
pub word_count: (u64, usize),
/// The window's viewport and the pass its Print page was last drawn in: a gap means the
/// page has just been opened. Per window, as each window counts its own passes.
print_page_pass: Option<(egui::ViewportId, u64)>,
last_autosave: f64,
/// The tab shown before the Equation tab came up (restored when editing ends).
pub(crate) equation_prev_tab: Option<String>,
+17
View File
@@ -178,6 +178,23 @@ pub fn show(app: &mut WordApp, ui: &mut Ui) {
let total = lay.pages.len();
let current = app.session.current_pages(&lay);
app.ui.print.preview = app.ui.print.preview.min(total.saturating_sub(1));
// Opened afresh, the page doesn't repeat how the last job went: that was said once in the
// status bar. What the printers are doing (finding them, none found) still shows.
// Passes are counted per viewport, so the marker is per window and names its viewport.
let here = (ctx.viewport_id(), ctx.cumulative_pass_nr());
let opened = app.print_page_pass.is_none_or(|(viewport, last)| viewport != here.0 || last.saturating_add(1) < here.1);
app.print_page_pass = Some(here);
// Only once the status bar has said it (`print_feedback`), so nothing goes unsaid.
if opened
&& !app.printing.busy()
&& app.printing.message == app.print_feedback_seen
&& matches!(
app.printing.message,
Some(crate::printing::Feedback::Submitted(_) | crate::printing::Feedback::Failed(_) | crate::printing::Feedback::WorkerStopped)
)
{
app.printing.message = None;
}
let settings = |app: &mut WordApp, ui: &mut Ui| {
{
+37
View File
@@ -3444,6 +3444,43 @@ fn the_print_button_shows_only_with_a_print_hook() {
}
}
/// Opened again, the Print page doesn't repeat how the last job went (that was said once, in the
/// status bar), but a failure that comes in while it is open stays, and what the printers are
/// doing (none found) shows each time.
#[test]
fn the_print_page_opens_without_the_last_jobs_message() {
use crate::printing::Feedback;
let mut a = app();
// A job went away earlier: its message was said in the status bar, and the page closed.
a.printing.message = Some(Feedback::Submitted("job 7".into()));
a.print_feedback_seen = a.printing.message.clone();
a.run("file.print", json!({})).unwrap();
let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(1440.0, 900.0)).build_ui_state(
|ui, app: &mut WordApp| {
let ctx = ui.ctx().clone();
app.logic(&ctx);
app.ui(ui);
},
a,
);
h.run_steps(4);
assert_eq!(h.state().printing.message, None, "the last job's message is gone");
h.state_mut().printing.message = Some(Feedback::Failed("no paper".into()));
h.run_steps(3);
assert_eq!(h.state().printing.message, Some(Feedback::Failed("no paper".into())), "a failure on the open page stays");
let leave_and_reopen = |h: &mut egui_kittest::Harness<'_, WordApp>| {
let _ = h.state_mut().run("ui.backstage", json!({"value": false}));
h.run_steps(2);
let _ = h.state_mut().run("file.print", json!({}));
h.run_steps(2);
};
leave_and_reopen(&mut h);
assert_eq!(h.state().printing.message, None, "reopened, the failure is gone");
h.state_mut().printing.message = Some(Feedback::NoPrinters);
leave_and_reopen(&mut h);
assert_eq!(h.state().printing.message, Some(Feedback::NoPrinters), "no printers still shows");
}
/// Return on the Print page prints, as in Word, where ⌘P opens on Print as the default
/// button; the document isn't typed into.
#[test]
+4
View File
@@ -39,6 +39,7 @@ pub(crate) struct WindowUi {
pub(crate) seen_full_screen: Option<bool>,
pub(crate) escape_free: bool,
pub(crate) word_count: (u64, usize),
pub(crate) print_page_pass: Option<(egui::ViewportId, u64)>,
/// Per window, as each window shows its own layout: one shared list would be read again
/// on every frame of every window.
pub(crate) missing_fonts: crate::chrome::MissingFontsMemo,
@@ -112,6 +113,7 @@ impl WindowUi {
seen_full_screen: None,
escape_free: false,
word_count: NOT_COUNTED,
print_page_pass: None,
missing_fonts: Default::default(),
last_autosave: 0.0,
equation_prev_tab: None,
@@ -239,6 +241,7 @@ impl WordApp {
seen_full_screen,
escape_free,
word_count,
print_page_pass,
missing_fonts,
last_autosave,
equation_prev_tab,
@@ -337,6 +340,7 @@ impl WordApp {
seen_full_screen,
escape_free,
word_count,
print_page_pass,
missing_fonts,
last_autosave,
equation_prev_tab,
+2 -1
View File
File diff suppressed because one or more lines are too long