From a8a97d6f64710981cf84fb4f33130edd004fbf4a Mon Sep 17 00:00:00 2001 From: Maximiliano Sandoval R Date: Sat, 2 Sep 2023 12:25:14 +0200 Subject: [PATCH] wip: print: Add accept_label Requires version 2. See https://github.com/flatpak/xdg-desktop-portal/pull/1094. --- src/desktop/print.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/desktop/print.rs b/src/desktop/print.rs index 830823942..9eeb7188b 100644 --- a/src/desktop/print.rs +++ b/src/desktop/print.rs @@ -556,14 +556,24 @@ struct PreparePrintOptions { handle_token: HandleToken, /// Whether to make the dialog modal. modal: Option, + /// Label for the accept button. Mnemonic underlines are allowed. + accept_label: Option, } impl PreparePrintOptions { /// Sets whether the dialog should be a modal. + #[must_use] pub fn modal(mut self, modal: impl Into>) -> Self { self.modal = modal.into(); self } + + /// Label for the accept button. Mnemonic underlines are allowed. + #[must_use] + pub fn accept_label<'a>(mut self, accept_label: impl Into>) -> Self { + self.accept_label = accept_label.into().map(ToOwned::to_owned); + self + } } #[derive(SerializeDict, Type, Debug, Default)] @@ -620,6 +630,7 @@ impl<'a> PrintProxy<'a> { Ok(Self(proxy)) } + // TODO accept_label: Added in version 2 of the interface. /// Presents a print dialog to the user and returns print settings and page /// setup. /// @@ -630,6 +641,7 @@ impl<'a> PrintProxy<'a> { /// * `settings` - [`Settings`]. /// * `page_setup` - [`PageSetup`]. /// * `modal` - Whether the dialog should be a modal. + /// * `accept_label` - Label for the accept button. Mnemonic underlines are allowed. /// /// # Specifications /// @@ -642,9 +654,12 @@ impl<'a> PrintProxy<'a> { title: &str, settings: Settings, page_setup: PageSetup, + accept_label: impl Into>, modal: bool, ) -> Result, Error> { - let options = PreparePrintOptions::default().modal(modal); + let options = PreparePrintOptions::default() + .modal(modal) + .accept_label(accept_label); self.0 .request( &options.handle_token,