Skip to main content

gtk/auto/
print_operation.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::{
6    PageSetup, PrintContext, PrintOperationAction, PrintOperationPreview, PrintOperationResult,
7    PrintSettings, PrintStatus, Unit, Widget, Window,
8};
9use glib::{
10    prelude::*,
11    signal::{connect_raw, SignalHandlerId},
12    translate::*,
13};
14use std::{boxed::Box as Box_, fmt, mem::transmute, ptr};
15
16glib::wrapper! {
17    /// GtkPrintOperation is the high-level, portable printing API.
18    /// It looks a bit different than other GTK+ dialogs such as the
19    /// [`FileChooser`][crate::FileChooser], since some platforms don’t expose enough
20    /// infrastructure to implement a good print dialog. On such
21    /// platforms, GtkPrintOperation uses the native print dialog.
22    /// On platforms which do not provide a native print dialog, GTK+
23    /// uses its own, see `GtkPrintUnixDialog`.
24    ///
25    /// The typical way to use the high-level printing API is to create
26    /// a GtkPrintOperation object with [`new()`][Self::new()] when
27    /// the user selects to print. Then you set some properties on it,
28    /// e.g. the page size, any [`PrintSettings`][crate::PrintSettings] from previous print
29    /// operations, the number of pages, the current page, etc.
30    ///
31    /// Then you start the print operation by calling [`PrintOperationExt::run()`][crate::prelude::PrintOperationExt::run()].
32    /// It will then show a dialog, let the user select a printer and
33    /// options. When the user finished the dialog various signals will
34    /// be emitted on the [`PrintOperation`][crate::PrintOperation], the main one being
35    /// [`draw-page`][struct@crate::PrintOperation#draw-page], which you are supposed to catch
36    /// and render the page on the provided [`PrintContext`][crate::PrintContext] using Cairo.
37    ///
38    /// # The high-level printing API
39    ///
40    ///
41    ///
42    /// **⚠️ The following code is in C ⚠️**
43    ///
44    /// ```C
45    /// static GtkPrintSettings *settings = NULL;
46    ///
47    /// static void
48    /// do_print (void)
49    /// {
50    ///   GtkPrintOperation *print;
51    ///   GtkPrintOperationResult res;
52    ///
53    ///   print = gtk_print_operation_new ();
54    ///
55    ///   if (settings != NULL)
56    ///     gtk_print_operation_set_print_settings (print, settings);
57    ///
58    ///   g_signal_connect (print, "begin_print", G_CALLBACK (begin_print), NULL);
59    ///   g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), NULL);
60    ///
61    ///   res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
62    ///                                  GTK_WINDOW (main_window), NULL);
63    ///
64    ///   if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
65    ///     {
66    ///       if (settings != NULL)
67    ///         g_object_unref (settings);
68    ///       settings = g_object_ref (gtk_print_operation_get_print_settings (print));
69    ///     }
70    ///
71    ///   g_object_unref (print);
72    /// }
73    /// ```
74    ///
75    /// By default GtkPrintOperation uses an external application to do
76    /// print preview. To implement a custom print preview, an application
77    /// must connect to the preview signal. The functions
78    /// [`PrintOperationPreviewExt::render_page()`][crate::prelude::PrintOperationPreviewExt::render_page()],
79    /// [`PrintOperationPreviewExt::end_preview()`][crate::prelude::PrintOperationPreviewExt::end_preview()] and
80    /// [`PrintOperationPreviewExt::is_selected()`][crate::prelude::PrintOperationPreviewExt::is_selected()]
81    /// are useful when implementing a print preview.
82    ///
83    /// ## Properties
84    ///
85    ///
86    /// #### `allow-async`
87    ///  Determines whether the print operation may run asynchronously or not.
88    ///
89    /// Some systems don't support asynchronous printing, but those that do
90    /// will return [`PrintOperationResult::InProgress`][crate::PrintOperationResult::InProgress] as the status, and
91    /// emit the [`done`][struct@crate::PrintOperation#done] signal when the operation is actually
92    /// done.
93    ///
94    /// The Windows port does not support asynchronous operation at all (this
95    /// is unlikely to change). On other platforms, all actions except for
96    /// [`PrintOperationAction::Export`][crate::PrintOperationAction::Export] support asynchronous operation.
97    ///
98    /// Readable | Writeable
99    ///
100    ///
101    /// #### `current-page`
102    ///  The current page in the document.
103    ///
104    /// If this is set before [`PrintOperationExt::run()`][crate::prelude::PrintOperationExt::run()],
105    /// the user will be able to select to print only the current page.
106    ///
107    /// Note that this only makes sense for pre-paginated documents.
108    ///
109    /// Readable | Writeable
110    ///
111    ///
112    /// #### `custom-tab-label`
113    ///  Used as the label of the tab containing custom widgets.
114    /// Note that this property may be ignored on some platforms.
115    ///
116    /// If this is [`None`], GTK+ uses a default label.
117    ///
118    /// Readable | Writeable
119    ///
120    ///
121    /// #### `default-page-setup`
122    ///  The [`PageSetup`][crate::PageSetup] used by default.
123    ///
124    /// This page setup will be used by [`PrintOperationExt::run()`][crate::prelude::PrintOperationExt::run()],
125    /// but it can be overridden on a per-page basis by connecting
126    /// to the [`request-page-setup`][struct@crate::PrintOperation#request-page-setup] signal.
127    ///
128    /// Readable | Writeable
129    ///
130    ///
131    /// #### `embed-page-setup`
132    ///  If [`true`], page size combo box and orientation combo box are embedded into page setup page.
133    ///
134    /// Readable | Writeable
135    ///
136    ///
137    /// #### `export-filename`
138    ///  The name of a file to generate instead of showing the print dialog.
139    /// Currently, PDF is the only supported format.
140    ///
141    /// The intended use of this property is for implementing
142    /// “Export to PDF” actions.
143    ///
144    /// “Print to PDF” support is independent of this and is done
145    /// by letting the user pick the “Print to PDF” item from the
146    /// list of printers in the print dialog.
147    ///
148    /// Readable | Writeable
149    ///
150    ///
151    /// #### `has-selection`
152    ///  Determines whether there is a selection in your application.
153    /// This can allow your application to print the selection.
154    /// This is typically used to make a "Selection" button sensitive.
155    ///
156    /// Readable | Writeable
157    ///
158    ///
159    /// #### `job-name`
160    ///  A string used to identify the job (e.g. in monitoring
161    /// applications like eggcups).
162    ///
163    /// If you don't set a job name, GTK+ picks a default one
164    /// by numbering successive print jobs.
165    ///
166    /// Readable | Writeable
167    ///
168    ///
169    /// #### `n-pages`
170    ///  The number of pages in the document.
171    ///
172    /// This must be set to a positive number
173    /// before the rendering starts. It may be set in a
174    /// [`begin-print`][struct@crate::PrintOperation#begin-print] signal hander.
175    ///
176    /// Note that the page numbers passed to the
177    /// [`request-page-setup`][struct@crate::PrintOperation#request-page-setup] and
178    /// [`draw-page`][struct@crate::PrintOperation#draw-page] signals are 0-based, i.e. if
179    /// the user chooses to print all pages, the last ::draw-page signal
180    /// will be for page `n_pages` - 1.
181    ///
182    /// Readable | Writeable
183    ///
184    ///
185    /// #### `n-pages-to-print`
186    ///  The number of pages that will be printed.
187    ///
188    /// Note that this value is set during print preparation phase
189    /// ([`PrintStatus::Preparing`][crate::PrintStatus::Preparing]), so this value should never be
190    /// get before the data generation phase ([`PrintStatus::GeneratingData`][crate::PrintStatus::GeneratingData]).
191    /// You can connect to the [`status-changed`][struct@crate::PrintOperation#status-changed] signal
192    /// and call [`PrintOperationExt::n_pages_to_print()`][crate::prelude::PrintOperationExt::n_pages_to_print()] when
193    /// print status is [`PrintStatus::GeneratingData`][crate::PrintStatus::GeneratingData].
194    /// This is typically used to track the progress of print operation.
195    ///
196    /// Readable
197    ///
198    ///
199    /// #### `print-settings`
200    ///  The [`PrintSettings`][crate::PrintSettings] used for initializing the dialog.
201    ///
202    /// Setting this property is typically used to re-establish
203    /// print settings from a previous print operation, see
204    /// [`PrintOperationExt::run()`][crate::prelude::PrintOperationExt::run()].
205    ///
206    /// Readable | Writeable
207    ///
208    ///
209    /// #### `show-progress`
210    ///  Determines whether to show a progress dialog during the
211    /// print operation.
212    ///
213    /// Readable | Writeable
214    ///
215    ///
216    /// #### `status`
217    ///  The status of the print operation.
218    ///
219    /// Readable
220    ///
221    ///
222    /// #### `status-string`
223    ///  A string representation of the status of the print operation.
224    /// The string is translated and suitable for displaying the print
225    /// status e.g. in a [`Statusbar`][crate::Statusbar].
226    ///
227    /// See the [`status`][struct@crate::PrintOperation#status] property for a status value that
228    /// is suitable for programmatic use.
229    ///
230    /// Readable
231    ///
232    ///
233    /// #### `support-selection`
234    ///  If [`true`], the print operation will support print of selection.
235    /// This allows the print dialog to show a "Selection" button.
236    ///
237    /// Readable | Writeable
238    ///
239    ///
240    /// #### `track-print-status`
241    ///  If [`true`], the print operation will try to continue report on
242    /// the status of the print job in the printer queues and printer.
243    /// This can allow your application to show things like “out of paper”
244    /// issues, and when the print job actually reaches the printer.
245    /// However, this is often implemented using polling, and should
246    /// not be enabled unless needed.
247    ///
248    /// Readable | Writeable
249    ///
250    ///
251    /// #### `unit`
252    ///  The transformation for the cairo context obtained from
253    /// [`PrintContext`][crate::PrintContext] is set up in such a way that distances
254    /// are measured in units of `unit`.
255    ///
256    /// Readable | Writeable
257    ///
258    ///
259    /// #### `use-full-page`
260    ///  If [`true`], the transformation for the cairo context obtained
261    /// from [`PrintContext`][crate::PrintContext] puts the origin at the top left corner
262    /// of the page (which may not be the top left corner of the sheet,
263    /// depending on page orientation and the number of pages per sheet).
264    /// Otherwise, the origin is at the top left corner of the imageable
265    /// area (i.e. inside the margins).
266    ///
267    /// Readable | Writeable
268    ///
269    /// ## Signals
270    ///
271    ///
272    /// #### `begin-print`
273    ///  Emitted after the user has finished changing print settings
274    /// in the dialog, before the actual rendering starts.
275    ///
276    /// A typical use for ::begin-print is to use the parameters from the
277    /// [`PrintContext`][crate::PrintContext] and paginate the document accordingly, and then
278    /// set the number of pages with [`PrintOperationExt::set_n_pages()`][crate::prelude::PrintOperationExt::set_n_pages()].
279    ///
280    ///
281    ///
282    ///
283    /// #### `create-custom-widget`
284    ///  Emitted when displaying the print dialog. If you return a
285    /// widget in a handler for this signal it will be added to a custom
286    /// tab in the print dialog. You typically return a container widget
287    /// with multiple widgets in it.
288    ///
289    /// The print dialog owns the returned widget, and its lifetime is not
290    /// controlled by the application. However, the widget is guaranteed
291    /// to stay around until the [`custom-widget-apply`][struct@crate::PrintOperation#custom-widget-apply]
292    /// signal is emitted on the operation. Then you can read out any
293    /// information you need from the widgets.
294    ///
295    ///
296    ///
297    ///
298    /// #### `custom-widget-apply`
299    ///  Emitted right before [`begin-print`][struct@crate::PrintOperation#begin-print] if you added
300    /// a custom widget in the [`create-custom-widget`][struct@crate::PrintOperation#create-custom-widget] handler.
301    /// When you get this signal you should read the information from the
302    /// custom widgets, as the widgets are not guaraneed to be around at a
303    /// later time.
304    ///
305    ///
306    ///
307    ///
308    /// #### `done`
309    ///  Emitted when the print operation run has finished doing
310    /// everything required for printing.
311    ///
312    /// `result` gives you information about what happened during the run.
313    /// If `result` is [`PrintOperationResult::Error`][crate::PrintOperationResult::Error] then you can call
314    /// `gtk_print_operation_get_error()` for more information.
315    ///
316    /// If you enabled print status tracking then
317    /// [`PrintOperationExt::is_finished()`][crate::prelude::PrintOperationExt::is_finished()] may still return [`false`]
318    /// after [`done`][struct@crate::PrintOperation#done] was emitted.
319    ///
320    ///
321    ///
322    ///
323    /// #### `draw-page`
324    ///  Emitted for every page that is printed. The signal handler
325    /// must render the `page_nr`'s page onto the cairo context obtained
326    /// from `context` using [`PrintContext::cairo_context()`][crate::PrintContext::cairo_context()].
327    ///
328    ///
329    /// **⚠️ The following code is in C ⚠️**
330    ///
331    /// ```C
332    /// static void
333    /// draw_page (GtkPrintOperation *operation,
334    ///            GtkPrintContext   *context,
335    ///            gint               page_nr,
336    ///            gpointer           user_data)
337    /// {
338    ///   cairo_t *cr;
339    ///   PangoLayout *layout;
340    ///   gdouble width, text_height;
341    ///   gint layout_height;
342    ///   PangoFontDescription *desc;
343    ///
344    ///   cr = gtk_print_context_get_cairo_context (context);
345    ///   width = gtk_print_context_get_width (context);
346    ///
347    ///   cairo_rectangle (cr, 0, 0, width, HEADER_HEIGHT);
348    ///
349    ///   cairo_set_source_rgb (cr, 0.8, 0.8, 0.8);
350    ///   cairo_fill (cr);
351    ///
352    ///   layout = gtk_print_context_create_pango_layout (context);
353    ///
354    ///   desc = pango_font_description_from_string ("sans 14");
355    ///   pango_layout_set_font_description (layout, desc);
356    ///   pango_font_description_free (desc);
357    ///
358    ///   pango_layout_set_text (layout, "some text", -1);
359    ///   pango_layout_set_width (layout, width * PANGO_SCALE);
360    ///   pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
361    ///
362    ///   pango_layout_get_size (layout, NULL, &layout_height);
363    ///   text_height = (gdouble)layout_height / PANGO_SCALE;
364    ///
365    ///   cairo_move_to (cr, width / 2,  (HEADER_HEIGHT - text_height) / 2);
366    ///   pango_cairo_show_layout (cr, layout);
367    ///
368    ///   g_object_unref (layout);
369    /// }
370    /// ```
371    ///
372    /// Use [`PrintOperationExt::set_use_full_page()`][crate::prelude::PrintOperationExt::set_use_full_page()] and
373    /// [`PrintOperationExt::set_unit()`][crate::prelude::PrintOperationExt::set_unit()] before starting the print operation
374    /// to set up the transformation of the cairo context according to your
375    /// needs.
376    ///
377    ///
378    ///
379    ///
380    /// #### `end-print`
381    ///  Emitted after all pages have been rendered.
382    /// A handler for this signal can clean up any resources that have
383    /// been allocated in the [`begin-print`][struct@crate::PrintOperation#begin-print] handler.
384    ///
385    ///
386    ///
387    ///
388    /// #### `paginate`
389    ///  Emitted after the [`begin-print`][struct@crate::PrintOperation#begin-print] signal, but before
390    /// the actual rendering starts. It keeps getting emitted until a connected
391    /// signal handler returns [`true`].
392    ///
393    /// The ::paginate signal is intended to be used for paginating a document
394    /// in small chunks, to avoid blocking the user interface for a long
395    /// time. The signal handler should update the number of pages using
396    /// [`PrintOperationExt::set_n_pages()`][crate::prelude::PrintOperationExt::set_n_pages()], and return [`true`] if the document
397    /// has been completely paginated.
398    ///
399    /// If you don't need to do pagination in chunks, you can simply do
400    /// it all in the ::begin-print handler, and set the number of pages
401    /// from there.
402    ///
403    ///
404    ///
405    ///
406    /// #### `preview`
407    ///  Gets emitted when a preview is requested from the native dialog.
408    ///
409    /// The default handler for this signal uses an external viewer
410    /// application to preview.
411    ///
412    /// To implement a custom print preview, an application must return
413    /// [`true`] from its handler for this signal. In order to use the
414    /// provided `context` for the preview implementation, it must be
415    /// given a suitable cairo context with [`PrintContext::set_cairo_context()`][crate::PrintContext::set_cairo_context()].
416    ///
417    /// The custom preview implementation can use
418    /// [`PrintOperationPreviewExt::is_selected()`][crate::prelude::PrintOperationPreviewExt::is_selected()] and
419    /// [`PrintOperationPreviewExt::render_page()`][crate::prelude::PrintOperationPreviewExt::render_page()] to find pages which
420    /// are selected for print and render them. The preview must be
421    /// finished by calling [`PrintOperationPreviewExt::end_preview()`][crate::prelude::PrintOperationPreviewExt::end_preview()]
422    /// (typically in response to the user clicking a close button).
423    ///
424    ///
425    ///
426    ///
427    /// #### `request-page-setup`
428    ///  Emitted once for every page that is printed, to give
429    /// the application a chance to modify the page setup. Any changes
430    /// done to `setup` will be in force only for printing this page.
431    ///
432    ///
433    ///
434    ///
435    /// #### `status-changed`
436    ///  Emitted at between the various phases of the print operation.
437    /// See [`PrintStatus`][crate::PrintStatus] for the phases that are being discriminated.
438    /// Use [`PrintOperationExt::status()`][crate::prelude::PrintOperationExt::status()] to find out the current
439    /// status.
440    ///
441    ///
442    ///
443    ///
444    /// #### `update-custom-widget`
445    ///  Emitted after change of selected printer. The actual page setup and
446    /// print settings are passed to the custom widget, which can actualize
447    /// itself according to this change.
448    ///
449    ///
450    /// <details><summary><h4>PrintOperationPreview</h4></summary>
451    ///
452    ///
453    /// #### `got-page-size`
454    ///  The ::got-page-size signal is emitted once for each page
455    /// that gets rendered to the preview.
456    ///
457    /// A handler for this signal should update the `context`
458    /// according to `page_setup` and set up a suitable cairo
459    /// context, using [`PrintContext::set_cairo_context()`][crate::PrintContext::set_cairo_context()].
460    ///
461    ///
462    ///
463    ///
464    /// #### `ready`
465    ///  The ::ready signal gets emitted once per preview operation,
466    /// before the first page is rendered.
467    ///
468    /// A handler for this signal can be used for setup tasks.
469    ///
470    ///
471    /// </details>
472    ///
473    /// # Implements
474    ///
475    /// [`PrintOperationExt`][trait@crate::prelude::PrintOperationExt], [`trait@glib::ObjectExt`], [`PrintOperationPreviewExt`][trait@crate::prelude::PrintOperationPreviewExt]
476    #[doc(alias = "GtkPrintOperation")]
477    pub struct PrintOperation(Object<ffi::GtkPrintOperation, ffi::GtkPrintOperationClass>) @implements PrintOperationPreview;
478
479    match fn {
480        type_ => || ffi::gtk_print_operation_get_type(),
481    }
482}
483
484impl PrintOperation {
485    pub const NONE: Option<&'static PrintOperation> = None;
486
487    /// Creates a new [`PrintOperation`][crate::PrintOperation].
488    ///
489    /// # Returns
490    ///
491    /// a new [`PrintOperation`][crate::PrintOperation]
492    #[doc(alias = "gtk_print_operation_new")]
493    pub fn new() -> PrintOperation {
494        assert_initialized_main_thread!();
495        unsafe { from_glib_full(ffi::gtk_print_operation_new()) }
496    }
497
498    // rustdoc-stripper-ignore-next
499    /// Creates a new builder-pattern struct instance to construct [`PrintOperation`] objects.
500    ///
501    /// This method returns an instance of [`PrintOperationBuilder`](crate::builders::PrintOperationBuilder) which can be used to create [`PrintOperation`] objects.
502    pub fn builder() -> PrintOperationBuilder {
503        PrintOperationBuilder::new()
504    }
505}
506
507impl Default for PrintOperation {
508    fn default() -> Self {
509        Self::new()
510    }
511}
512
513// rustdoc-stripper-ignore-next
514/// A [builder-pattern] type to construct [`PrintOperation`] objects.
515///
516/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
517#[must_use = "The builder must be built to be used"]
518pub struct PrintOperationBuilder {
519    builder: glib::object::ObjectBuilder<'static, PrintOperation>,
520}
521
522impl PrintOperationBuilder {
523    fn new() -> Self {
524        Self {
525            builder: glib::object::Object::builder(),
526        }
527    }
528
529    /// Determines whether the print operation may run asynchronously or not.
530    ///
531    /// Some systems don't support asynchronous printing, but those that do
532    /// will return [`PrintOperationResult::InProgress`][crate::PrintOperationResult::InProgress] as the status, and
533    /// emit the [`done`][struct@crate::PrintOperation#done] signal when the operation is actually
534    /// done.
535    ///
536    /// The Windows port does not support asynchronous operation at all (this
537    /// is unlikely to change). On other platforms, all actions except for
538    /// [`PrintOperationAction::Export`][crate::PrintOperationAction::Export] support asynchronous operation.
539    pub fn allow_async(self, allow_async: bool) -> Self {
540        Self {
541            builder: self.builder.property("allow-async", allow_async),
542        }
543    }
544
545    /// The current page in the document.
546    ///
547    /// If this is set before [`PrintOperationExt::run()`][crate::prelude::PrintOperationExt::run()],
548    /// the user will be able to select to print only the current page.
549    ///
550    /// Note that this only makes sense for pre-paginated documents.
551    pub fn current_page(self, current_page: i32) -> Self {
552        Self {
553            builder: self.builder.property("current-page", current_page),
554        }
555    }
556
557    /// Used as the label of the tab containing custom widgets.
558    /// Note that this property may be ignored on some platforms.
559    ///
560    /// If this is [`None`], GTK+ uses a default label.
561    pub fn custom_tab_label(self, custom_tab_label: impl Into<glib::GString>) -> Self {
562        Self {
563            builder: self
564                .builder
565                .property("custom-tab-label", custom_tab_label.into()),
566        }
567    }
568
569    /// The [`PageSetup`][crate::PageSetup] used by default.
570    ///
571    /// This page setup will be used by [`PrintOperationExt::run()`][crate::prelude::PrintOperationExt::run()],
572    /// but it can be overridden on a per-page basis by connecting
573    /// to the [`request-page-setup`][struct@crate::PrintOperation#request-page-setup] signal.
574    pub fn default_page_setup(self, default_page_setup: &PageSetup) -> Self {
575        Self {
576            builder: self
577                .builder
578                .property("default-page-setup", default_page_setup.clone()),
579        }
580    }
581
582    /// If [`true`], page size combo box and orientation combo box are embedded into page setup page.
583    pub fn embed_page_setup(self, embed_page_setup: bool) -> Self {
584        Self {
585            builder: self.builder.property("embed-page-setup", embed_page_setup),
586        }
587    }
588
589    /// The name of a file to generate instead of showing the print dialog.
590    /// Currently, PDF is the only supported format.
591    ///
592    /// The intended use of this property is for implementing
593    /// “Export to PDF” actions.
594    ///
595    /// “Print to PDF” support is independent of this and is done
596    /// by letting the user pick the “Print to PDF” item from the
597    /// list of printers in the print dialog.
598    pub fn export_filename(self, export_filename: impl Into<glib::GString>) -> Self {
599        Self {
600            builder: self
601                .builder
602                .property("export-filename", export_filename.into()),
603        }
604    }
605
606    /// Determines whether there is a selection in your application.
607    /// This can allow your application to print the selection.
608    /// This is typically used to make a "Selection" button sensitive.
609    pub fn has_selection(self, has_selection: bool) -> Self {
610        Self {
611            builder: self.builder.property("has-selection", has_selection),
612        }
613    }
614
615    /// A string used to identify the job (e.g. in monitoring
616    /// applications like eggcups).
617    ///
618    /// If you don't set a job name, GTK+ picks a default one
619    /// by numbering successive print jobs.
620    pub fn job_name(self, job_name: impl Into<glib::GString>) -> Self {
621        Self {
622            builder: self.builder.property("job-name", job_name.into()),
623        }
624    }
625
626    /// The number of pages in the document.
627    ///
628    /// This must be set to a positive number
629    /// before the rendering starts. It may be set in a
630    /// [`begin-print`][struct@crate::PrintOperation#begin-print] signal hander.
631    ///
632    /// Note that the page numbers passed to the
633    /// [`request-page-setup`][struct@crate::PrintOperation#request-page-setup] and
634    /// [`draw-page`][struct@crate::PrintOperation#draw-page] signals are 0-based, i.e. if
635    /// the user chooses to print all pages, the last ::draw-page signal
636    /// will be for page `n_pages` - 1.
637    pub fn n_pages(self, n_pages: i32) -> Self {
638        Self {
639            builder: self.builder.property("n-pages", n_pages),
640        }
641    }
642
643    /// The [`PrintSettings`][crate::PrintSettings] used for initializing the dialog.
644    ///
645    /// Setting this property is typically used to re-establish
646    /// print settings from a previous print operation, see
647    /// [`PrintOperationExt::run()`][crate::prelude::PrintOperationExt::run()].
648    pub fn print_settings(self, print_settings: &PrintSettings) -> Self {
649        Self {
650            builder: self
651                .builder
652                .property("print-settings", print_settings.clone()),
653        }
654    }
655
656    /// Determines whether to show a progress dialog during the
657    /// print operation.
658    pub fn show_progress(self, show_progress: bool) -> Self {
659        Self {
660            builder: self.builder.property("show-progress", show_progress),
661        }
662    }
663
664    /// If [`true`], the print operation will support print of selection.
665    /// This allows the print dialog to show a "Selection" button.
666    pub fn support_selection(self, support_selection: bool) -> Self {
667        Self {
668            builder: self
669                .builder
670                .property("support-selection", support_selection),
671        }
672    }
673
674    /// If [`true`], the print operation will try to continue report on
675    /// the status of the print job in the printer queues and printer.
676    /// This can allow your application to show things like “out of paper”
677    /// issues, and when the print job actually reaches the printer.
678    /// However, this is often implemented using polling, and should
679    /// not be enabled unless needed.
680    pub fn track_print_status(self, track_print_status: bool) -> Self {
681        Self {
682            builder: self
683                .builder
684                .property("track-print-status", track_print_status),
685        }
686    }
687
688    /// The transformation for the cairo context obtained from
689    /// [`PrintContext`][crate::PrintContext] is set up in such a way that distances
690    /// are measured in units of `unit`.
691    pub fn unit(self, unit: Unit) -> Self {
692        Self {
693            builder: self.builder.property("unit", unit),
694        }
695    }
696
697    /// If [`true`], the transformation for the cairo context obtained
698    /// from [`PrintContext`][crate::PrintContext] puts the origin at the top left corner
699    /// of the page (which may not be the top left corner of the sheet,
700    /// depending on page orientation and the number of pages per sheet).
701    /// Otherwise, the origin is at the top left corner of the imageable
702    /// area (i.e. inside the margins).
703    pub fn use_full_page(self, use_full_page: bool) -> Self {
704        Self {
705            builder: self.builder.property("use-full-page", use_full_page),
706        }
707    }
708
709    // rustdoc-stripper-ignore-next
710    /// Build the [`PrintOperation`].
711    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
712    pub fn build(self) -> PrintOperation {
713        self.builder.build()
714    }
715}
716
717mod sealed {
718    pub trait Sealed {}
719    impl<T: super::IsA<super::PrintOperation>> Sealed for T {}
720}
721
722/// Trait containing all [`struct@PrintOperation`] methods.
723///
724/// # Implementors
725///
726/// [`PrintOperation`][struct@crate::PrintOperation]
727pub trait PrintOperationExt: IsA<PrintOperation> + sealed::Sealed + 'static {
728    /// Cancels a running print operation. This function may
729    /// be called from a [`begin-print`][struct@crate::PrintOperation#begin-print],
730    /// [`paginate`][struct@crate::PrintOperation#paginate] or [`draw-page`][struct@crate::PrintOperation#draw-page]
731    /// signal handler to stop the currently running print
732    /// operation.
733    #[doc(alias = "gtk_print_operation_cancel")]
734    fn cancel(&self) {
735        unsafe {
736            ffi::gtk_print_operation_cancel(self.as_ref().to_glib_none().0);
737        }
738    }
739
740    /// Signalize that drawing of particular page is complete.
741    ///
742    /// It is called after completion of page drawing (e.g. drawing in another
743    /// thread).
744    /// If [`set_defer_drawing()`][Self::set_defer_drawing()] was called before, then this function
745    /// has to be called by application. In another case it is called by the library
746    /// itself.
747    #[doc(alias = "gtk_print_operation_draw_page_finish")]
748    fn draw_page_finish(&self) {
749        unsafe {
750            ffi::gtk_print_operation_draw_page_finish(self.as_ref().to_glib_none().0);
751        }
752    }
753
754    /// Returns the default page setup, see
755    /// [`set_default_page_setup()`][Self::set_default_page_setup()].
756    ///
757    /// # Returns
758    ///
759    /// the default page setup
760    #[doc(alias = "gtk_print_operation_get_default_page_setup")]
761    #[doc(alias = "get_default_page_setup")]
762    fn default_page_setup(&self) -> Option<PageSetup> {
763        unsafe {
764            from_glib_none(ffi::gtk_print_operation_get_default_page_setup(
765                self.as_ref().to_glib_none().0,
766            ))
767        }
768    }
769
770    /// Gets the value of [`embed-page-setup`][struct@crate::PrintOperation#embed-page-setup] property.
771    ///
772    /// # Returns
773    ///
774    /// whether page setup selection combos are embedded
775    #[doc(alias = "gtk_print_operation_get_embed_page_setup")]
776    #[doc(alias = "get_embed_page_setup")]
777    fn embeds_page_setup(&self) -> bool {
778        unsafe {
779            from_glib(ffi::gtk_print_operation_get_embed_page_setup(
780                self.as_ref().to_glib_none().0,
781            ))
782        }
783    }
784
785    /// Gets the value of [`has-selection`][struct@crate::PrintOperation#has-selection] property.
786    ///
787    /// # Returns
788    ///
789    /// whether there is a selection
790    #[doc(alias = "gtk_print_operation_get_has_selection")]
791    #[doc(alias = "get_has_selection")]
792    fn has_selection(&self) -> bool {
793        unsafe {
794            from_glib(ffi::gtk_print_operation_get_has_selection(
795                self.as_ref().to_glib_none().0,
796            ))
797        }
798    }
799
800    /// Returns the number of pages that will be printed.
801    ///
802    /// Note that this value is set during print preparation phase
803    /// ([`PrintStatus::Preparing`][crate::PrintStatus::Preparing]), so this function should never be
804    /// called before the data generation phase ([`PrintStatus::GeneratingData`][crate::PrintStatus::GeneratingData]).
805    /// You can connect to the [`status-changed`][struct@crate::PrintOperation#status-changed] signal
806    /// and call [`n_pages_to_print()`][Self::n_pages_to_print()] when
807    /// print status is [`PrintStatus::GeneratingData`][crate::PrintStatus::GeneratingData].
808    /// This is typically used to track the progress of print operation.
809    ///
810    /// # Returns
811    ///
812    /// the number of pages that will be printed
813    #[doc(alias = "gtk_print_operation_get_n_pages_to_print")]
814    #[doc(alias = "get_n_pages_to_print")]
815    fn n_pages_to_print(&self) -> i32 {
816        unsafe { ffi::gtk_print_operation_get_n_pages_to_print(self.as_ref().to_glib_none().0) }
817    }
818
819    /// Returns the current print settings.
820    ///
821    /// Note that the return value is [`None`] until either
822    /// [`set_print_settings()`][Self::set_print_settings()] or
823    /// [`run()`][Self::run()] have been called.
824    ///
825    /// # Returns
826    ///
827    /// the current print settings of `self`.
828    #[doc(alias = "gtk_print_operation_get_print_settings")]
829    #[doc(alias = "get_print_settings")]
830    fn print_settings(&self) -> Option<PrintSettings> {
831        unsafe {
832            from_glib_none(ffi::gtk_print_operation_get_print_settings(
833                self.as_ref().to_glib_none().0,
834            ))
835        }
836    }
837
838    /// Returns the status of the print operation.
839    /// Also see [`status_string()`][Self::status_string()].
840    ///
841    /// # Returns
842    ///
843    /// the status of the print operation
844    #[doc(alias = "gtk_print_operation_get_status")]
845    #[doc(alias = "get_status")]
846    fn status(&self) -> PrintStatus {
847        unsafe {
848            from_glib(ffi::gtk_print_operation_get_status(
849                self.as_ref().to_glib_none().0,
850            ))
851        }
852    }
853
854    /// Returns a string representation of the status of the
855    /// print operation. The string is translated and suitable
856    /// for displaying the print status e.g. in a [`Statusbar`][crate::Statusbar].
857    ///
858    /// Use [`status()`][Self::status()] to obtain a status
859    /// value that is suitable for programmatic use.
860    ///
861    /// # Returns
862    ///
863    /// a string representation of the status
864    ///  of the print operation
865    #[doc(alias = "gtk_print_operation_get_status_string")]
866    #[doc(alias = "get_status_string")]
867    fn status_string(&self) -> Option<glib::GString> {
868        unsafe {
869            from_glib_none(ffi::gtk_print_operation_get_status_string(
870                self.as_ref().to_glib_none().0,
871            ))
872        }
873    }
874
875    /// Gets the value of [`support-selection`][struct@crate::PrintOperation#support-selection] property.
876    ///
877    /// # Returns
878    ///
879    /// whether the application supports print of selection
880    #[doc(alias = "gtk_print_operation_get_support_selection")]
881    #[doc(alias = "get_support_selection")]
882    fn supports_selection(&self) -> bool {
883        unsafe {
884            from_glib(ffi::gtk_print_operation_get_support_selection(
885                self.as_ref().to_glib_none().0,
886            ))
887        }
888    }
889
890    /// A convenience function to find out if the print operation
891    /// is finished, either successfully ([`PrintStatus::Finished`][crate::PrintStatus::Finished])
892    /// or unsuccessfully ([`PrintStatus::FinishedAborted`][crate::PrintStatus::FinishedAborted]).
893    ///
894    /// Note: when you enable print status tracking the print operation
895    /// can be in a non-finished state even after done has been called, as
896    /// the operation status then tracks the print job status on the printer.
897    ///
898    /// # Returns
899    ///
900    /// [`true`], if the print operation is finished.
901    #[doc(alias = "gtk_print_operation_is_finished")]
902    fn is_finished(&self) -> bool {
903        unsafe {
904            from_glib(ffi::gtk_print_operation_is_finished(
905                self.as_ref().to_glib_none().0,
906            ))
907        }
908    }
909
910    /// Runs the print operation, by first letting the user modify
911    /// print settings in the print dialog, and then print the document.
912    ///
913    /// Normally that this function does not return until the rendering of all
914    /// pages is complete. You can connect to the
915    /// [`status-changed`][struct@crate::PrintOperation#status-changed] signal on `self` to obtain some
916    /// information about the progress of the print operation.
917    /// Furthermore, it may use a recursive mainloop to show the print dialog.
918    ///
919    /// If you call [`set_allow_async()`][Self::set_allow_async()] or set the
920    /// [`allow-async`][struct@crate::PrintOperation#allow-async] property the operation will run
921    /// asynchronously if this is supported on the platform. The
922    /// [`done`][struct@crate::PrintOperation#done] signal will be emitted with the result of the
923    /// operation when the it is done (i.e. when the dialog is canceled, or when
924    /// the print succeeds or fails).
925    ///
926    ///
927    /// **⚠️ The following code is in C ⚠️**
928    ///
929    /// ```C
930    /// if (settings != NULL)
931    ///   gtk_print_operation_set_print_settings (print, settings);
932    ///
933    /// if (page_setup != NULL)
934    ///   gtk_print_operation_set_default_page_setup (print, page_setup);
935    ///
936    /// g_signal_connect (print, "begin-print",
937    ///                   G_CALLBACK (begin_print), &data);
938    /// g_signal_connect (print, "draw-page",
939    ///                   G_CALLBACK (draw_page), &data);
940    ///
941    /// res = gtk_print_operation_run (print,
942    ///                                GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
943    ///                                parent,
944    ///                                &error);
945    ///
946    /// if (res == GTK_PRINT_OPERATION_RESULT_ERROR)
947    ///  {
948    ///    error_dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
949    ///                                    GTK_DIALOG_DESTROY_WITH_PARENT,
950    ///                          GTK_MESSAGE_ERROR,
951    ///                          GTK_BUTTONS_CLOSE,
952    ///                          "Error printing file:\n%s",
953    ///                          error->message);
954    ///    g_signal_connect (error_dialog, "response",
955    ///                      G_CALLBACK (gtk_widget_destroy), NULL);
956    ///    gtk_widget_show (error_dialog);
957    ///    g_error_free (error);
958    ///  }
959    /// else if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
960    ///  {
961    ///    if (settings != NULL)
962    /// g_object_unref (settings);
963    ///    settings = g_object_ref (gtk_print_operation_get_print_settings (print));
964    ///  }
965    /// ```
966    ///
967    /// Note that [`run()`][Self::run()] can only be called once on a
968    /// given [`PrintOperation`][crate::PrintOperation].
969    /// ## `action`
970    /// the action to start
971    /// ## `parent`
972    /// Transient parent of the dialog
973    ///
974    /// # Returns
975    ///
976    /// the result of the print operation. A return value of
977    ///  [`PrintOperationResult::Apply`][crate::PrintOperationResult::Apply] indicates that the printing was
978    ///  completed successfully. In this case, it is a good idea to obtain
979    ///  the used print settings with [`print_settings()`][Self::print_settings()]
980    ///  and store them for reuse with the next print operation. A value of
981    ///  [`PrintOperationResult::InProgress`][crate::PrintOperationResult::InProgress] means the operation is running
982    ///  asynchronously, and will emit the [`done`][struct@crate::PrintOperation#done] signal when
983    ///  done.
984    #[doc(alias = "gtk_print_operation_run")]
985    fn run(
986        &self,
987        action: PrintOperationAction,
988        parent: Option<&impl IsA<Window>>,
989    ) -> Result<PrintOperationResult, glib::Error> {
990        unsafe {
991            let mut error = ptr::null_mut();
992            let ret = ffi::gtk_print_operation_run(
993                self.as_ref().to_glib_none().0,
994                action.into_glib(),
995                parent.map(|p| p.as_ref()).to_glib_none().0,
996                &mut error,
997            );
998            if error.is_null() {
999                Ok(from_glib(ret))
1000            } else {
1001                Err(from_glib_full(error))
1002            }
1003        }
1004    }
1005
1006    /// Sets whether the [`run()`][Self::run()] may return
1007    /// before the print operation is completed. Note that
1008    /// some platforms may not allow asynchronous operation.
1009    /// ## `allow_async`
1010    /// [`true`] to allow asynchronous operation
1011    #[doc(alias = "gtk_print_operation_set_allow_async")]
1012    fn set_allow_async(&self, allow_async: bool) {
1013        unsafe {
1014            ffi::gtk_print_operation_set_allow_async(
1015                self.as_ref().to_glib_none().0,
1016                allow_async.into_glib(),
1017            );
1018        }
1019    }
1020
1021    /// Sets the current page.
1022    ///
1023    /// If this is called before [`run()`][Self::run()],
1024    /// the user will be able to select to print only the current page.
1025    ///
1026    /// Note that this only makes sense for pre-paginated documents.
1027    /// ## `current_page`
1028    /// the current page, 0-based
1029    #[doc(alias = "gtk_print_operation_set_current_page")]
1030    fn set_current_page(&self, current_page: i32) {
1031        unsafe {
1032            ffi::gtk_print_operation_set_current_page(self.as_ref().to_glib_none().0, current_page);
1033        }
1034    }
1035
1036    /// Sets the label for the tab holding custom widgets.
1037    /// ## `label`
1038    /// the label to use, or [`None`] to use the default label
1039    #[doc(alias = "gtk_print_operation_set_custom_tab_label")]
1040    fn set_custom_tab_label(&self, label: Option<&str>) {
1041        unsafe {
1042            ffi::gtk_print_operation_set_custom_tab_label(
1043                self.as_ref().to_glib_none().0,
1044                label.to_glib_none().0,
1045            );
1046        }
1047    }
1048
1049    /// Makes `default_page_setup` the default page setup for `self`.
1050    ///
1051    /// This page setup will be used by [`run()`][Self::run()],
1052    /// but it can be overridden on a per-page basis by connecting
1053    /// to the [`request-page-setup`][struct@crate::PrintOperation#request-page-setup] signal.
1054    /// ## `default_page_setup`
1055    /// a [`PageSetup`][crate::PageSetup], or [`None`]
1056    #[doc(alias = "gtk_print_operation_set_default_page_setup")]
1057    fn set_default_page_setup(&self, default_page_setup: Option<&PageSetup>) {
1058        unsafe {
1059            ffi::gtk_print_operation_set_default_page_setup(
1060                self.as_ref().to_glib_none().0,
1061                default_page_setup.to_glib_none().0,
1062            );
1063        }
1064    }
1065
1066    /// Sets up the [`PrintOperation`][crate::PrintOperation] to wait for calling of
1067    /// [`draw_page_finish()`][Self::draw_page_finish()] from application. It can
1068    /// be used for drawing page in another thread.
1069    ///
1070    /// This function must be called in the callback of “draw-page” signal.
1071    #[doc(alias = "gtk_print_operation_set_defer_drawing")]
1072    fn set_defer_drawing(&self) {
1073        unsafe {
1074            ffi::gtk_print_operation_set_defer_drawing(self.as_ref().to_glib_none().0);
1075        }
1076    }
1077
1078    /// Embed page size combo box and orientation combo box into page setup page.
1079    /// Selected page setup is stored as default page setup in [`PrintOperation`][crate::PrintOperation].
1080    /// ## `embed`
1081    /// [`true`] to embed page setup selection in the `GtkPrintUnixDialog`
1082    #[doc(alias = "gtk_print_operation_set_embed_page_setup")]
1083    fn set_embed_page_setup(&self, embed: bool) {
1084        unsafe {
1085            ffi::gtk_print_operation_set_embed_page_setup(
1086                self.as_ref().to_glib_none().0,
1087                embed.into_glib(),
1088            );
1089        }
1090    }
1091
1092    /// Sets up the [`PrintOperation`][crate::PrintOperation] to generate a file instead
1093    /// of showing the print dialog. The indended use of this function
1094    /// is for implementing “Export to PDF” actions. Currently, PDF
1095    /// is the only supported format.
1096    ///
1097    /// “Print to PDF” support is independent of this and is done
1098    /// by letting the user pick the “Print to PDF” item from the list
1099    /// of printers in the print dialog.
1100    /// ## `filename`
1101    /// the filename for the exported file
1102    #[doc(alias = "gtk_print_operation_set_export_filename")]
1103    fn set_export_filename(&self, filename: impl AsRef<std::path::Path>) {
1104        unsafe {
1105            ffi::gtk_print_operation_set_export_filename(
1106                self.as_ref().to_glib_none().0,
1107                filename.as_ref().to_glib_none().0,
1108            );
1109        }
1110    }
1111
1112    /// Sets whether there is a selection to print.
1113    ///
1114    /// Application has to set number of pages to which the selection
1115    /// will draw by [`set_n_pages()`][Self::set_n_pages()] in a callback of
1116    /// [`begin-print`][struct@crate::PrintOperation#begin-print].
1117    /// ## `has_selection`
1118    /// [`true`] indicates that a selection exists
1119    #[doc(alias = "gtk_print_operation_set_has_selection")]
1120    fn set_has_selection(&self, has_selection: bool) {
1121        unsafe {
1122            ffi::gtk_print_operation_set_has_selection(
1123                self.as_ref().to_glib_none().0,
1124                has_selection.into_glib(),
1125            );
1126        }
1127    }
1128
1129    /// Sets the name of the print job. The name is used to identify
1130    /// the job (e.g. in monitoring applications like eggcups).
1131    ///
1132    /// If you don’t set a job name, GTK+ picks a default one by
1133    /// numbering successive print jobs.
1134    /// ## `job_name`
1135    /// a string that identifies the print job
1136    #[doc(alias = "gtk_print_operation_set_job_name")]
1137    fn set_job_name(&self, job_name: &str) {
1138        unsafe {
1139            ffi::gtk_print_operation_set_job_name(
1140                self.as_ref().to_glib_none().0,
1141                job_name.to_glib_none().0,
1142            );
1143        }
1144    }
1145
1146    /// Sets the number of pages in the document.
1147    ///
1148    /// This must be set to a positive number
1149    /// before the rendering starts. It may be set in a
1150    /// [`begin-print`][struct@crate::PrintOperation#begin-print] signal hander.
1151    ///
1152    /// Note that the page numbers passed to the
1153    /// [`request-page-setup`][struct@crate::PrintOperation#request-page-setup]
1154    /// and [`draw-page`][struct@crate::PrintOperation#draw-page] signals are 0-based, i.e. if
1155    /// the user chooses to print all pages, the last ::draw-page signal
1156    /// will be for page `n_pages` - 1.
1157    /// ## `n_pages`
1158    /// the number of pages
1159    #[doc(alias = "gtk_print_operation_set_n_pages")]
1160    fn set_n_pages(&self, n_pages: i32) {
1161        unsafe {
1162            ffi::gtk_print_operation_set_n_pages(self.as_ref().to_glib_none().0, n_pages);
1163        }
1164    }
1165
1166    /// Sets the print settings for `self`. This is typically used to
1167    /// re-establish print settings from a previous print operation,
1168    /// see [`run()`][Self::run()].
1169    /// ## `print_settings`
1170    /// [`PrintSettings`][crate::PrintSettings]
1171    #[doc(alias = "gtk_print_operation_set_print_settings")]
1172    fn set_print_settings(&self, print_settings: Option<&PrintSettings>) {
1173        unsafe {
1174            ffi::gtk_print_operation_set_print_settings(
1175                self.as_ref().to_glib_none().0,
1176                print_settings.to_glib_none().0,
1177            );
1178        }
1179    }
1180
1181    /// If `show_progress` is [`true`], the print operation will show a
1182    /// progress dialog during the print operation.
1183    /// ## `show_progress`
1184    /// [`true`] to show a progress dialog
1185    #[doc(alias = "gtk_print_operation_set_show_progress")]
1186    fn set_show_progress(&self, show_progress: bool) {
1187        unsafe {
1188            ffi::gtk_print_operation_set_show_progress(
1189                self.as_ref().to_glib_none().0,
1190                show_progress.into_glib(),
1191            );
1192        }
1193    }
1194
1195    /// Sets whether selection is supported by [`PrintOperation`][crate::PrintOperation].
1196    /// ## `support_selection`
1197    /// [`true`] to support selection
1198    #[doc(alias = "gtk_print_operation_set_support_selection")]
1199    fn set_support_selection(&self, support_selection: bool) {
1200        unsafe {
1201            ffi::gtk_print_operation_set_support_selection(
1202                self.as_ref().to_glib_none().0,
1203                support_selection.into_glib(),
1204            );
1205        }
1206    }
1207
1208    /// If track_status is [`true`], the print operation will try to continue report
1209    /// on the status of the print job in the printer queues and printer. This
1210    /// can allow your application to show things like “out of paper” issues,
1211    /// and when the print job actually reaches the printer.
1212    ///
1213    /// This function is often implemented using some form of polling, so it should
1214    /// not be enabled unless needed.
1215    /// ## `track_status`
1216    /// [`true`] to track status after printing
1217    #[doc(alias = "gtk_print_operation_set_track_print_status")]
1218    fn set_track_print_status(&self, track_status: bool) {
1219        unsafe {
1220            ffi::gtk_print_operation_set_track_print_status(
1221                self.as_ref().to_glib_none().0,
1222                track_status.into_glib(),
1223            );
1224        }
1225    }
1226
1227    /// Sets up the transformation for the cairo context obtained from
1228    /// [`PrintContext`][crate::PrintContext] in such a way that distances are measured in
1229    /// units of `unit`.
1230    /// ## `unit`
1231    /// the unit to use
1232    #[doc(alias = "gtk_print_operation_set_unit")]
1233    fn set_unit(&self, unit: Unit) {
1234        unsafe {
1235            ffi::gtk_print_operation_set_unit(self.as_ref().to_glib_none().0, unit.into_glib());
1236        }
1237    }
1238
1239    /// If `full_page` is [`true`], the transformation for the cairo context
1240    /// obtained from [`PrintContext`][crate::PrintContext] puts the origin at the top left
1241    /// corner of the page (which may not be the top left corner of the
1242    /// sheet, depending on page orientation and the number of pages per
1243    /// sheet). Otherwise, the origin is at the top left corner of the
1244    /// imageable area (i.e. inside the margins).
1245    /// ## `full_page`
1246    /// [`true`] to set up the [`PrintContext`][crate::PrintContext] for the full page
1247    #[doc(alias = "gtk_print_operation_set_use_full_page")]
1248    fn set_use_full_page(&self, full_page: bool) {
1249        unsafe {
1250            ffi::gtk_print_operation_set_use_full_page(
1251                self.as_ref().to_glib_none().0,
1252                full_page.into_glib(),
1253            );
1254        }
1255    }
1256
1257    /// Determines whether the print operation may run asynchronously or not.
1258    ///
1259    /// Some systems don't support asynchronous printing, but those that do
1260    /// will return [`PrintOperationResult::InProgress`][crate::PrintOperationResult::InProgress] as the status, and
1261    /// emit the [`done`][struct@crate::PrintOperation#done] signal when the operation is actually
1262    /// done.
1263    ///
1264    /// The Windows port does not support asynchronous operation at all (this
1265    /// is unlikely to change). On other platforms, all actions except for
1266    /// [`PrintOperationAction::Export`][crate::PrintOperationAction::Export] support asynchronous operation.
1267    #[doc(alias = "allow-async")]
1268    fn allows_async(&self) -> bool {
1269        ObjectExt::property(self.as_ref(), "allow-async")
1270    }
1271
1272    /// The current page in the document.
1273    ///
1274    /// If this is set before [`run()`][Self::run()],
1275    /// the user will be able to select to print only the current page.
1276    ///
1277    /// Note that this only makes sense for pre-paginated documents.
1278    #[doc(alias = "current-page")]
1279    fn current_page(&self) -> i32 {
1280        ObjectExt::property(self.as_ref(), "current-page")
1281    }
1282
1283    /// Used as the label of the tab containing custom widgets.
1284    /// Note that this property may be ignored on some platforms.
1285    ///
1286    /// If this is [`None`], GTK+ uses a default label.
1287    #[doc(alias = "custom-tab-label")]
1288    fn custom_tab_label(&self) -> Option<glib::GString> {
1289        ObjectExt::property(self.as_ref(), "custom-tab-label")
1290    }
1291
1292    /// The name of a file to generate instead of showing the print dialog.
1293    /// Currently, PDF is the only supported format.
1294    ///
1295    /// The intended use of this property is for implementing
1296    /// “Export to PDF” actions.
1297    ///
1298    /// “Print to PDF” support is independent of this and is done
1299    /// by letting the user pick the “Print to PDF” item from the
1300    /// list of printers in the print dialog.
1301    #[doc(alias = "export-filename")]
1302    fn export_filename(&self) -> Option<glib::GString> {
1303        ObjectExt::property(self.as_ref(), "export-filename")
1304    }
1305
1306    /// A string used to identify the job (e.g. in monitoring
1307    /// applications like eggcups).
1308    ///
1309    /// If you don't set a job name, GTK+ picks a default one
1310    /// by numbering successive print jobs.
1311    #[doc(alias = "job-name")]
1312    fn job_name(&self) -> Option<glib::GString> {
1313        ObjectExt::property(self.as_ref(), "job-name")
1314    }
1315
1316    /// The number of pages in the document.
1317    ///
1318    /// This must be set to a positive number
1319    /// before the rendering starts. It may be set in a
1320    /// [`begin-print`][struct@crate::PrintOperation#begin-print] signal hander.
1321    ///
1322    /// Note that the page numbers passed to the
1323    /// [`request-page-setup`][struct@crate::PrintOperation#request-page-setup] and
1324    /// [`draw-page`][struct@crate::PrintOperation#draw-page] signals are 0-based, i.e. if
1325    /// the user chooses to print all pages, the last ::draw-page signal
1326    /// will be for page `n_pages` - 1.
1327    #[doc(alias = "n-pages")]
1328    fn n_pages(&self) -> i32 {
1329        ObjectExt::property(self.as_ref(), "n-pages")
1330    }
1331
1332    /// Determines whether to show a progress dialog during the
1333    /// print operation.
1334    #[doc(alias = "show-progress")]
1335    fn shows_progress(&self) -> bool {
1336        ObjectExt::property(self.as_ref(), "show-progress")
1337    }
1338
1339    /// If [`true`], the print operation will try to continue report on
1340    /// the status of the print job in the printer queues and printer.
1341    /// This can allow your application to show things like “out of paper”
1342    /// issues, and when the print job actually reaches the printer.
1343    /// However, this is often implemented using polling, and should
1344    /// not be enabled unless needed.
1345    #[doc(alias = "track-print-status")]
1346    fn tracks_print_status(&self) -> bool {
1347        ObjectExt::property(self.as_ref(), "track-print-status")
1348    }
1349
1350    /// The transformation for the cairo context obtained from
1351    /// [`PrintContext`][crate::PrintContext] is set up in such a way that distances
1352    /// are measured in units of `unit`.
1353    fn unit(&self) -> Unit {
1354        ObjectExt::property(self.as_ref(), "unit")
1355    }
1356
1357    /// If [`true`], the transformation for the cairo context obtained
1358    /// from [`PrintContext`][crate::PrintContext] puts the origin at the top left corner
1359    /// of the page (which may not be the top left corner of the sheet,
1360    /// depending on page orientation and the number of pages per sheet).
1361    /// Otherwise, the origin is at the top left corner of the imageable
1362    /// area (i.e. inside the margins).
1363    #[doc(alias = "use-full-page")]
1364    fn uses_full_page(&self) -> bool {
1365        ObjectExt::property(self.as_ref(), "use-full-page")
1366    }
1367
1368    /// Emitted after the user has finished changing print settings
1369    /// in the dialog, before the actual rendering starts.
1370    ///
1371    /// A typical use for ::begin-print is to use the parameters from the
1372    /// [`PrintContext`][crate::PrintContext] and paginate the document accordingly, and then
1373    /// set the number of pages with [`set_n_pages()`][Self::set_n_pages()].
1374    /// ## `context`
1375    /// the [`PrintContext`][crate::PrintContext] for the current operation
1376    #[doc(alias = "begin-print")]
1377    fn connect_begin_print<F: Fn(&Self, &PrintContext) + 'static>(&self, f: F) -> SignalHandlerId {
1378        unsafe extern "C" fn begin_print_trampoline<
1379            P: IsA<PrintOperation>,
1380            F: Fn(&P, &PrintContext) + 'static,
1381        >(
1382            this: *mut ffi::GtkPrintOperation,
1383            context: *mut ffi::GtkPrintContext,
1384            f: glib::ffi::gpointer,
1385        ) {
1386            let f: &F = &*(f as *const F);
1387            f(
1388                PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
1389                &from_glib_borrow(context),
1390            )
1391        }
1392        unsafe {
1393            let f: Box_<F> = Box_::new(f);
1394            connect_raw(
1395                self.as_ptr() as *mut _,
1396                b"begin-print\0".as_ptr() as *const _,
1397                Some(transmute::<_, unsafe extern "C" fn()>(
1398                    begin_print_trampoline::<Self, F> as *const (),
1399                )),
1400                Box_::into_raw(f),
1401            )
1402        }
1403    }
1404
1405    /// Emitted when displaying the print dialog. If you return a
1406    /// widget in a handler for this signal it will be added to a custom
1407    /// tab in the print dialog. You typically return a container widget
1408    /// with multiple widgets in it.
1409    ///
1410    /// The print dialog owns the returned widget, and its lifetime is not
1411    /// controlled by the application. However, the widget is guaranteed
1412    /// to stay around until the [`custom-widget-apply`][struct@crate::PrintOperation#custom-widget-apply]
1413    /// signal is emitted on the operation. Then you can read out any
1414    /// information you need from the widgets.
1415    ///
1416    /// # Returns
1417    ///
1418    /// A custom widget that gets embedded in
1419    ///  the print dialog, or [`None`]
1420    #[doc(alias = "create-custom-widget")]
1421    fn connect_create_custom_widget<F: Fn(&Self) -> glib::Object + 'static>(
1422        &self,
1423        f: F,
1424    ) -> SignalHandlerId {
1425        unsafe extern "C" fn create_custom_widget_trampoline<
1426            P: IsA<PrintOperation>,
1427            F: Fn(&P) -> glib::Object + 'static,
1428        >(
1429            this: *mut ffi::GtkPrintOperation,
1430            f: glib::ffi::gpointer,
1431        ) -> *mut glib::gobject_ffi::GObject {
1432            let f: &F = &*(f as *const F);
1433            f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref()) /*Not checked*/
1434                .to_glib_none()
1435                .0
1436        }
1437        unsafe {
1438            let f: Box_<F> = Box_::new(f);
1439            connect_raw(
1440                self.as_ptr() as *mut _,
1441                b"create-custom-widget\0".as_ptr() as *const _,
1442                Some(transmute::<_, unsafe extern "C" fn()>(
1443                    create_custom_widget_trampoline::<Self, F> as *const (),
1444                )),
1445                Box_::into_raw(f),
1446            )
1447        }
1448    }
1449
1450    /// Emitted right before [`begin-print`][struct@crate::PrintOperation#begin-print] if you added
1451    /// a custom widget in the [`create-custom-widget`][struct@crate::PrintOperation#create-custom-widget] handler.
1452    /// When you get this signal you should read the information from the
1453    /// custom widgets, as the widgets are not guaraneed to be around at a
1454    /// later time.
1455    /// ## `widget`
1456    /// the custom widget added in create-custom-widget
1457    #[doc(alias = "custom-widget-apply")]
1458    fn connect_custom_widget_apply<F: Fn(&Self, &Widget) + 'static>(
1459        &self,
1460        f: F,
1461    ) -> SignalHandlerId {
1462        unsafe extern "C" fn custom_widget_apply_trampoline<
1463            P: IsA<PrintOperation>,
1464            F: Fn(&P, &Widget) + 'static,
1465        >(
1466            this: *mut ffi::GtkPrintOperation,
1467            widget: *mut ffi::GtkWidget,
1468            f: glib::ffi::gpointer,
1469        ) {
1470            let f: &F = &*(f as *const F);
1471            f(
1472                PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
1473                &from_glib_borrow(widget),
1474            )
1475        }
1476        unsafe {
1477            let f: Box_<F> = Box_::new(f);
1478            connect_raw(
1479                self.as_ptr() as *mut _,
1480                b"custom-widget-apply\0".as_ptr() as *const _,
1481                Some(transmute::<_, unsafe extern "C" fn()>(
1482                    custom_widget_apply_trampoline::<Self, F> as *const (),
1483                )),
1484                Box_::into_raw(f),
1485            )
1486        }
1487    }
1488
1489    /// Emitted when the print operation run has finished doing
1490    /// everything required for printing.
1491    ///
1492    /// `result` gives you information about what happened during the run.
1493    /// If `result` is [`PrintOperationResult::Error`][crate::PrintOperationResult::Error] then you can call
1494    /// `gtk_print_operation_get_error()` for more information.
1495    ///
1496    /// If you enabled print status tracking then
1497    /// [`is_finished()`][Self::is_finished()] may still return [`false`]
1498    /// after [`done`][struct@crate::PrintOperation#done] was emitted.
1499    /// ## `result`
1500    /// the result of the print operation
1501    #[doc(alias = "done")]
1502    fn connect_done<F: Fn(&Self, PrintOperationResult) + 'static>(&self, f: F) -> SignalHandlerId {
1503        unsafe extern "C" fn done_trampoline<
1504            P: IsA<PrintOperation>,
1505            F: Fn(&P, PrintOperationResult) + 'static,
1506        >(
1507            this: *mut ffi::GtkPrintOperation,
1508            result: ffi::GtkPrintOperationResult,
1509            f: glib::ffi::gpointer,
1510        ) {
1511            let f: &F = &*(f as *const F);
1512            f(
1513                PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
1514                from_glib(result),
1515            )
1516        }
1517        unsafe {
1518            let f: Box_<F> = Box_::new(f);
1519            connect_raw(
1520                self.as_ptr() as *mut _,
1521                b"done\0".as_ptr() as *const _,
1522                Some(transmute::<_, unsafe extern "C" fn()>(
1523                    done_trampoline::<Self, F> as *const (),
1524                )),
1525                Box_::into_raw(f),
1526            )
1527        }
1528    }
1529
1530    /// Emitted for every page that is printed. The signal handler
1531    /// must render the `page_nr`'s page onto the cairo context obtained
1532    /// from `context` using [`PrintContext::cairo_context()`][crate::PrintContext::cairo_context()].
1533    ///
1534    ///
1535    /// **⚠️ The following code is in C ⚠️**
1536    ///
1537    /// ```C
1538    /// static void
1539    /// draw_page (GtkPrintOperation *operation,
1540    ///            GtkPrintContext   *context,
1541    ///            gint               page_nr,
1542    ///            gpointer           user_data)
1543    /// {
1544    ///   cairo_t *cr;
1545    ///   PangoLayout *layout;
1546    ///   gdouble width, text_height;
1547    ///   gint layout_height;
1548    ///   PangoFontDescription *desc;
1549    ///
1550    ///   cr = gtk_print_context_get_cairo_context (context);
1551    ///   width = gtk_print_context_get_width (context);
1552    ///
1553    ///   cairo_rectangle (cr, 0, 0, width, HEADER_HEIGHT);
1554    ///
1555    ///   cairo_set_source_rgb (cr, 0.8, 0.8, 0.8);
1556    ///   cairo_fill (cr);
1557    ///
1558    ///   layout = gtk_print_context_create_pango_layout (context);
1559    ///
1560    ///   desc = pango_font_description_from_string ("sans 14");
1561    ///   pango_layout_set_font_description (layout, desc);
1562    ///   pango_font_description_free (desc);
1563    ///
1564    ///   pango_layout_set_text (layout, "some text", -1);
1565    ///   pango_layout_set_width (layout, width * PANGO_SCALE);
1566    ///   pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
1567    ///
1568    ///   pango_layout_get_size (layout, NULL, &layout_height);
1569    ///   text_height = (gdouble)layout_height / PANGO_SCALE;
1570    ///
1571    ///   cairo_move_to (cr, width / 2,  (HEADER_HEIGHT - text_height) / 2);
1572    ///   pango_cairo_show_layout (cr, layout);
1573    ///
1574    ///   g_object_unref (layout);
1575    /// }
1576    /// ```
1577    ///
1578    /// Use [`set_use_full_page()`][Self::set_use_full_page()] and
1579    /// [`set_unit()`][Self::set_unit()] before starting the print operation
1580    /// to set up the transformation of the cairo context according to your
1581    /// needs.
1582    /// ## `context`
1583    /// the [`PrintContext`][crate::PrintContext] for the current operation
1584    /// ## `page_nr`
1585    /// the number of the currently printed page (0-based)
1586    #[doc(alias = "draw-page")]
1587    fn connect_draw_page<F: Fn(&Self, &PrintContext, i32) + 'static>(
1588        &self,
1589        f: F,
1590    ) -> SignalHandlerId {
1591        unsafe extern "C" fn draw_page_trampoline<
1592            P: IsA<PrintOperation>,
1593            F: Fn(&P, &PrintContext, i32) + 'static,
1594        >(
1595            this: *mut ffi::GtkPrintOperation,
1596            context: *mut ffi::GtkPrintContext,
1597            page_nr: libc::c_int,
1598            f: glib::ffi::gpointer,
1599        ) {
1600            let f: &F = &*(f as *const F);
1601            f(
1602                PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
1603                &from_glib_borrow(context),
1604                page_nr,
1605            )
1606        }
1607        unsafe {
1608            let f: Box_<F> = Box_::new(f);
1609            connect_raw(
1610                self.as_ptr() as *mut _,
1611                b"draw-page\0".as_ptr() as *const _,
1612                Some(transmute::<_, unsafe extern "C" fn()>(
1613                    draw_page_trampoline::<Self, F> as *const (),
1614                )),
1615                Box_::into_raw(f),
1616            )
1617        }
1618    }
1619
1620    /// Emitted after all pages have been rendered.
1621    /// A handler for this signal can clean up any resources that have
1622    /// been allocated in the [`begin-print`][struct@crate::PrintOperation#begin-print] handler.
1623    /// ## `context`
1624    /// the [`PrintContext`][crate::PrintContext] for the current operation
1625    #[doc(alias = "end-print")]
1626    fn connect_end_print<F: Fn(&Self, &PrintContext) + 'static>(&self, f: F) -> SignalHandlerId {
1627        unsafe extern "C" fn end_print_trampoline<
1628            P: IsA<PrintOperation>,
1629            F: Fn(&P, &PrintContext) + 'static,
1630        >(
1631            this: *mut ffi::GtkPrintOperation,
1632            context: *mut ffi::GtkPrintContext,
1633            f: glib::ffi::gpointer,
1634        ) {
1635            let f: &F = &*(f as *const F);
1636            f(
1637                PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
1638                &from_glib_borrow(context),
1639            )
1640        }
1641        unsafe {
1642            let f: Box_<F> = Box_::new(f);
1643            connect_raw(
1644                self.as_ptr() as *mut _,
1645                b"end-print\0".as_ptr() as *const _,
1646                Some(transmute::<_, unsafe extern "C" fn()>(
1647                    end_print_trampoline::<Self, F> as *const (),
1648                )),
1649                Box_::into_raw(f),
1650            )
1651        }
1652    }
1653
1654    /// Emitted after the [`begin-print`][struct@crate::PrintOperation#begin-print] signal, but before
1655    /// the actual rendering starts. It keeps getting emitted until a connected
1656    /// signal handler returns [`true`].
1657    ///
1658    /// The ::paginate signal is intended to be used for paginating a document
1659    /// in small chunks, to avoid blocking the user interface for a long
1660    /// time. The signal handler should update the number of pages using
1661    /// [`set_n_pages()`][Self::set_n_pages()], and return [`true`] if the document
1662    /// has been completely paginated.
1663    ///
1664    /// If you don't need to do pagination in chunks, you can simply do
1665    /// it all in the ::begin-print handler, and set the number of pages
1666    /// from there.
1667    /// ## `context`
1668    /// the [`PrintContext`][crate::PrintContext] for the current operation
1669    ///
1670    /// # Returns
1671    ///
1672    /// [`true`] if pagination is complete
1673    #[doc(alias = "paginate")]
1674    fn connect_paginate<F: Fn(&Self, &PrintContext) -> bool + 'static>(
1675        &self,
1676        f: F,
1677    ) -> SignalHandlerId {
1678        unsafe extern "C" fn paginate_trampoline<
1679            P: IsA<PrintOperation>,
1680            F: Fn(&P, &PrintContext) -> bool + 'static,
1681        >(
1682            this: *mut ffi::GtkPrintOperation,
1683            context: *mut ffi::GtkPrintContext,
1684            f: glib::ffi::gpointer,
1685        ) -> glib::ffi::gboolean {
1686            let f: &F = &*(f as *const F);
1687            f(
1688                PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
1689                &from_glib_borrow(context),
1690            )
1691            .into_glib()
1692        }
1693        unsafe {
1694            let f: Box_<F> = Box_::new(f);
1695            connect_raw(
1696                self.as_ptr() as *mut _,
1697                b"paginate\0".as_ptr() as *const _,
1698                Some(transmute::<_, unsafe extern "C" fn()>(
1699                    paginate_trampoline::<Self, F> as *const (),
1700                )),
1701                Box_::into_raw(f),
1702            )
1703        }
1704    }
1705
1706    /// Gets emitted when a preview is requested from the native dialog.
1707    ///
1708    /// The default handler for this signal uses an external viewer
1709    /// application to preview.
1710    ///
1711    /// To implement a custom print preview, an application must return
1712    /// [`true`] from its handler for this signal. In order to use the
1713    /// provided `context` for the preview implementation, it must be
1714    /// given a suitable cairo context with [`PrintContext::set_cairo_context()`][crate::PrintContext::set_cairo_context()].
1715    ///
1716    /// The custom preview implementation can use
1717    /// [`PrintOperationPreviewExt::is_selected()`][crate::prelude::PrintOperationPreviewExt::is_selected()] and
1718    /// [`PrintOperationPreviewExt::render_page()`][crate::prelude::PrintOperationPreviewExt::render_page()] to find pages which
1719    /// are selected for print and render them. The preview must be
1720    /// finished by calling [`PrintOperationPreviewExt::end_preview()`][crate::prelude::PrintOperationPreviewExt::end_preview()]
1721    /// (typically in response to the user clicking a close button).
1722    /// ## `preview`
1723    /// the [`PrintOperationPreview`][crate::PrintOperationPreview] for the current operation
1724    /// ## `context`
1725    /// the [`PrintContext`][crate::PrintContext] that will be used
1726    /// ## `parent`
1727    /// the [`Window`][crate::Window] to use as window parent, or [`None`]
1728    ///
1729    /// # Returns
1730    ///
1731    /// [`true`] if the listener wants to take over control of the preview
1732    #[doc(alias = "preview")]
1733    fn connect_preview<
1734        F: Fn(&Self, &PrintOperationPreview, &PrintContext, Option<&Window>) -> bool + 'static,
1735    >(
1736        &self,
1737        f: F,
1738    ) -> SignalHandlerId {
1739        unsafe extern "C" fn preview_trampoline<
1740            P: IsA<PrintOperation>,
1741            F: Fn(&P, &PrintOperationPreview, &PrintContext, Option<&Window>) -> bool + 'static,
1742        >(
1743            this: *mut ffi::GtkPrintOperation,
1744            preview: *mut ffi::GtkPrintOperationPreview,
1745            context: *mut ffi::GtkPrintContext,
1746            parent: *mut ffi::GtkWindow,
1747            f: glib::ffi::gpointer,
1748        ) -> glib::ffi::gboolean {
1749            let f: &F = &*(f as *const F);
1750            f(
1751                PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
1752                &from_glib_borrow(preview),
1753                &from_glib_borrow(context),
1754                Option::<Window>::from_glib_borrow(parent).as_ref().as_ref(),
1755            )
1756            .into_glib()
1757        }
1758        unsafe {
1759            let f: Box_<F> = Box_::new(f);
1760            connect_raw(
1761                self.as_ptr() as *mut _,
1762                b"preview\0".as_ptr() as *const _,
1763                Some(transmute::<_, unsafe extern "C" fn()>(
1764                    preview_trampoline::<Self, F> as *const (),
1765                )),
1766                Box_::into_raw(f),
1767            )
1768        }
1769    }
1770
1771    /// Emitted once for every page that is printed, to give
1772    /// the application a chance to modify the page setup. Any changes
1773    /// done to `setup` will be in force only for printing this page.
1774    /// ## `context`
1775    /// the [`PrintContext`][crate::PrintContext] for the current operation
1776    /// ## `page_nr`
1777    /// the number of the currently printed page (0-based)
1778    /// ## `setup`
1779    /// the [`PageSetup`][crate::PageSetup]
1780    #[doc(alias = "request-page-setup")]
1781    fn connect_request_page_setup<F: Fn(&Self, &PrintContext, i32, &PageSetup) + 'static>(
1782        &self,
1783        f: F,
1784    ) -> SignalHandlerId {
1785        unsafe extern "C" fn request_page_setup_trampoline<
1786            P: IsA<PrintOperation>,
1787            F: Fn(&P, &PrintContext, i32, &PageSetup) + 'static,
1788        >(
1789            this: *mut ffi::GtkPrintOperation,
1790            context: *mut ffi::GtkPrintContext,
1791            page_nr: libc::c_int,
1792            setup: *mut ffi::GtkPageSetup,
1793            f: glib::ffi::gpointer,
1794        ) {
1795            let f: &F = &*(f as *const F);
1796            f(
1797                PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
1798                &from_glib_borrow(context),
1799                page_nr,
1800                &from_glib_borrow(setup),
1801            )
1802        }
1803        unsafe {
1804            let f: Box_<F> = Box_::new(f);
1805            connect_raw(
1806                self.as_ptr() as *mut _,
1807                b"request-page-setup\0".as_ptr() as *const _,
1808                Some(transmute::<_, unsafe extern "C" fn()>(
1809                    request_page_setup_trampoline::<Self, F> as *const (),
1810                )),
1811                Box_::into_raw(f),
1812            )
1813        }
1814    }
1815
1816    /// Emitted at between the various phases of the print operation.
1817    /// See [`PrintStatus`][crate::PrintStatus] for the phases that are being discriminated.
1818    /// Use [`status()`][Self::status()] to find out the current
1819    /// status.
1820    #[doc(alias = "status-changed")]
1821    fn connect_status_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1822        unsafe extern "C" fn status_changed_trampoline<
1823            P: IsA<PrintOperation>,
1824            F: Fn(&P) + 'static,
1825        >(
1826            this: *mut ffi::GtkPrintOperation,
1827            f: glib::ffi::gpointer,
1828        ) {
1829            let f: &F = &*(f as *const F);
1830            f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1831        }
1832        unsafe {
1833            let f: Box_<F> = Box_::new(f);
1834            connect_raw(
1835                self.as_ptr() as *mut _,
1836                b"status-changed\0".as_ptr() as *const _,
1837                Some(transmute::<_, unsafe extern "C" fn()>(
1838                    status_changed_trampoline::<Self, F> as *const (),
1839                )),
1840                Box_::into_raw(f),
1841            )
1842        }
1843    }
1844
1845    /// Emitted after change of selected printer. The actual page setup and
1846    /// print settings are passed to the custom widget, which can actualize
1847    /// itself according to this change.
1848    /// ## `widget`
1849    /// the custom widget added in create-custom-widget
1850    /// ## `setup`
1851    /// actual page setup
1852    /// ## `settings`
1853    /// actual print settings
1854    #[doc(alias = "update-custom-widget")]
1855    fn connect_update_custom_widget<F: Fn(&Self, &Widget, &PageSetup, &PrintSettings) + 'static>(
1856        &self,
1857        f: F,
1858    ) -> SignalHandlerId {
1859        unsafe extern "C" fn update_custom_widget_trampoline<
1860            P: IsA<PrintOperation>,
1861            F: Fn(&P, &Widget, &PageSetup, &PrintSettings) + 'static,
1862        >(
1863            this: *mut ffi::GtkPrintOperation,
1864            widget: *mut ffi::GtkWidget,
1865            setup: *mut ffi::GtkPageSetup,
1866            settings: *mut ffi::GtkPrintSettings,
1867            f: glib::ffi::gpointer,
1868        ) {
1869            let f: &F = &*(f as *const F);
1870            f(
1871                PrintOperation::from_glib_borrow(this).unsafe_cast_ref(),
1872                &from_glib_borrow(widget),
1873                &from_glib_borrow(setup),
1874                &from_glib_borrow(settings),
1875            )
1876        }
1877        unsafe {
1878            let f: Box_<F> = Box_::new(f);
1879            connect_raw(
1880                self.as_ptr() as *mut _,
1881                b"update-custom-widget\0".as_ptr() as *const _,
1882                Some(transmute::<_, unsafe extern "C" fn()>(
1883                    update_custom_widget_trampoline::<Self, F> as *const (),
1884                )),
1885                Box_::into_raw(f),
1886            )
1887        }
1888    }
1889
1890    #[doc(alias = "allow-async")]
1891    fn connect_allow_async_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1892        unsafe extern "C" fn notify_allow_async_trampoline<
1893            P: IsA<PrintOperation>,
1894            F: Fn(&P) + 'static,
1895        >(
1896            this: *mut ffi::GtkPrintOperation,
1897            _param_spec: glib::ffi::gpointer,
1898            f: glib::ffi::gpointer,
1899        ) {
1900            let f: &F = &*(f as *const F);
1901            f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1902        }
1903        unsafe {
1904            let f: Box_<F> = Box_::new(f);
1905            connect_raw(
1906                self.as_ptr() as *mut _,
1907                b"notify::allow-async\0".as_ptr() as *const _,
1908                Some(transmute::<_, unsafe extern "C" fn()>(
1909                    notify_allow_async_trampoline::<Self, F> as *const (),
1910                )),
1911                Box_::into_raw(f),
1912            )
1913        }
1914    }
1915
1916    #[doc(alias = "current-page")]
1917    fn connect_current_page_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1918        unsafe extern "C" fn notify_current_page_trampoline<
1919            P: IsA<PrintOperation>,
1920            F: Fn(&P) + 'static,
1921        >(
1922            this: *mut ffi::GtkPrintOperation,
1923            _param_spec: glib::ffi::gpointer,
1924            f: glib::ffi::gpointer,
1925        ) {
1926            let f: &F = &*(f as *const F);
1927            f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1928        }
1929        unsafe {
1930            let f: Box_<F> = Box_::new(f);
1931            connect_raw(
1932                self.as_ptr() as *mut _,
1933                b"notify::current-page\0".as_ptr() as *const _,
1934                Some(transmute::<_, unsafe extern "C" fn()>(
1935                    notify_current_page_trampoline::<Self, F> as *const (),
1936                )),
1937                Box_::into_raw(f),
1938            )
1939        }
1940    }
1941
1942    #[doc(alias = "custom-tab-label")]
1943    fn connect_custom_tab_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1944        unsafe extern "C" fn notify_custom_tab_label_trampoline<
1945            P: IsA<PrintOperation>,
1946            F: Fn(&P) + 'static,
1947        >(
1948            this: *mut ffi::GtkPrintOperation,
1949            _param_spec: glib::ffi::gpointer,
1950            f: glib::ffi::gpointer,
1951        ) {
1952            let f: &F = &*(f as *const F);
1953            f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1954        }
1955        unsafe {
1956            let f: Box_<F> = Box_::new(f);
1957            connect_raw(
1958                self.as_ptr() as *mut _,
1959                b"notify::custom-tab-label\0".as_ptr() as *const _,
1960                Some(transmute::<_, unsafe extern "C" fn()>(
1961                    notify_custom_tab_label_trampoline::<Self, F> as *const (),
1962                )),
1963                Box_::into_raw(f),
1964            )
1965        }
1966    }
1967
1968    #[doc(alias = "default-page-setup")]
1969    fn connect_default_page_setup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1970        unsafe extern "C" fn notify_default_page_setup_trampoline<
1971            P: IsA<PrintOperation>,
1972            F: Fn(&P) + 'static,
1973        >(
1974            this: *mut ffi::GtkPrintOperation,
1975            _param_spec: glib::ffi::gpointer,
1976            f: glib::ffi::gpointer,
1977        ) {
1978            let f: &F = &*(f as *const F);
1979            f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
1980        }
1981        unsafe {
1982            let f: Box_<F> = Box_::new(f);
1983            connect_raw(
1984                self.as_ptr() as *mut _,
1985                b"notify::default-page-setup\0".as_ptr() as *const _,
1986                Some(transmute::<_, unsafe extern "C" fn()>(
1987                    notify_default_page_setup_trampoline::<Self, F> as *const (),
1988                )),
1989                Box_::into_raw(f),
1990            )
1991        }
1992    }
1993
1994    #[doc(alias = "embed-page-setup")]
1995    fn connect_embed_page_setup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1996        unsafe extern "C" fn notify_embed_page_setup_trampoline<
1997            P: IsA<PrintOperation>,
1998            F: Fn(&P) + 'static,
1999        >(
2000            this: *mut ffi::GtkPrintOperation,
2001            _param_spec: glib::ffi::gpointer,
2002            f: glib::ffi::gpointer,
2003        ) {
2004            let f: &F = &*(f as *const F);
2005            f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2006        }
2007        unsafe {
2008            let f: Box_<F> = Box_::new(f);
2009            connect_raw(
2010                self.as_ptr() as *mut _,
2011                b"notify::embed-page-setup\0".as_ptr() as *const _,
2012                Some(transmute::<_, unsafe extern "C" fn()>(
2013                    notify_embed_page_setup_trampoline::<Self, F> as *const (),
2014                )),
2015                Box_::into_raw(f),
2016            )
2017        }
2018    }
2019
2020    #[doc(alias = "export-filename")]
2021    fn connect_export_filename_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2022        unsafe extern "C" fn notify_export_filename_trampoline<
2023            P: IsA<PrintOperation>,
2024            F: Fn(&P) + 'static,
2025        >(
2026            this: *mut ffi::GtkPrintOperation,
2027            _param_spec: glib::ffi::gpointer,
2028            f: glib::ffi::gpointer,
2029        ) {
2030            let f: &F = &*(f as *const F);
2031            f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2032        }
2033        unsafe {
2034            let f: Box_<F> = Box_::new(f);
2035            connect_raw(
2036                self.as_ptr() as *mut _,
2037                b"notify::export-filename\0".as_ptr() as *const _,
2038                Some(transmute::<_, unsafe extern "C" fn()>(
2039                    notify_export_filename_trampoline::<Self, F> as *const (),
2040                )),
2041                Box_::into_raw(f),
2042            )
2043        }
2044    }
2045
2046    #[doc(alias = "has-selection")]
2047    fn connect_has_selection_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2048        unsafe extern "C" fn notify_has_selection_trampoline<
2049            P: IsA<PrintOperation>,
2050            F: Fn(&P) + 'static,
2051        >(
2052            this: *mut ffi::GtkPrintOperation,
2053            _param_spec: glib::ffi::gpointer,
2054            f: glib::ffi::gpointer,
2055        ) {
2056            let f: &F = &*(f as *const F);
2057            f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2058        }
2059        unsafe {
2060            let f: Box_<F> = Box_::new(f);
2061            connect_raw(
2062                self.as_ptr() as *mut _,
2063                b"notify::has-selection\0".as_ptr() as *const _,
2064                Some(transmute::<_, unsafe extern "C" fn()>(
2065                    notify_has_selection_trampoline::<Self, F> as *const (),
2066                )),
2067                Box_::into_raw(f),
2068            )
2069        }
2070    }
2071
2072    #[doc(alias = "job-name")]
2073    fn connect_job_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2074        unsafe extern "C" fn notify_job_name_trampoline<
2075            P: IsA<PrintOperation>,
2076            F: Fn(&P) + 'static,
2077        >(
2078            this: *mut ffi::GtkPrintOperation,
2079            _param_spec: glib::ffi::gpointer,
2080            f: glib::ffi::gpointer,
2081        ) {
2082            let f: &F = &*(f as *const F);
2083            f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2084        }
2085        unsafe {
2086            let f: Box_<F> = Box_::new(f);
2087            connect_raw(
2088                self.as_ptr() as *mut _,
2089                b"notify::job-name\0".as_ptr() as *const _,
2090                Some(transmute::<_, unsafe extern "C" fn()>(
2091                    notify_job_name_trampoline::<Self, F> as *const (),
2092                )),
2093                Box_::into_raw(f),
2094            )
2095        }
2096    }
2097
2098    #[doc(alias = "n-pages")]
2099    fn connect_n_pages_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2100        unsafe extern "C" fn notify_n_pages_trampoline<
2101            P: IsA<PrintOperation>,
2102            F: Fn(&P) + 'static,
2103        >(
2104            this: *mut ffi::GtkPrintOperation,
2105            _param_spec: glib::ffi::gpointer,
2106            f: glib::ffi::gpointer,
2107        ) {
2108            let f: &F = &*(f as *const F);
2109            f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2110        }
2111        unsafe {
2112            let f: Box_<F> = Box_::new(f);
2113            connect_raw(
2114                self.as_ptr() as *mut _,
2115                b"notify::n-pages\0".as_ptr() as *const _,
2116                Some(transmute::<_, unsafe extern "C" fn()>(
2117                    notify_n_pages_trampoline::<Self, F> as *const (),
2118                )),
2119                Box_::into_raw(f),
2120            )
2121        }
2122    }
2123
2124    #[doc(alias = "n-pages-to-print")]
2125    fn connect_n_pages_to_print_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2126        unsafe extern "C" fn notify_n_pages_to_print_trampoline<
2127            P: IsA<PrintOperation>,
2128            F: Fn(&P) + 'static,
2129        >(
2130            this: *mut ffi::GtkPrintOperation,
2131            _param_spec: glib::ffi::gpointer,
2132            f: glib::ffi::gpointer,
2133        ) {
2134            let f: &F = &*(f as *const F);
2135            f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2136        }
2137        unsafe {
2138            let f: Box_<F> = Box_::new(f);
2139            connect_raw(
2140                self.as_ptr() as *mut _,
2141                b"notify::n-pages-to-print\0".as_ptr() as *const _,
2142                Some(transmute::<_, unsafe extern "C" fn()>(
2143                    notify_n_pages_to_print_trampoline::<Self, F> as *const (),
2144                )),
2145                Box_::into_raw(f),
2146            )
2147        }
2148    }
2149
2150    #[doc(alias = "print-settings")]
2151    fn connect_print_settings_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2152        unsafe extern "C" fn notify_print_settings_trampoline<
2153            P: IsA<PrintOperation>,
2154            F: Fn(&P) + 'static,
2155        >(
2156            this: *mut ffi::GtkPrintOperation,
2157            _param_spec: glib::ffi::gpointer,
2158            f: glib::ffi::gpointer,
2159        ) {
2160            let f: &F = &*(f as *const F);
2161            f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2162        }
2163        unsafe {
2164            let f: Box_<F> = Box_::new(f);
2165            connect_raw(
2166                self.as_ptr() as *mut _,
2167                b"notify::print-settings\0".as_ptr() as *const _,
2168                Some(transmute::<_, unsafe extern "C" fn()>(
2169                    notify_print_settings_trampoline::<Self, F> as *const (),
2170                )),
2171                Box_::into_raw(f),
2172            )
2173        }
2174    }
2175
2176    #[doc(alias = "show-progress")]
2177    fn connect_show_progress_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2178        unsafe extern "C" fn notify_show_progress_trampoline<
2179            P: IsA<PrintOperation>,
2180            F: Fn(&P) + 'static,
2181        >(
2182            this: *mut ffi::GtkPrintOperation,
2183            _param_spec: glib::ffi::gpointer,
2184            f: glib::ffi::gpointer,
2185        ) {
2186            let f: &F = &*(f as *const F);
2187            f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2188        }
2189        unsafe {
2190            let f: Box_<F> = Box_::new(f);
2191            connect_raw(
2192                self.as_ptr() as *mut _,
2193                b"notify::show-progress\0".as_ptr() as *const _,
2194                Some(transmute::<_, unsafe extern "C" fn()>(
2195                    notify_show_progress_trampoline::<Self, F> as *const (),
2196                )),
2197                Box_::into_raw(f),
2198            )
2199        }
2200    }
2201
2202    #[doc(alias = "status")]
2203    fn connect_status_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2204        unsafe extern "C" fn notify_status_trampoline<
2205            P: IsA<PrintOperation>,
2206            F: Fn(&P) + 'static,
2207        >(
2208            this: *mut ffi::GtkPrintOperation,
2209            _param_spec: glib::ffi::gpointer,
2210            f: glib::ffi::gpointer,
2211        ) {
2212            let f: &F = &*(f as *const F);
2213            f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2214        }
2215        unsafe {
2216            let f: Box_<F> = Box_::new(f);
2217            connect_raw(
2218                self.as_ptr() as *mut _,
2219                b"notify::status\0".as_ptr() as *const _,
2220                Some(transmute::<_, unsafe extern "C" fn()>(
2221                    notify_status_trampoline::<Self, F> as *const (),
2222                )),
2223                Box_::into_raw(f),
2224            )
2225        }
2226    }
2227
2228    #[doc(alias = "status-string")]
2229    fn connect_status_string_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2230        unsafe extern "C" fn notify_status_string_trampoline<
2231            P: IsA<PrintOperation>,
2232            F: Fn(&P) + 'static,
2233        >(
2234            this: *mut ffi::GtkPrintOperation,
2235            _param_spec: glib::ffi::gpointer,
2236            f: glib::ffi::gpointer,
2237        ) {
2238            let f: &F = &*(f as *const F);
2239            f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2240        }
2241        unsafe {
2242            let f: Box_<F> = Box_::new(f);
2243            connect_raw(
2244                self.as_ptr() as *mut _,
2245                b"notify::status-string\0".as_ptr() as *const _,
2246                Some(transmute::<_, unsafe extern "C" fn()>(
2247                    notify_status_string_trampoline::<Self, F> as *const (),
2248                )),
2249                Box_::into_raw(f),
2250            )
2251        }
2252    }
2253
2254    #[doc(alias = "support-selection")]
2255    fn connect_support_selection_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2256        unsafe extern "C" fn notify_support_selection_trampoline<
2257            P: IsA<PrintOperation>,
2258            F: Fn(&P) + 'static,
2259        >(
2260            this: *mut ffi::GtkPrintOperation,
2261            _param_spec: glib::ffi::gpointer,
2262            f: glib::ffi::gpointer,
2263        ) {
2264            let f: &F = &*(f as *const F);
2265            f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2266        }
2267        unsafe {
2268            let f: Box_<F> = Box_::new(f);
2269            connect_raw(
2270                self.as_ptr() as *mut _,
2271                b"notify::support-selection\0".as_ptr() as *const _,
2272                Some(transmute::<_, unsafe extern "C" fn()>(
2273                    notify_support_selection_trampoline::<Self, F> as *const (),
2274                )),
2275                Box_::into_raw(f),
2276            )
2277        }
2278    }
2279
2280    #[doc(alias = "track-print-status")]
2281    fn connect_track_print_status_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2282        unsafe extern "C" fn notify_track_print_status_trampoline<
2283            P: IsA<PrintOperation>,
2284            F: Fn(&P) + 'static,
2285        >(
2286            this: *mut ffi::GtkPrintOperation,
2287            _param_spec: glib::ffi::gpointer,
2288            f: glib::ffi::gpointer,
2289        ) {
2290            let f: &F = &*(f as *const F);
2291            f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2292        }
2293        unsafe {
2294            let f: Box_<F> = Box_::new(f);
2295            connect_raw(
2296                self.as_ptr() as *mut _,
2297                b"notify::track-print-status\0".as_ptr() as *const _,
2298                Some(transmute::<_, unsafe extern "C" fn()>(
2299                    notify_track_print_status_trampoline::<Self, F> as *const (),
2300                )),
2301                Box_::into_raw(f),
2302            )
2303        }
2304    }
2305
2306    #[doc(alias = "unit")]
2307    fn connect_unit_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2308        unsafe extern "C" fn notify_unit_trampoline<P: IsA<PrintOperation>, F: Fn(&P) + 'static>(
2309            this: *mut ffi::GtkPrintOperation,
2310            _param_spec: glib::ffi::gpointer,
2311            f: glib::ffi::gpointer,
2312        ) {
2313            let f: &F = &*(f as *const F);
2314            f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2315        }
2316        unsafe {
2317            let f: Box_<F> = Box_::new(f);
2318            connect_raw(
2319                self.as_ptr() as *mut _,
2320                b"notify::unit\0".as_ptr() as *const _,
2321                Some(transmute::<_, unsafe extern "C" fn()>(
2322                    notify_unit_trampoline::<Self, F> as *const (),
2323                )),
2324                Box_::into_raw(f),
2325            )
2326        }
2327    }
2328
2329    #[doc(alias = "use-full-page")]
2330    fn connect_use_full_page_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2331        unsafe extern "C" fn notify_use_full_page_trampoline<
2332            P: IsA<PrintOperation>,
2333            F: Fn(&P) + 'static,
2334        >(
2335            this: *mut ffi::GtkPrintOperation,
2336            _param_spec: glib::ffi::gpointer,
2337            f: glib::ffi::gpointer,
2338        ) {
2339            let f: &F = &*(f as *const F);
2340            f(PrintOperation::from_glib_borrow(this).unsafe_cast_ref())
2341        }
2342        unsafe {
2343            let f: Box_<F> = Box_::new(f);
2344            connect_raw(
2345                self.as_ptr() as *mut _,
2346                b"notify::use-full-page\0".as_ptr() as *const _,
2347                Some(transmute::<_, unsafe extern "C" fn()>(
2348                    notify_use_full_page_trampoline::<Self, F> as *const (),
2349                )),
2350                Box_::into_raw(f),
2351            )
2352        }
2353    }
2354}
2355
2356impl<O: IsA<PrintOperation>> PrintOperationExt for O {}
2357
2358impl fmt::Display for PrintOperation {
2359    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2360        f.write_str("PrintOperation")
2361    }
2362}