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  = GtkPrinter.html
27  * outPack = gtk
28  * outFile = Printer
29  * strct   = GtkPrinter
30  * realStrct=
31  * ctorStrct=
32  * clss    = Printer
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_printer_
41  * 	- gtk_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- glib.ListG
49  * 	- gtk.PageSetup
50  * structWrap:
51  * 	- GList* -> ListG
52  * 	- GtkPageSetup* -> PageSetup
53  * 	- GtkPrinter* -> Printer
54  * module aliases:
55  * local aliases:
56  * overrides:
57  */
58 
59 module gtk.Printer;
60 
61 public  import gtkc.gtktypes;
62 
63 private import gtkc.gtk;
64 private import glib.ConstructionException;
65 private import gobject.ObjectG;
66 
67 private import gobject.Signals;
68 public  import gtkc.gdktypes;
69 private import glib.Str;
70 private import glib.ListG;
71 private import gtk.PageSetup;
72 
73 
74 private import gobject.ObjectG;
75 
76 /**
77  * A GtkPrinter object represents a printer. You only need to
78  * deal directly with printers if you use the non-portable
79  * GtkPrintUnixDialog API.
80  *
81  * A GtkPrinter allows to get status information about the printer,
82  * such as its description, its location, the number of queued jobs,
83  * etc. Most importantly, a GtkPrinter object can be used to create
84  * a GtkPrintJob object, which lets you print to the printer.
85  *
86  * Printing support was added in GTK+ 2.10.
87  */
88 public class Printer : ObjectG
89 {
90 	
91 	/** the main Gtk struct */
92 	protected GtkPrinter* gtkPrinter;
93 	
94 	
95 	/** Get the main Gtk struct */
96 	public GtkPrinter* getPrinterStruct()
97 	{
98 		return gtkPrinter;
99 	}
100 	
101 	
102 	/** the main Gtk struct as a void* */
103 	protected override void* getStruct()
104 	{
105 		return cast(void*)gtkPrinter;
106 	}
107 	
108 	/**
109 	 * Sets our main struct and passes it to the parent class
110 	 */
111 	public this (GtkPrinter* gtkPrinter)
112 	{
113 		super(cast(GObject*)gtkPrinter);
114 		this.gtkPrinter = gtkPrinter;
115 	}
116 	
117 	protected override void setStruct(GObject* obj)
118 	{
119 		super.setStruct(obj);
120 		gtkPrinter = cast(GtkPrinter*)obj;
121 	}
122 	
123 	/**
124 	 */
125 	int[string] connectedSignals;
126 	
127 	void delegate(gboolean, Printer)[] onDetailsAcquiredListeners;
128 	/**
129 	 * Gets emitted in response to a request for detailed information
130 	 * about a printer from the print backend. The success parameter
131 	 * indicates if the information was actually obtained.
132 	 * TRUE if the details were successfully acquired
133 	 * Since 2.10
134 	 */
135 	void addOnDetailsAcquired(void delegate(gboolean, Printer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
136 	{
137 		if ( !("details-acquired" in connectedSignals) )
138 		{
139 			Signals.connectData(
140 			getStruct(),
141 			"details-acquired",
142 			cast(GCallback)&callBackDetailsAcquired,
143 			cast(void*)this,
144 			null,
145 			connectFlags);
146 			connectedSignals["details-acquired"] = 1;
147 		}
148 		onDetailsAcquiredListeners ~= dlg;
149 	}
150 	extern(C) static void callBackDetailsAcquired(GtkPrinter* printerStruct, gboolean success, Printer _printer)
151 	{
152 		foreach ( void delegate(gboolean, Printer) dlg ; _printer.onDetailsAcquiredListeners )
153 		{
154 			dlg(success, _printer);
155 		}
156 	}
157 	
158 	
159 	/**
160 	 * Creates a new GtkPrinter.
161 	 * Since 2.10
162 	 * Params:
163 	 * name = the name of the printer
164 	 * backend = a GtkPrintBackend
165 	 * Throws: ConstructionException GTK+ fails to create the object.
166 	 */
167 	public this (string name, GtkPrintBackend* backend, int virtua)
168 	{
169 		// GtkPrinter * gtk_printer_new (const gchar *name,  GtkPrintBackend *backend,  gboolean virtual_);
170 		auto p = gtk_printer_new(Str.toStringz(name), backend, virtua);
171 		if(p is null)
172 		{
173 			throw new ConstructionException("null returned by gtk_printer_new(Str.toStringz(name), backend, virtua)");
174 		}
175 		this(cast(GtkPrinter*) p);
176 	}
177 	
178 	/**
179 	 * Returns the backend of the printer.
180 	 * Since 2.10
181 	 * Returns: the backend of printer. [transfer none]
182 	 */
183 	public GtkPrintBackend* getBackend()
184 	{
185 		// GtkPrintBackend * gtk_printer_get_backend (GtkPrinter *printer);
186 		return gtk_printer_get_backend(gtkPrinter);
187 	}
188 	
189 	/**
190 	 * Returns the name of the printer.
191 	 * Since 2.10
192 	 * Returns: the name of printer
193 	 */
194 	public string getName()
195 	{
196 		// const gchar * gtk_printer_get_name (GtkPrinter *printer);
197 		return Str.toString(gtk_printer_get_name(gtkPrinter));
198 	}
199 	
200 	/**
201 	 * Returns the state message describing the current state
202 	 * of the printer.
203 	 * Since 2.10
204 	 * Returns: the state message of printer
205 	 */
206 	public string getStateMessage()
207 	{
208 		// const gchar * gtk_printer_get_state_message (GtkPrinter *printer);
209 		return Str.toString(gtk_printer_get_state_message(gtkPrinter));
210 	}
211 	
212 	/**
213 	 * Gets the description of the printer.
214 	 * Since 2.10
215 	 * Returns: the description of printer
216 	 */
217 	public string getDescription()
218 	{
219 		// const gchar * gtk_printer_get_description (GtkPrinter *printer);
220 		return Str.toString(gtk_printer_get_description(gtkPrinter));
221 	}
222 	
223 	/**
224 	 * Returns a description of the location of the printer.
225 	 * Since 2.10
226 	 * Returns: the location of printer
227 	 */
228 	public string getLocation()
229 	{
230 		// const gchar * gtk_printer_get_location (GtkPrinter *printer);
231 		return Str.toString(gtk_printer_get_location(gtkPrinter));
232 	}
233 	
234 	/**
235 	 * Gets the name of the icon to use for the printer.
236 	 * Since 2.10
237 	 * Returns: the icon name for printer
238 	 */
239 	public string getIconName()
240 	{
241 		// const gchar * gtk_printer_get_icon_name (GtkPrinter *printer);
242 		return Str.toString(gtk_printer_get_icon_name(gtkPrinter));
243 	}
244 	
245 	/**
246 	 * Gets the number of jobs currently queued on the printer.
247 	 * Since 2.10
248 	 * Returns: the number of jobs on printer
249 	 */
250 	public int getJobCount()
251 	{
252 		// gint gtk_printer_get_job_count (GtkPrinter *printer);
253 		return gtk_printer_get_job_count(gtkPrinter);
254 	}
255 	
256 	/**
257 	 * Returns whether the printer is currently active (i.e.
258 	 * accepts new jobs).
259 	 * Since 2.10
260 	 * Returns: TRUE if printer is active
261 	 */
262 	public int isActive()
263 	{
264 		// gboolean gtk_printer_is_active (GtkPrinter *printer);
265 		return gtk_printer_is_active(gtkPrinter);
266 	}
267 	
268 	/**
269 	 * Returns whether the printer is currently paused.
270 	 * A paused printer still accepts jobs, but it is not
271 	 * printing them.
272 	 * Since 2.14
273 	 * Returns: TRUE if printer is paused
274 	 */
275 	public int isPaused()
276 	{
277 		// gboolean gtk_printer_is_paused (GtkPrinter *printer);
278 		return gtk_printer_is_paused(gtkPrinter);
279 	}
280 	
281 	/**
282 	 * Returns whether the printer is accepting jobs
283 	 * Since 2.14
284 	 * Returns: TRUE if printer is accepting jobs
285 	 */
286 	public int isAcceptingJobs()
287 	{
288 		// gboolean gtk_printer_is_accepting_jobs (GtkPrinter *printer);
289 		return gtk_printer_is_accepting_jobs(gtkPrinter);
290 	}
291 	
292 	/**
293 	 * Returns whether the printer is virtual (i.e. does not
294 	 * represent actual printer hardware, but something like
295 	 * a CUPS class).
296 	 * Since 2.10
297 	 * Returns: TRUE if printer is virtual
298 	 */
299 	public int isVirtual()
300 	{
301 		// gboolean gtk_printer_is_virtual (GtkPrinter *printer);
302 		return gtk_printer_is_virtual(gtkPrinter);
303 	}
304 	
305 	/**
306 	 * Returns whether the printer is the default printer.
307 	 * Since 2.10
308 	 * Returns: TRUE if printer is the default
309 	 */
310 	public int isDefault()
311 	{
312 		// gboolean gtk_printer_is_default (GtkPrinter *printer);
313 		return gtk_printer_is_default(gtkPrinter);
314 	}
315 	
316 	/**
317 	 * Returns whether the printer accepts input in
318 	 * PostScript format.
319 	 * Since 2.10
320 	 * Returns: TRUE if printer accepts PostScript
321 	 */
322 	public int acceptsPs()
323 	{
324 		// gboolean gtk_printer_accepts_ps (GtkPrinter *printer);
325 		return gtk_printer_accepts_ps(gtkPrinter);
326 	}
327 	
328 	/**
329 	 * Returns whether the printer accepts input in
330 	 * PDF format.
331 	 * Since 2.10
332 	 * Returns: TRUE if printer accepts PDF
333 	 */
334 	public int acceptsPdf()
335 	{
336 		// gboolean gtk_printer_accepts_pdf (GtkPrinter *printer);
337 		return gtk_printer_accepts_pdf(gtkPrinter);
338 	}
339 	
340 	/**
341 	 * Lists all the paper sizes printer supports.
342 	 * This will return and empty list unless the printer's details are
343 	 * available, see gtk_printer_has_details() and gtk_printer_request_details().
344 	 * Since 2.12
345 	 * Returns: a newly allocated list of newly allocated GtkPageSetup s. [element-type GtkPageSetup][transfer full]
346 	 */
347 	public ListG listPapers()
348 	{
349 		// GList * gtk_printer_list_papers (GtkPrinter *printer);
350 		auto p = gtk_printer_list_papers(gtkPrinter);
351 		
352 		if(p is null)
353 		{
354 			return null;
355 		}
356 		
357 		return ObjectG.getDObject!(ListG)(cast(GList*) p);
358 	}
359 	
360 	/**
361 	 * Compares two printers.
362 	 * Since 2.10
363 	 * Params:
364 	 * a = a GtkPrinter
365 	 * b = another GtkPrinter
366 	 * Returns: 0 if the printer match, a negative value if a < b, or a positive value if a > b
367 	 */
368 	public int compare(Printer b)
369 	{
370 		// gint gtk_printer_compare (GtkPrinter *a,  GtkPrinter *b);
371 		return gtk_printer_compare(gtkPrinter, (b is null) ? null : b.getPrinterStruct());
372 	}
373 	
374 	/**
375 	 * Returns whether the printer details are available.
376 	 * Since 2.12
377 	 * Returns: TRUE if printer details are available
378 	 */
379 	public int hasDetails()
380 	{
381 		// gboolean gtk_printer_has_details (GtkPrinter *printer);
382 		return gtk_printer_has_details(gtkPrinter);
383 	}
384 	
385 	/**
386 	 * Requests the printer details. When the details are available,
387 	 * the "details-acquired" signal will be emitted on printer.
388 	 * Since 2.12
389 	 */
390 	public void requestDetails()
391 	{
392 		// void gtk_printer_request_details (GtkPrinter *printer);
393 		gtk_printer_request_details(gtkPrinter);
394 	}
395 	
396 	/**
397 	 * Returns the printer's capabilities.
398 	 * This is useful when you're using GtkPrintUnixDialog's manual-capabilities
399 	 * setting and need to know which settings the printer can handle and which
400 	 * you must handle yourself.
401 	 * This will return 0 unless the printer's details are available, see
402 	 * gtk_printer_has_details() and gtk_printer_request_details().
403 	 * Since 2.12
404 	 * Returns: the printer's capabilities
405 	 */
406 	public GtkPrintCapabilities getCapabilities()
407 	{
408 		// GtkPrintCapabilities gtk_printer_get_capabilities (GtkPrinter *printer);
409 		return gtk_printer_get_capabilities(gtkPrinter);
410 	}
411 	
412 	/**
413 	 * Returns default page size of printer.
414 	 * Since 2.14
415 	 * Returns: a newly allocated GtkPageSetup with default page size of the printer.
416 	 */
417 	public PageSetup getDefaultPageSize()
418 	{
419 		// GtkPageSetup * gtk_printer_get_default_page_size (GtkPrinter *printer);
420 		auto p = gtk_printer_get_default_page_size(gtkPrinter);
421 		
422 		if(p is null)
423 		{
424 			return null;
425 		}
426 		
427 		return ObjectG.getDObject!(PageSetup)(cast(GtkPageSetup*) p);
428 	}
429 	
430 	/**
431 	 * Retrieve the hard margins of printer, i.e. the margins that define
432 	 * the area at the borders of the paper that the printer cannot print to.
433 	 * Note: This will not succeed unless the printer's details are available,
434 	 * see gtk_printer_has_details() and gtk_printer_request_details().
435 	 * Since 2.20
436 	 * Params:
437 	 * top = a location to store the top margin in. [out]
438 	 * bottom = a location to store the bottom margin in. [out]
439 	 * left = a location to store the left margin in. [out]
440 	 * right = a location to store the right margin in. [out]
441 	 * Returns: TRUE iff the hard margins were retrieved
442 	 */
443 	public int getHardMargins(out double top, out double bottom, out double left, out double right)
444 	{
445 		// gboolean gtk_printer_get_hard_margins (GtkPrinter *printer,  gdouble *top,  gdouble *bottom,  gdouble *left,  gdouble *right);
446 		return gtk_printer_get_hard_margins(gtkPrinter, &top, &bottom, &left, &right);
447 	}
448 	
449 	/**
450 	 * Calls a function for all GtkPrinters.
451 	 * If func returns TRUE, the enumeration is stopped.
452 	 * Since 2.10
453 	 * Params:
454 	 * func = a function to call for each printer
455 	 * data = user data to pass to func
456 	 * destroy = function to call if data is no longer needed
457 	 * wait = if TRUE, wait in a recursive mainloop until
458 	 * all printers are enumerated; otherwise return early
459 	 */
460 	public static void enumeratePrinters(GtkPrinterFunc func, void* data, GDestroyNotify destroy, int wait)
461 	{
462 		// void gtk_enumerate_printers (GtkPrinterFunc func,  gpointer data,  GDestroyNotify destroy,  gboolean wait);
463 		gtk_enumerate_printers(func, data, destroy, wait);
464 	}
465 }