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