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