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 module gtk.PrintOperation; 26 27 private import glib.ConstructionException; 28 private import glib.ErrorG; 29 private import glib.GException; 30 private import glib.Str; 31 private import gobject.ObjectG; 32 private import gobject.Signals; 33 private import gtk.PageSetup; 34 private import gtk.PrintContext; 35 private import gtk.PrintOperationPreview; 36 private import gtk.PrintOperationPreviewIF; 37 private import gtk.PrintOperationPreviewT; 38 private import gtk.PrintSettings; 39 private import gtk.Widget; 40 private import gtk.Window; 41 private import gtkc.gtk; 42 public import gtkc.gtktypes; 43 private import std.algorithm; 44 45 46 /** 47 * GtkPrintOperation is the high-level, portable printing API. 48 * It looks a bit different than other GTK+ dialogs such as the 49 * #GtkFileChooser, since some platforms don’t expose enough 50 * infrastructure to implement a good print dialog. On such 51 * platforms, GtkPrintOperation uses the native print dialog. 52 * On platforms which do not provide a native print dialog, GTK+ 53 * uses its own, see #GtkPrintUnixDialog. 54 * 55 * The typical way to use the high-level printing API is to create 56 * a GtkPrintOperation object with gtk_print_operation_new() when 57 * the user selects to print. Then you set some properties on it, 58 * e.g. the page size, any #GtkPrintSettings from previous print 59 * operations, the number of pages, the current page, etc. 60 * 61 * Then you start the print operation by calling gtk_print_operation_run(). 62 * It will then show a dialog, let the user select a printer and 63 * options. When the user finished the dialog various signals will 64 * be emitted on the #GtkPrintOperation, the main one being 65 * #GtkPrintOperation::draw-page, which you are supposed to catch 66 * and render the page on the provided #GtkPrintContext using Cairo. 67 * 68 * # The high-level printing API 69 * 70 * |[<!-- language="C" --> 71 * static GtkPrintSettings *settings = NULL; 72 * 73 * static void 74 * do_print (void) 75 * { 76 * GtkPrintOperation *print; 77 * GtkPrintOperationResult res; 78 * 79 * print = gtk_print_operation_new (); 80 * 81 * if (settings != NULL) 82 * gtk_print_operation_set_print_settings (print, settings); 83 * 84 * g_signal_connect (print, "begin_print", G_CALLBACK (begin_print), NULL); 85 * g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), NULL); 86 * 87 * res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, 88 * GTK_WINDOW (main_window), NULL); 89 * 90 * if (res == GTK_PRINT_OPERATION_RESULT_APPLY) 91 * { 92 * if (settings != NULL) 93 * g_object_unref (settings); 94 * settings = g_object_ref (gtk_print_operation_get_print_settings (print)); 95 * } 96 * 97 * g_object_unref (print); 98 * } 99 * ]| 100 * 101 * By default GtkPrintOperation uses an external application to do 102 * print preview. To implement a custom print preview, an application 103 * must connect to the preview signal. The functions 104 * gtk_print_operation_preview_render_page(), 105 * gtk_print_operation_preview_end_preview() and 106 * gtk_print_operation_preview_is_selected() 107 * are useful when implementing a print preview. 108 */ 109 public class PrintOperation : ObjectG, PrintOperationPreviewIF 110 { 111 /** the main Gtk struct */ 112 protected GtkPrintOperation* gtkPrintOperation; 113 114 /** Get the main Gtk struct */ 115 public GtkPrintOperation* getPrintOperationStruct() 116 { 117 return gtkPrintOperation; 118 } 119 120 /** the main Gtk struct as a void* */ 121 protected override void* getStruct() 122 { 123 return cast(void*)gtkPrintOperation; 124 } 125 126 protected override void setStruct(GObject* obj) 127 { 128 gtkPrintOperation = cast(GtkPrintOperation*)obj; 129 super.setStruct(obj); 130 } 131 132 /** 133 * Sets our main struct and passes it to the parent class. 134 */ 135 public this (GtkPrintOperation* gtkPrintOperation, bool ownedRef = false) 136 { 137 this.gtkPrintOperation = gtkPrintOperation; 138 super(cast(GObject*)gtkPrintOperation, ownedRef); 139 } 140 141 // add the PrintOperationPreview capabilities 142 mixin PrintOperationPreviewT!(GtkPrintOperation); 143 144 145 /** */ 146 public static GType getType() 147 { 148 return gtk_print_operation_get_type(); 149 } 150 151 /** 152 * Creates a new #GtkPrintOperation. 153 * 154 * Returns: a new #GtkPrintOperation 155 * 156 * Since: 2.10 157 * 158 * Throws: ConstructionException GTK+ fails to create the object. 159 */ 160 public this() 161 { 162 auto p = gtk_print_operation_new(); 163 164 if(p is null) 165 { 166 throw new ConstructionException("null returned by new"); 167 } 168 169 this(cast(GtkPrintOperation*) p, true); 170 } 171 172 /** 173 * Cancels a running print operation. This function may 174 * be called from a #GtkPrintOperation::begin-print, 175 * #GtkPrintOperation::paginate or #GtkPrintOperation::draw-page 176 * signal handler to stop the currently running print 177 * operation. 178 * 179 * Since: 2.10 180 */ 181 public void cancel() 182 { 183 gtk_print_operation_cancel(gtkPrintOperation); 184 } 185 186 /** 187 * Signalize that drawing of particular page is complete. 188 * 189 * It is called after completion of page drawing (e.g. drawing in another 190 * thread). 191 * If gtk_print_operation_set_defer_drawing() was called before, then this function 192 * has to be called by application. In another case it is called by the library 193 * itself. 194 * 195 * Since: 2.16 196 */ 197 public void drawPageFinish() 198 { 199 gtk_print_operation_draw_page_finish(gtkPrintOperation); 200 } 201 202 /** 203 * Returns the default page setup, see 204 * gtk_print_operation_set_default_page_setup(). 205 * 206 * Returns: the default page setup 207 * 208 * Since: 2.10 209 */ 210 public PageSetup getDefaultPageSetup() 211 { 212 auto p = gtk_print_operation_get_default_page_setup(gtkPrintOperation); 213 214 if(p is null) 215 { 216 return null; 217 } 218 219 return ObjectG.getDObject!(PageSetup)(cast(GtkPageSetup*) p); 220 } 221 222 /** 223 * Gets the value of #GtkPrintOperation:embed-page-setup property. 224 * 225 * Returns: whether page setup selection combos are embedded 226 * 227 * Since: 2.18 228 */ 229 public bool getEmbedPageSetup() 230 { 231 return gtk_print_operation_get_embed_page_setup(gtkPrintOperation) != 0; 232 } 233 234 /** 235 * Call this when the result of a print operation is 236 * %GTK_PRINT_OPERATION_RESULT_ERROR, either as returned by 237 * gtk_print_operation_run(), or in the #GtkPrintOperation::done signal 238 * handler. The returned #GError will contain more details on what went wrong. 239 * 240 * Since: 2.10 241 * 242 * Throws: GException on failure. 243 */ 244 public void getError() 245 { 246 GError* err = null; 247 248 gtk_print_operation_get_error(gtkPrintOperation, &err); 249 250 if (err !is null) 251 { 252 throw new GException( new ErrorG(err) ); 253 } 254 } 255 256 /** 257 * Gets the value of #GtkPrintOperation:has-selection property. 258 * 259 * Returns: whether there is a selection 260 * 261 * Since: 2.18 262 */ 263 public bool getHasSelection() 264 { 265 return gtk_print_operation_get_has_selection(gtkPrintOperation) != 0; 266 } 267 268 /** 269 * Returns the number of pages that will be printed. 270 * 271 * Note that this value is set during print preparation phase 272 * (%GTK_PRINT_STATUS_PREPARING), so this function should never be 273 * called before the data generation phase (%GTK_PRINT_STATUS_GENERATING_DATA). 274 * You can connect to the #GtkPrintOperation::status-changed signal 275 * and call gtk_print_operation_get_n_pages_to_print() when 276 * print status is %GTK_PRINT_STATUS_GENERATING_DATA. 277 * This is typically used to track the progress of print operation. 278 * 279 * Returns: the number of pages that will be printed 280 * 281 * Since: 2.18 282 */ 283 public int getNPagesToPrint() 284 { 285 return gtk_print_operation_get_n_pages_to_print(gtkPrintOperation); 286 } 287 288 /** 289 * Returns the current print settings. 290 * 291 * Note that the return value is %NULL until either 292 * gtk_print_operation_set_print_settings() or 293 * gtk_print_operation_run() have been called. 294 * 295 * Returns: the current print settings of @op. 296 * 297 * Since: 2.10 298 */ 299 public PrintSettings getPrintSettings() 300 { 301 auto p = gtk_print_operation_get_print_settings(gtkPrintOperation); 302 303 if(p is null) 304 { 305 return null; 306 } 307 308 return ObjectG.getDObject!(PrintSettings)(cast(GtkPrintSettings*) p); 309 } 310 311 /** 312 * Returns the status of the print operation. 313 * Also see gtk_print_operation_get_status_string(). 314 * 315 * Returns: the status of the print operation 316 * 317 * Since: 2.10 318 */ 319 public GtkPrintStatus getStatus() 320 { 321 return gtk_print_operation_get_status(gtkPrintOperation); 322 } 323 324 /** 325 * Returns a string representation of the status of the 326 * print operation. The string is translated and suitable 327 * for displaying the print status e.g. in a #GtkStatusbar. 328 * 329 * Use gtk_print_operation_get_status() to obtain a status 330 * value that is suitable for programmatic use. 331 * 332 * Returns: a string representation of the status 333 * of the print operation 334 * 335 * Since: 2.10 336 */ 337 public string getStatusString() 338 { 339 return Str.toString(gtk_print_operation_get_status_string(gtkPrintOperation)); 340 } 341 342 /** 343 * Gets the value of #GtkPrintOperation:support-selection property. 344 * 345 * Returns: whether the application supports print of selection 346 * 347 * Since: 2.18 348 */ 349 public bool getSupportSelection() 350 { 351 return gtk_print_operation_get_support_selection(gtkPrintOperation) != 0; 352 } 353 354 /** 355 * A convenience function to find out if the print operation 356 * is finished, either successfully (%GTK_PRINT_STATUS_FINISHED) 357 * or unsuccessfully (%GTK_PRINT_STATUS_FINISHED_ABORTED). 358 * 359 * Note: when you enable print status tracking the print operation 360 * can be in a non-finished state even after done has been called, as 361 * the operation status then tracks the print job status on the printer. 362 * 363 * Returns: %TRUE, if the print operation is finished. 364 * 365 * Since: 2.10 366 */ 367 public bool isFinished() 368 { 369 return gtk_print_operation_is_finished(gtkPrintOperation) != 0; 370 } 371 372 /** 373 * Runs the print operation, by first letting the user modify 374 * print settings in the print dialog, and then print the document. 375 * 376 * Normally that this function does not return until the rendering of all 377 * pages is complete. You can connect to the 378 * #GtkPrintOperation::status-changed signal on @op to obtain some 379 * information about the progress of the print operation. 380 * Furthermore, it may use a recursive mainloop to show the print dialog. 381 * 382 * If you call gtk_print_operation_set_allow_async() or set the 383 * #GtkPrintOperation:allow-async property the operation will run 384 * asynchronously if this is supported on the platform. The 385 * #GtkPrintOperation::done signal will be emitted with the result of the 386 * operation when the it is done (i.e. when the dialog is canceled, or when 387 * the print succeeds or fails). 388 * |[<!-- language="C" --> 389 * if (settings != NULL) 390 * gtk_print_operation_set_print_settings (print, settings); 391 * 392 * if (page_setup != NULL) 393 * gtk_print_operation_set_default_page_setup (print, page_setup); 394 * 395 * g_signal_connect (print, "begin-print", 396 * G_CALLBACK (begin_print), &data); 397 * g_signal_connect (print, "draw-page", 398 * G_CALLBACK (draw_page), &data); 399 * 400 * res = gtk_print_operation_run (print, 401 * GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, 402 * parent, 403 * &error); 404 * 405 * if (res == GTK_PRINT_OPERATION_RESULT_ERROR) 406 * { 407 * error_dialog = gtk_message_dialog_new (GTK_WINDOW (parent), 408 * GTK_DIALOG_DESTROY_WITH_PARENT, 409 * GTK_MESSAGE_ERROR, 410 * GTK_BUTTONS_CLOSE, 411 * "Error printing file:\n%s", 412 * error->message); 413 * g_signal_connect (error_dialog, "response", 414 * G_CALLBACK (gtk_widget_destroy), NULL); 415 * gtk_widget_show (error_dialog); 416 * g_error_free (error); 417 * } 418 * else if (res == GTK_PRINT_OPERATION_RESULT_APPLY) 419 * { 420 * if (settings != NULL) 421 * g_object_unref (settings); 422 * settings = g_object_ref (gtk_print_operation_get_print_settings (print)); 423 * } 424 * ]| 425 * 426 * Note that gtk_print_operation_run() can only be called once on a 427 * given #GtkPrintOperation. 428 * 429 * Params: 430 * action = the action to start 431 * parent = Transient parent of the dialog 432 * 433 * Returns: the result of the print operation. A return value of 434 * %GTK_PRINT_OPERATION_RESULT_APPLY indicates that the printing was 435 * completed successfully. In this case, it is a good idea to obtain 436 * the used print settings with gtk_print_operation_get_print_settings() 437 * and store them for reuse with the next print operation. A value of 438 * %GTK_PRINT_OPERATION_RESULT_IN_PROGRESS means the operation is running 439 * asynchronously, and will emit the #GtkPrintOperation::done signal when 440 * done. 441 * 442 * Since: 2.10 443 * 444 * Throws: GException on failure. 445 */ 446 public GtkPrintOperationResult run(GtkPrintOperationAction action, Window parent) 447 { 448 GError* err = null; 449 450 auto p = gtk_print_operation_run(gtkPrintOperation, action, (parent is null) ? null : parent.getWindowStruct(), &err); 451 452 if (err !is null) 453 { 454 throw new GException( new ErrorG(err) ); 455 } 456 457 return p; 458 } 459 460 /** 461 * Sets whether the gtk_print_operation_run() may return 462 * before the print operation is completed. Note that 463 * some platforms may not allow asynchronous operation. 464 * 465 * Params: 466 * allowAsync = %TRUE to allow asynchronous operation 467 * 468 * Since: 2.10 469 */ 470 public void setAllowAsync(bool allowAsync) 471 { 472 gtk_print_operation_set_allow_async(gtkPrintOperation, allowAsync); 473 } 474 475 /** 476 * Sets the current page. 477 * 478 * If this is called before gtk_print_operation_run(), 479 * the user will be able to select to print only the current page. 480 * 481 * Note that this only makes sense for pre-paginated documents. 482 * 483 * Params: 484 * currentPage = the current page, 0-based 485 * 486 * Since: 2.10 487 */ 488 public void setCurrentPage(int currentPage) 489 { 490 gtk_print_operation_set_current_page(gtkPrintOperation, currentPage); 491 } 492 493 /** 494 * Sets the label for the tab holding custom widgets. 495 * 496 * Params: 497 * label = the label to use, or %NULL to use the default label 498 * 499 * Since: 2.10 500 */ 501 public void setCustomTabLabel(string label) 502 { 503 gtk_print_operation_set_custom_tab_label(gtkPrintOperation, Str.toStringz(label)); 504 } 505 506 /** 507 * Makes @default_page_setup the default page setup for @op. 508 * 509 * This page setup will be used by gtk_print_operation_run(), 510 * but it can be overridden on a per-page basis by connecting 511 * to the #GtkPrintOperation::request-page-setup signal. 512 * 513 * Params: 514 * defaultPageSetup = a #GtkPageSetup, or %NULL 515 * 516 * Since: 2.10 517 */ 518 public void setDefaultPageSetup(PageSetup defaultPageSetup) 519 { 520 gtk_print_operation_set_default_page_setup(gtkPrintOperation, (defaultPageSetup is null) ? null : defaultPageSetup.getPageSetupStruct()); 521 } 522 523 /** 524 * Sets up the #GtkPrintOperation to wait for calling of 525 * gtk_print_operation_draw_page_finish() from application. It can 526 * be used for drawing page in another thread. 527 * 528 * This function must be called in the callback of “draw-page” signal. 529 * 530 * Since: 2.16 531 */ 532 public void setDeferDrawing() 533 { 534 gtk_print_operation_set_defer_drawing(gtkPrintOperation); 535 } 536 537 /** 538 * Embed page size combo box and orientation combo box into page setup page. 539 * Selected page setup is stored as default page setup in #GtkPrintOperation. 540 * 541 * Params: 542 * embed = %TRUE to embed page setup selection in the #GtkPrintUnixDialog 543 * 544 * Since: 2.18 545 */ 546 public void setEmbedPageSetup(bool embed) 547 { 548 gtk_print_operation_set_embed_page_setup(gtkPrintOperation, embed); 549 } 550 551 /** 552 * Sets up the #GtkPrintOperation to generate a file instead 553 * of showing the print dialog. The indended use of this function 554 * is for implementing “Export to PDF” actions. Currently, PDF 555 * is the only supported format. 556 * 557 * “Print to PDF” support is independent of this and is done 558 * by letting the user pick the “Print to PDF” item from the list 559 * of printers in the print dialog. 560 * 561 * Params: 562 * filename = the filename for the exported file 563 * 564 * Since: 2.10 565 */ 566 public void setExportFilename(string filename) 567 { 568 gtk_print_operation_set_export_filename(gtkPrintOperation, Str.toStringz(filename)); 569 } 570 571 /** 572 * Sets whether there is a selection to print. 573 * 574 * Application has to set number of pages to which the selection 575 * will draw by gtk_print_operation_set_n_pages() in a callback of 576 * #GtkPrintOperation::begin-print. 577 * 578 * Params: 579 * hasSelection = %TRUE indicates that a selection exists 580 * 581 * Since: 2.18 582 */ 583 public void setHasSelection(bool hasSelection) 584 { 585 gtk_print_operation_set_has_selection(gtkPrintOperation, hasSelection); 586 } 587 588 /** 589 * Sets the name of the print job. The name is used to identify 590 * the job (e.g. in monitoring applications like eggcups). 591 * 592 * If you don’t set a job name, GTK+ picks a default one by 593 * numbering successive print jobs. 594 * 595 * Params: 596 * jobName = a string that identifies the print job 597 * 598 * Since: 2.10 599 */ 600 public void setJobName(string jobName) 601 { 602 gtk_print_operation_set_job_name(gtkPrintOperation, Str.toStringz(jobName)); 603 } 604 605 /** 606 * Sets the number of pages in the document. 607 * 608 * This must be set to a positive number 609 * before the rendering starts. It may be set in a 610 * #GtkPrintOperation::begin-print signal hander. 611 * 612 * Note that the page numbers passed to the 613 * #GtkPrintOperation::request-page-setup 614 * and #GtkPrintOperation::draw-page signals are 0-based, i.e. if 615 * the user chooses to print all pages, the last ::draw-page signal 616 * will be for page @n_pages - 1. 617 * 618 * Params: 619 * nPages = the number of pages 620 * 621 * Since: 2.10 622 */ 623 public void setNPages(int nPages) 624 { 625 gtk_print_operation_set_n_pages(gtkPrintOperation, nPages); 626 } 627 628 /** 629 * Sets the print settings for @op. This is typically used to 630 * re-establish print settings from a previous print operation, 631 * see gtk_print_operation_run(). 632 * 633 * Params: 634 * printSettings = #GtkPrintSettings 635 * 636 * Since: 2.10 637 */ 638 public void setPrintSettings(PrintSettings printSettings) 639 { 640 gtk_print_operation_set_print_settings(gtkPrintOperation, (printSettings is null) ? null : printSettings.getPrintSettingsStruct()); 641 } 642 643 /** 644 * If @show_progress is %TRUE, the print operation will show a 645 * progress dialog during the print operation. 646 * 647 * Params: 648 * showProgress = %TRUE to show a progress dialog 649 * 650 * Since: 2.10 651 */ 652 public void setShowProgress(bool showProgress) 653 { 654 gtk_print_operation_set_show_progress(gtkPrintOperation, showProgress); 655 } 656 657 /** 658 * Sets whether selection is supported by #GtkPrintOperation. 659 * 660 * Params: 661 * supportSelection = %TRUE to support selection 662 * 663 * Since: 2.18 664 */ 665 public void setSupportSelection(bool supportSelection) 666 { 667 gtk_print_operation_set_support_selection(gtkPrintOperation, supportSelection); 668 } 669 670 /** 671 * If track_status is %TRUE, the print operation will try to continue report 672 * on the status of the print job in the printer queues and printer. This 673 * can allow your application to show things like “out of paper” issues, 674 * and when the print job actually reaches the printer. 675 * 676 * This function is often implemented using some form of polling, so it should 677 * not be enabled unless needed. 678 * 679 * Params: 680 * trackStatus = %TRUE to track status after printing 681 * 682 * Since: 2.10 683 */ 684 public void setTrackPrintStatus(bool trackStatus) 685 { 686 gtk_print_operation_set_track_print_status(gtkPrintOperation, trackStatus); 687 } 688 689 /** 690 * Sets up the transformation for the cairo context obtained from 691 * #GtkPrintContext in such a way that distances are measured in 692 * units of @unit. 693 * 694 * Params: 695 * unit = the unit to use 696 * 697 * Since: 2.10 698 */ 699 public void setUnit(GtkUnit unit) 700 { 701 gtk_print_operation_set_unit(gtkPrintOperation, unit); 702 } 703 704 /** 705 * If @full_page is %TRUE, the transformation for the cairo context 706 * obtained from #GtkPrintContext puts the origin at the top left 707 * corner of the page (which may not be the top left corner of the 708 * sheet, depending on page orientation and the number of pages per 709 * sheet). Otherwise, the origin is at the top left corner of the 710 * imageable area (i.e. inside the margins). 711 * 712 * Params: 713 * fullPage = %TRUE to set up the #GtkPrintContext for the full page 714 * 715 * Since: 2.10 716 */ 717 public void setUseFullPage(bool fullPage) 718 { 719 gtk_print_operation_set_use_full_page(gtkPrintOperation, fullPage); 720 } 721 722 protected class OnBeginPrintDelegateWrapper 723 { 724 static OnBeginPrintDelegateWrapper[] listeners; 725 void delegate(PrintContext, PrintOperation) dlg; 726 gulong handlerId; 727 728 this(void delegate(PrintContext, PrintOperation) dlg) 729 { 730 this.dlg = dlg; 731 this.listeners ~= this; 732 } 733 734 void remove(OnBeginPrintDelegateWrapper source) 735 { 736 foreach(index, wrapper; listeners) 737 { 738 if (wrapper.handlerId == source.handlerId) 739 { 740 listeners[index] = null; 741 listeners = std.algorithm.remove(listeners, index); 742 break; 743 } 744 } 745 } 746 } 747 748 /** 749 * Emitted after the user has finished changing print settings 750 * in the dialog, before the actual rendering starts. 751 * 752 * A typical use for ::begin-print is to use the parameters from the 753 * #GtkPrintContext and paginate the document accordingly, and then 754 * set the number of pages with gtk_print_operation_set_n_pages(). 755 * 756 * Params: 757 * context = the #GtkPrintContext for the current operation 758 * 759 * Since: 2.10 760 */ 761 gulong addOnBeginPrint(void delegate(PrintContext, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 762 { 763 auto wrapper = new OnBeginPrintDelegateWrapper(dlg); 764 wrapper.handlerId = Signals.connectData( 765 this, 766 "begin-print", 767 cast(GCallback)&callBackBeginPrint, 768 cast(void*)wrapper, 769 cast(GClosureNotify)&callBackBeginPrintDestroy, 770 connectFlags); 771 return wrapper.handlerId; 772 } 773 774 extern(C) static void callBackBeginPrint(GtkPrintOperation* printoperationStruct, GtkPrintContext* context, OnBeginPrintDelegateWrapper wrapper) 775 { 776 wrapper.dlg(ObjectG.getDObject!(PrintContext)(context), wrapper.outer); 777 } 778 779 extern(C) static void callBackBeginPrintDestroy(OnBeginPrintDelegateWrapper wrapper, GClosure* closure) 780 { 781 wrapper.remove(wrapper); 782 } 783 784 protected class OnCreateCustomWidgetDelegateWrapper 785 { 786 static OnCreateCustomWidgetDelegateWrapper[] listeners; 787 ObjectG delegate(PrintOperation) dlg; 788 gulong handlerId; 789 790 this(ObjectG delegate(PrintOperation) dlg) 791 { 792 this.dlg = dlg; 793 this.listeners ~= this; 794 } 795 796 void remove(OnCreateCustomWidgetDelegateWrapper source) 797 { 798 foreach(index, wrapper; listeners) 799 { 800 if (wrapper.handlerId == source.handlerId) 801 { 802 listeners[index] = null; 803 listeners = std.algorithm.remove(listeners, index); 804 break; 805 } 806 } 807 } 808 } 809 810 /** 811 * Emitted when displaying the print dialog. If you return a 812 * widget in a handler for this signal it will be added to a custom 813 * tab in the print dialog. You typically return a container widget 814 * with multiple widgets in it. 815 * 816 * The print dialog owns the returned widget, and its lifetime is not 817 * controlled by the application. However, the widget is guaranteed 818 * to stay around until the #GtkPrintOperation::custom-widget-apply 819 * signal is emitted on the operation. Then you can read out any 820 * information you need from the widgets. 821 * 822 * Returns: A custom widget that gets embedded in 823 * the print dialog, or %NULL 824 * 825 * Since: 2.10 826 */ 827 gulong addOnCreateCustomWidget(ObjectG delegate(PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 828 { 829 auto wrapper = new OnCreateCustomWidgetDelegateWrapper(dlg); 830 wrapper.handlerId = Signals.connectData( 831 this, 832 "create-custom-widget", 833 cast(GCallback)&callBackCreateCustomWidget, 834 cast(void*)wrapper, 835 cast(GClosureNotify)&callBackCreateCustomWidgetDestroy, 836 connectFlags); 837 return wrapper.handlerId; 838 } 839 840 extern(C) static GObject* callBackCreateCustomWidget(GtkPrintOperation* printoperationStruct, OnCreateCustomWidgetDelegateWrapper wrapper) 841 { 842 auto r = wrapper.dlg(wrapper.outer); 843 return r.getObjectGStruct(); 844 } 845 846 extern(C) static void callBackCreateCustomWidgetDestroy(OnCreateCustomWidgetDelegateWrapper wrapper, GClosure* closure) 847 { 848 wrapper.remove(wrapper); 849 } 850 851 protected class OnCustomWidgetApplyDelegateWrapper 852 { 853 static OnCustomWidgetApplyDelegateWrapper[] listeners; 854 void delegate(Widget, PrintOperation) dlg; 855 gulong handlerId; 856 857 this(void delegate(Widget, PrintOperation) dlg) 858 { 859 this.dlg = dlg; 860 this.listeners ~= this; 861 } 862 863 void remove(OnCustomWidgetApplyDelegateWrapper source) 864 { 865 foreach(index, wrapper; listeners) 866 { 867 if (wrapper.handlerId == source.handlerId) 868 { 869 listeners[index] = null; 870 listeners = std.algorithm.remove(listeners, index); 871 break; 872 } 873 } 874 } 875 } 876 877 /** 878 * Emitted right before #GtkPrintOperation::begin-print if you added 879 * a custom widget in the #GtkPrintOperation::create-custom-widget handler. 880 * When you get this signal you should read the information from the 881 * custom widgets, as the widgets are not guaraneed to be around at a 882 * later time. 883 * 884 * Params: 885 * widget = the custom widget added in create-custom-widget 886 * 887 * Since: 2.10 888 */ 889 gulong addOnCustomWidgetApply(void delegate(Widget, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 890 { 891 auto wrapper = new OnCustomWidgetApplyDelegateWrapper(dlg); 892 wrapper.handlerId = Signals.connectData( 893 this, 894 "custom-widget-apply", 895 cast(GCallback)&callBackCustomWidgetApply, 896 cast(void*)wrapper, 897 cast(GClosureNotify)&callBackCustomWidgetApplyDestroy, 898 connectFlags); 899 return wrapper.handlerId; 900 } 901 902 extern(C) static void callBackCustomWidgetApply(GtkPrintOperation* printoperationStruct, GtkWidget* widget, OnCustomWidgetApplyDelegateWrapper wrapper) 903 { 904 wrapper.dlg(ObjectG.getDObject!(Widget)(widget), wrapper.outer); 905 } 906 907 extern(C) static void callBackCustomWidgetApplyDestroy(OnCustomWidgetApplyDelegateWrapper wrapper, GClosure* closure) 908 { 909 wrapper.remove(wrapper); 910 } 911 912 protected class OnDoneDelegateWrapper 913 { 914 static OnDoneDelegateWrapper[] listeners; 915 void delegate(GtkPrintOperationResult, PrintOperation) dlg; 916 gulong handlerId; 917 918 this(void delegate(GtkPrintOperationResult, PrintOperation) dlg) 919 { 920 this.dlg = dlg; 921 this.listeners ~= this; 922 } 923 924 void remove(OnDoneDelegateWrapper source) 925 { 926 foreach(index, wrapper; listeners) 927 { 928 if (wrapper.handlerId == source.handlerId) 929 { 930 listeners[index] = null; 931 listeners = std.algorithm.remove(listeners, index); 932 break; 933 } 934 } 935 } 936 } 937 938 /** 939 * Emitted when the print operation run has finished doing 940 * everything required for printing. 941 * 942 * @result gives you information about what happened during the run. 943 * If @result is %GTK_PRINT_OPERATION_RESULT_ERROR then you can call 944 * gtk_print_operation_get_error() for more information. 945 * 946 * If you enabled print status tracking then 947 * gtk_print_operation_is_finished() may still return %FALSE 948 * after #GtkPrintOperation::done was emitted. 949 * 950 * Params: 951 * result = the result of the print operation 952 * 953 * Since: 2.10 954 */ 955 gulong addOnDone(void delegate(GtkPrintOperationResult, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 956 { 957 auto wrapper = new OnDoneDelegateWrapper(dlg); 958 wrapper.handlerId = Signals.connectData( 959 this, 960 "done", 961 cast(GCallback)&callBackDone, 962 cast(void*)wrapper, 963 cast(GClosureNotify)&callBackDoneDestroy, 964 connectFlags); 965 return wrapper.handlerId; 966 } 967 968 extern(C) static void callBackDone(GtkPrintOperation* printoperationStruct, GtkPrintOperationResult result, OnDoneDelegateWrapper wrapper) 969 { 970 wrapper.dlg(result, wrapper.outer); 971 } 972 973 extern(C) static void callBackDoneDestroy(OnDoneDelegateWrapper wrapper, GClosure* closure) 974 { 975 wrapper.remove(wrapper); 976 } 977 978 protected class OnDrawPageDelegateWrapper 979 { 980 static OnDrawPageDelegateWrapper[] listeners; 981 void delegate(PrintContext, int, PrintOperation) dlg; 982 gulong handlerId; 983 984 this(void delegate(PrintContext, int, PrintOperation) dlg) 985 { 986 this.dlg = dlg; 987 this.listeners ~= this; 988 } 989 990 void remove(OnDrawPageDelegateWrapper source) 991 { 992 foreach(index, wrapper; listeners) 993 { 994 if (wrapper.handlerId == source.handlerId) 995 { 996 listeners[index] = null; 997 listeners = std.algorithm.remove(listeners, index); 998 break; 999 } 1000 } 1001 } 1002 } 1003 1004 /** 1005 * Emitted for every page that is printed. The signal handler 1006 * must render the @page_nr's page onto the cairo context obtained 1007 * from @context using gtk_print_context_get_cairo_context(). 1008 * |[<!-- language="C" --> 1009 * static void 1010 * draw_page (GtkPrintOperation *operation, 1011 * GtkPrintContext *context, 1012 * gint page_nr, 1013 * gpointer user_data) 1014 * { 1015 * cairo_t *cr; 1016 * PangoLayout *layout; 1017 * gdouble width, text_height; 1018 * gint layout_height; 1019 * PangoFontDescription *desc; 1020 * 1021 * cr = gtk_print_context_get_cairo_context (context); 1022 * width = gtk_print_context_get_width (context); 1023 * 1024 * cairo_rectangle (cr, 0, 0, width, HEADER_HEIGHT); 1025 * 1026 * cairo_set_source_rgb (cr, 0.8, 0.8, 0.8); 1027 * cairo_fill (cr); 1028 * 1029 * layout = gtk_print_context_create_pango_layout (context); 1030 * 1031 * desc = pango_font_description_from_string ("sans 14"); 1032 * pango_layout_set_font_description (layout, desc); 1033 * pango_font_description_free (desc); 1034 * 1035 * pango_layout_set_text (layout, "some text", -1); 1036 * pango_layout_set_width (layout, width * PANGO_SCALE); 1037 * pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER); 1038 * 1039 * pango_layout_get_size (layout, NULL, &layout_height); 1040 * text_height = (gdouble)layout_height / PANGO_SCALE; 1041 * 1042 * cairo_move_to (cr, width / 2, (HEADER_HEIGHT - text_height) / 2); 1043 * pango_cairo_show_layout (cr, layout); 1044 * 1045 * g_object_unref (layout); 1046 * } 1047 * ]| 1048 * 1049 * Use gtk_print_operation_set_use_full_page() and 1050 * gtk_print_operation_set_unit() before starting the print operation 1051 * to set up the transformation of the cairo context according to your 1052 * needs. 1053 * 1054 * Params: 1055 * context = the #GtkPrintContext for the current operation 1056 * pageNr = the number of the currently printed page (0-based) 1057 * 1058 * Since: 2.10 1059 */ 1060 gulong addOnDrawPage(void delegate(PrintContext, int, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1061 { 1062 auto wrapper = new OnDrawPageDelegateWrapper(dlg); 1063 wrapper.handlerId = Signals.connectData( 1064 this, 1065 "draw-page", 1066 cast(GCallback)&callBackDrawPage, 1067 cast(void*)wrapper, 1068 cast(GClosureNotify)&callBackDrawPageDestroy, 1069 connectFlags); 1070 return wrapper.handlerId; 1071 } 1072 1073 extern(C) static void callBackDrawPage(GtkPrintOperation* printoperationStruct, GtkPrintContext* context, int pageNr, OnDrawPageDelegateWrapper wrapper) 1074 { 1075 wrapper.dlg(ObjectG.getDObject!(PrintContext)(context), pageNr, wrapper.outer); 1076 } 1077 1078 extern(C) static void callBackDrawPageDestroy(OnDrawPageDelegateWrapper wrapper, GClosure* closure) 1079 { 1080 wrapper.remove(wrapper); 1081 } 1082 1083 protected class OnEndPrintDelegateWrapper 1084 { 1085 static OnEndPrintDelegateWrapper[] listeners; 1086 void delegate(PrintContext, PrintOperation) dlg; 1087 gulong handlerId; 1088 1089 this(void delegate(PrintContext, PrintOperation) dlg) 1090 { 1091 this.dlg = dlg; 1092 this.listeners ~= this; 1093 } 1094 1095 void remove(OnEndPrintDelegateWrapper source) 1096 { 1097 foreach(index, wrapper; listeners) 1098 { 1099 if (wrapper.handlerId == source.handlerId) 1100 { 1101 listeners[index] = null; 1102 listeners = std.algorithm.remove(listeners, index); 1103 break; 1104 } 1105 } 1106 } 1107 } 1108 1109 /** 1110 * Emitted after all pages have been rendered. 1111 * A handler for this signal can clean up any resources that have 1112 * been allocated in the #GtkPrintOperation::begin-print handler. 1113 * 1114 * Params: 1115 * context = the #GtkPrintContext for the current operation 1116 * 1117 * Since: 2.10 1118 */ 1119 gulong addOnEndPrint(void delegate(PrintContext, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1120 { 1121 auto wrapper = new OnEndPrintDelegateWrapper(dlg); 1122 wrapper.handlerId = Signals.connectData( 1123 this, 1124 "end-print", 1125 cast(GCallback)&callBackEndPrint, 1126 cast(void*)wrapper, 1127 cast(GClosureNotify)&callBackEndPrintDestroy, 1128 connectFlags); 1129 return wrapper.handlerId; 1130 } 1131 1132 extern(C) static void callBackEndPrint(GtkPrintOperation* printoperationStruct, GtkPrintContext* context, OnEndPrintDelegateWrapper wrapper) 1133 { 1134 wrapper.dlg(ObjectG.getDObject!(PrintContext)(context), wrapper.outer); 1135 } 1136 1137 extern(C) static void callBackEndPrintDestroy(OnEndPrintDelegateWrapper wrapper, GClosure* closure) 1138 { 1139 wrapper.remove(wrapper); 1140 } 1141 1142 protected class OnPaginateDelegateWrapper 1143 { 1144 static OnPaginateDelegateWrapper[] listeners; 1145 bool delegate(PrintContext, PrintOperation) dlg; 1146 gulong handlerId; 1147 1148 this(bool delegate(PrintContext, PrintOperation) dlg) 1149 { 1150 this.dlg = dlg; 1151 this.listeners ~= this; 1152 } 1153 1154 void remove(OnPaginateDelegateWrapper source) 1155 { 1156 foreach(index, wrapper; listeners) 1157 { 1158 if (wrapper.handlerId == source.handlerId) 1159 { 1160 listeners[index] = null; 1161 listeners = std.algorithm.remove(listeners, index); 1162 break; 1163 } 1164 } 1165 } 1166 } 1167 1168 /** 1169 * Emitted after the #GtkPrintOperation::begin-print signal, but before 1170 * the actual rendering starts. It keeps getting emitted until a connected 1171 * signal handler returns %TRUE. 1172 * 1173 * The ::paginate signal is intended to be used for paginating a document 1174 * in small chunks, to avoid blocking the user interface for a long 1175 * time. The signal handler should update the number of pages using 1176 * gtk_print_operation_set_n_pages(), and return %TRUE if the document 1177 * has been completely paginated. 1178 * 1179 * If you don't need to do pagination in chunks, you can simply do 1180 * it all in the ::begin-print handler, and set the number of pages 1181 * from there. 1182 * 1183 * Params: 1184 * context = the #GtkPrintContext for the current operation 1185 * 1186 * Returns: %TRUE if pagination is complete 1187 * 1188 * Since: 2.10 1189 */ 1190 gulong addOnPaginate(bool delegate(PrintContext, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1191 { 1192 auto wrapper = new OnPaginateDelegateWrapper(dlg); 1193 wrapper.handlerId = Signals.connectData( 1194 this, 1195 "paginate", 1196 cast(GCallback)&callBackPaginate, 1197 cast(void*)wrapper, 1198 cast(GClosureNotify)&callBackPaginateDestroy, 1199 connectFlags); 1200 return wrapper.handlerId; 1201 } 1202 1203 extern(C) static int callBackPaginate(GtkPrintOperation* printoperationStruct, GtkPrintContext* context, OnPaginateDelegateWrapper wrapper) 1204 { 1205 return wrapper.dlg(ObjectG.getDObject!(PrintContext)(context), wrapper.outer); 1206 } 1207 1208 extern(C) static void callBackPaginateDestroy(OnPaginateDelegateWrapper wrapper, GClosure* closure) 1209 { 1210 wrapper.remove(wrapper); 1211 } 1212 1213 protected class OnPreviewDelegateWrapper 1214 { 1215 static OnPreviewDelegateWrapper[] listeners; 1216 bool delegate(PrintOperationPreviewIF, PrintContext, Window, PrintOperation) dlg; 1217 gulong handlerId; 1218 1219 this(bool delegate(PrintOperationPreviewIF, PrintContext, Window, PrintOperation) dlg) 1220 { 1221 this.dlg = dlg; 1222 this.listeners ~= this; 1223 } 1224 1225 void remove(OnPreviewDelegateWrapper source) 1226 { 1227 foreach(index, wrapper; listeners) 1228 { 1229 if (wrapper.handlerId == source.handlerId) 1230 { 1231 listeners[index] = null; 1232 listeners = std.algorithm.remove(listeners, index); 1233 break; 1234 } 1235 } 1236 } 1237 } 1238 1239 /** 1240 * Gets emitted when a preview is requested from the native dialog. 1241 * 1242 * The default handler for this signal uses an external viewer 1243 * application to preview. 1244 * 1245 * To implement a custom print preview, an application must return 1246 * %TRUE from its handler for this signal. In order to use the 1247 * provided @context for the preview implementation, it must be 1248 * given a suitable cairo context with gtk_print_context_set_cairo_context(). 1249 * 1250 * The custom preview implementation can use 1251 * gtk_print_operation_preview_is_selected() and 1252 * gtk_print_operation_preview_render_page() to find pages which 1253 * are selected for print and render them. The preview must be 1254 * finished by calling gtk_print_operation_preview_end_preview() 1255 * (typically in response to the user clicking a close button). 1256 * 1257 * Params: 1258 * preview = the #GtkPrintOperationPreview for the current operation 1259 * context = the #GtkPrintContext that will be used 1260 * parent = the #GtkWindow to use as window parent, or %NULL 1261 * 1262 * Returns: %TRUE if the listener wants to take over control of the preview 1263 * 1264 * Since: 2.10 1265 */ 1266 gulong addOnPreview(bool delegate(PrintOperationPreviewIF, PrintContext, Window, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1267 { 1268 auto wrapper = new OnPreviewDelegateWrapper(dlg); 1269 wrapper.handlerId = Signals.connectData( 1270 this, 1271 "preview", 1272 cast(GCallback)&callBackPreview, 1273 cast(void*)wrapper, 1274 cast(GClosureNotify)&callBackPreviewDestroy, 1275 connectFlags); 1276 return wrapper.handlerId; 1277 } 1278 1279 extern(C) static int callBackPreview(GtkPrintOperation* printoperationStruct, GtkPrintOperationPreview* preview, GtkPrintContext* context, GtkWindow* parent, OnPreviewDelegateWrapper wrapper) 1280 { 1281 return wrapper.dlg(ObjectG.getDObject!(PrintOperationPreview, PrintOperationPreviewIF)(preview), ObjectG.getDObject!(PrintContext)(context), ObjectG.getDObject!(Window)(parent), wrapper.outer); 1282 } 1283 1284 extern(C) static void callBackPreviewDestroy(OnPreviewDelegateWrapper wrapper, GClosure* closure) 1285 { 1286 wrapper.remove(wrapper); 1287 } 1288 1289 protected class OnRequestPageSetupDelegateWrapper 1290 { 1291 static OnRequestPageSetupDelegateWrapper[] listeners; 1292 void delegate(PrintContext, int, PageSetup, PrintOperation) dlg; 1293 gulong handlerId; 1294 1295 this(void delegate(PrintContext, int, PageSetup, PrintOperation) dlg) 1296 { 1297 this.dlg = dlg; 1298 this.listeners ~= this; 1299 } 1300 1301 void remove(OnRequestPageSetupDelegateWrapper source) 1302 { 1303 foreach(index, wrapper; listeners) 1304 { 1305 if (wrapper.handlerId == source.handlerId) 1306 { 1307 listeners[index] = null; 1308 listeners = std.algorithm.remove(listeners, index); 1309 break; 1310 } 1311 } 1312 } 1313 } 1314 1315 /** 1316 * Emitted once for every page that is printed, to give 1317 * the application a chance to modify the page setup. Any changes 1318 * done to @setup will be in force only for printing this page. 1319 * 1320 * Params: 1321 * context = the #GtkPrintContext for the current operation 1322 * pageNr = the number of the currently printed page (0-based) 1323 * setup = the #GtkPageSetup 1324 * 1325 * Since: 2.10 1326 */ 1327 gulong addOnRequestPageSetup(void delegate(PrintContext, int, PageSetup, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1328 { 1329 auto wrapper = new OnRequestPageSetupDelegateWrapper(dlg); 1330 wrapper.handlerId = Signals.connectData( 1331 this, 1332 "request-page-setup", 1333 cast(GCallback)&callBackRequestPageSetup, 1334 cast(void*)wrapper, 1335 cast(GClosureNotify)&callBackRequestPageSetupDestroy, 1336 connectFlags); 1337 return wrapper.handlerId; 1338 } 1339 1340 extern(C) static void callBackRequestPageSetup(GtkPrintOperation* printoperationStruct, GtkPrintContext* context, int pageNr, GtkPageSetup* setup, OnRequestPageSetupDelegateWrapper wrapper) 1341 { 1342 wrapper.dlg(ObjectG.getDObject!(PrintContext)(context), pageNr, ObjectG.getDObject!(PageSetup)(setup), wrapper.outer); 1343 } 1344 1345 extern(C) static void callBackRequestPageSetupDestroy(OnRequestPageSetupDelegateWrapper wrapper, GClosure* closure) 1346 { 1347 wrapper.remove(wrapper); 1348 } 1349 1350 protected class OnStatusChangedDelegateWrapper 1351 { 1352 static OnStatusChangedDelegateWrapper[] listeners; 1353 void delegate(PrintOperation) dlg; 1354 gulong handlerId; 1355 1356 this(void delegate(PrintOperation) dlg) 1357 { 1358 this.dlg = dlg; 1359 this.listeners ~= this; 1360 } 1361 1362 void remove(OnStatusChangedDelegateWrapper source) 1363 { 1364 foreach(index, wrapper; listeners) 1365 { 1366 if (wrapper.handlerId == source.handlerId) 1367 { 1368 listeners[index] = null; 1369 listeners = std.algorithm.remove(listeners, index); 1370 break; 1371 } 1372 } 1373 } 1374 } 1375 1376 /** 1377 * Emitted at between the various phases of the print operation. 1378 * See #GtkPrintStatus for the phases that are being discriminated. 1379 * Use gtk_print_operation_get_status() to find out the current 1380 * status. 1381 * 1382 * Since: 2.10 1383 */ 1384 gulong addOnStatusChanged(void delegate(PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1385 { 1386 auto wrapper = new OnStatusChangedDelegateWrapper(dlg); 1387 wrapper.handlerId = Signals.connectData( 1388 this, 1389 "status-changed", 1390 cast(GCallback)&callBackStatusChanged, 1391 cast(void*)wrapper, 1392 cast(GClosureNotify)&callBackStatusChangedDestroy, 1393 connectFlags); 1394 return wrapper.handlerId; 1395 } 1396 1397 extern(C) static void callBackStatusChanged(GtkPrintOperation* printoperationStruct, OnStatusChangedDelegateWrapper wrapper) 1398 { 1399 wrapper.dlg(wrapper.outer); 1400 } 1401 1402 extern(C) static void callBackStatusChangedDestroy(OnStatusChangedDelegateWrapper wrapper, GClosure* closure) 1403 { 1404 wrapper.remove(wrapper); 1405 } 1406 1407 protected class OnUpdateCustomWidgetDelegateWrapper 1408 { 1409 static OnUpdateCustomWidgetDelegateWrapper[] listeners; 1410 void delegate(Widget, PageSetup, PrintSettings, PrintOperation) dlg; 1411 gulong handlerId; 1412 1413 this(void delegate(Widget, PageSetup, PrintSettings, PrintOperation) dlg) 1414 { 1415 this.dlg = dlg; 1416 this.listeners ~= this; 1417 } 1418 1419 void remove(OnUpdateCustomWidgetDelegateWrapper source) 1420 { 1421 foreach(index, wrapper; listeners) 1422 { 1423 if (wrapper.handlerId == source.handlerId) 1424 { 1425 listeners[index] = null; 1426 listeners = std.algorithm.remove(listeners, index); 1427 break; 1428 } 1429 } 1430 } 1431 } 1432 1433 /** 1434 * Emitted after change of selected printer. The actual page setup and 1435 * print settings are passed to the custom widget, which can actualize 1436 * itself according to this change. 1437 * 1438 * Params: 1439 * widget = the custom widget added in create-custom-widget 1440 * setup = actual page setup 1441 * settings = actual print settings 1442 * 1443 * Since: 2.18 1444 */ 1445 gulong addOnUpdateCustomWidget(void delegate(Widget, PageSetup, PrintSettings, PrintOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1446 { 1447 auto wrapper = new OnUpdateCustomWidgetDelegateWrapper(dlg); 1448 wrapper.handlerId = Signals.connectData( 1449 this, 1450 "update-custom-widget", 1451 cast(GCallback)&callBackUpdateCustomWidget, 1452 cast(void*)wrapper, 1453 cast(GClosureNotify)&callBackUpdateCustomWidgetDestroy, 1454 connectFlags); 1455 return wrapper.handlerId; 1456 } 1457 1458 extern(C) static void callBackUpdateCustomWidget(GtkPrintOperation* printoperationStruct, GtkWidget* widget, GtkPageSetup* setup, GtkPrintSettings* settings, OnUpdateCustomWidgetDelegateWrapper wrapper) 1459 { 1460 wrapper.dlg(ObjectG.getDObject!(Widget)(widget), ObjectG.getDObject!(PageSetup)(setup), ObjectG.getDObject!(PrintSettings)(settings), wrapper.outer); 1461 } 1462 1463 extern(C) static void callBackUpdateCustomWidgetDestroy(OnUpdateCustomWidgetDelegateWrapper wrapper, GClosure* closure) 1464 { 1465 wrapper.remove(wrapper); 1466 } 1467 1468 /** 1469 * Runs a page setup dialog, letting the user modify the values from 1470 * @page_setup. If the user cancels the dialog, the returned #GtkPageSetup 1471 * is identical to the passed in @page_setup, otherwise it contains the 1472 * modifications done in the dialog. 1473 * 1474 * Note that this function may use a recursive mainloop to show the page 1475 * setup dialog. See gtk_print_run_page_setup_dialog_async() if this is 1476 * a problem. 1477 * 1478 * Params: 1479 * parent = transient parent 1480 * pageSetup = an existing #GtkPageSetup 1481 * settings = a #GtkPrintSettings 1482 * 1483 * Returns: a new #GtkPageSetup 1484 * 1485 * Since: 2.10 1486 */ 1487 public static PageSetup printRunPageSetupDialog(Window parent, PageSetup pageSetup, PrintSettings settings) 1488 { 1489 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()); 1490 1491 if(p is null) 1492 { 1493 return null; 1494 } 1495 1496 return ObjectG.getDObject!(PageSetup)(cast(GtkPageSetup*) p, true); 1497 } 1498 1499 /** 1500 * Runs a page setup dialog, letting the user modify the values from @page_setup. 1501 * 1502 * In contrast to gtk_print_run_page_setup_dialog(), this function returns after 1503 * showing the page setup dialog on platforms that support this, and calls @done_cb 1504 * from a signal handler for the ::response signal of the dialog. 1505 * 1506 * Params: 1507 * parent = transient parent, or %NULL 1508 * pageSetup = an existing #GtkPageSetup, or %NULL 1509 * settings = a #GtkPrintSettings 1510 * doneCb = a function to call when the user saves 1511 * the modified page setup 1512 * data = user data to pass to @done_cb 1513 * 1514 * Since: 2.10 1515 */ 1516 public static void printRunPageSetupDialogAsync(Window parent, PageSetup pageSetup, PrintSettings settings, GtkPageSetupDoneFunc doneCb, void* data) 1517 { 1518 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); 1519 } 1520 }