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  * 	- gtk_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- cairo.Surface
49  * 	- gtk.Printer
50  * 	- gtk.PageSetup
51  * 	- gtk.PrintSettings
52  * 	- glib.ErrorG
53  * 	- glib.GException
54  * structWrap:
55  * 	- GtkPageSetup* -> PageSetup
56  * 	- GtkPrintSettings* -> PrintSettings
57  * 	- GtkPrinter* -> Printer
58  * 	- cairo_surface_t* -> Surface
59  * module aliases:
60  * local aliases:
61  * overrides:
62  */
63 
64 module gtk.PrintJob;
65 
66 public  import gtkc.gtktypes;
67 
68 private import gtkc.gtk;
69 private import glib.ConstructionException;
70 private import gobject.ObjectG;
71 
72 private import gobject.Signals;
73 public  import gtkc.gdktypes;
74 
75 private import glib.Str;
76 private import cairo.Surface;
77 private import gtk.Printer;
78 private import gtk.PageSetup;
79 private import gtk.PrintSettings;
80 private import glib.ErrorG;
81 private import glib.GException;
82 
83 
84 
85 private import gobject.ObjectG;
86 
87 /**
88  * Description
89  * A GtkPrintJob object represents a job that is sent to a
90  * printer. You only need to deal directly with print jobs if
91  * you use the non-portable GtkPrintUnixDialog API.
92  * Use gtk_print_job_get_surface() to obtain the cairo surface
93  * onto which the pages must be drawn. Use gtk_print_job_send()
94  * to send the finished job to the printer. If you don't use cairo
95  * GtkPrintJob also supports printing of manually generated postscript,
96  * via gtk_print_job_set_source_file().
97  * Printing support was added in GTK+ 2.10.
98  */
99 public class PrintJob : ObjectG
100 {
101 	
102 	/** the main Gtk struct */
103 	protected GtkPrintJob* gtkPrintJob;
104 	
105 	
106 	public GtkPrintJob* getPrintJobStruct()
107 	{
108 		return gtkPrintJob;
109 	}
110 	
111 	
112 	/** the main Gtk struct as a void* */
113 	protected override void* getStruct()
114 	{
115 		return cast(void*)gtkPrintJob;
116 	}
117 	
118 	/**
119 	 * Sets our main struct and passes it to the parent class
120 	 */
121 	public this (GtkPrintJob* gtkPrintJob)
122 	{
123 		super(cast(GObject*)gtkPrintJob);
124 		this.gtkPrintJob = gtkPrintJob;
125 	}
126 	
127 	protected override void setStruct(GObject* obj)
128 	{
129 		super.setStruct(obj);
130 		gtkPrintJob = cast(GtkPrintJob*)obj;
131 	}
132 	
133 	/**
134 	 */
135 	int[string] connectedSignals;
136 	
137 	void delegate(PrintJob)[] onStatusChangedListeners;
138 	/**
139 	 * Gets emitted when the status of a job changes. The signal handler
140 	 * can use gtk_print_job_get_status() to obtain the new status.
141 	 * Since 2.10
142 	 */
143 	void addOnStatusChanged(void delegate(PrintJob) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
144 	{
145 		if ( !("status-changed" in connectedSignals) )
146 		{
147 			Signals.connectData(
148 			getStruct(),
149 			"status-changed",
150 			cast(GCallback)&callBackStatusChanged,
151 			cast(void*)this,
152 			null,
153 			connectFlags);
154 			connectedSignals["status-changed"] = 1;
155 		}
156 		onStatusChangedListeners ~= dlg;
157 	}
158 	extern(C) static void callBackStatusChanged(GtkPrintJob* jobStruct, PrintJob _printJob)
159 	{
160 		foreach ( void delegate(PrintJob) dlg ; _printJob.onStatusChangedListeners )
161 		{
162 			dlg(_printJob);
163 		}
164 	}
165 	
166 	
167 	/**
168 	 * Creates a new GtkPrintJob.
169 	 * Since 2.10
170 	 * Params:
171 	 * title = the job title
172 	 * printer = a GtkPrinter
173 	 * settings = a GtkPrintSettings
174 	 * pageSetup = a GtkPageSetup
175 	 * Throws: ConstructionException GTK+ fails to create the object.
176 	 */
177 	public this (string title, Printer printer, PrintSettings settings, PageSetup pageSetup)
178 	{
179 		// GtkPrintJob * gtk_print_job_new (const gchar *title,  GtkPrinter *printer,  GtkPrintSettings *settings,  GtkPageSetup *page_setup);
180 		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());
181 		if(p is null)
182 		{
183 			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())");
184 		}
185 		this(cast(GtkPrintJob*) p);
186 	}
187 	
188 	/**
189 	 * Gets the GtkPrintSettings of the print job.
190 	 * Since 2.10
191 	 * Returns: the settings of job. [transfer none]
192 	 */
193 	public PrintSettings getSettings()
194 	{
195 		// GtkPrintSettings * gtk_print_job_get_settings (GtkPrintJob *job);
196 		auto p = gtk_print_job_get_settings(gtkPrintJob);
197 		
198 		if(p is null)
199 		{
200 			return null;
201 		}
202 		
203 		return ObjectG.getDObject!(PrintSettings)(cast(GtkPrintSettings*) p);
204 	}
205 	
206 	/**
207 	 * Gets the GtkPrinter of the print job.
208 	 * Since 2.10
209 	 * Returns: the printer of job. [transfer none]
210 	 */
211 	public Printer getPrinter()
212 	{
213 		// GtkPrinter * gtk_print_job_get_printer (GtkPrintJob *job);
214 		auto p = gtk_print_job_get_printer(gtkPrintJob);
215 		
216 		if(p is null)
217 		{
218 			return null;
219 		}
220 		
221 		return ObjectG.getDObject!(Printer)(cast(GtkPrinter*) p);
222 	}
223 	
224 	/**
225 	 * Gets the job title.
226 	 * Since 2.10
227 	 * Returns: the title of job
228 	 */
229 	public string getTitle()
230 	{
231 		// const gchar * gtk_print_job_get_title (GtkPrintJob *job);
232 		return Str.toString(gtk_print_job_get_title(gtkPrintJob));
233 	}
234 	
235 	/**
236 	 * Gets the status of the print job.
237 	 * Since 2.10
238 	 * Returns: the status of job
239 	 */
240 	public GtkPrintStatus getStatus()
241 	{
242 		// GtkPrintStatus gtk_print_job_get_status (GtkPrintJob *job);
243 		return gtk_print_job_get_status(gtkPrintJob);
244 	}
245 	
246 	/**
247 	 * Make the GtkPrintJob send an existing document to the
248 	 * printing system. The file can be in any format understood
249 	 * by the platforms printing system (typically PostScript,
250 	 * but on many platforms PDF may work too). See
251 	 * gtk_printer_accepts_pdf() and gtk_printer_accepts_ps().
252 	 * Since 2.10
253 	 * Params:
254 	 * filename = the file to be printed
255 	 * Returns: FALSE if an error occurred
256 	 * Throws: GException on failure.
257 	 */
258 	public int setSourceFile(string filename)
259 	{
260 		// gboolean gtk_print_job_set_source_file (GtkPrintJob *job,  const gchar *filename,  GError **error);
261 		GError* err = null;
262 		
263 		auto p = gtk_print_job_set_source_file(gtkPrintJob, Str.toStringz(filename), &err);
264 		
265 		if (err !is null)
266 		{
267 			throw new GException( new ErrorG(err) );
268 		}
269 		
270 		return p;
271 	}
272 	
273 	/**
274 	 * Gets a cairo surface onto which the pages of
275 	 * the print job should be rendered.
276 	 * Since 2.10
277 	 * Returns: the cairo surface of job. [transfer none]
278 	 * Throws: GException on failure.
279 	 */
280 	public Surface getSurface()
281 	{
282 		// cairo_surface_t * gtk_print_job_get_surface (GtkPrintJob *job,  GError **error);
283 		GError* err = null;
284 		
285 		auto p = gtk_print_job_get_surface(gtkPrintJob, &err);
286 		
287 		if (err !is null)
288 		{
289 			throw new GException( new ErrorG(err) );
290 		}
291 		
292 		
293 		if(p is null)
294 		{
295 			return null;
296 		}
297 		
298 		return ObjectG.getDObject!(Surface)(cast(cairo_surface_t*) p);
299 	}
300 	
301 	/**
302 	 * Sends the print job off to the printer.
303 	 * Since 2.10
304 	 * Params:
305 	 * callback = function to call when the job completes or an error occurs
306 	 * userData = user data that gets passed to callback
307 	 * dnotify = destroy notify for user_data
308 	 */
309 	public void send(GtkPrintJobCompleteFunc callback, void* userData, GDestroyNotify dnotify)
310 	{
311 		// void gtk_print_job_send (GtkPrintJob *job,  GtkPrintJobCompleteFunc callback,  gpointer user_data,  GDestroyNotify dnotify);
312 		gtk_print_job_send(gtkPrintJob, callback, userData, dnotify);
313 	}
314 	
315 	/**
316 	 * If track_status is TRUE, the print job will try to continue report
317 	 * on the status of the print job in the printer queues and printer. This
318 	 * can allow your application to show things like "out of paper" issues,
319 	 * and when the print job actually reaches the printer.
320 	 * This function is often implemented using some form of polling, so it should
321 	 * not be enabled unless needed.
322 	 * Since 2.10
323 	 * Params:
324 	 * trackStatus = TRUE to track status after printing
325 	 */
326 	public void setTrackPrintStatus(int trackStatus)
327 	{
328 		// void gtk_print_job_set_track_print_status  (GtkPrintJob *job,  gboolean track_status);
329 		gtk_print_job_set_track_print_status(gtkPrintJob, trackStatus);
330 	}
331 	
332 	/**
333 	 * Returns wheter jobs will be tracked after printing.
334 	 * For details, see gtk_print_job_set_track_print_status().
335 	 * Since 2.10
336 	 * Returns: TRUE if print job status will be reported after printing
337 	 */
338 	public int getTrackPrintStatus()
339 	{
340 		// gboolean gtk_print_job_get_track_print_status  (GtkPrintJob *job);
341 		return gtk_print_job_get_track_print_status(gtkPrintJob);
342 	}
343 }