gtk4/auto/
print_dialog.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{ffi, PageSetup, PrintSettings, PrintSetup, Window};
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::{boxed::Box as Box_, pin::Pin};
12
13glib::wrapper! {
14    /// Asynchronous API to present a print dialog to the user.
15    ///
16    /// [`PrintDialog`][crate::PrintDialog] collects the arguments that are needed to present
17    ///  the dialog, such as a title for the dialog and whether it should
18    ///  be modal.
19    ///
20    /// The dialog is shown with the [`setup()`][Self::setup()] function.
21    ///
22    /// The actual printing can be done with [`print()`][Self::print()] or
23    /// [`print_file()`][Self::print_file()]. These APIs follows the GIO async pattern,
24    /// and the results can be obtained by calling the corresponding finish methods.
25    ///
26    /// ## Properties
27    ///
28    ///
29    /// #### `accept-label`
30    ///  A label that may be shown on the accept button of a print dialog
31    /// that is presented by [`PrintDialog::setup()`][crate::PrintDialog::setup()].
32    ///
33    /// Readable | Writeable
34    ///
35    ///
36    /// #### `modal`
37    ///  Whether the print dialog is modal.
38    ///
39    /// Readable | Writeable
40    ///
41    ///
42    /// #### `page-setup`
43    ///  The page setup to use.
44    ///
45    /// Readable | Writeable
46    ///
47    ///
48    /// #### `print-settings`
49    ///  The print settings to use.
50    ///
51    /// Readable | Writeable
52    ///
53    ///
54    /// #### `title`
55    ///  A title that may be shown on the print dialog that is
56    /// presented by [`PrintDialog::setup()`][crate::PrintDialog::setup()].
57    ///
58    /// Readable | Writeable
59    ///
60    /// # Implements
61    ///
62    /// [`trait@glib::ObjectExt`]
63    #[doc(alias = "GtkPrintDialog")]
64    pub struct PrintDialog(Object<ffi::GtkPrintDialog, ffi::GtkPrintDialogClass>);
65
66    match fn {
67        type_ => || ffi::gtk_print_dialog_get_type(),
68    }
69}
70
71impl PrintDialog {
72    /// Creates a new [`PrintDialog`][crate::PrintDialog] object.
73    ///
74    /// # Returns
75    ///
76    /// the new [`PrintDialog`][crate::PrintDialog]
77    #[doc(alias = "gtk_print_dialog_new")]
78    pub fn new() -> PrintDialog {
79        assert_initialized_main_thread!();
80        unsafe { from_glib_full(ffi::gtk_print_dialog_new()) }
81    }
82
83    // rustdoc-stripper-ignore-next
84    /// Creates a new builder-pattern struct instance to construct [`PrintDialog`] objects.
85    ///
86    /// This method returns an instance of [`PrintDialogBuilder`](crate::builders::PrintDialogBuilder) which can be used to create [`PrintDialog`] objects.
87    pub fn builder() -> PrintDialogBuilder {
88        PrintDialogBuilder::new()
89    }
90
91    /// Returns the label that will be shown on the
92    /// accept button of the print dialog.
93    ///
94    /// # Returns
95    ///
96    /// the accept label
97    #[doc(alias = "gtk_print_dialog_get_accept_label")]
98    #[doc(alias = "get_accept_label")]
99    #[doc(alias = "accept-label")]
100    pub fn accept_label(&self) -> glib::GString {
101        unsafe {
102            from_glib_none(ffi::gtk_print_dialog_get_accept_label(
103                self.to_glib_none().0,
104            ))
105        }
106    }
107
108    /// Returns whether the print dialog blocks
109    /// interaction with the parent window while
110    /// it is presented.
111    ///
112    /// # Returns
113    ///
114    /// whether the print dialog is modal
115    #[doc(alias = "gtk_print_dialog_get_modal")]
116    #[doc(alias = "get_modal")]
117    #[doc(alias = "modal")]
118    pub fn is_modal(&self) -> bool {
119        unsafe { from_glib(ffi::gtk_print_dialog_get_modal(self.to_glib_none().0)) }
120    }
121
122    /// Returns the page setup.
123    ///
124    /// # Returns
125    ///
126    /// the page setup
127    #[doc(alias = "gtk_print_dialog_get_page_setup")]
128    #[doc(alias = "get_page_setup")]
129    #[doc(alias = "page-setup")]
130    pub fn page_setup(&self) -> Option<PageSetup> {
131        unsafe { from_glib_none(ffi::gtk_print_dialog_get_page_setup(self.to_glib_none().0)) }
132    }
133
134    /// Returns the print settings for the print dialog.
135    ///
136    /// # Returns
137    ///
138    /// the settings
139    #[doc(alias = "gtk_print_dialog_get_print_settings")]
140    #[doc(alias = "get_print_settings")]
141    #[doc(alias = "print-settings")]
142    pub fn print_settings(&self) -> Option<PrintSettings> {
143        unsafe {
144            from_glib_none(ffi::gtk_print_dialog_get_print_settings(
145                self.to_glib_none().0,
146            ))
147        }
148    }
149
150    /// Returns the title that will be shown on the
151    /// print dialog.
152    ///
153    /// # Returns
154    ///
155    /// the title
156    #[doc(alias = "gtk_print_dialog_get_title")]
157    #[doc(alias = "get_title")]
158    pub fn title(&self) -> glib::GString {
159        unsafe { from_glib_none(ffi::gtk_print_dialog_get_title(self.to_glib_none().0)) }
160    }
161
162    /// This function prints content from a stream.
163    ///
164    /// If you pass `NULL` as @setup, then this method will present a print dialog.
165    /// Otherwise, it will attempt to print directly, without user interaction.
166    ///
167    /// The @callback will be called when the printing is done.
168    /// ## `parent`
169    /// the parent [`Window`][crate::Window]
170    /// ## `setup`
171    /// the [`PrintSetup`][crate::PrintSetup] to use
172    /// ## `cancellable`
173    /// a `GCancellable` to cancel the operation
174    /// ## `callback`
175    /// a callback to call when the
176    ///   operation is complete
177    #[doc(alias = "gtk_print_dialog_print")]
178    pub fn print<P: FnOnce(Result<gio::OutputStream, glib::Error>) + 'static>(
179        &self,
180        parent: Option<&impl IsA<Window>>,
181        setup: Option<&PrintSetup>,
182        cancellable: Option<&impl IsA<gio::Cancellable>>,
183        callback: P,
184    ) {
185        let main_context = glib::MainContext::ref_thread_default();
186        let is_main_context_owner = main_context.is_owner();
187        let has_acquired_main_context = (!is_main_context_owner)
188            .then(|| main_context.acquire().ok())
189            .flatten();
190        assert!(
191            is_main_context_owner || has_acquired_main_context.is_some(),
192            "Async operations only allowed if the thread is owning the MainContext"
193        );
194
195        let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
196            Box_::new(glib::thread_guard::ThreadGuard::new(callback));
197        unsafe extern "C" fn print_trampoline<
198            P: FnOnce(Result<gio::OutputStream, glib::Error>) + 'static,
199        >(
200            _source_object: *mut glib::gobject_ffi::GObject,
201            res: *mut gio::ffi::GAsyncResult,
202            user_data: glib::ffi::gpointer,
203        ) {
204            let mut error = std::ptr::null_mut();
205            let ret = ffi::gtk_print_dialog_print_finish(_source_object as *mut _, res, &mut error);
206            let result = if error.is_null() {
207                Ok(from_glib_full(ret))
208            } else {
209                Err(from_glib_full(error))
210            };
211            let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
212                Box_::from_raw(user_data as *mut _);
213            let callback: P = callback.into_inner();
214            callback(result);
215        }
216        let callback = print_trampoline::<P>;
217        unsafe {
218            ffi::gtk_print_dialog_print(
219                self.to_glib_none().0,
220                parent.map(|p| p.as_ref()).to_glib_none().0,
221                setup.to_glib_none().0,
222                cancellable.map(|p| p.as_ref()).to_glib_none().0,
223                Some(callback),
224                Box_::into_raw(user_data) as *mut _,
225            );
226        }
227    }
228
229    pub fn print_future(
230        &self,
231        parent: Option<&(impl IsA<Window> + Clone + 'static)>,
232        setup: Option<&PrintSetup>,
233    ) -> Pin<Box_<dyn std::future::Future<Output = Result<gio::OutputStream, glib::Error>> + 'static>>
234    {
235        let parent = parent.map(ToOwned::to_owned);
236        let setup = setup.map(ToOwned::to_owned);
237        Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
238            obj.print(
239                parent.as_ref().map(::std::borrow::Borrow::borrow),
240                setup.as_ref().map(::std::borrow::Borrow::borrow),
241                Some(cancellable),
242                move |res| {
243                    send.resolve(res);
244                },
245            );
246        }))
247    }
248
249    /// This function prints a file.
250    ///
251    /// If you pass `NULL` as @setup, then this method will present a print dialog.
252    /// Otherwise, it will attempt to print directly, without user interaction.
253    /// ## `parent`
254    /// the parent [`Window`][crate::Window]
255    /// ## `setup`
256    /// the [`PrintSetup`][crate::PrintSetup] to use
257    /// ## `file`
258    /// the `GFile` to print
259    /// ## `cancellable`
260    /// a `GCancellable` to cancel the operation
261    /// ## `callback`
262    /// a callback to call when the
263    ///   operation is complete
264    #[doc(alias = "gtk_print_dialog_print_file")]
265    pub fn print_file<P: FnOnce(Result<(), glib::Error>) + 'static>(
266        &self,
267        parent: Option<&impl IsA<Window>>,
268        setup: Option<&PrintSetup>,
269        file: &impl IsA<gio::File>,
270        cancellable: Option<&impl IsA<gio::Cancellable>>,
271        callback: P,
272    ) {
273        let main_context = glib::MainContext::ref_thread_default();
274        let is_main_context_owner = main_context.is_owner();
275        let has_acquired_main_context = (!is_main_context_owner)
276            .then(|| main_context.acquire().ok())
277            .flatten();
278        assert!(
279            is_main_context_owner || has_acquired_main_context.is_some(),
280            "Async operations only allowed if the thread is owning the MainContext"
281        );
282
283        let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
284            Box_::new(glib::thread_guard::ThreadGuard::new(callback));
285        unsafe extern "C" fn print_file_trampoline<P: FnOnce(Result<(), glib::Error>) + 'static>(
286            _source_object: *mut glib::gobject_ffi::GObject,
287            res: *mut gio::ffi::GAsyncResult,
288            user_data: glib::ffi::gpointer,
289        ) {
290            let mut error = std::ptr::null_mut();
291            ffi::gtk_print_dialog_print_file_finish(_source_object as *mut _, res, &mut error);
292            let result = if error.is_null() {
293                Ok(())
294            } else {
295                Err(from_glib_full(error))
296            };
297            let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
298                Box_::from_raw(user_data as *mut _);
299            let callback: P = callback.into_inner();
300            callback(result);
301        }
302        let callback = print_file_trampoline::<P>;
303        unsafe {
304            ffi::gtk_print_dialog_print_file(
305                self.to_glib_none().0,
306                parent.map(|p| p.as_ref()).to_glib_none().0,
307                setup.to_glib_none().0,
308                file.as_ref().to_glib_none().0,
309                cancellable.map(|p| p.as_ref()).to_glib_none().0,
310                Some(callback),
311                Box_::into_raw(user_data) as *mut _,
312            );
313        }
314    }
315
316    pub fn print_file_future(
317        &self,
318        parent: Option<&(impl IsA<Window> + Clone + 'static)>,
319        setup: Option<&PrintSetup>,
320        file: &(impl IsA<gio::File> + Clone + 'static),
321    ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
322        let parent = parent.map(ToOwned::to_owned);
323        let setup = setup.map(ToOwned::to_owned);
324        let file = file.clone();
325        Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
326            obj.print_file(
327                parent.as_ref().map(::std::borrow::Borrow::borrow),
328                setup.as_ref().map(::std::borrow::Borrow::borrow),
329                &file,
330                Some(cancellable),
331                move |res| {
332                    send.resolve(res);
333                },
334            );
335        }))
336    }
337
338    /// Sets the label that will be shown on the
339    /// accept button of the print dialog shown for
340    /// [`setup()`][Self::setup()].
341    /// ## `accept_label`
342    /// the new accept label
343    #[doc(alias = "gtk_print_dialog_set_accept_label")]
344    #[doc(alias = "accept-label")]
345    pub fn set_accept_label(&self, accept_label: &str) {
346        unsafe {
347            ffi::gtk_print_dialog_set_accept_label(
348                self.to_glib_none().0,
349                accept_label.to_glib_none().0,
350            );
351        }
352    }
353
354    /// Sets whether the print dialog blocks
355    /// interaction with the parent window while
356    /// it is presented.
357    /// ## `modal`
358    /// the new value
359    #[doc(alias = "gtk_print_dialog_set_modal")]
360    #[doc(alias = "modal")]
361    pub fn set_modal(&self, modal: bool) {
362        unsafe {
363            ffi::gtk_print_dialog_set_modal(self.to_glib_none().0, modal.into_glib());
364        }
365    }
366
367    /// Set the page setup for the print dialog.
368    /// ## `page_setup`
369    /// the new page setup
370    #[doc(alias = "gtk_print_dialog_set_page_setup")]
371    #[doc(alias = "page-setup")]
372    pub fn set_page_setup(&self, page_setup: &PageSetup) {
373        unsafe {
374            ffi::gtk_print_dialog_set_page_setup(
375                self.to_glib_none().0,
376                page_setup.to_glib_none().0,
377            );
378        }
379    }
380
381    /// Sets the print settings for the print dialog.
382    /// ## `print_settings`
383    /// the new print settings
384    #[doc(alias = "gtk_print_dialog_set_print_settings")]
385    #[doc(alias = "print-settings")]
386    pub fn set_print_settings(&self, print_settings: &PrintSettings) {
387        unsafe {
388            ffi::gtk_print_dialog_set_print_settings(
389                self.to_glib_none().0,
390                print_settings.to_glib_none().0,
391            );
392        }
393    }
394
395    /// Sets the title that will be shown on the print dialog.
396    /// ## `title`
397    /// the new title
398    #[doc(alias = "gtk_print_dialog_set_title")]
399    #[doc(alias = "title")]
400    pub fn set_title(&self, title: &str) {
401        unsafe {
402            ffi::gtk_print_dialog_set_title(self.to_glib_none().0, title.to_glib_none().0);
403        }
404    }
405
406    /// This function presents a print dialog to let the user select a printer,
407    /// and set up print settings and page setup.
408    ///
409    /// The @callback will be called when the dialog is dismissed.
410    /// The obtained [`PrintSetup`][crate::PrintSetup] can then be passed
411    /// to [`print()`][Self::print()] or [`print_file()`][Self::print_file()].
412    ///
413    /// One possible use for this method is to have the user select a printer,
414    /// then show a page setup UI in the application (e.g. to arrange images
415    /// on a page), then call [`print()`][Self::print()] on @self
416    /// to do the printing without further user interaction.
417    /// ## `parent`
418    /// the parent [`Window`][crate::Window]
419    /// ## `cancellable`
420    /// a `GCancellable` to cancel the operation
421    /// ## `callback`
422    /// a callback to call when the
423    ///   operation is complete
424    #[doc(alias = "gtk_print_dialog_setup")]
425    pub fn setup<P: FnOnce(Result<PrintSetup, glib::Error>) + 'static>(
426        &self,
427        parent: Option<&impl IsA<Window>>,
428        cancellable: Option<&impl IsA<gio::Cancellable>>,
429        callback: P,
430    ) {
431        let main_context = glib::MainContext::ref_thread_default();
432        let is_main_context_owner = main_context.is_owner();
433        let has_acquired_main_context = (!is_main_context_owner)
434            .then(|| main_context.acquire().ok())
435            .flatten();
436        assert!(
437            is_main_context_owner || has_acquired_main_context.is_some(),
438            "Async operations only allowed if the thread is owning the MainContext"
439        );
440
441        let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
442            Box_::new(glib::thread_guard::ThreadGuard::new(callback));
443        unsafe extern "C" fn setup_trampoline<
444            P: FnOnce(Result<PrintSetup, glib::Error>) + 'static,
445        >(
446            _source_object: *mut glib::gobject_ffi::GObject,
447            res: *mut gio::ffi::GAsyncResult,
448            user_data: glib::ffi::gpointer,
449        ) {
450            let mut error = std::ptr::null_mut();
451            let ret = ffi::gtk_print_dialog_setup_finish(_source_object as *mut _, res, &mut error);
452            let result = if error.is_null() {
453                Ok(from_glib_full(ret))
454            } else {
455                Err(from_glib_full(error))
456            };
457            let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
458                Box_::from_raw(user_data as *mut _);
459            let callback: P = callback.into_inner();
460            callback(result);
461        }
462        let callback = setup_trampoline::<P>;
463        unsafe {
464            ffi::gtk_print_dialog_setup(
465                self.to_glib_none().0,
466                parent.map(|p| p.as_ref()).to_glib_none().0,
467                cancellable.map(|p| p.as_ref()).to_glib_none().0,
468                Some(callback),
469                Box_::into_raw(user_data) as *mut _,
470            );
471        }
472    }
473
474    pub fn setup_future(
475        &self,
476        parent: Option<&(impl IsA<Window> + Clone + 'static)>,
477    ) -> Pin<Box_<dyn std::future::Future<Output = Result<PrintSetup, glib::Error>> + 'static>>
478    {
479        let parent = parent.map(ToOwned::to_owned);
480        Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
481            obj.setup(
482                parent.as_ref().map(::std::borrow::Borrow::borrow),
483                Some(cancellable),
484                move |res| {
485                    send.resolve(res);
486                },
487            );
488        }))
489    }
490
491    #[cfg(feature = "v4_14")]
492    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
493    #[doc(alias = "accept-label")]
494    pub fn connect_accept_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
495        unsafe extern "C" fn notify_accept_label_trampoline<F: Fn(&PrintDialog) + 'static>(
496            this: *mut ffi::GtkPrintDialog,
497            _param_spec: glib::ffi::gpointer,
498            f: glib::ffi::gpointer,
499        ) {
500            let f: &F = &*(f as *const F);
501            f(&from_glib_borrow(this))
502        }
503        unsafe {
504            let f: Box_<F> = Box_::new(f);
505            connect_raw(
506                self.as_ptr() as *mut _,
507                c"notify::accept-label".as_ptr() as *const _,
508                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
509                    notify_accept_label_trampoline::<F> as *const (),
510                )),
511                Box_::into_raw(f),
512            )
513        }
514    }
515
516    #[cfg(feature = "v4_14")]
517    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
518    #[doc(alias = "modal")]
519    pub fn connect_modal_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
520        unsafe extern "C" fn notify_modal_trampoline<F: Fn(&PrintDialog) + 'static>(
521            this: *mut ffi::GtkPrintDialog,
522            _param_spec: glib::ffi::gpointer,
523            f: glib::ffi::gpointer,
524        ) {
525            let f: &F = &*(f as *const F);
526            f(&from_glib_borrow(this))
527        }
528        unsafe {
529            let f: Box_<F> = Box_::new(f);
530            connect_raw(
531                self.as_ptr() as *mut _,
532                c"notify::modal".as_ptr() as *const _,
533                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
534                    notify_modal_trampoline::<F> as *const (),
535                )),
536                Box_::into_raw(f),
537            )
538        }
539    }
540
541    #[cfg(feature = "v4_14")]
542    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
543    #[doc(alias = "page-setup")]
544    pub fn connect_page_setup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
545        unsafe extern "C" fn notify_page_setup_trampoline<F: Fn(&PrintDialog) + 'static>(
546            this: *mut ffi::GtkPrintDialog,
547            _param_spec: glib::ffi::gpointer,
548            f: glib::ffi::gpointer,
549        ) {
550            let f: &F = &*(f as *const F);
551            f(&from_glib_borrow(this))
552        }
553        unsafe {
554            let f: Box_<F> = Box_::new(f);
555            connect_raw(
556                self.as_ptr() as *mut _,
557                c"notify::page-setup".as_ptr() as *const _,
558                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
559                    notify_page_setup_trampoline::<F> as *const (),
560                )),
561                Box_::into_raw(f),
562            )
563        }
564    }
565
566    #[cfg(feature = "v4_14")]
567    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
568    #[doc(alias = "print-settings")]
569    pub fn connect_print_settings_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
570        unsafe extern "C" fn notify_print_settings_trampoline<F: Fn(&PrintDialog) + 'static>(
571            this: *mut ffi::GtkPrintDialog,
572            _param_spec: glib::ffi::gpointer,
573            f: glib::ffi::gpointer,
574        ) {
575            let f: &F = &*(f as *const F);
576            f(&from_glib_borrow(this))
577        }
578        unsafe {
579            let f: Box_<F> = Box_::new(f);
580            connect_raw(
581                self.as_ptr() as *mut _,
582                c"notify::print-settings".as_ptr() as *const _,
583                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
584                    notify_print_settings_trampoline::<F> as *const (),
585                )),
586                Box_::into_raw(f),
587            )
588        }
589    }
590
591    #[cfg(feature = "v4_14")]
592    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
593    #[doc(alias = "title")]
594    pub fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
595        unsafe extern "C" fn notify_title_trampoline<F: Fn(&PrintDialog) + 'static>(
596            this: *mut ffi::GtkPrintDialog,
597            _param_spec: glib::ffi::gpointer,
598            f: glib::ffi::gpointer,
599        ) {
600            let f: &F = &*(f as *const F);
601            f(&from_glib_borrow(this))
602        }
603        unsafe {
604            let f: Box_<F> = Box_::new(f);
605            connect_raw(
606                self.as_ptr() as *mut _,
607                c"notify::title".as_ptr() as *const _,
608                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
609                    notify_title_trampoline::<F> as *const (),
610                )),
611                Box_::into_raw(f),
612            )
613        }
614    }
615}
616
617#[cfg(feature = "v4_14")]
618#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
619impl Default for PrintDialog {
620    fn default() -> Self {
621        Self::new()
622    }
623}
624
625// rustdoc-stripper-ignore-next
626/// A [builder-pattern] type to construct [`PrintDialog`] objects.
627///
628/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
629#[must_use = "The builder must be built to be used"]
630pub struct PrintDialogBuilder {
631    builder: glib::object::ObjectBuilder<'static, PrintDialog>,
632}
633
634impl PrintDialogBuilder {
635    fn new() -> Self {
636        Self {
637            builder: glib::object::Object::builder(),
638        }
639    }
640
641    /// A label that may be shown on the accept button of a print dialog
642    /// that is presented by [`PrintDialog::setup()`][crate::PrintDialog::setup()].
643    #[cfg(feature = "v4_14")]
644    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
645    pub fn accept_label(self, accept_label: impl Into<glib::GString>) -> Self {
646        Self {
647            builder: self.builder.property("accept-label", accept_label.into()),
648        }
649    }
650
651    /// Whether the print dialog is modal.
652    #[cfg(feature = "v4_14")]
653    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
654    pub fn modal(self, modal: bool) -> Self {
655        Self {
656            builder: self.builder.property("modal", modal),
657        }
658    }
659
660    /// The page setup to use.
661    #[cfg(feature = "v4_14")]
662    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
663    pub fn page_setup(self, page_setup: &PageSetup) -> Self {
664        Self {
665            builder: self.builder.property("page-setup", page_setup.clone()),
666        }
667    }
668
669    /// The print settings to use.
670    #[cfg(feature = "v4_14")]
671    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
672    pub fn print_settings(self, print_settings: &PrintSettings) -> Self {
673        Self {
674            builder: self
675                .builder
676                .property("print-settings", print_settings.clone()),
677        }
678    }
679
680    /// A title that may be shown on the print dialog that is
681    /// presented by [`PrintDialog::setup()`][crate::PrintDialog::setup()].
682    #[cfg(feature = "v4_14")]
683    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
684    pub fn title(self, title: impl Into<glib::GString>) -> Self {
685        Self {
686            builder: self.builder.property("title", title.into()),
687        }
688    }
689
690    // rustdoc-stripper-ignore-next
691    /// Build the [`PrintDialog`].
692    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
693    pub fn build(self) -> PrintDialog {
694        assert_initialized_main_thread!();
695        self.builder.build()
696    }
697}