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