1 /* 2 * This file is part of EvinceD. 3 * EvinceD is based on GtkD. 4 * 5 * EvinceD is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU Lesser General Public License 7 * as published by the Free Software Foundation; either version 3 8 * of the License, or (at your option) any later version, with 9 * some exceptions, please read the COPYING file. 10 * 11 * EvinceD is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public License 17 * along with EvinceD; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 19 */ 20 21 // generated automatically - do not change 22 // find conversion definition on APILookup.txt 23 24 25 module evince.document.Document; 26 27 private import cairo.Context; 28 private import cairo.Surface; 29 private import evince.document.DocumentInfo; 30 private import evince.document.Page; 31 private import evince.document.RenderContext; 32 private import evince.document.SourceLink; 33 private import evince.document.c.functions; 34 public import evince.document.c.types; 35 private import gdk.Screen; 36 private import gdkpixbuf.Pixbuf; 37 private import gio.Cancellable; 38 private import gio.FileIF; 39 private import gio.InputStream; 40 private import glib.DateTime; 41 private import glib.ErrorG; 42 private import glib.GException; 43 private import glib.Mutex; 44 private import glib.Str; 45 private import gobject.ObjectG; 46 private import gtk.Border; 47 private import gtk.Widget; 48 49 50 /** */ 51 public class Document : ObjectG 52 { 53 /** the main Gtk struct */ 54 protected EvDocument* evDocument; 55 56 /** Get the main Gtk struct */ 57 public EvDocument* getDocumentStruct(bool transferOwnership = false) 58 { 59 if (transferOwnership) 60 ownedRef = false; 61 return evDocument; 62 } 63 64 /** the main Gtk struct as a void* */ 65 protected override void* getStruct() 66 { 67 return cast(void*)evDocument; 68 } 69 70 /** 71 * Sets our main struct and passes it to the parent class. 72 */ 73 public this (EvDocument* evDocument, bool ownedRef = false) 74 { 75 this.evDocument = evDocument; 76 super(cast(GObject*)evDocument, ownedRef); 77 } 78 79 80 /** */ 81 public static GType getType() 82 { 83 return ev_document_get_type(); 84 } 85 86 /** */ 87 public static void docMutexLock() 88 { 89 ev_document_doc_mutex_lock(); 90 } 91 92 /** */ 93 public static bool docMutexTrylock() 94 { 95 return ev_document_doc_mutex_trylock() != 0; 96 } 97 98 /** */ 99 public static void docMutexUnlock() 100 { 101 ev_document_doc_mutex_unlock(); 102 } 103 104 /** 105 * Adds some file filters to @chooser. 106 * 107 * Always add a "All documents" format. 108 * 109 * If @document is not %NULL, adds a #GtkFileFilter for @document's MIME type. 110 * 111 * If @document is %NULL, adds a #GtkFileFilter for each document type that evince 112 * can handle. 113 * 114 * Params: 115 * chooser = a #GtkFileChooser 116 * document = a #EvDocument, or %NULL 117 */ 118 public static void factoryAddFilters(Widget chooser, Document document) 119 { 120 ev_document_factory_add_filters((chooser is null) ? null : chooser.getWidgetStruct(), (document is null) ? null : document.getDocumentStruct()); 121 } 122 123 /** 124 * Creates a #EvDocument for the document at @uri; or, if no backend handling 125 * the document's type is found, or an error occurred on opening the document, 126 * returns %NULL and fills in @error. 127 * If the document is encrypted, it is returned but also @error is set to 128 * %EV_DOCUMENT_ERROR_ENCRYPTED. 129 * 130 * Params: 131 * uri = an URI 132 * 133 * Returns: a new #EvDocument, or %NULL 134 * 135 * Throws: GException on failure. 136 */ 137 public static Document factoryGetDocument(string uri) 138 { 139 GError* err = null; 140 141 auto __p = ev_document_factory_get_document(Str.toStringz(uri), &err); 142 143 if (err !is null) 144 { 145 throw new GException( new ErrorG(err) ); 146 } 147 148 if(__p is null) 149 { 150 return null; 151 } 152 153 return ObjectG.getDObject!(Document)(cast(EvDocument*) __p, true); 154 } 155 156 /** 157 * Synchronously creates a #EvDocument for the document at @file; or, if no 158 * backend handling the document's type is found, or an error occurred on 159 * opening the document, returns %NULL and fills in @error. 160 * If the document is encrypted, it is returned but also @error is set to 161 * %EV_DOCUMENT_ERROR_ENCRYPTED. 162 * 163 * Params: 164 * file = a #GFile 165 * flags = flags from #EvDocumentLoadFlags 166 * cancellable = a #GCancellable, or %NULL 167 * 168 * Returns: a new #EvDocument, or %NULL 169 * 170 * Since: 3.6 171 * 172 * Throws: GException on failure. 173 */ 174 public static Document factoryGetDocumentForGfile(FileIF file, EvDocumentLoadFlags flags, Cancellable cancellable) 175 { 176 GError* err = null; 177 178 auto __p = ev_document_factory_get_document_for_gfile((file is null) ? null : file.getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 179 180 if (err !is null) 181 { 182 throw new GException( new ErrorG(err) ); 183 } 184 185 if(__p is null) 186 { 187 return null; 188 } 189 190 return ObjectG.getDObject!(Document)(cast(EvDocument*) __p, true); 191 } 192 193 /** 194 * Synchronously creates a #EvDocument for the document from @stream; or, if no 195 * backend handling the document's type is found, or an error occurred 196 * on opening the document, returns %NULL and fills in @error. 197 * If the document is encrypted, it is returned but also @error is set to 198 * %EV_DOCUMENT_ERROR_ENCRYPTED. 199 * 200 * If @mime_type is non-%NULL, this overrides any type inferred from the stream. 201 * If the mime type cannot be inferred from the stream, and @mime_type is %NULL, 202 * an error is returned. 203 * 204 * Params: 205 * stream = a #GInputStream 206 * mimeType = a mime type hint 207 * flags = flags from #EvDocumentLoadFlags 208 * cancellable = a #GCancellable, or %NULL 209 * 210 * Returns: a new #EvDocument, or %NULL 211 * 212 * Since: 3.6 213 * 214 * Throws: GException on failure. 215 */ 216 public static Document factoryGetDocumentForStream(InputStream stream, string mimeType, EvDocumentLoadFlags flags, Cancellable cancellable) 217 { 218 GError* err = null; 219 220 auto __p = ev_document_factory_get_document_for_stream((stream is null) ? null : stream.getInputStreamStruct(), Str.toStringz(mimeType), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 221 222 if (err !is null) 223 { 224 throw new GException( new ErrorG(err) ); 225 } 226 227 if(__p is null) 228 { 229 return null; 230 } 231 232 return ObjectG.getDObject!(Document)(cast(EvDocument*) __p, true); 233 } 234 235 /** 236 * Creates a #EvDocument for the document at @uri; or, if no backend handling 237 * the document's type is found, or an error occurred on opening the document, 238 * returns %NULL and fills in @error. 239 * If the document is encrypted, it is returned but also @error is set to 240 * %EV_DOCUMENT_ERROR_ENCRYPTED. 241 * 242 * Params: 243 * uri = an URI 244 * flags = flags from #EvDocumentLoadFlags 245 * 246 * Returns: a new #EvDocument, or %NULL 247 * 248 * Throws: GException on failure. 249 */ 250 public static Document factoryGetDocumentFull(string uri, EvDocumentLoadFlags flags) 251 { 252 GError* err = null; 253 254 auto __p = ev_document_factory_get_document_full(Str.toStringz(uri), flags, &err); 255 256 if (err !is null) 257 { 258 throw new GException( new ErrorG(err) ); 259 } 260 261 if(__p is null) 262 { 263 return null; 264 } 265 266 return ObjectG.getDObject!(Document)(cast(EvDocument*) __p, true); 267 } 268 269 /** */ 270 public static void fcMutexLock() 271 { 272 ev_document_fc_mutex_lock(); 273 } 274 275 /** */ 276 public static bool fcMutexTrylock() 277 { 278 return ev_document_fc_mutex_trylock() != 0; 279 } 280 281 /** */ 282 public static void fcMutexUnlock() 283 { 284 ev_document_fc_mutex_unlock(); 285 } 286 287 /** */ 288 public static Mutex getDocMutex() 289 { 290 auto __p = ev_document_get_doc_mutex(); 291 292 if(__p is null) 293 { 294 return null; 295 } 296 297 return new Mutex(cast(GMutex*) __p); 298 } 299 300 /** */ 301 public static Mutex getFcMutex() 302 { 303 auto __p = ev_document_get_fc_mutex(); 304 305 if(__p is null) 306 { 307 return null; 308 } 309 310 return new Mutex(cast(GMutex*) __p); 311 } 312 313 /** 314 * 315 * 316 * Deprecated: use ev_document_misc_format_datetime instead as GTime is 317 * deprecated because it is not year-2038 safe. 318 * 319 * Params: 320 * utime = a #GTime 321 * 322 * Returns: a locale specific date and time representation. 323 */ 324 public static string miscFormatDate(GTime utime) 325 { 326 auto retStr = ev_document_misc_format_date(utime); 327 328 scope(exit) Str.freeString(retStr); 329 return Str.toString(retStr); 330 } 331 332 /** 333 * Determine the preferred date and time representation for the current locale 334 * for @dt. 335 * 336 * Params: 337 * dt = a #GDateTime 338 * 339 * Returns: a new allocated string or NULL in the case 340 * that there was an error (such as a format specifier not being supported 341 * in the current locale). The string should be freed with g_free(). 342 * 343 * Since: 3.38 344 */ 345 public static string miscFormatDatetime(DateTime dt) 346 { 347 auto retStr = ev_document_misc_format_datetime((dt is null) ? null : dt.getDateTimeStruct()); 348 349 scope(exit) Str.freeString(retStr); 350 return Str.toString(retStr); 351 } 352 353 /** 354 * 355 * Params: 356 * width = the desired width 357 * height = the desired height 358 * invertedColors = whether to invert colors 359 * Returns: a #GdkPixbuf 360 */ 361 public static Pixbuf miscGetLoadingThumbnail(int width, int height, bool invertedColors) 362 { 363 auto __p = ev_document_misc_get_loading_thumbnail(width, height, invertedColors); 364 365 if(__p is null) 366 { 367 return null; 368 } 369 370 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) __p, true); 371 } 372 373 /** */ 374 public static void miscGetPageBorderSize(int pageWidth, int pageHeight, Border border) 375 { 376 ev_document_misc_get_page_border_size(pageWidth, pageHeight, (border is null) ? null : border.getBorderStruct()); 377 } 378 379 /** 380 * Get the pointer's x and y position relative to @widget. 381 * 382 * Params: 383 * widget = a #GtkWidget 384 * x = the pointer's "x" position, or -1 if the position is not 385 * available 386 * y = the pointer's "y" position, or -1 if the position is not 387 * available 388 */ 389 public static void miscGetPointerPosition(Widget widget, out int x, out int y) 390 { 391 ev_document_misc_get_pointer_position((widget is null) ? null : widget.getWidgetStruct(), &x, &y); 392 } 393 394 /** 395 * 396 * 397 * Deprecated: This uses a deprecated GDK API. Use 398 * ev_document_misc_get_widget_dpi() instead, which uses GDK's per-monitor 399 * information. 400 * 401 * Params: 402 * screen = a #GtkScreen 403 * 404 * Returns: The DPI of @screen, or 96 if the DPI is not available 405 */ 406 public static double miscGetScreenDpi(Screen screen) 407 { 408 return ev_document_misc_get_screen_dpi((screen is null) ? null : screen.getScreenStruct()); 409 } 410 411 /** 412 * 413 * Params: 414 * width = the desired width 415 * height = the desired height 416 * sourcePixbuf = a #GdkPixbuf 417 * Returns: a #GdkPixbuf 418 */ 419 public static Pixbuf miscGetThumbnailFrame(int width, int height, Pixbuf sourcePixbuf) 420 { 421 auto __p = ev_document_misc_get_thumbnail_frame(width, height, (sourcePixbuf is null) ? null : sourcePixbuf.getPixbufStruct()); 422 423 if(__p is null) 424 { 425 return null; 426 } 427 428 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) __p, true); 429 } 430 431 /** 432 * Returns DPI for monitor on which given widget has been realized. 433 * Returns DPI of primary monitor or DPI of first monitor in the list inside 434 * of GdkDisplay if the widget has not been realized yet. 435 * Returns 96 as fallback value. 436 * 437 * Params: 438 * widget = a #GtkWidget 439 * 440 * Returns: DPI as gdouble 441 */ 442 public static double miscGetWidgetDpi(Widget widget) 443 { 444 return ev_document_misc_get_widget_dpi((widget is null) ? null : widget.getWidgetStruct()); 445 } 446 447 /** */ 448 public static void miscInvertPixbuf(Pixbuf pixbuf) 449 { 450 ev_document_misc_invert_pixbuf((pixbuf is null) ? null : pixbuf.getPixbufStruct()); 451 } 452 453 /** */ 454 public static void miscInvertSurface(Surface surface) 455 { 456 ev_document_misc_invert_surface((surface is null) ? null : surface.getSurfaceStruct()); 457 } 458 459 /** */ 460 public static void miscPaintOnePage(Context cr, Widget widget, GdkRectangle* area, Border border, bool highlight, bool invertedColors) 461 { 462 ev_document_misc_paint_one_page((cr is null) ? null : cr.getContextStruct(), (widget is null) ? null : widget.getWidgetStruct(), area, (border is null) ? null : border.getBorderStruct(), highlight, invertedColors); 463 } 464 465 /** 466 * 467 * Params: 468 * surface = a #cairo_surface_t 469 * Returns: a #GdkPixbuf 470 */ 471 public static Pixbuf miscPixbufFromSurface(Surface surface) 472 { 473 auto __p = ev_document_misc_pixbuf_from_surface((surface is null) ? null : surface.getSurfaceStruct()); 474 475 if(__p is null) 476 { 477 return null; 478 } 479 480 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) __p, true); 481 } 482 483 /** 484 * 485 * Params: 486 * widget = a #GtkWidget to use for style information 487 * width = the desired width 488 * height = the desired height 489 * invertedColors = whether to invert colors 490 * Returns: a #GdkPixbuf 491 * 492 * Since: 3.8 493 */ 494 public static Pixbuf miscRenderLoadingThumbnail(Widget widget, int width, int height, bool invertedColors) 495 { 496 auto __p = ev_document_misc_render_loading_thumbnail((widget is null) ? null : widget.getWidgetStruct(), width, height, invertedColors); 497 498 if(__p is null) 499 { 500 return null; 501 } 502 503 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) __p, true); 504 } 505 506 /** 507 * 508 * Params: 509 * widget = a #GtkWidget to use for style information 510 * width = the desired width 511 * height = the desired height 512 * invertedColors = whether to invert colors 513 * Returns: a #cairo_surface_t 514 * 515 * Since: 3.14 516 */ 517 public static Surface miscRenderLoadingThumbnailSurface(Widget widget, int width, int height, bool invertedColors) 518 { 519 auto __p = ev_document_misc_render_loading_thumbnail_surface((widget is null) ? null : widget.getWidgetStruct(), width, height, invertedColors); 520 521 if(__p is null) 522 { 523 return null; 524 } 525 526 return new Surface(cast(cairo_surface_t*) __p); 527 } 528 529 /** 530 * 531 * Params: 532 * widget = a #GtkWidget to use for style information 533 * sourceSurface = a #cairo_surface_t 534 * width = the desired width 535 * height = the desired height 536 * Returns: a #cairo_surface_t 537 * 538 * Since: 3.14 539 */ 540 public static Surface miscRenderThumbnailSurfaceWithFrame(Widget widget, Surface sourceSurface, int width, int height) 541 { 542 auto __p = ev_document_misc_render_thumbnail_surface_with_frame((widget is null) ? null : widget.getWidgetStruct(), (sourceSurface is null) ? null : sourceSurface.getSurfaceStruct(), width, height); 543 544 if(__p is null) 545 { 546 return null; 547 } 548 549 return new Surface(cast(cairo_surface_t*) __p); 550 } 551 552 /** 553 * 554 * Params: 555 * widget = a #GtkWidget to use for style information 556 * sourcePixbuf = a #GdkPixbuf 557 * Returns: a #GdkPixbuf 558 * 559 * Since: 3.8 560 */ 561 public static Pixbuf miscRenderThumbnailWithFrame(Widget widget, Pixbuf sourcePixbuf) 562 { 563 auto __p = ev_document_misc_render_thumbnail_with_frame((widget is null) ? null : widget.getWidgetStruct(), (sourcePixbuf is null) ? null : sourcePixbuf.getPixbufStruct()); 564 565 if(__p is null) 566 { 567 return null; 568 } 569 570 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) __p, true); 571 } 572 573 /** */ 574 public static Surface miscSurfaceFromPixbuf(Pixbuf pixbuf) 575 { 576 auto __p = ev_document_misc_surface_from_pixbuf((pixbuf is null) ? null : pixbuf.getPixbufStruct()); 577 578 if(__p is null) 579 { 580 return null; 581 } 582 583 return new Surface(cast(cairo_surface_t*) __p); 584 } 585 586 /** */ 587 public static Surface miscSurfaceRotateAndScale(Surface surface, int destWidth, int destHeight, int destRotation) 588 { 589 auto __p = ev_document_misc_surface_rotate_and_scale((surface is null) ? null : surface.getSurfaceStruct(), destWidth, destHeight, destRotation); 590 591 if(__p is null) 592 { 593 return null; 594 } 595 596 return new Surface(cast(cairo_surface_t*) __p); 597 } 598 599 /** */ 600 public bool checkDimensions() 601 { 602 return ev_document_check_dimensions(evDocument) != 0; 603 } 604 605 /** */ 606 public bool findPageByLabel(string pageLabel, int* pageIndex) 607 { 608 return ev_document_find_page_by_label(evDocument, Str.toStringz(pageLabel), pageIndex) != 0; 609 } 610 611 /** */ 612 public bool getBackendInfo(EvDocumentBackendInfo* info) 613 { 614 return ev_document_get_backend_info(evDocument, info) != 0; 615 } 616 617 /** 618 * Returns the #EvDocumentInfo for the document. 619 * 620 * Returns: a #EvDocumentInfo 621 */ 622 public DocumentInfo getInfo() 623 { 624 auto __p = ev_document_get_info(evDocument); 625 626 if(__p is null) 627 { 628 return null; 629 } 630 631 return ObjectG.getDObject!(DocumentInfo)(cast(EvDocumentInfo*) __p); 632 } 633 634 /** */ 635 public int getMaxLabelLen() 636 { 637 return ev_document_get_max_label_len(evDocument); 638 } 639 640 /** */ 641 public void getMaxPageSize(double* width, double* height) 642 { 643 ev_document_get_max_page_size(evDocument, width, height); 644 } 645 646 /** */ 647 public void getMinPageSize(double* width, double* height) 648 { 649 ev_document_get_min_page_size(evDocument, width, height); 650 } 651 652 /** 653 * Returns: %TRUE iff the document has been modified. 654 * 655 * You can monitor changes to the modification state by connecting to the 656 * notify::modified signal on @document. 657 * 658 * Since: 3.28 659 */ 660 public bool getModified() 661 { 662 return ev_document_get_modified(evDocument) != 0; 663 } 664 665 /** */ 666 public int getNPages() 667 { 668 return ev_document_get_n_pages(evDocument); 669 } 670 671 /** 672 * 673 * Params: 674 * index = index of page 675 * Returns: Newly created #EvPage for the given index. 676 */ 677 public Page getPage(int index) 678 { 679 auto __p = ev_document_get_page(evDocument, index); 680 681 if(__p is null) 682 { 683 return null; 684 } 685 686 return ObjectG.getDObject!(Page)(cast(EvPage*) __p, true); 687 } 688 689 /** */ 690 public string getPageLabel(int pageIndex) 691 { 692 auto retStr = ev_document_get_page_label(evDocument, pageIndex); 693 694 scope(exit) Str.freeString(retStr); 695 return Str.toString(retStr); 696 } 697 698 /** */ 699 public void getPageSize(int pageIndex, out double width, out double height) 700 { 701 ev_document_get_page_size(evDocument, pageIndex, &width, &height); 702 } 703 704 /** */ 705 public ulong getSize() 706 { 707 return ev_document_get_size(evDocument); 708 } 709 710 /** 711 * 712 * Params: 713 * rc = an #EvRenderContext 714 * Returns: a #GdkPixbuf 715 */ 716 public Pixbuf getThumbnail(RenderContext rc) 717 { 718 auto __p = ev_document_get_thumbnail(evDocument, (rc is null) ? null : rc.getRenderContextStruct()); 719 720 if(__p is null) 721 { 722 return null; 723 } 724 725 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) __p, true); 726 } 727 728 /** 729 * 730 * Params: 731 * rc = an #EvRenderContext 732 * Returns: a #cairo_surface_t 733 * 734 * Since: 3.14 735 */ 736 public Surface getThumbnailSurface(RenderContext rc) 737 { 738 auto __p = ev_document_get_thumbnail_surface(evDocument, (rc is null) ? null : rc.getRenderContextStruct()); 739 740 if(__p is null) 741 { 742 return null; 743 } 744 745 return new Surface(cast(cairo_surface_t*) __p); 746 } 747 748 /** */ 749 public string getTitle() 750 { 751 return Str.toString(ev_document_get_title(evDocument)); 752 } 753 754 /** */ 755 public string getUri() 756 { 757 return Str.toString(ev_document_get_uri(evDocument)); 758 } 759 760 /** */ 761 public bool hasSynctex() 762 { 763 return ev_document_has_synctex(evDocument) != 0; 764 } 765 766 /** */ 767 public bool hasTextPageLabels() 768 { 769 return ev_document_has_text_page_labels(evDocument) != 0; 770 } 771 772 /** */ 773 public bool isPageSizeUniform() 774 { 775 return ev_document_is_page_size_uniform(evDocument) != 0; 776 } 777 778 /** 779 * Loads @document from @uri. 780 * 781 * On failure, %FALSE is returned and @error is filled in. 782 * If the document is encrypted, EV_DEFINE_ERROR_ENCRYPTED is returned. 783 * If the backend cannot load the specific document, EV_DOCUMENT_ERROR_INVALID 784 * is returned. If the backend does not support the format for the document's 785 * contents, EV_DOCUMENT_ERROR_UNSUPPORTED_CONTENT is returned. Other errors 786 * are possible too, depending on the backend used to load the document and 787 * the URI, e.g. #GIOError, #GFileError, and #GConvertError. 788 * 789 * Params: 790 * uri = the document's URI 791 * 792 * Returns: %TRUE on success, or %FALSE on failure. 793 * 794 * Throws: GException on failure. 795 */ 796 public bool load(string uri) 797 { 798 GError* err = null; 799 800 auto __p = ev_document_load(evDocument, Str.toStringz(uri), &err) != 0; 801 802 if (err !is null) 803 { 804 throw new GException( new ErrorG(err) ); 805 } 806 807 return __p; 808 } 809 810 /** 811 * Loads @document from @uri. 812 * 813 * On failure, %FALSE is returned and @error is filled in. 814 * If the document is encrypted, EV_DEFINE_ERROR_ENCRYPTED is returned. 815 * If the backend cannot load the specific document, EV_DOCUMENT_ERROR_INVALID 816 * is returned. Other errors are possible too, depending on the backend 817 * used to load the document and the URI, e.g. #GIOError, #GFileError, and 818 * #GConvertError. 819 * 820 * Params: 821 * uri = the document's URI 822 * flags = flags from #EvDocumentLoadFlags 823 * 824 * Returns: %TRUE on success, or %FALSE on failure. 825 * 826 * Throws: GException on failure. 827 */ 828 public bool loadFull(string uri, EvDocumentLoadFlags flags) 829 { 830 GError* err = null; 831 832 auto __p = ev_document_load_full(evDocument, Str.toStringz(uri), flags, &err) != 0; 833 834 if (err !is null) 835 { 836 throw new GException( new ErrorG(err) ); 837 } 838 839 return __p; 840 } 841 842 /** 843 * Synchronously loads the document from @file. 844 * See ev_document_load() for more information. 845 * 846 * Params: 847 * file = a #GFile 848 * flags = flags from #EvDocumentLoadFlags 849 * cancellable = a #GCancellable, or %NULL 850 * 851 * Returns: %TRUE if loading succeeded, or %FALSE on error with @error filled in 852 * 853 * Since: 3.6 854 * 855 * Throws: GException on failure. 856 */ 857 public bool loadGfile(FileIF file, EvDocumentLoadFlags flags, Cancellable cancellable) 858 { 859 GError* err = null; 860 861 auto __p = ev_document_load_gfile(evDocument, (file is null) ? null : file.getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 862 863 if (err !is null) 864 { 865 throw new GException( new ErrorG(err) ); 866 } 867 868 return __p; 869 } 870 871 /** 872 * Synchronously loads the document from @stream. 873 * See ev_document_load() for more information. 874 * 875 * Params: 876 * stream = a #GInputStream 877 * flags = flags from #EvDocumentLoadFlags 878 * cancellable = a #GCancellable, or %NULL 879 * 880 * Returns: %TRUE if loading succeeded, or %FALSE on error with @error filled in 881 * 882 * Since: 3.6 883 * 884 * Throws: GException on failure. 885 */ 886 public bool loadStream(InputStream stream, EvDocumentLoadFlags flags, Cancellable cancellable) 887 { 888 GError* err = null; 889 890 auto __p = ev_document_load_stream(evDocument, (stream is null) ? null : stream.getInputStreamStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 891 892 if (err !is null) 893 { 894 throw new GException( new ErrorG(err) ); 895 } 896 897 return __p; 898 } 899 900 /** */ 901 public Surface render(RenderContext rc) 902 { 903 auto __p = ev_document_render(evDocument, (rc is null) ? null : rc.getRenderContextStruct()); 904 905 if(__p is null) 906 { 907 return null; 908 } 909 910 return new Surface(cast(cairo_surface_t*) __p); 911 } 912 913 /** 914 * Saves @document to @uri. 915 * 916 * Params: 917 * uri = the target URI 918 * 919 * Returns: %TRUE on success, or %FALSE on error with @error filled in 920 * 921 * Throws: GException on failure. 922 */ 923 public bool save(string uri) 924 { 925 GError* err = null; 926 927 auto __p = ev_document_save(evDocument, Str.toStringz(uri), &err) != 0; 928 929 if (err !is null) 930 { 931 throw new GException( new ErrorG(err) ); 932 } 933 934 return __p; 935 } 936 937 /** 938 * Set the @document modification state as @modified. 939 * 940 * Params: 941 * modified = a boolean value to set the document as modified or not. 942 * 943 * Since: 3.28 944 */ 945 public void setModified(bool modified) 946 { 947 ev_document_set_modified(evDocument, modified); 948 } 949 950 /** 951 * Peforms a Synctex backward search to obtain the TeX input file, line and 952 * (possibly) column corresponding to the position (@x,@y) (in 72dpi 953 * coordinates) in the @page of @document. 954 * 955 * Params: 956 * pageIndex = the target page 957 * x = X coordinate 958 * y = Y coordinate 959 * 960 * Returns: A pointer to the EvSourceLink structure that holds the result. @NULL if synctex 961 * is not enabled for the document or no result is found. 962 * The EvSourceLink pointer should be freed with g_free after it is used. 963 */ 964 public SourceLink synctexBackwardSearch(int pageIndex, float x, float y) 965 { 966 auto __p = ev_document_synctex_backward_search(evDocument, pageIndex, x, y); 967 968 if(__p is null) 969 { 970 return null; 971 } 972 973 return ObjectG.getDObject!(SourceLink)(cast(EvSourceLink*) __p, true); 974 } 975 976 /** 977 * Peforms a Synctex forward search to obtain the area in the document 978 * corresponding to the position (line and column in @source_link) in 979 * the source Tex file. 980 * 981 * Params: 982 * sourceLink = a #EvSourceLink 983 * 984 * Returns: An EvMapping with the page number and area corresponding to 985 * the given line in the source file. It must be free with g_free when done 986 */ 987 public EvMapping* synctexForwardSearch(SourceLink sourceLink) 988 { 989 return ev_document_synctex_forward_search(evDocument, (sourceLink is null) ? null : sourceLink.getSourceLinkStruct()); 990 } 991 }