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