Skip to content

Commit

Permalink
wip: print: Add accept_label
Browse files Browse the repository at this point in the history
Requires version 2.

See flatpak/xdg-desktop-portal#1094.
  • Loading branch information
A6GibKm committed Sep 2, 2023
1 parent 14d4c01 commit a8a97d6
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/desktop/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,14 +556,24 @@ struct PreparePrintOptions {
handle_token: HandleToken,
/// Whether to make the dialog modal.
modal: Option<bool>,
/// Label for the accept button. Mnemonic underlines are allowed.
accept_label: Option<String>,
}

impl PreparePrintOptions {
/// Sets whether the dialog should be a modal.
#[must_use]
pub fn modal(mut self, modal: impl Into<Option<bool>>) -> 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<Option<&'a str>>) -> Self {
self.accept_label = accept_label.into().map(ToOwned::to_owned);
self
}
}

#[derive(SerializeDict, Type, Debug, Default)]
Expand Down Expand Up @@ -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.
///
Expand All @@ -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
///
Expand All @@ -642,9 +654,12 @@ impl<'a> PrintProxy<'a> {
title: &str,
settings: Settings,
page_setup: PageSetup,
accept_label: impl Into<Option<&'a str>>,
modal: bool,
) -> Result<Request<PreparePrint>, Error> {
let options = PreparePrintOptions::default().modal(modal);
let options = PreparePrintOptions::default()
.modal(modal)
.accept_label(accept_label);
self.0
.request(
&options.handle_token,
Expand Down

0 comments on commit a8a97d6

Please sign in to comment.