Skip to content

feat: print - #206

Merged
anderix merged 2 commits into
mainfrom
164-print
Nov 24, 2026
Merged

anderix merged 2 commits into
mainfrom
164-print

Conversation

@anderix

@anderix anderix commented Nov 24, 2026

Copy link
Copy Markdown
Member

Closes #164

  • File > Print… and Ctrl+P in all three applications. The PDF is the export's, made on the export's thread, with the new odox_pdf::Options::printing.
    • With printing set, a picture with no description is drawn as an artifact, as a decorative one is, so printing never asks about pictures.
    • The PDF goes to <temp>/odox-print-<pid>/<document>.pdf.
    • Tests: print_export_never_asks_about_pictures (RED with the flag off) and temporary_pdf_named_after_document.
  • Linux (print.rs): the portal's PreparePrint, then Print with the file's descriptor and the returned token, over zbus, which was already a dependency.
    • Each Response signal is subscribed at the handle-token path before the call goes out.
    • Without a session bus or a portal, the PDF opens with xdg-open.
    • Windows: explorer.exe <pdf>. macOS: NSWorkspace openURL.
  • Checked on Linux in Xephyr (private bus, GTK portal):
    • Ctrl+P brought up the portal's dialog. Print to File gave odox's own PDF, and the notice said "Sent letter.pdf to be printed."
    • Cancel ended with no notice.
    • With no session bus, a fake xdg-open received /tmp/odox-print-<pid>/letter.pdf, and the notice pointed to the viewer.
  • Not checked on macOS or Windows.
    • On macmini the branch built and was signed sandboxed with the Apple Development identity. It couldn't be launched: no one is logged in at the console, so ssh has no GUI domain.
    • The Windows VM was off.
  • Bug caught while writing this: the first version took the export request twice in Export::show, which dropped every plain export. The existing picture-question test failed, and it is fixed in this commit.

@anderix

anderix commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

The review fixes are in the second commit.

Critical

  • 1: the portal wait now races the Response against NameOwnerChanged for org.freedesktop.portal.Desktop, using futures-lite (already in the tree under zbus) with zbus::block_on. When the owner vanishes, the request ends and the PDF goes to the viewer. Reproduced and checked in Xephyr: with the session's xdg-desktop-portal killed mid-dialog, Cancel gave "Opened letter.odt in the viewer" and the fake xdg-open received the file. A second Ctrl+P re-activated the portal and opened the dialog again.

Important

  • 2: each print writes to odox-print-<pid>/<n>/<stem>.pdf (each_print_has_a_file_of_its_own).
  • 3: whether MSIX virtualizes %TEMP% is not settled. The VM was off, so it goes on the list of unverified Windows behaviour, with Print as a whole on Windows.

Minors fixed

  • 4: when the handle the call returns differs from the predicted path, it is listened to instead.
  • 5: Print response 2 is now reported as "the print dialog did not print it".
  • 7: the viewer's process is waited on apart from the worker. A missing program reads "no program here opens PDF files".
  • 8: the spinner says "Printing {file}…", and the notices name the document.
  • 9: the test removes its folder.

Deferred: 6 (the dialog's parent window) and the "nothing to export" wording.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Print, in all three applications

1 participant