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  * Conversion parameters:
26  * inFile  = GtkPrintJob.html
27  * outPack = gtk
28  * outFile = PrintJob
29  * strct   = GtkPrintJob
30  * realStrct=
31  * ctorStrct=
32  * clss    = PrintJob
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_print_job_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- glib.ErrorG
48  * 	- glib.GException
49  * 	- cairo.Surface
50  * 	- gtk.PageSetup
51  * 	- gtk.Printer
52  * 	- gtk.PrintSettings
53  * structWrap:
54  * 	- GtkPageSetup* -> PageSetup
55  * 	- GtkPrintSettings* -> PrintSettings
56  * 	- GtkPrinter* -> Printer
57  * 	- cairo_surface_t* -> Surface
58  * module aliases:
59  * local aliases:
60  * overrides:
61  */
62 
63 module gtk.PrintJob;
64 
65 public  import gtkc.gtktypes;
66 
67 private import gtkc.gtk;
68 private import glib.ConstructionException;
69 private import gobject.ObjectG;
70 
71 private import gobject.Signals;
72 public  import gtkc.gdktypes;
73 private import glib.Str;
74 private import glib.ErrorG;
75 private import glib.GException;
76 private import cairo.Surface;
77 private import gtk.PageSetup;
78 private import gtk.Printer;
79 private import gtk.PrintSettings;
80 
81 
82 private import gobject.ObjectG;
83 
84 /**
85  * A GtkPrintJob object represents a job that is sent to a
86  * printer. You only need to deal directly with print jobs if
87  * you use the non-portable GtkPrintUnixDialog API.
88  *
89  * Use gtk_print_job_get_surface() to obtain the cairo surface
90  * onto which the pages must be drawn. Use gtk_print_job_send()
91  * to send the finished job to the printer. If you don't use cairo
92  * GtkPrintJob also supports printing of manually generated postscript,
93  * via gtk_print_job_set_source_file().
94  */
95 public class PrintJob : ObjectG
96 {
97 	
98 	/** the main Gtk struct */
99 	protected GtkPrintJob* gtkPrintJob;
100 	
101 	
102 	/** Get the main Gtk struct */
103 	public GtkPrintJob* getPrintJobStruct()
104 	{
105 		return gtkPrintJob;
106 	}
107 	
108 	
109 	/** the main Gtk struct as a void* */
110 	protected override void* getStruct()
111 	{
112 		return cast(void*)gtkPrintJob;
113 	}
114 	
115 	/**
116 	 * Sets our main struct and passes it to the parent class
117 	 */
118 	public this (GtkPrintJob* gtkPrintJob)
119 	{
120 		super(cast(GObject*)gtkPrintJob);
121 		this.gtkPrintJob = gtkPrintJob;
122 	}
123 	
124 	protected override void setStruct(GObject* obj)
125 	{
126 		super.setStruct(obj);
127 		gtkPrintJob = cast(GtkPrintJob*)obj;
128 	}
129 	
130 	/**
131 	 */
132 	int[string] connectedSignals;
133 	
134 	void delegate(PrintJob)[] onStatusChangedListeners;
135 	/**
136 	 * Gets emitted when the status of a job changes. The signal handler
137 	 * can use gtk_print_job_get_status() to obtain the new status.
138 	 * Since 2.10
139 	 */
140 	void addOnStatusChanged(void delegate(PrintJob) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
141 	{
142 		if ( !("status-changed" in connectedSignals) )
143 		{
144 			Signals.connectData(
145 			getStruct(),
146 			"status-changed",
147 			cast(GCallback)&callBackStatusChanged,
148 			cast(void*)this,
149 			null,
150 			connectFlags);
151 			connectedSignals["status-changed"] = 1;
152 		}
153 		onStatusChangedListeners ~= dlg;
154 	}
155 	extern(C) static void callBackStatusChanged(GtkPrintJob* jobStruct, PrintJob _printJob)
156 	{
157 		foreach ( void delegate(PrintJob) dlg ; _printJob.onStatusChangedListeners )
158 		{
159 			dlg(_printJob);
160 		}
161 	}
162 	
163 	
164 	/**
165 	 * Creates a new GtkPrintJob.
166 	 * Since 2.10
167 	 * Params:
168 	 * title = the job title
169 	 * printer = a GtkPrinter
170 	 * settings = a GtkPrintSettings
171 	 * pageSetup = a GtkPageSetup
172 	 * Throws: ConstructionException GTK+ fails to create the object.
173 	 */
174 	public this (string title, Printer printer, PrintSettings settings, PageSetup pageSetup)
175 	{
176 		// GtkPrintJob * gtk_print_job_new (const gchar *title,  GtkPrinter *printer,  GtkPrintSettings *settings,  GtkPageSetup *page_setup);
177 		auto p = gtk_print_job_new(Str.toStringz(title), (printer is null) ? null : printer.getPrinterStruct(), (settings is null) ? null : settings.getPrintSettingsStruct(), (pageSetup is null) ? null : pageSetup.getPageSetupStruct());
178 		if(p is null)
179 		{
180 			throw new ConstructionException("null returned by gtk_print_job_new(Str.toStringz(title), (printer is null) ? null : printer.getPrinterStruct(), (settings is null) ? null : settings.getPrintSettingsStruct(), (pageSetup is null) ? null : pageSetup.getPageSetupStruct())");
181 		}
182 		this(cast(GtkPrintJob*) p);
183 	}
184 	
185 	/**
186 	 * Gets the GtkPrintSettings of the print job.
187 	 * Since 2.10
188 	 * Returns: the settings of job. [transfer none]
189 	 */
190 	public PrintSettings getSettings()
191 	{
192 		// GtkPrintSettings * gtk_print_job_get_settings (GtkPrintJob *job);
193 		auto p = gtk_print_job_get_settings(gtkPrintJob);
194 		
195 		if(p is null)
196 		{
197 			return null;
198 		}
199 		
200 		return ObjectG.getDObject!(PrintSettings)(cast(GtkPrintSettings*) p);
201 	}
202 	
203 	/**
204 	 * Gets the GtkPrinter of the print job.
205 	 * Since 2.10
206 	 * Returns: the printer of job. [transfer none]
207 	 */
208 	public Printer getPrinter()
209 	{
210 		// GtkPrinter * gtk_print_job_get_printer (GtkPrintJob *job);
211 		auto p = gtk_print_job_get_printer(gtkPrintJob);
212 		
213 		if(p is null)
214 		{
215 			return null;
216 		}
217 		
218 		return ObjectG.getDObject!(Printer)(cast(GtkPrinter*) p);
219 	}
220 	
221 	/**
222 	 * Gets the job title.
223 	 * Since 2.10
224 	 * Returns: the title of job
225 	 */
226 	public string getTitle()
227 	{
228 		// const gchar * gtk_print_job_get_title (GtkPrintJob *job);
229 		return Str.toString(gtk_print_job_get_title(gtkPrintJob));
230 	}
231 	
232 	/**
233 	 * Gets the status of the print job.
234 	 * Since 2.10
235 	 * Returns: the status of job
236 	 */
237 	public GtkPrintStatus getStatus()
238 	{
239 		// GtkPrintStatus gtk_print_job_get_status (GtkPrintJob *job);
240 		return gtk_print_job_get_status(gtkPrintJob);
241 	}
242 	
243 	/**
244 	 * Make the GtkPrintJob send an existing document to the
245 	 * printing system. The file can be in any format understood
246 	 * by the platforms printing system (typically PostScript,
247 	 * but on many platforms PDF may work too). See
248 	 * gtk_printer_accepts_pdf() and gtk_printer_accepts_ps().
249 	 * Since 2.10
250 	 * Params:
251 	 * filename = the file to be printed. [type filename]
252 	 * Returns: FALSE if an error occurred
253 	 * Throws: GException on failure.
254 	 */
255 	public int setSourceFile(string filename)
256 	{
257 		// gboolean gtk_print_job_set_source_file (GtkPrintJob *job,  const gchar *filename,  GError **error);
258 		GError* err = null;
259 		
260 		auto p = gtk_print_job_set_source_file(gtkPrintJob, Str.toStringz(filename), &err);
261 		
262 		if (err !is null)
263 		{
264 			throw new GException( new ErrorG(err) );
265 		}
266 		
267 		return p;
268 	}
269 	
270 	/**
271 	 * Gets a cairo surface onto which the pages of
272 	 * the print job should be rendered.
273 	 * Since 2.10
274 	 * Returns: the cairo surface of job. [transfer none]
275 	 * Throws: GException on failure.
276 	 */
277 	public Surface getSurface()
278 	{
279 		// cairo_surface_t * gtk_print_job_get_surface (GtkPrintJob *job,  GError **error);
280 		GError* err = null;
281 		
282 		auto p = gtk_print_job_get_surface(gtkPrintJob, &err);
283 		
284 		if (err !is null)
285 		{
286 			throw new GException( new ErrorG(err) );
287 		}
288 		
289 		
290 		if(p is null)
291 		{
292 			return null;
293 		}
294 		
295 		return ObjectG.getDObject!(Surface)(cast(cairo_surface_t*) p);
296 	}
297 	
298 	/**
299 	 * Sends the print job off to the printer.
300 	 * Since 2.10
301 	 * Params:
302 	 * callback = function to call when the job completes or an error occurs
303 	 * userData = user data that gets passed to callback
304 	 * dnotify = destroy notify for user_data
305 	 */
306 	public void send(GtkPrintJobCompleteFunc callback, void* userData, GDestroyNotify dnotify)
307 	{
308 		// void gtk_print_job_send (GtkPrintJob *job,  GtkPrintJobCompleteFunc callback,  gpointer user_data,  GDestroyNotify dnotify);
309 		gtk_print_job_send(gtkPrintJob, callback, userData, dnotify);
310 	}
311 	
312 	/**
313 	 * If track_status is TRUE, the print job will try to continue report
314 	 * on the status of the print job in the printer queues and printer. This
315 	 * can allow your application to show things like "out of paper" issues,
316 	 * and when the print job actually reaches the printer.
317 	 * This function is often implemented using some form of polling, so it should
318 	 * not be enabled unless needed.
319 	 * Since 2.10
320 	 * Params:
321 	 * trackStatus = TRUE to track status after printing
322 	 */
323 	public void setTrackPrintStatus(int trackStatus)
324 	{
325 		// void gtk_print_job_set_track_print_status  (GtkPrintJob *job,  gboolean track_status);
326 		gtk_print_job_set_track_print_status(gtkPrintJob, trackStatus);
327 	}
328 	
329 	/**
330 	 * Returns wheter jobs will be tracked after printing.
331 	 * For details, see gtk_print_job_set_track_print_status().
332 	 * Since 2.10
333 	 * Returns: TRUE if print job status will be reported after printing
334 	 */
335 	public int getTrackPrintStatus()
336 	{
337 		// gboolean gtk_print_job_get_track_print_status  (GtkPrintJob *job);
338 		return gtk_print_job_get_track_print_status(gtkPrintJob);
339 	}
340 	
341 	/**
342 	 * Gets the GtkPrintPages setting for this job.
343 	 * Returns: the GtkPrintPages setting Since 3.0
344 	 */
345 	public GtkPrintPages getPages()
346 	{
347 		// GtkPrintPages gtk_print_job_get_pages (GtkPrintJob *job);
348 		return gtk_print_job_get_pages(gtkPrintJob);
349 	}
350 	
351 	/**
352 	 * Sets the GtkPrintPages setting for this job.
353 	 * Params:
354 	 * pages = the GtkPrintPages setting
355 	 * Since 3.0
356 	 */
357 	public void setPages(GtkPrintPages pages)
358 	{
359 		// void gtk_print_job_set_pages (GtkPrintJob *job,  GtkPrintPages pages);
360 		gtk_print_job_set_pages(gtkPrintJob, pages);
361 	}
362 	
363 	/**
364 	 * Gets the page ranges for this job.
365 	 * Returns: a pointer to an array of GtkPageRange structs. [array length=n_ranges][transfer none] Since 3.0
366 	 */
367 	public GtkPageRange[] getPageRanges()
368 	{
369 		// GtkPageRange * gtk_print_job_get_page_ranges (GtkPrintJob *job,  gint *n_ranges);
370 		int nRanges;
371 		auto p = gtk_print_job_get_page_ranges(gtkPrintJob, &nRanges);
372 		
373 		if(p is null)
374 		{
375 			return null;
376 		}
377 		
378 		return p[0 .. nRanges];
379 	}
380 	
381 	/**
382 	 * Sets the page ranges for this job.
383 	 * Params:
384 	 * ranges = pointer to an array of
385 	 * GtkPageRange structs. [array length=n_ranges]
386 	 */
387 	public void setPageRanges(GtkPageRange[] ranges)
388 	{
389 		// void gtk_print_job_set_page_ranges (GtkPrintJob *job,  GtkPageRange *ranges,  gint n_ranges);
390 		gtk_print_job_set_page_ranges(gtkPrintJob, ranges.ptr, cast(int) ranges.length);
391 	}
392 	
393 	/**
394 	 * Gets the GtkPageSet setting for this job.
395 	 * Returns: the GtkPageSet setting Since 3.0
396 	 */
397 	public GtkPageSet getPageSet()
398 	{
399 		// GtkPageSet gtk_print_job_get_page_set (GtkPrintJob *job);
400 		return gtk_print_job_get_page_set(gtkPrintJob);
401 	}
402 	
403 	/**
404 	 * Sets the GtkPageSet setting for this job.
405 	 * Params:
406 	 * pageSet = a GtkPageSet setting
407 	 * Since 3.0
408 	 */
409 	public void setPageSet(GtkPageSet pageSet)
410 	{
411 		// void gtk_print_job_set_page_set (GtkPrintJob *job,  GtkPageSet page_set);
412 		gtk_print_job_set_page_set(gtkPrintJob, pageSet);
413 	}
414 	
415 	/**
416 	 * Gets the number of copies of this job.
417 	 * Returns: the number of copies Since 3.0
418 	 */
419 	public int getNumCopies()
420 	{
421 		// gint gtk_print_job_get_num_copies (GtkPrintJob *job);
422 		return gtk_print_job_get_num_copies(gtkPrintJob);
423 	}
424 	
425 	/**
426 	 * Sets the number of copies for this job.
427 	 * Params:
428 	 * numCopies = the number of copies
429 	 * Since 3.0
430 	 */
431 	public void setNumCopies(int numCopies)
432 	{
433 		// void gtk_print_job_set_num_copies (GtkPrintJob *job,  gint num_copies);
434 		gtk_print_job_set_num_copies(gtkPrintJob, numCopies);
435 	}
436 	
437 	/**
438 	 * Gets the scale for this job (where 1.0 means unscaled).
439 	 * Returns: the scale Since 3.0
440 	 */
441 	public double getScale()
442 	{
443 		// gdouble gtk_print_job_get_scale (GtkPrintJob *job);
444 		return gtk_print_job_get_scale(gtkPrintJob);
445 	}
446 	
447 	/**
448 	 * Sets the scale for this job (where 1.0 means unscaled).
449 	 * Params:
450 	 * scale = the scale
451 	 * Since 3.0
452 	 */
453 	public void setScale(double scale)
454 	{
455 		// void gtk_print_job_set_scale (GtkPrintJob *job,  gdouble scale);
456 		gtk_print_job_set_scale(gtkPrintJob, scale);
457 	}
458 	
459 	/**
460 	 * Gets the n-up setting for this job.
461 	 * Returns: the n-up setting Since 3.0
462 	 */
463 	public uint getNUp()
464 	{
465 		// guint gtk_print_job_get_n_up (GtkPrintJob *job);
466 		return gtk_print_job_get_n_up(gtkPrintJob);
467 	}
468 	
469 	/**
470 	 * Sets the n-up setting for this job.
471 	 * Params:
472 	 * nUp = the n-up value
473 	 * Since 3.0
474 	 */
475 	public void setNUp(uint nUp)
476 	{
477 		// void gtk_print_job_set_n_up (GtkPrintJob *job,  guint n_up);
478 		gtk_print_job_set_n_up(gtkPrintJob, nUp);
479 	}
480 	
481 	/**
482 	 * Gets the n-up layout setting for this job.
483 	 * Returns: the n-up layout Since 3.0
484 	 */
485 	public GtkNumberUpLayout getNUpLayout()
486 	{
487 		// GtkNumberUpLayout gtk_print_job_get_n_up_layout (GtkPrintJob *job);
488 		return gtk_print_job_get_n_up_layout(gtkPrintJob);
489 	}
490 	
491 	/**
492 	 * Sets the n-up layout setting for this job.
493 	 * Params:
494 	 * layout = the n-up layout setting
495 	 * Since 3.0
496 	 */
497 	public void setNUpLayout(GtkNumberUpLayout layout)
498 	{
499 		// void gtk_print_job_set_n_up_layout (GtkPrintJob *job,  GtkNumberUpLayout layout);
500 		gtk_print_job_set_n_up_layout(gtkPrintJob, layout);
501 	}
502 	
503 	/**
504 	 * Gets whether the job is printed rotated.
505 	 * Returns: whether the job is printed rotated Since 3.0
506 	 */
507 	public int getRotate()
508 	{
509 		// gboolean gtk_print_job_get_rotate (GtkPrintJob *job);
510 		return gtk_print_job_get_rotate(gtkPrintJob);
511 	}
512 	
513 	/**
514 	 * Sets whether this job is printed rotated.
515 	 * Params:
516 	 * rotate = whether to print rotated
517 	 * Since 3.0
518 	 */
519 	public void setRotate(int rotate)
520 	{
521 		// void gtk_print_job_set_rotate (GtkPrintJob *job,  gboolean rotate);
522 		gtk_print_job_set_rotate(gtkPrintJob, rotate);
523 	}
524 	
525 	/**
526 	 * Gets whether this job is printed collated.
527 	 * Returns: whether the job is printed collated Since 3.0
528 	 */
529 	public int getCollate()
530 	{
531 		// gboolean gtk_print_job_get_collate (GtkPrintJob *job);
532 		return gtk_print_job_get_collate(gtkPrintJob);
533 	}
534 	
535 	/**
536 	 * Sets whether this job is printed collated.
537 	 * Params:
538 	 * collate = whether the job is printed collated
539 	 * Since 3.0
540 	 */
541 	public void setCollate(int collate)
542 	{
543 		// void gtk_print_job_set_collate (GtkPrintJob *job,  gboolean collate);
544 		gtk_print_job_set_collate(gtkPrintJob, collate);
545 	}
546 	
547 	/**
548 	 * Gets whether this job is printed reversed.
549 	 * Returns: whether the job is printed reversed. Since 3.0
550 	 */
551 	public int getReverse()
552 	{
553 		// gboolean gtk_print_job_get_reverse (GtkPrintJob *job);
554 		return gtk_print_job_get_reverse(gtkPrintJob);
555 	}
556 	
557 	/**
558 	 * Sets whether this job is printed reversed.
559 	 * Params:
560 	 * reverse = whether the job is printed reversed
561 	 * Since 3.0
562 	 */
563 	public void setReverse(int reverse)
564 	{
565 		// void gtk_print_job_set_reverse (GtkPrintJob *job,  gboolean reverse);
566 		gtk_print_job_set_reverse(gtkPrintJob, reverse);
567 	}
568 }