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 = gtk-High-level-Printing-API.html 27 * outPack = gtk 28 * outFile = PrintOperation 29 * strct = GtkPrintOperation 30 * realStrct= 31 * ctorStrct= 32 * clss = PrintOperation 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * - PrintOperationPreviewIF 40 * prefixes: 41 * - gtk_print_operation_ 42 * omit structs: 43 * omit prefixes: 44 * - gtk_print_operation_preview_ 45 * omit code: 46 * omit signals: 47 * - got-page-size 48 * - ready 49 * imports: 50 * - glib.Str 51 * - gtk.Widget 52 * - gtk.Window 53 * - gtk.PageSetup 54 * - gtk.PrintContext 55 * - gtk.PrintSettings 56 * - glib.ErrorG 57 * - glib.GException 58 * - gtk.PrintOperationPreviewT 59 * - gtk.PrintOperationPreviewIF 60 * structWrap: 61 * - GtkPageSetup* -> PageSetup 62 * - GtkPrintContext* -> PrintContext 63 * - GtkPrintSettings* -> PrintSettings 64 * - GtkWidget* -> Widget 65 * - GtkWindow* -> Window 66 * module aliases: 67 * local aliases: 68 * overrides: 69 */ 70 71 module gtk.PrintOperation; 72 73 public import gtkc.gtktypes; 74 75 private import gtkc.gtk; 76 private import glib.ConstructionException; 77 private import gobject.ObjectG; 78 79 private import gobject.Signals; 80 public import gtkc.gdktypes; 81 82 private import glib.Str; 83 private import gtk.Widget; 84 private import gtk.Window; 85 private import gtk.PageSetup; 86 private import gtk.PrintContext; 87 private import gtk.PrintSettings; 88 private import glib.ErrorG; 89 private import glib.GException; 90 private import gtk.PrintOperationPreviewT; 91 private import gtk.PrintOperationPreviewIF; 92 93 94 95 private import gobject.ObjectG; 96 97 /** 98 * Description 99 * GtkPrintOperation is the high-level, portable printing API. It looks 100 * a bit different than other GTK+ dialogs such as the GtkFileChooser, 101 * since some platforms don't expose enough infrastructure to implement 102 * a good print dialog. On such platforms, GtkPrintOperation uses the 103 * native print dialog. On platforms which do not provide a native 104 * print dialog, GTK+ uses its own, see GtkPrintUnixDialog. 105 * The typical way to use the high-level printing API is to create a 106 * GtkPrintOperation object with gtk_print_operation_new() when the user 107 * selects to print. Then you set some properties on it, e.g. the page size, 108 * any GtkPrintSettings from previous print operations, the number of pages, 109 * the current page, etc. 110 * Then you start the print operation by calling gtk_print_operation_run(). 111 * It will then show a dialog, let the user select a printer and options. 112 * When the user finished the dialog various signals will be emitted on the 113 * GtkPrintOperation, the main one being ::draw-page, which you are supposed 114 * to catch and render the page on the provided GtkPrintContext using Cairo. 115 * $(DDOC_COMMENT example) 116 * By default GtkPrintOperation uses an external application to do 117 * print preview. To implement a custom print preview, an application 118 * must connect to the preview signal. The functions 119 * gtk_print_operation_print_preview_render_page(), 120 * gtk_print_operation_preview_end_preview() and 121 * gtk_print_operation_preview_is_selected() are useful 122 * when implementing a print preview. 123 * Printing support was added in GTK+ 2.10. 124 */ 125 public class PrintOperation : ObjectG, PrintOperationPreviewIF 126 { 127 128 /** the main Gtk struct */ 129 protected GtkPrintOperation* gtkPrintOperation; 130 131 132 public GtkPrintOperation* getPrintOperationStruct() 133 { 134 return gtkPrintOperation; 135 } 136 137 138 /** the main Gtk struct as a void* */ 139 protected override void* getStruct() 140 { 141 return cast(void*)gtkPrintOperation; 142 } 143 144 /** 145 * Sets our main struct and passes it to the parent class 146 */ 147 public this (GtkPrintOperation* gtkPrintOperation) 148 { 149 super(cast(GObject*)gtkPrintOperation); 150 this.gtkPrintOperation = gtkPrintOperation; 151 } 152 153 protected override void setStruct(GObject* obj) 154 { 155 super.setStruct(obj); 156 gtkPrintOperation = cast(GtkPrintOperation*)obj; 157 } 158 159 // add the PrintOperationPreview capabilities 160 mixin PrintOperationPreviewT!(GtkPrintOperation); 161 162 /** 163 */ 164 int[string] connectedSignals; 165 166 void delegate(PrintContext, PrintOperation)[] onBeginPrintListeners; 167 /** 168 * Emitted after the user has finished changing print settings 169 * in the dialog, before the actual rendering starts. 170 * A typical use for ::begin-print is to use the parameters from the 171 * GtkPrintContext and paginate the document accordingly, and then 172 * set the number of pages with gtk_print_operation_set_n_pages(). 173 * Since 2.10 174 */ 175 void addOnBeginPrint(void delegate(PrintContext, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 176 { 177 if ( !("begin-print" in connectedSignals) ) 178 { 179 Signals.connectData( 180 getStruct(), 181 "begin-print", 182 cast(GCallback)&callBackBeginPrint, 183 cast(void*)this, 184 null, 185 connectFlags); 186 connectedSignals["begin-print"] = 1; 187 } 188 onBeginPrintListeners ~= dlg; 189 } 190 extern(C) static void callBackBeginPrint(GtkPrintOperation* operationStruct, GtkPrintContext* context, PrintOperation _printOperation) 191 { 192 foreach ( void delegate(PrintContext, PrintOperation) dlg ; _printOperation.onBeginPrintListeners ) 193 { 194 dlg(ObjectG.getDObject!(PrintContext)(context), _printOperation); 195 } 196 } 197 198 GObject* delegate(PrintOperation)[] onCreateCustomWidgetListeners; 199 /** 200 * Emitted when displaying the print dialog. If you return a 201 * widget in a handler for this signal it will be added to a custom 202 * tab in the print dialog. You typically return a container widget 203 * with multiple widgets in it. 204 * The print dialog owns the returned widget, and its lifetime is not 205 * controlled by the application. However, the widget is guaranteed 206 * to stay around until the "custom-widget-apply" 207 * signal is emitted on the operation. Then you can read out any 208 * information you need from the widgets. 209 * Since 2.10 210 */ 211 void addOnCreateCustomWidget(GObject* delegate(PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 212 { 213 if ( !("create-custom-widget" in connectedSignals) ) 214 { 215 Signals.connectData( 216 getStruct(), 217 "create-custom-widget", 218 cast(GCallback)&callBackCreateCustomWidget, 219 cast(void*)this, 220 null, 221 connectFlags); 222 connectedSignals["create-custom-widget"] = 1; 223 } 224 onCreateCustomWidgetListeners ~= dlg; 225 } 226 extern(C) static void callBackCreateCustomWidget(GtkPrintOperation* operationStruct, PrintOperation _printOperation) 227 { 228 foreach ( GObject* delegate(PrintOperation) dlg ; _printOperation.onCreateCustomWidgetListeners ) 229 { 230 dlg(_printOperation); 231 } 232 } 233 234 void delegate(Widget, PrintOperation)[] onCustomWidgetApplyListeners; 235 /** 236 * Emitted right before "begin-print" if you added 237 * a custom widget in the "create-custom-widget" handler. 238 * When you get this signal you should read the information from the 239 * custom widgets, as the widgets are not guaraneed to be around at a 240 * later time. 241 * Since 2.10 242 */ 243 void addOnCustomWidgetApply(void delegate(Widget, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 244 { 245 if ( !("custom-widget-apply" in connectedSignals) ) 246 { 247 Signals.connectData( 248 getStruct(), 249 "custom-widget-apply", 250 cast(GCallback)&callBackCustomWidgetApply, 251 cast(void*)this, 252 null, 253 connectFlags); 254 connectedSignals["custom-widget-apply"] = 1; 255 } 256 onCustomWidgetApplyListeners ~= dlg; 257 } 258 extern(C) static void callBackCustomWidgetApply(GtkPrintOperation* operationStruct, GtkWidget* widget, PrintOperation _printOperation) 259 { 260 foreach ( void delegate(Widget, PrintOperation) dlg ; _printOperation.onCustomWidgetApplyListeners ) 261 { 262 dlg(ObjectG.getDObject!(Widget)(widget), _printOperation); 263 } 264 } 265 266 void delegate(GtkPrintOperationResult, PrintOperation)[] onDoneListeners; 267 /** 268 * Emitted when the print operation run has finished doing 269 * everything required for printing. 270 * result gives you information about what happened during the run. 271 * If result is GTK_PRINT_OPERATION_RESULT_ERROR then you can call 272 * gtk_print_operation_get_error() for more information. 273 * If you enabled print status tracking then 274 * gtk_print_operation_is_finished() may still return FALSE 275 * after "done" was emitted. 276 * Since 2.10 277 */ 278 void addOnDone(void delegate(GtkPrintOperationResult, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 279 { 280 if ( !("done" in connectedSignals) ) 281 { 282 Signals.connectData( 283 getStruct(), 284 "done", 285 cast(GCallback)&callBackDone, 286 cast(void*)this, 287 null, 288 connectFlags); 289 connectedSignals["done"] = 1; 290 } 291 onDoneListeners ~= dlg; 292 } 293 extern(C) static void callBackDone(GtkPrintOperation* operationStruct, GtkPrintOperationResult result, PrintOperation _printOperation) 294 { 295 foreach ( void delegate(GtkPrintOperationResult, PrintOperation) dlg ; _printOperation.onDoneListeners ) 296 { 297 dlg(result, _printOperation); 298 } 299 } 300 301 void delegate(PrintContext, gint, PrintOperation)[] onDrawPageListeners; 302 /** 303 * Emitted for every page that is printed. The signal handler 304 * must render the page_nr's page onto the cairo context obtained 305 * from context using gtk_print_context_get_cairo_context(). 306 * $(DDOC_COMMENT example) 307 * Use gtk_print_operation_set_use_full_page() and 308 * gtk_print_operation_set_unit() before starting the print operation 309 * to set up the transformation of the cairo context according to your 310 * needs. 311 * Since 2.10 312 */ 313 void addOnDrawPage(void delegate(PrintContext, gint, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 314 { 315 if ( !("draw-page" in connectedSignals) ) 316 { 317 Signals.connectData( 318 getStruct(), 319 "draw-page", 320 cast(GCallback)&callBackDrawPage, 321 cast(void*)this, 322 null, 323 connectFlags); 324 connectedSignals["draw-page"] = 1; 325 } 326 onDrawPageListeners ~= dlg; 327 } 328 extern(C) static void callBackDrawPage(GtkPrintOperation* operationStruct, GtkPrintContext* context, gint pageNr, PrintOperation _printOperation) 329 { 330 foreach ( void delegate(PrintContext, gint, PrintOperation) dlg ; _printOperation.onDrawPageListeners ) 331 { 332 dlg(ObjectG.getDObject!(PrintContext)(context), pageNr, _printOperation); 333 } 334 } 335 336 void delegate(PrintContext, PrintOperation)[] onEndPrintListeners; 337 /** 338 * Emitted after all pages have been rendered. 339 * A handler for this signal can clean up any resources that have 340 * been allocated in the "begin-print" handler. 341 * Since 2.10 342 */ 343 void addOnEndPrint(void delegate(PrintContext, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 344 { 345 if ( !("end-print" in connectedSignals) ) 346 { 347 Signals.connectData( 348 getStruct(), 349 "end-print", 350 cast(GCallback)&callBackEndPrint, 351 cast(void*)this, 352 null, 353 connectFlags); 354 connectedSignals["end-print"] = 1; 355 } 356 onEndPrintListeners ~= dlg; 357 } 358 extern(C) static void callBackEndPrint(GtkPrintOperation* operationStruct, GtkPrintContext* context, PrintOperation _printOperation) 359 { 360 foreach ( void delegate(PrintContext, PrintOperation) dlg ; _printOperation.onEndPrintListeners ) 361 { 362 dlg(ObjectG.getDObject!(PrintContext)(context), _printOperation); 363 } 364 } 365 366 bool delegate(PrintContext, PrintOperation)[] onPaginateListeners; 367 /** 368 * Emitted after the "begin-print" signal, but before 369 * the actual rendering starts. It keeps getting emitted until a connected 370 * signal handler returns TRUE. 371 * The ::paginate signal is intended to be used for paginating a document 372 * in small chunks, to avoid blocking the user interface for a long 373 * time. The signal handler should update the number of pages using 374 * gtk_print_operation_set_n_pages(), and return TRUE if the document 375 * has been completely paginated. 376 * If you don't need to do pagination in chunks, you can simply do 377 * it all in the ::begin-print handler, and set the number of pages 378 * from there. 379 * TRUE if pagination is complete 380 * Since 2.10 381 */ 382 void addOnPaginate(bool delegate(PrintContext, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 383 { 384 if ( !("paginate" in connectedSignals) ) 385 { 386 Signals.connectData( 387 getStruct(), 388 "paginate", 389 cast(GCallback)&callBackPaginate, 390 cast(void*)this, 391 null, 392 connectFlags); 393 connectedSignals["paginate"] = 1; 394 } 395 onPaginateListeners ~= dlg; 396 } 397 extern(C) static gboolean callBackPaginate(GtkPrintOperation* operationStruct, GtkPrintContext* context, PrintOperation _printOperation) 398 { 399 foreach ( bool delegate(PrintContext, PrintOperation) dlg ; _printOperation.onPaginateListeners ) 400 { 401 if ( dlg(ObjectG.getDObject!(PrintContext)(context), _printOperation) ) 402 { 403 return 1; 404 } 405 } 406 407 return 0; 408 } 409 410 bool delegate(GtkPrintOperationPreview*, PrintContext, Window, PrintOperation)[] onPreviewListeners; 411 /** 412 * Gets emitted when a preview is requested from the native dialog. 413 * The default handler for this signal uses an external viewer 414 * application to preview. 415 * To implement a custom print preview, an application must return 416 * TRUE from its handler for this signal. In order to use the 417 * provided context for the preview implementation, it must be 418 * given a suitable cairo context with gtk_print_context_set_cairo_context(). 419 * The custom preview implementation can use 420 * gtk_print_operation_preview_is_selected() and 421 * gtk_print_operation_preview_render_page() to find pages which 422 * are selected for print and render them. The preview must be 423 * finished by calling gtk_print_operation_preview_end_preview() 424 * (typically in response to the user clicking a close button). 425 * TRUE if the listener wants to take over control of the preview 426 * Since 2.10 427 */ 428 void addOnPreview(bool delegate(GtkPrintOperationPreview*, PrintContext, Window, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 429 { 430 if ( !("preview" in connectedSignals) ) 431 { 432 Signals.connectData( 433 getStruct(), 434 "preview", 435 cast(GCallback)&callBackPreview, 436 cast(void*)this, 437 null, 438 connectFlags); 439 connectedSignals["preview"] = 1; 440 } 441 onPreviewListeners ~= dlg; 442 } 443 extern(C) static gboolean callBackPreview(GtkPrintOperation* operationStruct, GtkPrintOperationPreview* preview, GtkPrintContext* context, GtkWindow* parent, PrintOperation _printOperation) 444 { 445 foreach ( bool delegate(GtkPrintOperationPreview*, PrintContext, Window, PrintOperation) dlg ; _printOperation.onPreviewListeners ) 446 { 447 if ( dlg(preview, ObjectG.getDObject!(PrintContext)(context), ObjectG.getDObject!(Window)(parent), _printOperation) ) 448 { 449 return 1; 450 } 451 } 452 453 return 0; 454 } 455 456 void delegate(PrintContext, gint, PageSetup, PrintOperation)[] onRequestPageSetupListeners; 457 /** 458 * Emitted once for every page that is printed, to give 459 * the application a chance to modify the page setup. Any changes 460 * done to setup will be in force only for printing this page. 461 * Since 2.10 462 */ 463 void addOnRequestPageSetup(void delegate(PrintContext, gint, PageSetup, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 464 { 465 if ( !("request-page-setup" in connectedSignals) ) 466 { 467 Signals.connectData( 468 getStruct(), 469 "request-page-setup", 470 cast(GCallback)&callBackRequestPageSetup, 471 cast(void*)this, 472 null, 473 connectFlags); 474 connectedSignals["request-page-setup"] = 1; 475 } 476 onRequestPageSetupListeners ~= dlg; 477 } 478 extern(C) static void callBackRequestPageSetup(GtkPrintOperation* operationStruct, GtkPrintContext* context, gint pageNr, GtkPageSetup* setup, PrintOperation _printOperation) 479 { 480 foreach ( void delegate(PrintContext, gint, PageSetup, PrintOperation) dlg ; _printOperation.onRequestPageSetupListeners ) 481 { 482 dlg(ObjectG.getDObject!(PrintContext)(context), pageNr, ObjectG.getDObject!(PageSetup)(setup), _printOperation); 483 } 484 } 485 486 void delegate(PrintOperation)[] onStatusChangedListeners; 487 /** 488 * Emitted at between the various phases of the print operation. 489 * See GtkPrintStatus for the phases that are being discriminated. 490 * Use gtk_print_operation_get_status() to find out the current 491 * status. 492 * Since 2.10 493 */ 494 void addOnStatusChanged(void delegate(PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 495 { 496 if ( !("status-changed" in connectedSignals) ) 497 { 498 Signals.connectData( 499 getStruct(), 500 "status-changed", 501 cast(GCallback)&callBackStatusChanged, 502 cast(void*)this, 503 null, 504 connectFlags); 505 connectedSignals["status-changed"] = 1; 506 } 507 onStatusChangedListeners ~= dlg; 508 } 509 extern(C) static void callBackStatusChanged(GtkPrintOperation* operationStruct, PrintOperation _printOperation) 510 { 511 foreach ( void delegate(PrintOperation) dlg ; _printOperation.onStatusChangedListeners ) 512 { 513 dlg(_printOperation); 514 } 515 } 516 517 void delegate(Widget, PageSetup, PrintSettings, PrintOperation)[] onUpdateCustomWidgetListeners; 518 /** 519 * Emitted after change of selected printer. The actual page setup and 520 * print settings are passed to the custom widget, which can actualize 521 * itself according to this change. 522 * Since 2.18 523 */ 524 void addOnUpdateCustomWidget(void delegate(Widget, PageSetup, PrintSettings, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 525 { 526 if ( !("update-custom-widget" in connectedSignals) ) 527 { 528 Signals.connectData( 529 getStruct(), 530 "update-custom-widget", 531 cast(GCallback)&callBackUpdateCustomWidget, 532 cast(void*)this, 533 null, 534 connectFlags); 535 connectedSignals["update-custom-widget"] = 1; 536 } 537 onUpdateCustomWidgetListeners ~= dlg; 538 } 539 extern(C) static void callBackUpdateCustomWidget(GtkPrintOperation* operationStruct, GtkWidget* widget, GtkPageSetup* setup, GtkPrintSettings* settings, PrintOperation _printOperation) 540 { 541 foreach ( void delegate(Widget, PageSetup, PrintSettings, PrintOperation) dlg ; _printOperation.onUpdateCustomWidgetListeners ) 542 { 543 dlg(ObjectG.getDObject!(Widget)(widget), ObjectG.getDObject!(PageSetup)(setup), ObjectG.getDObject!(PrintSettings)(settings), _printOperation); 544 } 545 } 546 547 548 /** 549 * Creates a new GtkPrintOperation. 550 * Since 2.10 551 * Throws: ConstructionException GTK+ fails to create the object. 552 */ 553 public this () 554 { 555 // GtkPrintOperation * gtk_print_operation_new (void); 556 auto p = gtk_print_operation_new(); 557 if(p is null) 558 { 559 throw new ConstructionException("null returned by gtk_print_operation_new()"); 560 } 561 this(cast(GtkPrintOperation*) p); 562 } 563 564 /** 565 * Sets whether the gtk_print_operation_run() may return 566 * before the print operation is completed. Note that 567 * some platforms may not allow asynchronous operation. 568 * Since 2.10 569 * Params: 570 * allowAsync = TRUE to allow asynchronous operation 571 */ 572 public void setAllowAsync(int allowAsync) 573 { 574 // void gtk_print_operation_set_allow_async (GtkPrintOperation *op, gboolean allow_async); 575 gtk_print_operation_set_allow_async(gtkPrintOperation, allowAsync); 576 } 577 578 /** 579 * Call this when the result of a print operation is 580 * GTK_PRINT_OPERATION_RESULT_ERROR, either as returned by 581 * gtk_print_operation_run(), or in the "done" signal 582 * handler. The returned GError will contain more details on what went wrong. 583 * Since 2.10 584 */ 585 public void getError() 586 { 587 // void gtk_print_operation_get_error (GtkPrintOperation *op, GError **error); 588 GError* err = null; 589 590 gtk_print_operation_get_error(gtkPrintOperation, &err); 591 592 if (err !is null) 593 { 594 throw new GException( new ErrorG(err) ); 595 } 596 597 } 598 599 /** 600 * Makes default_page_setup the default page setup for op. 601 * This page setup will be used by gtk_print_operation_run(), 602 * but it can be overridden on a per-page basis by connecting 603 * to the "request-page-setup" signal. 604 * Since 2.10 605 * Params: 606 * defaultPageSetup = a GtkPageSetup, or NULL. [allow-none] 607 */ 608 public void setDefaultPageSetup(PageSetup defaultPageSetup) 609 { 610 // void gtk_print_operation_set_default_page_setup (GtkPrintOperation *op, GtkPageSetup *default_page_setup); 611 gtk_print_operation_set_default_page_setup(gtkPrintOperation, (defaultPageSetup is null) ? null : defaultPageSetup.getPageSetupStruct()); 612 } 613 614 /** 615 * Returns the default page setup, see 616 * gtk_print_operation_set_default_page_setup(). 617 * Since 2.10 618 * Returns: the default page setup. [transfer none] 619 */ 620 public PageSetup getDefaultPageSetup() 621 { 622 // GtkPageSetup * gtk_print_operation_get_default_page_setup (GtkPrintOperation *op); 623 auto p = gtk_print_operation_get_default_page_setup(gtkPrintOperation); 624 625 if(p is null) 626 { 627 return null; 628 } 629 630 return ObjectG.getDObject!(PageSetup)(cast(GtkPageSetup*) p); 631 } 632 633 /** 634 * Sets the print settings for op. This is typically used to 635 * re-establish print settings from a previous print operation, 636 * see gtk_print_operation_run(). 637 * Since 2.10 638 * Params: 639 * printSettings = GtkPrintSettings. [allow-none] 640 */ 641 public void setPrintSettings(PrintSettings printSettings) 642 { 643 // void gtk_print_operation_set_print_settings (GtkPrintOperation *op, GtkPrintSettings *print_settings); 644 gtk_print_operation_set_print_settings(gtkPrintOperation, (printSettings is null) ? null : printSettings.getPrintSettingsStruct()); 645 } 646 647 /** 648 * Returns the current print settings. 649 * Note that the return value is NULL until either 650 * gtk_print_operation_set_print_settings() or 651 * gtk_print_operation_run() have been called. 652 * Since 2.10 653 * Returns: the current print settings of op. [transfer none] 654 */ 655 public PrintSettings getPrintSettings() 656 { 657 // GtkPrintSettings * gtk_print_operation_get_print_settings (GtkPrintOperation *op); 658 auto p = gtk_print_operation_get_print_settings(gtkPrintOperation); 659 660 if(p is null) 661 { 662 return null; 663 } 664 665 return ObjectG.getDObject!(PrintSettings)(cast(GtkPrintSettings*) p); 666 } 667 668 /** 669 * Sets the name of the print job. The name is used to identify 670 * the job (e.g. in monitoring applications like eggcups). 671 * If you don't set a job name, GTK+ picks a default one by 672 * numbering successive print jobs. 673 * Since 2.10 674 * Params: 675 * jobName = a string that identifies the print job 676 */ 677 public void setJobName(string jobName) 678 { 679 // void gtk_print_operation_set_job_name (GtkPrintOperation *op, const gchar *job_name); 680 gtk_print_operation_set_job_name(gtkPrintOperation, Str.toStringz(jobName)); 681 } 682 683 /** 684 * Sets the number of pages in the document. 685 * This must be set to a positive number 686 * before the rendering starts. It may be set in a 687 * "begin-print" signal hander. 688 * Note that the page numbers passed to the 689 * "request-page-setup" 690 * and "draw-page" signals are 0-based, i.e. if 691 * the user chooses to print all pages, the last ::draw-page signal 692 * will be for page n_pages - 1. 693 * Since 2.10 694 * Params: 695 * nPages = the number of pages 696 */ 697 public void setNPages(int nPages) 698 { 699 // void gtk_print_operation_set_n_pages (GtkPrintOperation *op, gint n_pages); 700 gtk_print_operation_set_n_pages(gtkPrintOperation, nPages); 701 } 702 703 /** 704 * Returns the number of pages that will be printed. 705 * Note that this value is set during print preparation phase 706 * (GTK_PRINT_STATUS_PREPARING), so this function should never be 707 * called before the data generation phase (GTK_PRINT_STATUS_GENERATING_DATA). 708 * You can connect to the "status-changed" signal 709 * and call gtk_print_operation_get_n_pages_to_print() when 710 * print status is GTK_PRINT_STATUS_GENERATING_DATA. 711 * This is typically used to track the progress of print operation. 712 * Since 2.18 713 * Returns: the number of pages that will be printed 714 */ 715 public int getNPagesToPrint() 716 { 717 // gint gtk_print_operation_get_n_pages_to_print (GtkPrintOperation *op); 718 return gtk_print_operation_get_n_pages_to_print(gtkPrintOperation); 719 } 720 721 /** 722 * Sets the current page. 723 * If this is called before gtk_print_operation_run(), 724 * the user will be able to select to print only the current page. 725 * Note that this only makes sense for pre-paginated documents. 726 * Since 2.10 727 * Params: 728 * currentPage = the current page, 0-based 729 */ 730 public void setCurrentPage(int currentPage) 731 { 732 // void gtk_print_operation_set_current_page (GtkPrintOperation *op, gint current_page); 733 gtk_print_operation_set_current_page(gtkPrintOperation, currentPage); 734 } 735 736 /** 737 * If full_page is TRUE, the transformation for the cairo context 738 * obtained from GtkPrintContext puts the origin at the top left 739 * corner of the page (which may not be the top left corner of the 740 * sheet, depending on page orientation and the number of pages per 741 * sheet). Otherwise, the origin is at the top left corner of the 742 * imageable area (i.e. inside the margins). 743 * Since 2.10 744 * Params: 745 * fullPage = TRUE to set up the GtkPrintContext for the full page 746 */ 747 public void setUseFullPage(int fullPage) 748 { 749 // void gtk_print_operation_set_use_full_page (GtkPrintOperation *op, gboolean full_page); 750 gtk_print_operation_set_use_full_page(gtkPrintOperation, fullPage); 751 } 752 753 /** 754 * Sets up the transformation for the cairo context obtained from 755 * GtkPrintContext in such a way that distances are measured in 756 * units of unit. 757 * Since 2.10 758 * Params: 759 * unit = the unit to use 760 */ 761 public void setUnit(GtkUnit unit) 762 { 763 // void gtk_print_operation_set_unit (GtkPrintOperation *op, GtkUnit unit); 764 gtk_print_operation_set_unit(gtkPrintOperation, unit); 765 } 766 767 /** 768 * Sets up the GtkPrintOperation to generate a file instead 769 * of showing the print dialog. The indended use of this function 770 * is for implementing "Export to PDF" actions. Currently, PDF 771 * is the only supported format. 772 * "Print to PDF" support is independent of this and is done 773 * by letting the user pick the "Print to PDF" item from the list 774 * of printers in the print dialog. 775 * Since 2.10 776 * Params: 777 * filename = the filename for the exported file 778 */ 779 public void setExportFilename(string filename) 780 { 781 // void gtk_print_operation_set_export_filename (GtkPrintOperation *op, const gchar *filename); 782 gtk_print_operation_set_export_filename(gtkPrintOperation, Str.toStringz(filename)); 783 } 784 785 /** 786 * If show_progress is TRUE, the print operation will show a 787 * progress dialog during the print operation. 788 * Since 2.10 789 * Params: 790 * showProgress = TRUE to show a progress dialog 791 */ 792 public void setShowProgress(int showProgress) 793 { 794 // void gtk_print_operation_set_show_progress (GtkPrintOperation *op, gboolean show_progress); 795 gtk_print_operation_set_show_progress(gtkPrintOperation, showProgress); 796 } 797 798 /** 799 * If track_status is TRUE, the print operation will try to continue report 800 * on the status of the print job in the printer queues and printer. This 801 * can allow your application to show things like "out of paper" issues, 802 * and when the print job actually reaches the printer. 803 * This function is often implemented using some form of polling, so it should 804 * not be enabled unless needed. 805 * Since 2.10 806 * Params: 807 * trackStatus = TRUE to track status after printing 808 */ 809 public void setTrackPrintStatus(int trackStatus) 810 { 811 // void gtk_print_operation_set_track_print_status (GtkPrintOperation *op, gboolean track_status); 812 gtk_print_operation_set_track_print_status(gtkPrintOperation, trackStatus); 813 } 814 815 /** 816 * Sets the label for the tab holding custom widgets. 817 * Since 2.10 818 * Params: 819 * label = the label to use, or NULL to use the default label. [allow-none] 820 */ 821 public void setCustomTabLabel(string label) 822 { 823 // void gtk_print_operation_set_custom_tab_label (GtkPrintOperation *op, const gchar *label); 824 gtk_print_operation_set_custom_tab_label(gtkPrintOperation, Str.toStringz(label)); 825 } 826 827 /** 828 * Runs the print operation, by first letting the user modify 829 * print settings in the print dialog, and then print the document. 830 * Normally that this function does not return until the rendering of all 831 * pages is complete. You can connect to the 832 * "status-changed" signal on op to obtain some 833 * information about the progress of the print operation. 834 * Furthermore, it may use a recursive mainloop to show the print dialog. 835 * If you call gtk_print_operation_set_allow_async() or set the 836 * "allow-async" property the operation will run 837 * asynchronously if this is supported on the platform. The 838 * "done" signal will be emitted with the result of the 839 * operation when the it is done (i.e. when the dialog is canceled, or when 840 * the print succeeds or fails). 841 * $(DDOC_COMMENT example) 842 * Note that gtk_print_operation_run() can only be called once on a 843 * given GtkPrintOperation. 844 * Since 2.10 845 * Params: 846 * action = the action to start 847 * parent = Transient parent of the dialog. [allow-none] 848 * Returns: the result of the print operation. A return value of GTK_PRINT_OPERATION_RESULT_APPLY indicates that the printing was completed successfully. In this case, it is a good idea to obtain the used print settings with gtk_print_operation_get_print_settings() and store them for reuse with the next print operation. A value of GTK_PRINT_OPERATION_RESULT_IN_PROGRESS means the operation is running asynchronously, and will emit the "done" signal when done. 849 * Throws: GException on failure. 850 */ 851 public GtkPrintOperationResult run(GtkPrintOperationAction action, Window parent) 852 { 853 // GtkPrintOperationResult gtk_print_operation_run (GtkPrintOperation *op, GtkPrintOperationAction action, GtkWindow *parent, GError **error); 854 GError* err = null; 855 856 auto p = gtk_print_operation_run(gtkPrintOperation, action, (parent is null) ? null : parent.getWindowStruct(), &err); 857 858 if (err !is null) 859 { 860 throw new GException( new ErrorG(err) ); 861 } 862 863 return p; 864 } 865 866 /** 867 * Cancels a running print operation. This function may 868 * be called from a "begin-print", 869 * "paginate" or "draw-page" 870 * signal handler to stop the currently running print 871 * operation. 872 * Since 2.10 873 */ 874 public void cancel() 875 { 876 // void gtk_print_operation_cancel (GtkPrintOperation *op); 877 gtk_print_operation_cancel(gtkPrintOperation); 878 } 879 880 /** 881 * Signalize that drawing of particular page is complete. 882 * It is called after completion of page drawing (e.g. drawing in another 883 * thread). 884 * If gtk_print_operation_set_defer_drawing() was called before, then this function 885 * has to be called by application. In another case it is called by the library 886 * itself. 887 * Since 2.16 888 */ 889 public void drawPageFinish() 890 { 891 // void gtk_print_operation_draw_page_finish (GtkPrintOperation *op); 892 gtk_print_operation_draw_page_finish(gtkPrintOperation); 893 } 894 895 /** 896 * Sets up the GtkPrintOperation to wait for calling of 897 * gtk_print_operation_draw_page_finish() from application. It can 898 * be used for drawing page in another thread. 899 * This function must be called in the callback of "draw-page" signal. 900 * Since 2.16 901 */ 902 public void setDeferDrawing() 903 { 904 // void gtk_print_operation_set_defer_drawing (GtkPrintOperation *op); 905 gtk_print_operation_set_defer_drawing(gtkPrintOperation); 906 } 907 908 /** 909 * Returns the status of the print operation. 910 * Also see gtk_print_operation_get_status_string(). 911 * Since 2.10 912 * Returns: the status of the print operation 913 */ 914 public GtkPrintStatus getStatus() 915 { 916 // GtkPrintStatus gtk_print_operation_get_status (GtkPrintOperation *op); 917 return gtk_print_operation_get_status(gtkPrintOperation); 918 } 919 920 /** 921 * Returns a string representation of the status of the 922 * print operation. The string is translated and suitable 923 * for displaying the print status e.g. in a GtkStatusbar. 924 * Use gtk_print_operation_get_status() to obtain a status 925 * value that is suitable for programmatic use. 926 * Since 2.10 927 * Returns: a string representation of the status of the print operation 928 */ 929 public string getStatusString() 930 { 931 // const gchar * gtk_print_operation_get_status_string (GtkPrintOperation *op); 932 return Str.toString(gtk_print_operation_get_status_string(gtkPrintOperation)); 933 } 934 935 /** 936 * A convenience function to find out if the print operation 937 * is finished, either successfully (GTK_PRINT_STATUS_FINISHED) 938 * or unsuccessfully (GTK_PRINT_STATUS_FINISHED_ABORTED). 939 * Note: when you enable print status tracking the print operation 940 * can be in a non-finished state even after done has been called, as 941 * the operation status then tracks the print job status on the printer. 942 * Since 2.10 943 * Returns: TRUE, if the print operation is finished. 944 */ 945 public int isFinished() 946 { 947 // gboolean gtk_print_operation_is_finished (GtkPrintOperation *op); 948 return gtk_print_operation_is_finished(gtkPrintOperation); 949 } 950 951 /** 952 * Sets whether selection is supported by GtkPrintOperation. 953 * Since 2.18 954 * Params: 955 * supportSelection = TRUE to support selection 956 */ 957 public void setSupportSelection(int supportSelection) 958 { 959 // void gtk_print_operation_set_support_selection (GtkPrintOperation *op, gboolean support_selection); 960 gtk_print_operation_set_support_selection(gtkPrintOperation, supportSelection); 961 } 962 963 /** 964 * Gets the value of "support-selection" property. 965 * Since 2.18 966 * Returns: whether the application supports print of selection 967 */ 968 public int getSupportSelection() 969 { 970 // gboolean gtk_print_operation_get_support_selection (GtkPrintOperation *op); 971 return gtk_print_operation_get_support_selection(gtkPrintOperation); 972 } 973 974 /** 975 * Sets whether there is a selection to print. 976 * Application has to set number of pages to which the selection 977 * will draw by gtk_print_operation_set_n_pages() in a callback of 978 * "begin-print". 979 * Since 2.18 980 * Params: 981 * hasSelection = TRUE indicates that a selection exists 982 */ 983 public void setHasSelection(int hasSelection) 984 { 985 // void gtk_print_operation_set_has_selection (GtkPrintOperation *op, gboolean has_selection); 986 gtk_print_operation_set_has_selection(gtkPrintOperation, hasSelection); 987 } 988 989 /** 990 * Gets the value of "has-selection" property. 991 * Since 2.18 992 * Returns: whether there is a selection 993 */ 994 public int getHasSelection() 995 { 996 // gboolean gtk_print_operation_get_has_selection (GtkPrintOperation *op); 997 return gtk_print_operation_get_has_selection(gtkPrintOperation); 998 } 999 1000 /** 1001 * Embed page size combo box and orientation combo box into page setup page. 1002 * Selected page setup is stored as default page setup in GtkPrintOperation. 1003 * Since 2.18 1004 * Params: 1005 * embed = TRUE to embed page setup selection in the GtkPrintDialog 1006 */ 1007 public void setEmbedPageSetup(int embed) 1008 { 1009 // void gtk_print_operation_set_embed_page_setup (GtkPrintOperation *op, gboolean embed); 1010 gtk_print_operation_set_embed_page_setup(gtkPrintOperation, embed); 1011 } 1012 1013 /** 1014 * Gets the value of "embed-page-setup" property. 1015 * Since 2.18 1016 * Returns: whether page setup selection combos are embedded 1017 */ 1018 public int getEmbedPageSetup() 1019 { 1020 // gboolean gtk_print_operation_get_embed_page_setup (GtkPrintOperation *op); 1021 return gtk_print_operation_get_embed_page_setup(gtkPrintOperation); 1022 } 1023 1024 /** 1025 * Runs a page setup dialog, letting the user modify the values from 1026 * page_setup. If the user cancels the dialog, the returned GtkPageSetup 1027 * is identical to the passed in page_setup, otherwise it contains the 1028 * modifications done in the dialog. 1029 * Note that this function may use a recursive mainloop to show the page 1030 * setup dialog. See gtk_print_run_page_setup_dialog_async() if this is 1031 * a problem. 1032 * Since 2.10 1033 * Params: 1034 * parent = transient parent. [allow-none] 1035 * pageSetup = an existing GtkPageSetup. [allow-none] 1036 * settings = a GtkPrintSettings 1037 * Returns: a new GtkPageSetup. [transfer full] 1038 */ 1039 public static PageSetup gtkPrintRunPageSetupDialog(Window parent, PageSetup pageSetup, PrintSettings settings) 1040 { 1041 // GtkPageSetup * gtk_print_run_page_setup_dialog (GtkWindow *parent, GtkPageSetup *page_setup, GtkPrintSettings *settings); 1042 auto p = gtk_print_run_page_setup_dialog((parent is null) ? null : parent.getWindowStruct(), (pageSetup is null) ? null : pageSetup.getPageSetupStruct(), (settings is null) ? null : settings.getPrintSettingsStruct()); 1043 1044 if(p is null) 1045 { 1046 return null; 1047 } 1048 1049 return ObjectG.getDObject!(PageSetup)(cast(GtkPageSetup*) p); 1050 } 1051 1052 /** 1053 * Runs a page setup dialog, letting the user modify the values from page_setup. 1054 * In contrast to gtk_print_run_page_setup_dialog(), this function returns after 1055 * showing the page setup dialog on platforms that support this, and calls done_cb 1056 * from a signal handler for the ::response signal of the dialog. 1057 * Since 2.10 1058 * Params: 1059 * parent = transient parent, or NULL. [allow-none] 1060 * pageSetup = an existing GtkPageSetup, or NULL. [allow-none] 1061 * settings = a GtkPrintSettings 1062 * doneCb = a function to call when the user saves the modified page setup 1063 * data = user data to pass to done_cb 1064 */ 1065 public static void gtkPrintRunPageSetupDialogAsync(Window parent, PageSetup pageSetup, PrintSettings settings, GtkPageSetupDoneFunc doneCb, void* data) 1066 { 1067 // void gtk_print_run_page_setup_dialog_async (GtkWindow *parent, GtkPageSetup *page_setup, GtkPrintSettings *settings, GtkPageSetupDoneFunc done_cb, gpointer data); 1068 gtk_print_run_page_setup_dialog_async((parent is null) ? null : parent.getWindowStruct(), (pageSetup is null) ? null : pageSetup.getPageSetupStruct(), (settings is null) ? null : settings.getPrintSettingsStruct(), doneCb, data); 1069 } 1070 }