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