mirror of
https://github.com/storytold/deckcraft.git
synced 2026-12-02 22:30:34 +00:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b38732e120 | ||
|
|
16cb262983 | ||
|
|
cf091013e6 | ||
|
|
c29124a389 | ||
|
|
e4c99e2d6f | ||
|
|
c33deedb94 |
@@ -0,0 +1,45 @@
|
||||
name: DeckCraft Windows print integration
|
||||
on:
|
||||
push:
|
||||
branches: [verify/deckcraft-windows-print-4859]
|
||||
permissions:
|
||||
contents: read
|
||||
jobs:
|
||||
print:
|
||||
runs-on: windows-2025
|
||||
timeout-minutes: 120
|
||||
env:
|
||||
CARGO_PROFILE_DEV_DEBUG: '0'
|
||||
CARGO_PROFILE_TEST_DEBUG: '0'
|
||||
CARGO_INCREMENTAL: '0'
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
|
||||
- uses: storytold/craft-common-actions/actions/checkout-craft-fonts@58848078cd09e3ca182891a8b76ee979f1eb6e1c
|
||||
with:
|
||||
ref: 37827adc41fd165f9a9234ac40f94dbad353aa69
|
||||
- name: Choose the build volume
|
||||
shell: pwsh
|
||||
run: |
|
||||
$disk = Get-PSDrive -PSProvider FileSystem | Where-Object { $_.Free -gt 0 -and $_.Root -match '^[A-Za-z]:\\$' } | Sort-Object -Descending Free | Select-Object -First 1
|
||||
"CARGO_TARGET_DIR=$(Join-Path $disk.Root "deck-print-$env:GITHUB_RUN_ID")" >> $env:GITHUB_ENV
|
||||
- name: Run native print UI and fallback tests together
|
||||
shell: bash
|
||||
run: |
|
||||
set -eo pipefail
|
||||
cargo test --locked -p deckcraft-ui-egui --lib print 2>&1 | tee deck-print-ui.log
|
||||
grep -E 'direct_print_reports_the_spooler_failure_and_keeps_the_viewer.*ok' deck-print-ui.log
|
||||
grep -E 'print_previews_pages_and_prints_a_pdf.*ok' deck-print-ui.log
|
||||
- name: Exercise the desktop executable's print-helper entry point
|
||||
shell: bash
|
||||
run: |
|
||||
set -eu
|
||||
cargo build --locked -p deckcraft --bin deckcraft
|
||||
python - <<'PY'
|
||||
import os, subprocess
|
||||
from pathlib import Path
|
||||
exe = Path(os.environ["CARGO_TARGET_DIR"]) / "debug" / "deckcraft.exe"
|
||||
child = subprocess.run([exe, "--craft-print-helper"], capture_output=True, text=True, timeout=15)
|
||||
print(child.stdout, child.stderr)
|
||||
assert child.returncode == 1
|
||||
assert "CRAFT_PRINT:" in child.stdout and "print helper directory missing" in child.stdout
|
||||
PY
|
||||
@@ -22,7 +22,7 @@ log = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
craft = { workspace = true, features = ["web-api", "web-host", "platform-browser"] }
|
||||
craft = { workspace = true, features = ["web-api", "web-host", "platform-browser", "print"] }
|
||||
# `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback.
|
||||
eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] }
|
||||
wasm-bindgen = "0.2"
|
||||
|
||||
@@ -90,6 +90,7 @@ pub fn start() {
|
||||
}
|
||||
let mut app = SlideApp::new(&cc.egui_ctx, platform).map_err(|error| std::io::Error::other(error.to_string()))?;
|
||||
app.services.presenter = crate::presenter::opener(&cc.egui_ctx);
|
||||
app.services.browser_print = Some(Box::new(craft::print::browser::print_pdf));
|
||||
// In host mode the parent sends the presentation to edit; no sample meanwhile.
|
||||
if app_bridge.is_some() {
|
||||
if let Err(e) = app.start_for_host() {
|
||||
|
||||
@@ -15,7 +15,7 @@ craft-nightly = { workspace = true }
|
||||
deckcraft-engine = { workspace = true }
|
||||
deckcraft-ui-egui = { workspace = true }
|
||||
deckcraft-media = { workspace = true }
|
||||
craft = { workspace = true, features = ["ui-app", "window", "gpu-startup", "quit", "dialogs", "platform", "platform-clipboard-system", "automation", "settings", "font-catalog"] }
|
||||
craft = { workspace = true, features = ["ui-app", "window", "gpu-startup", "quit", "dialogs", "platform", "platform-clipboard-system", "automation", "settings", "font-catalog", "print"] }
|
||||
# `clipboard` is the OS clipboard (Ctrl+C/X/V with other apps). Without it egui simulates one inside
|
||||
# the app; the egui 0.37 migration (#1350) dropped it from this list.
|
||||
eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit", "clipboard", "links", "wayland", "x11"] }
|
||||
|
||||
@@ -268,6 +268,10 @@ fn report_launch_profile_error(error: &str) {
|
||||
pub(crate) const LOG_DIR: &str = "logs";
|
||||
|
||||
fn main() -> eframe::Result {
|
||||
#[cfg(windows)]
|
||||
if let Some(code) = craft::print::spool::isolated::helper_main() {
|
||||
std::process::exit(code);
|
||||
}
|
||||
let Some(arguments) = prepare_launch() else { return Ok(()) };
|
||||
let nightly = launch_profile::current().is_nightly();
|
||||
// Nightly session health: the record names this window's owner and survives an abnormal end.
|
||||
@@ -433,6 +437,7 @@ fn main() -> eframe::Result {
|
||||
}
|
||||
}
|
||||
let mut app = SlideApp::new(ctx, platform)?;
|
||||
app.enable_direct_print();
|
||||
if !nightly {
|
||||
// Nightly is managed by ArtCraft Launcher: no self-update prompt or stable feed.
|
||||
app.enable_update_checks();
|
||||
|
||||
@@ -28,7 +28,7 @@ log = { workspace = true }
|
||||
web-time = { workspace = true }
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
craft = { workspace = true, features = ["update"] }
|
||||
craft = { workspace = true, features = ["update", "print"] }
|
||||
craft-update = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
@@ -195,6 +195,8 @@ impl SlideApp {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
print_previews: Default::default(),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
print_spool: None,
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
updates_rt: Default::default(),
|
||||
selpane: Default::default(),
|
||||
align_to: None,
|
||||
@@ -220,6 +222,12 @@ impl SlideApp {
|
||||
self.print_previews.cleanup();
|
||||
}
|
||||
|
||||
/// Installs the system print spool for the native desktop shell.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn enable_direct_print(&mut self) {
|
||||
self.print_spool = Some(craft::print::spool::Spool::new(self.host.jobs_shared().clone()));
|
||||
}
|
||||
|
||||
/// Holds the close request until dirty presentations have passed the closing guard.
|
||||
pub fn close_decision(&mut self) -> embed::CloseDecision {
|
||||
let dirty: Vec<_> = self.session.documents().iter().filter(|doc| doc.is_dirty()).map(|doc| doc.uid).collect();
|
||||
@@ -248,6 +256,9 @@ impl SlideApp {
|
||||
}
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
if let Some(spool) = self.print_spool.take() {
|
||||
spool.shutdown();
|
||||
}
|
||||
self.start_pending_update();
|
||||
self.cleanup_print_previews();
|
||||
}
|
||||
|
||||
@@ -257,14 +257,24 @@ impl SlideApp {
|
||||
self.submit_save(uid, None, files, &suggested, false, instance)
|
||||
}
|
||||
|
||||
/// File › Print: DeckCraft prints through a PDF. On the desktop the PDF (with the Print page's
|
||||
/// layout, slides and options) is written to the temporary folder and opened in the system's
|
||||
/// PDF viewer, which has the printers; on the web it downloads.
|
||||
/// File › Print: use the same PDF layout, slides and options with the host's available route.
|
||||
/// The browser opens its print dialog when installed. Other hosts open their viewer or export.
|
||||
pub fn print_pdf(&mut self, params: Value) -> bool {
|
||||
if self.session.active().is_none() {
|
||||
return false;
|
||||
}
|
||||
let Some(active) = self.session.active() else { return false };
|
||||
let params = if params.is_object() { params } else { json!({}) };
|
||||
if let Some(print) = self.services.browser_print.as_mut() {
|
||||
let result = deckcraft_engine::cmd::file::pdf_bytes(&active.doc, ¶ms).map_err(|e| e.to_string()).and_then(|bytes| print(&bytes));
|
||||
match result {
|
||||
Ok(()) => {
|
||||
self.set_status("Opening the browser print dialog");
|
||||
return true;
|
||||
}
|
||||
Err(error) => {
|
||||
self.set_status(format!("Couldn't open the browser print dialog: {error}"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
if !self.host.files().browser_saves() {
|
||||
return self.print_preview(params);
|
||||
@@ -272,6 +282,13 @@ impl SlideApp {
|
||||
self.export_as("pdf", params)
|
||||
}
|
||||
|
||||
/// The Print page's "Open as PDF instead": the print PDF in the system's PDF viewer.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn print_pdf_viewer(&mut self, params: Value) -> bool {
|
||||
let params = if params.is_object() { params } else { json!({}) };
|
||||
self.print_preview(params)
|
||||
}
|
||||
|
||||
/// Writes the print PDF to a private temporary file and opens it in the system's PDF viewer.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn print_preview(&mut self, mut params: Value) -> bool {
|
||||
|
||||
@@ -206,6 +206,9 @@ pub struct Backstage {
|
||||
pub print_landscape: bool,
|
||||
/// Zero-based page displayed by the print preview.
|
||||
pub preview_page: usize,
|
||||
/// Desktop: printing straight to a printer from the Print page.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub direct_print: print::DirectPrint,
|
||||
/// The selected export task.
|
||||
pub export: ExportTask,
|
||||
/// Export › Change File Type / Save As: the chosen type (an [`SAVE_TYPES`] id).
|
||||
@@ -237,6 +240,8 @@ impl Backstage {
|
||||
print_paper: "letter",
|
||||
print_landscape: false,
|
||||
preview_page: 0,
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
direct_print: print::DirectPrint::default(),
|
||||
export: ExportTask::Pdf,
|
||||
file_type: "pptx",
|
||||
handouts_per_page: 3,
|
||||
|
||||
@@ -21,6 +21,8 @@ use craft::ui::primitives::{ContentPainterCx, DocRun, DocText, PaintShape};
|
||||
use craft::ui::style::{Corners, DataColor, SurfaceKind, TypeRole};
|
||||
use craft::ui::text::TextField;
|
||||
use egui::{Color32, Rect, Shape, Stroke, StrokeKind, pos2, vec2};
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// The slides the Print page prints, in order (0-based).
|
||||
@@ -94,15 +96,33 @@ pub(super) fn print(app: &mut SlideApp, ui: &mut Ui, _cx: &mut BodyCx<'_>, bs: &
|
||||
let mut range_changed = false;
|
||||
Stack::new().wrap_width(WrapWidth::Column).show(ui, |ui, _| {
|
||||
let good_range = slides.as_ref().is_ok_and(|slides| !slides.is_empty());
|
||||
let detail = if app.host.files().can_pick() {
|
||||
"DeckCraft prints through a PDF: it opens in your PDF viewer, where you choose the printer."
|
||||
} else {
|
||||
"DeckCraft prints through a PDF: it downloads, ready to print from your browser or PDF viewer."
|
||||
};
|
||||
if task_row(ui, Icon::Print, "Print", "Print", detail, good_range)
|
||||
&& let Ok(slides) = &slides
|
||||
{
|
||||
app.print_pdf(print_params(bs, slides));
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let direct = app.print_spool.is_some();
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let direct = false;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
if direct {
|
||||
direct_print(app, ui, bs, &doc, slides.as_ref().ok().filter(|slides| !slides.is_empty()));
|
||||
}
|
||||
if !direct {
|
||||
let browser = app.services.browser_print.is_some();
|
||||
let detail = if browser {
|
||||
"Opens the browser print dialog for the selected slides."
|
||||
} else {
|
||||
"DeckCraft prints through a PDF, ready to open in your browser or PDF viewer."
|
||||
};
|
||||
if task_row(ui, Icon::Print, "Print", "Print", detail, good_range)
|
||||
&& let Ok(slides) = &slides
|
||||
{
|
||||
app.print_pdf(print_params(bs, slides));
|
||||
}
|
||||
if browser
|
||||
&& let Ok(slides) = &slides
|
||||
&& !slides.is_empty()
|
||||
&& Link::new("Export PDF instead").show(ui).clicked()
|
||||
{
|
||||
app.export_as("pdf", print_params(bs, slides));
|
||||
}
|
||||
}
|
||||
Text::new("Settings").role(TypeRole::Heading).show(ui);
|
||||
FieldGroup::new("Settings").show(ui, |ui, _| {
|
||||
@@ -388,3 +408,110 @@ pub(super) fn export(app: &mut SlideApp, ui: &mut Ui, _cx: &mut BodyCx<'_>, bs:
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// Printing straight to a printer: the spooler's printers, the chosen one, copies, and the job
|
||||
/// being sent on a worker thread.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
type PrinterDiscovery = Rc<std::sync::mpsc::Receiver<Vec<craft::print::Printer>>>;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
type PrintReceipt = Rc<std::sync::mpsc::Receiver<Result<String, String>>>;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct DirectPrint {
|
||||
printers: Option<Vec<craft::print::Printer>>,
|
||||
discovery: Option<PrinterDiscovery>,
|
||||
printer: String,
|
||||
copies: String,
|
||||
/// The job being sent: the printer it went to, and its result.
|
||||
job: Option<(String, PrintReceipt)>,
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
impl Default for DirectPrint {
|
||||
fn default() -> Self {
|
||||
DirectPrint { printers: None, discovery: None, printer: String::new(), copies: "1".into(), job: None }
|
||||
}
|
||||
}
|
||||
|
||||
/// Desktop Print sends the prepared PDF to the shared spooler. "Open as PDF instead" keeps the
|
||||
/// PDF viewer route, including queues whose sign-in requires the system viewer.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn direct_print(app: &mut SlideApp, ui: &mut Ui, bs: &mut Backstage, doc: &deckcraft_model::Presentation, slides: Option<&Vec<usize>>) {
|
||||
let Some(spool) = app.print_spool.clone() else { return };
|
||||
let dp = &mut bs.direct_print;
|
||||
if dp.printers.is_none() {
|
||||
let discovery = dp.discovery.get_or_insert_with(|| Rc::new(spool.discover()));
|
||||
match discovery.try_recv() {
|
||||
Ok(printers) => {
|
||||
dp.printer = printers.iter().find(|p| p.default).or(printers.first()).map(|p| p.name.clone()).unwrap_or_default();
|
||||
dp.printers = Some(printers);
|
||||
dp.discovery = None;
|
||||
}
|
||||
Err(std::sync::mpsc::TryRecvError::Empty) => ui.ctx().request_repaint_after(std::time::Duration::from_millis(200)),
|
||||
Err(std::sync::mpsc::TryRecvError::Disconnected) => {
|
||||
dp.printers = Some(Vec::new());
|
||||
dp.discovery = None;
|
||||
app.set_status("Couldn't find printers");
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some((sent_to, rx)) = &dp.job {
|
||||
match rx.try_recv() {
|
||||
Ok(Ok(message)) => {
|
||||
app.set_status(format!("Sent to {sent_to}: {message}"));
|
||||
dp.job = None;
|
||||
}
|
||||
Ok(Err(e)) => {
|
||||
app.set_status(format!("Couldn't print: {e}"));
|
||||
dp.job = None;
|
||||
}
|
||||
Err(std::sync::mpsc::TryRecvError::Empty) => ui.ctx().request_repaint_after(std::time::Duration::from_millis(200)),
|
||||
Err(std::sync::mpsc::TryRecvError::Disconnected) => {
|
||||
app.set_status("Couldn't confirm whether the print job reached the printer");
|
||||
dp.job = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
let copies = dp.copies.trim().parse::<u32>().ok().filter(|c| (1..=999).contains(c));
|
||||
let sending = dp.job.is_some();
|
||||
let ready = slides.is_some() && !sending && !dp.printer.is_empty() && copies.is_some();
|
||||
let detail = if sending { "Sending the job to the printer…" } else { "Sends the slides straight to the printer chosen below." };
|
||||
if task_row(ui, Icon::Print, "Print", "Print", detail, ready)
|
||||
&& let (Some(slides), Some(copies)) = (slides, copies)
|
||||
{
|
||||
match deckcraft_engine::cmd::file::pdf_bytes(doc, &print_params(bs, slides)) {
|
||||
Ok(bytes) => {
|
||||
let dp = &mut bs.direct_print;
|
||||
let title = app.session.active().map(|d| d.title()).unwrap_or_else(|| "DeckCraft".into());
|
||||
let job = craft::print::Job { printer: Some(dp.printer.clone()), copies, collate: true, title, ..Default::default() };
|
||||
dp.job = Some((dp.printer.clone(), Rc::new(spool.submit(bytes, job))));
|
||||
app.set_status(format!("Sending to {}…", dp.printer));
|
||||
}
|
||||
Err(e) => app.set_status(format!("Couldn't make the pages to print: {e}")),
|
||||
}
|
||||
}
|
||||
let dp = &mut bs.direct_print;
|
||||
let names: Vec<String> = dp.printers.iter().flatten().map(|p| p.name.clone()).collect();
|
||||
FieldGroup::new("Printer").show(ui, |ui, _| {
|
||||
if dp.discovery.is_some() {
|
||||
Text::new("Finding printers…").shade(Shade::Muted).show(ui);
|
||||
} else if names.is_empty() {
|
||||
Text::new("No printers found.").shade(Shade::Muted).show(ui);
|
||||
} else {
|
||||
let entries: Vec<_> = names.iter().map(|n| Entry::new(n.clone(), n.clone())).collect();
|
||||
Field::new("Printer").show(ui, |ui, _| {
|
||||
Select::new("Printer", Bind::bound(&mut dp.printer), &entries).show(ui);
|
||||
});
|
||||
}
|
||||
Field::new("Copies").show(ui, |ui, _| {
|
||||
TextField::new("Copies", Bind::bound(&mut dp.copies)).show(ui);
|
||||
});
|
||||
});
|
||||
if Link::new("Open as PDF instead").show(ui).clicked()
|
||||
&& let Some(slides) = slides
|
||||
{
|
||||
app.print_pdf_viewer(print_params(bs, slides));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -618,6 +618,40 @@ fn print_previews_pages_and_prints_a_pdf() {
|
||||
assert!(std::fs::read(printed).unwrap().starts_with(b"%PDF"));
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[test]
|
||||
fn direct_print_reports_the_spooler_failure_and_keeps_the_viewer() {
|
||||
use craft::print::spool::{Pending, Spool, SpoolBackend};
|
||||
use craft::print::{Error, Job, Printer};
|
||||
|
||||
struct RejectingPrinter;
|
||||
|
||||
impl SpoolBackend for RejectingPrinter {
|
||||
fn printers(&self) -> Option<Vec<Printer>> {
|
||||
Some(vec![Printer { name: "Test printer".into(), default: true, description: String::new(), two_sided: None }])
|
||||
}
|
||||
|
||||
fn prepare(&self, pdf: Vec<u8>, job: Job) -> Pending {
|
||||
assert!(pdf.starts_with(b"%PDF"));
|
||||
assert_eq!(job.printer.as_deref(), Some("Test printer"));
|
||||
Pending {
|
||||
cancel: Box::new(|| true),
|
||||
run: Box::new(|| Err(Error::Spool("test queue refused the print job".into()))),
|
||||
waits_after_cancel: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut h = new_app();
|
||||
h.state_mut().print_spool = Some(Spool::with_backend(Arc::new(craft::host::InlineJobs), Arc::new(RejectingPrinter)));
|
||||
h.key_press_modifiers(Modifiers::COMMAND, Key::P);
|
||||
h.run_steps(3);
|
||||
page_button(&h, "Print").click();
|
||||
h.run_steps(3);
|
||||
assert!(h.state().status.as_ref().is_some_and(|(message, _)| message.contains("test queue refused the print job")));
|
||||
assert!(h.query_by_label("Open as PDF instead").is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn print_slides_follow_the_settings() {
|
||||
let mut s = Session::with_new();
|
||||
|
||||
@@ -122,6 +122,26 @@ fn host_exports_and_print_are_copies() {
|
||||
assert_eq!(path(app).as_deref(), Some("deck.pptx"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn browser_print_preserves_settings_and_reports_setup_failure() {
|
||||
let (mut h, got) = host_app(false);
|
||||
let app = h.state_mut();
|
||||
app.open_from_host(Some("deck.pptx"), &pptx(3));
|
||||
let params = json!({"slides": [1], "layout": "notes", "frame": true, "paper": "a4", "orientation": "landscape"});
|
||||
let expected = deckcraft_engine::cmd::file::pdf_bytes(&app.session.active().unwrap().doc, ¶ms).unwrap();
|
||||
let mut opened = false;
|
||||
app.services.browser_print = Some(Box::new(move |bytes| {
|
||||
assert_eq!(bytes, expected);
|
||||
if std::mem::replace(&mut opened, true) { Err("print frame unavailable".into()) } else { Ok(()) }
|
||||
}));
|
||||
assert!(app.print_pdf(params.clone()));
|
||||
assert!(!app.print_pdf(params.clone()));
|
||||
assert!(calls(&got).is_empty(), "a print error must not trigger an export");
|
||||
assert!(app.status.as_ref().is_some_and(|(message, _)| message.contains("print frame unavailable")));
|
||||
assert!(app.export_as("pdf", params));
|
||||
assert_eq!(calls(&got), [("deck.pdf".into(), false)], "the user can still explicitly export");
|
||||
}
|
||||
|
||||
/// The page not getting the file is a failed save: the presentation keeps its changes.
|
||||
#[test]
|
||||
fn a_host_save_that_fails_leaves_the_presentation_unsaved() {
|
||||
|
||||
@@ -222,6 +222,8 @@ pub struct SlideApp {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
print_previews: craft::platform::temp::TempFiles,
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
print_spool: Option<craft::print::spool::Spool>,
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
updates_rt: updates_ui::Runtime,
|
||||
/// Selection pane: folded groups and the Shift-run anchor.
|
||||
pub selpane: selpane::State,
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
/// The browser-owned connection to the presenter window.
|
||||
/// Hands a prepared PDF to the browser's print dialog.
|
||||
pub type BrowserPrint = Box<dyn FnMut(&[u8]) -> Result<(), String>>;
|
||||
|
||||
/// Browser-owned services.
|
||||
#[derive(Default)]
|
||||
pub struct Services {
|
||||
/// Presenter popup link; absent on native hosts.
|
||||
pub presenter: Option<Box<dyn craft::web_host::link::WindowLink>>,
|
||||
/// Absent on hosts that cannot open the browser print dialog.
|
||||
pub browser_print: Option<BrowserPrint>,
|
||||
}
|
||||
|
||||
@@ -1253,7 +1253,7 @@ fn remote_presenter_uses_the_audience_state_and_closes_with_the_show() {
|
||||
let mut session = deckcraft_engine::Session::with_new();
|
||||
session.execute("slide.new", &json!({})).unwrap();
|
||||
session.execute("slide.new", &json!({})).unwrap();
|
||||
let services = Services { presenter: Some(Box::new(Mock(bridge.clone()))) };
|
||||
let services = Services { presenter: Some(Box::new(Mock(bridge.clone()))), ..Default::default() };
|
||||
let mut h = harness_with(session, services, egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)), |_| {});
|
||||
h.state_mut().ui.presenter_view = true;
|
||||
h.run_steps(3);
|
||||
|
||||
Reference in New Issue
Block a user