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