1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.PrintOperation;
26 
27 private import glib.ConstructionException;
28 private import glib.ErrorG;
29 private import glib.GException;
30 private import glib.Str;
31 private import glib.c.functions;
32 private import gobject.ObjectG;
33 private import gobject.Signals;
34 private import gtk.PageSetup;
35 private import gtk.PrintContext;
36 private import gtk.PrintOperationPreviewIF;
37 private import gtk.PrintOperationPreviewT;
38 private import gtk.PrintSettings;
39 private import gtk.Widget;
40 private import gtk.Window;
41 private import gtk.c.functions;
42 public  import gtk.c.types;
43 private import std.algorithm;
44 
45 
46 /**
47  * `GtkPrintOperation` is the high-level, portable printing API.
48  * 
49  * It looks a bit different than other GTK dialogs such as the
50  * `GtkFileChooser`, since some platforms don’t expose enough
51  * infrastructure to implement a good print dialog. On such
52  * platforms, `GtkPrintOperation` uses the native print dialog.
53  * On platforms which do not provide a native print dialog, GTK
54  * uses its own, see [class@Gtk.PrintUnixDialog].
55  * 
56  * The typical way to use the high-level printing API is to create
57  * a `GtkPrintOperation` object with [ctor@Gtk.PrintOperation.new]
58  * when the user selects to print. Then you set some properties on it,
59  * e.g. the page size, any [class@Gtk.PrintSettings] from previous print
60  * operations, the number of pages, the current page, etc.
61  * 
62  * Then you start the print operation by calling [method@Gtk.PrintOperation.run].
63  * It will then show a dialog, let the user select a printer and options.
64  * When the user finished the dialog, various signals will be emitted on
65  * the `GtkPrintOperation`, the main one being
66  * [signal@Gtk.PrintOperation::draw-page], which you are supposed to handle
67  * and render the page on the provided [class@Gtk.PrintContext] using Cairo.
68  * 
69  * # The high-level printing API
70  * 
71  * ```c
72  * static GtkPrintSettings *settings = NULL;
73  * 
74  * static void
75  * do_print (void)
76  * {
77  * GtkPrintOperation *print;
78  * GtkPrintOperationResult res;
79  * 
80  * print = gtk_print_operation_new ();
81  * 
82  * if (settings != NULL)
83  * gtk_print_operation_set_print_settings (print, settings);
84  * 
85  * g_signal_connect (print, "begin_print", G_CALLBACK (begin_print), NULL);
86  * g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), NULL);
87  * 
88  * res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
89  * GTK_WINDOW (main_window), NULL);
90  * 
91  * if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
92  * {
93  * if (settings != NULL)
94  * g_object_unref (settings);
95  * settings = g_object_ref (gtk_print_operation_get_print_settings (print));
96  * }
97  * 
98  * g_object_unref (print);
99  * }
100  * ```
101  * 
102  * By default `GtkPrintOperation` uses an external application to do
103  * print preview. To implement a custom print preview, an application
104  * must connect to the preview signal. The functions
105  * [method@Gtk.PrintOperationPreview.render_page],
106  * [method@Gtk.PrintOperationPreview.end_preview] and
107  * [method@Gtk.PrintOperationPreview.is_selected]
108  * are useful when implementing a print preview.
109  */
110 public class PrintOperation : ObjectG, PrintOperationPreviewIF
111 {
112 	/** the main Gtk struct */
113 	protected GtkPrintOperation* gtkPrintOperation;
114 
115 	/** Get the main Gtk struct */
116 	public GtkPrintOperation* getPrintOperationStruct(bool transferOwnership = false)
117 	{
118 		if (transferOwnership)
119 			ownedRef = false;
120 		return gtkPrintOperation;
121 	}
122 
123 	/** the main Gtk struct as a void* */
124 	protected override void* getStruct()
125 	{
126 		return cast(void*)gtkPrintOperation;
127 	}
128 
129 	/**
130 	 * Sets our main struct and passes it to the parent class.
131 	 */
132 	public this (GtkPrintOperation* gtkPrintOperation, bool ownedRef = false)
133 	{
134 		this.gtkPrintOperation = gtkPrintOperation;
135 		super(cast(GObject*)gtkPrintOperation, ownedRef);
136 	}
137 
138 	// add the PrintOperationPreview capabilities
139 	mixin PrintOperationPreviewT!(GtkPrintOperation);
140 
141 
142 	/** */
143 	public static GType getType()
144 	{
145 		return gtk_print_operation_get_type();
146 	}
147 
148 	/**
149 	 * Creates a new `GtkPrintOperation`.
150 	 *
151 	 * Returns: a new `GtkPrintOperation`
152 	 *
153 	 * Throws: ConstructionException GTK+ fails to create the object.
154 	 */
155 	public this()
156 	{
157 		auto __p = gtk_print_operation_new();
158 
159 		if(__p is null)
160 		{
161 			throw new ConstructionException("null returned by new");
162 		}
163 
164 		this(cast(GtkPrintOperation*) __p, true);
165 	}
166 
167 	/**
168 	 * Cancels a running print operation.
169 	 *
170 	 * This function may be called from a [signal@Gtk.PrintOperation::begin-print],
171 	 * [signal@Gtk.PrintOperation::paginate] or [signal@Gtk.PrintOperation::draw-page]
172 	 * signal handler to stop the currently running print operation.
173 	 */
174 	public void cancel()
175 	{
176 		gtk_print_operation_cancel(gtkPrintOperation);
177 	}
178 
179 	/**
180 	 * Signal that drawing of particular page is complete.
181 	 *
182 	 * It is called after completion of page drawing (e.g. drawing
183 	 * in another thread). If [method@Gtk.PrintOperation.set_defer_drawing]
184 	 * was called before, then this function has to be called by application.
185 	 * Otherwise it is called by GTK itself.
186 	 */
187 	public void drawPageFinish()
188 	{
189 		gtk_print_operation_draw_page_finish(gtkPrintOperation);
190 	}
191 
192 	/**
193 	 * Returns the default page setup.
194 	 *
195 	 * Returns: the default page setup
196 	 */
197 	public PageSetup getDefaultPageSetup()
198 	{
199 		auto __p = gtk_print_operation_get_default_page_setup(gtkPrintOperation);
200 
201 		if(__p is null)
202 		{
203 			return null;
204 		}
205 
206 		return ObjectG.getDObject!(PageSetup)(cast(GtkPageSetup*) __p);
207 	}
208 
209 	/**
210 	 * Gets whether page setup selection combos are embedded
211 	 *
212 	 * Returns: whether page setup selection combos are embedded
213 	 */
214 	public bool getEmbedPageSetup()
215 	{
216 		return gtk_print_operation_get_embed_page_setup(gtkPrintOperation) != 0;
217 	}
218 
219 	/**
220 	 * Call this when the result of a print operation is
221 	 * %GTK_PRINT_OPERATION_RESULT_ERROR.
222 	 *
223 	 * It can be called either after [method@Gtk.PrintOperation.run]
224 	 * returns, or in the [signal@Gtk.PrintOperation::done] signal
225 	 * handler.
226 	 *
227 	 * The returned `GError` will contain more details on what went wrong.
228 	 *
229 	 * Throws: GException on failure.
230 	 */
231 	public void getError()
232 	{
233 		GError* err = null;
234 
235 		gtk_print_operation_get_error(gtkPrintOperation, &err);
236 
237 		if (err !is null)
238 		{
239 			throw new GException( new ErrorG(err) );
240 		}
241 	}
242 
243 	/**
244 	 * Gets whether there is a selection.
245 	 *
246 	 * Returns: whether there is a selection
247 	 */
248 	public bool getHasSelection()
249 	{
250 		return gtk_print_operation_get_has_selection(gtkPrintOperation) != 0;
251 	}
252 
253 	/**
254 	 * Returns the number of pages that will be printed.
255 	 *
256 	 * Note that this value is set during print preparation phase
257 	 * (%GTK_PRINT_STATUS_PREPARING), so this function should never be
258 	 * called before the data generation phase (%GTK_PRINT_STATUS_GENERATING_DATA).
259 	 * You can connect to the [signal@Gtk.PrintOperation::status-changed]
260 	 * signal and call gtk_print_operation_get_n_pages_to_print() when
261 	 * print status is %GTK_PRINT_STATUS_GENERATING_DATA.
262 	 *
263 	 * This is typically used to track the progress of print operation.
264 	 *
265 	 * Returns: the number of pages that will be printed
266 	 */
267 	public int getNPagesToPrint()
268 	{
269 		return gtk_print_operation_get_n_pages_to_print(gtkPrintOperation);
270 	}
271 
272 	/**
273 	 * Returns the current print settings.
274 	 *
275 	 * Note that the return value is %NULL until either
276 	 * [method@Gtk.PrintOperation.set_print_settings] or
277 	 * [method@Gtk.PrintOperation.run] have been called.
278 	 *
279 	 * Returns: the current print settings of @op.
280 	 */
281 	public PrintSettings getPrintSettings()
282 	{
283 		auto __p = gtk_print_operation_get_print_settings(gtkPrintOperation);
284 
285 		if(__p is null)
286 		{
287 			return null;
288 		}
289 
290 		return ObjectG.getDObject!(PrintSettings)(cast(GtkPrintSettings*) __p);
291 	}
292 
293 	/**
294 	 * Returns the status of the print operation.
295 	 *
296 	 * Also see [method@Gtk.PrintOperation.get_status_string].
297 	 *
298 	 * Returns: the status of the print operation
299 	 */
300 	public GtkPrintStatus getStatus()
301 	{
302 		return gtk_print_operation_get_status(gtkPrintOperation);
303 	}
304 
305 	/**
306 	 * Returns a string representation of the status of the
307 	 * print operation.
308 	 *
309 	 * The string is translated and suitable for displaying
310 	 * the print status e.g. in a `GtkStatusbar`.
311 	 *
312 	 * Use [method@Gtk.PrintOperation.get_status] to obtain
313 	 * a status value that is suitable for programmatic use.
314 	 *
315 	 * Returns: a string representation of the status
316 	 *     of the print operation
317 	 */
318 	public string getStatusString()
319 	{
320 		return Str.toString(gtk_print_operation_get_status_string(gtkPrintOperation));
321 	}
322 
323 	/**
324 	 * Gets whether the application supports print of selection
325 	 *
326 	 * Returns: whether the application supports print of selection
327 	 */
328 	public bool getSupportSelection()
329 	{
330 		return gtk_print_operation_get_support_selection(gtkPrintOperation) != 0;
331 	}
332 
333 	/**
334 	 * A convenience function to find out if the print operation
335 	 * is finished.
336 	 *
337 	 * a print operation is finished if its status is either
338 	 * %GTK_PRINT_STATUS_FINISHED or %GTK_PRINT_STATUS_FINISHED_ABORTED.
339 	 *
340 	 * Note: when you enable print status tracking the print operation
341 	 * can be in a non-finished state even after done has been called, as
342 	 * the operation status then tracks the print job status on the printer.
343 	 *
344 	 * Returns: %TRUE, if the print operation is finished.
345 	 */
346 	public bool isFinished()
347 	{
348 		return gtk_print_operation_is_finished(gtkPrintOperation) != 0;
349 	}
350 
351 	/**
352 	 * Runs the print operation.
353 	 *
354 	 * Normally that this function does not return until the rendering
355 	 * of all pages is complete. You can connect to the
356 	 * [signal@Gtk.PrintOperation::status-changed] signal on @op to obtain
357 	 * some information about the progress of the print operation.
358 	 *
359 	 * Furthermore, it may use a recursive mainloop to show the print dialog.
360 	 *
361 	 * If you set the [Gtk.PrintOperation:allow-async] property, the operation
362 	 * will run asynchronously if this is supported on the platform. The
363 	 * [signal@Gtk.PrintOperation::done] signal will be emitted with the result
364 	 * of the operation when the it is done (i.e. when the dialog is canceled,
365 	 * or when the print succeeds or fails).
366 	 *
367 	 * ```c
368 	 * if (settings != NULL)
369 	 * gtk_print_operation_set_print_settings (print, settings);
370 	 *
371 	 * if (page_setup != NULL)
372 	 * gtk_print_operation_set_default_page_setup (print, page_setup);
373 	 *
374 	 * g_signal_connect (print, "begin-print",
375 	 * G_CALLBACK (begin_print), &data);
376 	 * g_signal_connect (print, "draw-page",
377 	 * G_CALLBACK (draw_page), &data);
378 	 *
379 	 * res = gtk_print_operation_run (print,
380 	 * GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
381 	 * parent,
382 	 * &error);
383 	 *
384 	 * if (res == GTK_PRINT_OPERATION_RESULT_ERROR)
385 	 * {
386 	 * error_dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
387 	 * GTK_DIALOG_DESTROY_WITH_PARENT,
388 	 * GTK_MESSAGE_ERROR,
389 	 * GTK_BUTTONS_CLOSE,
390 	 * "Error printing file:\n%s",
391 	 * error->message);
392 	 * g_signal_connect (error_dialog, "response",
393 	 * G_CALLBACK (gtk_window_destroy), NULL);
394 	 * gtk_widget_show (error_dialog);
395 	 * g_error_free (error);
396 	 * }
397 	 * else if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
398 	 * {
399 	 * if (settings != NULL)
400 	 * g_object_unref (settings);
401 	 * settings = g_object_ref (gtk_print_operation_get_print_settings (print));
402 	 * }
403 	 * ```
404 	 *
405 	 * Note that gtk_print_operation_run() can only be called once on a
406 	 * given `GtkPrintOperation`.
407 	 *
408 	 * Params:
409 	 *     action = the action to start
410 	 *     parent = Transient parent of the dialog
411 	 *
412 	 * Returns: the result of the print operation. A return value of
413 	 *     %GTK_PRINT_OPERATION_RESULT_APPLY indicates that the printing was
414 	 *     completed successfully. In this case, it is a good idea to obtain
415 	 *     the used print settings with
416 	 *     [method@Gtk.PrintOperation.get_print_settings]
417 	 *     and store them for reuse with the next print operation. A value of
418 	 *     %GTK_PRINT_OPERATION_RESULT_IN_PROGRESS means the operation is running
419 	 *     asynchronously, and will emit the [signal@Gtk.PrintOperation::done]
420 	 *     signal when done.
421 	 *
422 	 * Throws: GException on failure.
423 	 */
424 	public GtkPrintOperationResult run(GtkPrintOperationAction action, Window parent)
425 	{
426 		GError* err = null;
427 
428 		auto __p = gtk_print_operation_run(gtkPrintOperation, action, (parent is null) ? null : parent.getWindowStruct(), &err);
429 
430 		if (err !is null)
431 		{
432 			throw new GException( new ErrorG(err) );
433 		}
434 
435 		return __p;
436 	}
437 
438 	/**
439 	 * Sets whether gtk_print_operation_run() may return
440 	 * before the print operation is completed.
441 	 *
442 	 * Note that some platforms may not allow asynchronous
443 	 * operation.
444 	 *
445 	 * Params:
446 	 *     allowAsync = %TRUE to allow asynchronous operation
447 	 */
448 	public void setAllowAsync(bool allowAsync)
449 	{
450 		gtk_print_operation_set_allow_async(gtkPrintOperation, allowAsync);
451 	}
452 
453 	/**
454 	 * Sets the current page.
455 	 *
456 	 * If this is called before [method@Gtk.PrintOperation.run],
457 	 * the user will be able to select to print only the current page.
458 	 *
459 	 * Note that this only makes sense for pre-paginated documents.
460 	 *
461 	 * Params:
462 	 *     currentPage = the current page, 0-based
463 	 */
464 	public void setCurrentPage(int currentPage)
465 	{
466 		gtk_print_operation_set_current_page(gtkPrintOperation, currentPage);
467 	}
468 
469 	/**
470 	 * Sets the label for the tab holding custom widgets.
471 	 *
472 	 * Params:
473 	 *     label = the label to use, or %NULL to use the default label
474 	 */
475 	public void setCustomTabLabel(string label)
476 	{
477 		gtk_print_operation_set_custom_tab_label(gtkPrintOperation, Str.toStringz(label));
478 	}
479 
480 	/**
481 	 * Makes @default_page_setup the default page setup for @op.
482 	 *
483 	 * This page setup will be used by [method@Gtk.PrintOperation.run],
484 	 * but it can be overridden on a per-page basis by connecting
485 	 * to the [signal@Gtk.PrintOperation::request-page-setup] signal.
486 	 *
487 	 * Params:
488 	 *     defaultPageSetup = a `GtkPageSetup`, or %NULL
489 	 */
490 	public void setDefaultPageSetup(PageSetup defaultPageSetup)
491 	{
492 		gtk_print_operation_set_default_page_setup(gtkPrintOperation, (defaultPageSetup is null) ? null : defaultPageSetup.getPageSetupStruct());
493 	}
494 
495 	/**
496 	 * Sets up the `GtkPrintOperation` to wait for calling of
497 	 * [method@Gtk.PrintOperation.draw_page_finish from application.
498 	 *
499 	 * This can be used for drawing page in another thread.
500 	 *
501 	 * This function must be called in the callback of the
502 	 * [signal@Gtk.PrintOperation::draw-page] signal.
503 	 */
504 	public void setDeferDrawing()
505 	{
506 		gtk_print_operation_set_defer_drawing(gtkPrintOperation);
507 	}
508 
509 	/**
510 	 * Embed page size combo box and orientation combo box into page setup page.
511 	 *
512 	 * Selected page setup is stored as default page setup in `GtkPrintOperation`.
513 	 *
514 	 * Params:
515 	 *     embed = %TRUE to embed page setup selection in the `GtkPrintUnixDialog`
516 	 */
517 	public void setEmbedPageSetup(bool embed)
518 	{
519 		gtk_print_operation_set_embed_page_setup(gtkPrintOperation, embed);
520 	}
521 
522 	/**
523 	 * Sets up the `GtkPrintOperation` to generate a file instead
524 	 * of showing the print dialog.
525 	 *
526 	 * The intended use of this function is for implementing
527 	 * “Export to PDF” actions. Currently, PDF is the only supported
528 	 * format.
529 	 *
530 	 * “Print to PDF” support is independent of this and is done
531 	 * by letting the user pick the “Print to PDF” item from the list
532 	 * of printers in the print dialog.
533 	 *
534 	 * Params:
535 	 *     filename = the filename for the exported file
536 	 */
537 	public void setExportFilename(string filename)
538 	{
539 		gtk_print_operation_set_export_filename(gtkPrintOperation, Str.toStringz(filename));
540 	}
541 
542 	/**
543 	 * Sets whether there is a selection to print.
544 	 *
545 	 * Application has to set number of pages to which the selection
546 	 * will draw by [method@Gtk.PrintOperation.set_n_pages] in a handler
547 	 * for the [signal@Gtk.PrintOperation::begin-print] signal.
548 	 *
549 	 * Params:
550 	 *     hasSelection = %TRUE indicates that a selection exists
551 	 */
552 	public void setHasSelection(bool hasSelection)
553 	{
554 		gtk_print_operation_set_has_selection(gtkPrintOperation, hasSelection);
555 	}
556 
557 	/**
558 	 * Sets the name of the print job.
559 	 *
560 	 * The name is used to identify the job (e.g. in monitoring
561 	 * applications like eggcups).
562 	 *
563 	 * If you don’t set a job name, GTK picks a default one by
564 	 * numbering successive print jobs.
565 	 *
566 	 * Params:
567 	 *     jobName = a string that identifies the print job
568 	 */
569 	public void setJobName(string jobName)
570 	{
571 		gtk_print_operation_set_job_name(gtkPrintOperation, Str.toStringz(jobName));
572 	}
573 
574 	/**
575 	 * Sets the number of pages in the document.
576 	 *
577 	 * This must be set to a positive number before the rendering
578 	 * starts. It may be set in a [signal@Gtk.PrintOperation::begin-print]
579 	 * signal handler.
580 	 *
581 	 * Note that the page numbers passed to the
582 	 * [signal@Gtk.PrintOperation::request-page-setup]
583 	 * and [signal@Gtk.PrintOperation::draw-page] signals are 0-based, i.e.
584 	 * if the user chooses to print all pages, the last ::draw-page signal
585 	 * will be for page @n_pages - 1.
586 	 *
587 	 * Params:
588 	 *     nPages = the number of pages
589 	 */
590 	public void setNPages(int nPages)
591 	{
592 		gtk_print_operation_set_n_pages(gtkPrintOperation, nPages);
593 	}
594 
595 	/**
596 	 * Sets the print settings for @op.
597 	 *
598 	 * This is typically used to re-establish print settings
599 	 * from a previous print operation, see [method@Gtk.PrintOperation.run].
600 	 *
601 	 * Params:
602 	 *     printSettings = `GtkPrintSettings`
603 	 */
604 	public void setPrintSettings(PrintSettings printSettings)
605 	{
606 		gtk_print_operation_set_print_settings(gtkPrintOperation, (printSettings is null) ? null : printSettings.getPrintSettingsStruct());
607 	}
608 
609 	/**
610 	 * If @show_progress is %TRUE, the print operation will show
611 	 * a progress dialog during the print operation.
612 	 *
613 	 * Params:
614 	 *     showProgress = %TRUE to show a progress dialog
615 	 */
616 	public void setShowProgress(bool showProgress)
617 	{
618 		gtk_print_operation_set_show_progress(gtkPrintOperation, showProgress);
619 	}
620 
621 	/**
622 	 * Sets whether selection is supported by `GtkPrintOperation`.
623 	 *
624 	 * Params:
625 	 *     supportSelection = %TRUE to support selection
626 	 */
627 	public void setSupportSelection(bool supportSelection)
628 	{
629 		gtk_print_operation_set_support_selection(gtkPrintOperation, supportSelection);
630 	}
631 
632 	/**
633 	 * If track_status is %TRUE, the print operation will try to continue
634 	 * report on the status of the print job in the printer queues and printer.
635 	 *
636 	 * This can allow your application to show things like “out of paper”
637 	 * issues, and when the print job actually reaches the printer.
638 	 *
639 	 * This function is often implemented using some form of polling,
640 	 * so it should not be enabled unless needed.
641 	 *
642 	 * Params:
643 	 *     trackStatus = %TRUE to track status after printing
644 	 */
645 	public void setTrackPrintStatus(bool trackStatus)
646 	{
647 		gtk_print_operation_set_track_print_status(gtkPrintOperation, trackStatus);
648 	}
649 
650 	/**
651 	 * Sets up the transformation for the cairo context obtained from
652 	 * `GtkPrintContext` in such a way that distances are measured in
653 	 * units of @unit.
654 	 *
655 	 * Params:
656 	 *     unit = the unit to use
657 	 */
658 	public void setUnit(GtkUnit unit)
659 	{
660 		gtk_print_operation_set_unit(gtkPrintOperation, unit);
661 	}
662 
663 	/**
664 	 * If @full_page is %TRUE, the transformation for the cairo context
665 	 * obtained from `GtkPrintContext` puts the origin at the top left
666 	 * corner of the page.
667 	 *
668 	 * This may not be the top left corner of the sheet, depending on page
669 	 * orientation and the number of pages per sheet). Otherwise, the origin
670 	 * is at the top left corner of the imageable area (i.e. inside the margins).
671 	 *
672 	 * Params:
673 	 *     fullPage = %TRUE to set up the `GtkPrintContext` for the full page
674 	 */
675 	public void setUseFullPage(bool fullPage)
676 	{
677 		gtk_print_operation_set_use_full_page(gtkPrintOperation, fullPage);
678 	}
679 
680 	/**
681 	 * Emitted after the user has finished changing print settings
682 	 * in the dialog, before the actual rendering starts.
683 	 *
684 	 * A typical use for ::begin-print is to use the parameters from the
685 	 * [class@Gtk.PrintContext] and paginate the document accordingly,
686 	 * and then set the number of pages with
687 	 * [method@Gtk.PrintOperation.set_n_pages].
688 	 *
689 	 * Params:
690 	 *     context = the `GtkPrintContext` for the current operation
691 	 */
692 	gulong addOnBeginPrint(void delegate(PrintContext, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
693 	{
694 		return Signals.connect(this, "begin-print", dlg, connectFlags ^ ConnectFlags.SWAPPED);
695 	}
696 
697 	/**
698 	 * Emitted when displaying the print dialog.
699 	 *
700 	 * If you return a widget in a handler for this signal it will be
701 	 * added to a custom tab in the print dialog. You typically return a
702 	 * container widget with multiple widgets in it.
703 	 *
704 	 * The print dialog owns the returned widget, and its lifetime is not
705 	 * controlled by the application. However, the widget is guaranteed
706 	 * to stay around until the [signal@Gtk.PrintOperation::custom-widget-apply]
707 	 * signal is emitted on the operation. Then you can read out any
708 	 * information you need from the widgets.
709 	 *
710 	 * Returns: A custom widget that gets embedded in
711 	 *     the print dialog, or %NULL
712 	 */
713 	gulong addOnCreateCustomWidget(ObjectG delegate(PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
714 	{
715 		return Signals.connect(this, "create-custom-widget", dlg, connectFlags ^ ConnectFlags.SWAPPED);
716 	}
717 
718 	/**
719 	 * Emitted right before ::begin-print if you added
720 	 * a custom widget in the ::create-custom-widget handler.
721 	 *
722 	 * When you get this signal you should read the information from the
723 	 * custom widgets, as the widgets are not guaranteed to be around at a
724 	 * later time.
725 	 *
726 	 * Params:
727 	 *     widget = the custom widget added in ::create-custom-widget
728 	 */
729 	gulong addOnCustomWidgetApply(void delegate(Widget, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
730 	{
731 		return Signals.connect(this, "custom-widget-apply", dlg, connectFlags ^ ConnectFlags.SWAPPED);
732 	}
733 
734 	/**
735 	 * Emitted when the print operation run has finished doing
736 	 * everything required for printing.
737 	 *
738 	 * @result gives you information about what happened during the run.
739 	 * If @result is %GTK_PRINT_OPERATION_RESULT_ERROR then you can call
740 	 * [method@Gtk.PrintOperation.get_error] for more information.
741 	 *
742 	 * If you enabled print status tracking then
743 	 * [method@Gtk.PrintOperation.is_finished] may still return %FALSE
744 	 * after the ::done signal was emitted.
745 	 *
746 	 * Params:
747 	 *     result = the result of the print operation
748 	 */
749 	gulong addOnDone(void delegate(GtkPrintOperationResult, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
750 	{
751 		return Signals.connect(this, "done", dlg, connectFlags ^ ConnectFlags.SWAPPED);
752 	}
753 
754 	/**
755 	 * Emitted for every page that is printed.
756 	 *
757 	 * The signal handler must render the @page_nr's page onto the cairo
758 	 * context obtained from @context using
759 	 * [method@Gtk.PrintContext.get_cairo_context].
760 	 *
761 	 * ```c
762 	 * static void
763 	 * draw_page (GtkPrintOperation *operation,
764 	 * GtkPrintContext   *context,
765 	 * int                page_nr,
766 	 * gpointer           user_data)
767 	 * {
768 	 * cairo_t *cr;
769 	 * PangoLayout *layout;
770 	 * double width, text_height;
771 	 * int layout_height;
772 	 * PangoFontDescription *desc;
773 	 *
774 	 * cr = gtk_print_context_get_cairo_context (context);
775 	 * width = gtk_print_context_get_width (context);
776 	 *
777 	 * cairo_rectangle (cr, 0, 0, width, HEADER_HEIGHT);
778 	 *
779 	 * cairo_set_source_rgb (cr, 0.8, 0.8, 0.8);
780 	 * cairo_fill (cr);
781 	 *
782 	 * layout = gtk_print_context_create_pango_layout (context);
783 	 *
784 	 * desc = pango_font_description_from_string ("sans 14");
785 	 * pango_layout_set_font_description (layout, desc);
786 	 * pango_font_description_free (desc);
787 	 *
788 	 * pango_layout_set_text (layout, "some text", -1);
789 	 * pango_layout_set_width (layout, width * PANGO_SCALE);
790 	 * pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
791 	 *
792 	 * pango_layout_get_size (layout, NULL, &layout_height);
793 	 * text_height = (double)layout_height / PANGO_SCALE;
794 	 *
795 	 * cairo_move_to (cr, width / 2,  (HEADER_HEIGHT - text_height) / 2);
796 	 * pango_cairo_show_layout (cr, layout);
797 	 *
798 	 * g_object_unref (layout);
799 	 * }
800 	 * ```
801 	 *
802 	 * Use [method@Gtk.PrintOperation.set_use_full_page] and
803 	 * [method@Gtk.PrintOperation.set_unit] before starting the print
804 	 * operation to set up the transformation of the cairo context
805 	 * according to your needs.
806 	 *
807 	 * Params:
808 	 *     context = the `GtkPrintContext` for the current operation
809 	 *     pageNr = the number of the currently printed page (0-based)
810 	 */
811 	gulong addOnDrawPage(void delegate(PrintContext, int, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
812 	{
813 		return Signals.connect(this, "draw-page", dlg, connectFlags ^ ConnectFlags.SWAPPED);
814 	}
815 
816 	/**
817 	 * Emitted after all pages have been rendered.
818 	 *
819 	 * A handler for this signal can clean up any resources that have
820 	 * been allocated in the [signal@Gtk.PrintOperation::begin-print] handler.
821 	 *
822 	 * Params:
823 	 *     context = the `GtkPrintContext` for the current operation
824 	 */
825 	gulong addOnEndPrint(void delegate(PrintContext, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
826 	{
827 		return Signals.connect(this, "end-print", dlg, connectFlags ^ ConnectFlags.SWAPPED);
828 	}
829 
830 	/**
831 	 * Emitted after the ::begin-print signal, but before the actual rendering
832 	 * starts.
833 	 *
834 	 * It keeps getting emitted until a connected signal handler returns %TRUE.
835 	 *
836 	 * The ::paginate signal is intended to be used for paginating a document
837 	 * in small chunks, to avoid blocking the user interface for a long
838 	 * time. The signal handler should update the number of pages using
839 	 * [method@Gtk.PrintOperation.set_n_pages], and return %TRUE if the document
840 	 * has been completely paginated.
841 	 *
842 	 * If you don't need to do pagination in chunks, you can simply do
843 	 * it all in the ::begin-print handler, and set the number of pages
844 	 * from there.
845 	 *
846 	 * Params:
847 	 *     context = the `GtkPrintContext` for the current operation
848 	 *
849 	 * Returns: %TRUE if pagination is complete
850 	 */
851 	gulong addOnPaginate(bool delegate(PrintContext, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
852 	{
853 		return Signals.connect(this, "paginate", dlg, connectFlags ^ ConnectFlags.SWAPPED);
854 	}
855 
856 	/**
857 	 * Gets emitted when a preview is requested from the native dialog.
858 	 *
859 	 * The default handler for this signal uses an external viewer
860 	 * application to preview.
861 	 *
862 	 * To implement a custom print preview, an application must return
863 	 * %TRUE from its handler for this signal. In order to use the
864 	 * provided @context for the preview implementation, it must be
865 	 * given a suitable cairo context with
866 	 * [method@Gtk.PrintContext.set_cairo_context].
867 	 *
868 	 * The custom preview implementation can use
869 	 * [method@Gtk.PrintOperationPreview.is_selected] and
870 	 * [method@Gtk.PrintOperationPreview.render_page] to find pages which
871 	 * are selected for print and render them. The preview must be
872 	 * finished by calling [method@Gtk.PrintOperationPreview.end_preview]
873 	 * (typically in response to the user clicking a close button).
874 	 *
875 	 * Params:
876 	 *     preview = the `GtkPrintOperationPreview` for the current operation
877 	 *     context = the `GtkPrintContext` that will be used
878 	 *     parent = the `GtkWindow` to use as window parent, or %NULL
879 	 *
880 	 * Returns: %TRUE if the listener wants to take over control of the preview
881 	 */
882 	gulong addOnPreview(bool delegate(PrintOperationPreviewIF, PrintContext, Window, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
883 	{
884 		return Signals.connect(this, "preview", dlg, connectFlags ^ ConnectFlags.SWAPPED);
885 	}
886 
887 	/**
888 	 * Emitted once for every page that is printed.
889 	 *
890 	 * This gives the application a chance to modify the page setup.
891 	 * Any changes done to @setup will be in force only for printing
892 	 * this page.
893 	 *
894 	 * Params:
895 	 *     context = the `GtkPrintContext` for the current operation
896 	 *     pageNr = the number of the currently printed page (0-based)
897 	 *     setup = the `GtkPageSetup`
898 	 */
899 	gulong addOnRequestPageSetup(void delegate(PrintContext, int, PageSetup, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
900 	{
901 		return Signals.connect(this, "request-page-setup", dlg, connectFlags ^ ConnectFlags.SWAPPED);
902 	}
903 
904 	/**
905 	 * Emitted at between the various phases of the print operation.
906 	 *
907 	 * See [enum@Gtk.PrintStatus] for the phases that are being discriminated.
908 	 * Use [method@Gtk.PrintOperation.get_status] to find out the current
909 	 * status.
910 	 */
911 	gulong addOnStatusChanged(void delegate(PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
912 	{
913 		return Signals.connect(this, "status-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
914 	}
915 
916 	/**
917 	 * Emitted after change of selected printer.
918 	 *
919 	 * The actual page setup and print settings are passed to the custom
920 	 * widget, which can actualize itself according to this change.
921 	 *
922 	 * Params:
923 	 *     widget = the custom widget added in ::create-custom-widget
924 	 *     setup = actual page setup
925 	 *     settings = actual print settings
926 	 */
927 	gulong addOnUpdateCustomWidget(void delegate(Widget, PageSetup, PrintSettings, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
928 	{
929 		return Signals.connect(this, "update-custom-widget", dlg, connectFlags ^ ConnectFlags.SWAPPED);
930 	}
931 }