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.view.View; 26 27 private import evince.document.Annotation; 28 private import evince.document.Link; 29 private import evince.document.LinkAction; 30 private import evince.document.SourceLink; 31 private import evince.view.DocumentModel; 32 private import evince.view.JobFind; 33 private import evince.view.c.functions; 34 public import evince.view.c.types; 35 private import glib.ConstructionException; 36 private import glib.Str; 37 private import gobject.ObjectG; 38 private import gobject.Signals; 39 private import gtk.Border; 40 private import gtk.BuildableIF; 41 private import gtk.BuildableT; 42 private import gtk.Container; 43 private import gtk.ScrollableIF; 44 private import gtk.ScrollableT; 45 private import gtk.Widget; 46 private import std.algorithm; 47 48 49 /** */ 50 public class View : Container, ScrollableIF 51 { 52 /** the main Gtk struct */ 53 protected EvView* evView; 54 55 /** Get the main Gtk struct */ 56 public EvView* getViewStruct(bool transferOwnership = false) 57 { 58 if (transferOwnership) 59 ownedRef = false; 60 return evView; 61 } 62 63 /** the main Gtk struct as a void* */ 64 protected override void* getStruct() 65 { 66 return cast(void*)evView; 67 } 68 69 /** 70 * Sets our main struct and passes it to the parent class. 71 */ 72 public this (EvView* evView, bool ownedRef = false) 73 { 74 this.evView = evView; 75 super(cast(GtkContainer*)evView, ownedRef); 76 } 77 78 // add the Scrollable capabilities 79 mixin ScrollableT!(EvView); 80 81 82 /** */ 83 public static GType getType() 84 { 85 return ev_view_get_type(); 86 } 87 88 /** */ 89 public this() 90 { 91 auto __p = ev_view_new(); 92 93 if(__p is null) 94 { 95 throw new ConstructionException("null returned by new"); 96 } 97 98 this(cast(EvView*) __p); 99 } 100 101 /** 102 * Adds a Text Markup annotation (defaulting to a 'highlight' one) to 103 * the currently selected text on the document. 104 * 105 * When the selected text spans more than one page, it will add a 106 * corresponding annotation for each page that contains selected text. 107 * 108 * Returns: %TRUE if annotations were added successfully, %FALSE otherwise. 109 * 110 * Since: 3.30 111 */ 112 public bool addTextMarkupAnnotationForSelectedText() 113 { 114 return ev_view_add_text_markup_annotation_for_selected_text(evView) != 0; 115 } 116 117 /** */ 118 public void autoscrollStart() 119 { 120 ev_view_autoscroll_start(evView); 121 } 122 123 /** */ 124 public void autoscrollStop() 125 { 126 ev_view_autoscroll_stop(evView); 127 } 128 129 /** */ 130 public void beginAddAnnotation(EvAnnotationType annotType) 131 { 132 ev_view_begin_add_annotation(evView, annotType); 133 } 134 135 /** */ 136 public bool canZoomIn() 137 { 138 return ev_view_can_zoom_in(evView) != 0; 139 } 140 141 /** */ 142 public bool canZoomOut() 143 { 144 return ev_view_can_zoom_out(evView) != 0; 145 } 146 147 /** */ 148 public void cancelAddAnnotation() 149 { 150 ev_view_cancel_add_annotation(evView); 151 } 152 153 /** */ 154 public void copy() 155 { 156 ev_view_copy(evView); 157 } 158 159 /** */ 160 public void copyLinkAddress(LinkAction action) 161 { 162 ev_view_copy_link_address(evView, (action is null) ? null : action.getLinkActionStruct()); 163 } 164 165 /** */ 166 public void findCancel() 167 { 168 ev_view_find_cancel(evView); 169 } 170 171 /** */ 172 public void findNext() 173 { 174 ev_view_find_next(evView); 175 } 176 177 /** */ 178 public void findPrevious() 179 { 180 ev_view_find_previous(evView); 181 } 182 183 /** 184 * Restart the current search operation from the given @page. 185 * 186 * Params: 187 * page = a page index 188 * 189 * Since: 3.12 190 */ 191 public void findRestart(int page) 192 { 193 ev_view_find_restart(evView, page); 194 } 195 196 /** */ 197 public void findSearchChanged() 198 { 199 ev_view_find_search_changed(evView); 200 } 201 202 /** */ 203 public void findSetHighlightSearch(bool value) 204 { 205 ev_view_find_set_highlight_search(evView, value); 206 } 207 208 /** 209 * FIXME 210 * 211 * Since: 3.10 212 */ 213 public void findSetResult(int page, int result) 214 { 215 ev_view_find_set_result(evView, page, result); 216 } 217 218 /** */ 219 public void findStarted(JobFind job) 220 { 221 ev_view_find_started(evView, (job is null) ? null : job.getJobFindStruct()); 222 } 223 224 /** */ 225 public void focusAnnotation(EvMapping* annotMapping) 226 { 227 ev_view_focus_annotation(evView, annotMapping); 228 } 229 230 /** */ 231 public bool getAllowLinksChangeZoom() 232 { 233 return ev_view_get_allow_links_change_zoom(evView) != 0; 234 } 235 236 /** */ 237 public bool getEnableSpellchecking() 238 { 239 return ev_view_get_enable_spellchecking(evView) != 0; 240 } 241 242 /** */ 243 public bool getHasSelection() 244 { 245 return ev_view_get_has_selection(evView) != 0; 246 } 247 248 /** */ 249 public bool getPageExtents(int page, GdkRectangle* pageArea, Border border) 250 { 251 return ev_view_get_page_extents(evView, page, pageArea, (border is null) ? null : border.getBorderStruct()) != 0; 252 } 253 254 /** */ 255 public bool getPageExtentsForBorder(int page, Border border, GdkRectangle* pageArea) 256 { 257 return ev_view_get_page_extents_for_border(evView, page, (border is null) ? null : border.getBorderStruct(), pageArea) != 0; 258 } 259 260 /** 261 * Returns a pointer to a constant string containing the selected 262 * text in the view. 263 * 264 * The value returned may be NULL if there is no selected text. 265 * 266 * Returns: The string representing selected text. 267 * 268 * Since: 3.30 269 */ 270 public string getSelectedText() 271 { 272 auto retStr = ev_view_get_selected_text(evView); 273 274 scope(exit) Str.freeString(retStr); 275 return Str.toString(retStr); 276 } 277 278 /** */ 279 public void handleLink(Link link) 280 { 281 ev_view_handle_link(evView, (link is null) ? null : link.getLinkStruct()); 282 } 283 284 /** */ 285 public void hideCursor() 286 { 287 ev_view_hide_cursor(evView); 288 } 289 290 /** */ 291 public void highlightForwardSearch(SourceLink link) 292 { 293 ev_view_highlight_forward_search(evView, (link is null) ? null : link.getSourceLinkStruct()); 294 } 295 296 /** */ 297 public bool isCaretNavigationEnabled() 298 { 299 return ev_view_is_caret_navigation_enabled(evView) != 0; 300 } 301 302 /** 303 * Returns: %TRUE iff the view is currently loading a document 304 * 305 * Since: 3.8 306 */ 307 public bool isLoading() 308 { 309 return ev_view_is_loading(evView) != 0; 310 } 311 312 /** */ 313 public bool nextPage() 314 { 315 return ev_view_next_page(evView) != 0; 316 } 317 318 /** */ 319 public bool previousPage() 320 { 321 return ev_view_previous_page(evView) != 0; 322 } 323 324 /** */ 325 public void reload() 326 { 327 ev_view_reload(evView); 328 } 329 330 /** */ 331 public void removeAnnotation(Annotation annot) 332 { 333 ev_view_remove_annotation(evView, (annot is null) ? null : annot.getAnnotationStruct()); 334 } 335 336 /** */ 337 public void scroll(GtkScrollType scroll, bool horizontal) 338 { 339 ev_view_scroll(evView, scroll, horizontal); 340 } 341 342 /** */ 343 public void selectAll() 344 { 345 ev_view_select_all(evView); 346 } 347 348 /** */ 349 public void setAllowLinksChangeZoom(bool allowed) 350 { 351 ev_view_set_allow_links_change_zoom(evView, allowed); 352 } 353 354 /** */ 355 public void setCaretCursorPosition(uint page, uint offset) 356 { 357 ev_view_set_caret_cursor_position(evView, page, offset); 358 } 359 360 /** 361 * Enables or disables caret navigation mode for the document. 362 * 363 * Params: 364 * enabled = whether to enable caret navigation mode 365 * 366 * Since: 3.10 367 */ 368 public void setCaretNavigationEnabled(bool enabled) 369 { 370 ev_view_set_caret_navigation_enabled(evView, enabled); 371 } 372 373 /** */ 374 public void setEnableSpellchecking(bool spellcheck) 375 { 376 ev_view_set_enable_spellchecking(evView, spellcheck); 377 } 378 379 /** */ 380 public void setLoading(bool loading) 381 { 382 ev_view_set_loading(evView, loading); 383 } 384 385 /** */ 386 public void setModel(DocumentModel model) 387 { 388 ev_view_set_model(evView, (model is null) ? null : model.getDocumentModelStruct()); 389 } 390 391 /** 392 * Sets the maximum size in bytes that will be used to cache 393 * rendered pages. Use 0 to disable caching rendered pages. 394 * 395 * Note that this limit doesn't affect the current visible page range, 396 * which will always be rendered. In order to limit the total memory used 397 * you have to use ev_document_model_set_max_scale() too. 398 * 399 * Params: 400 * cacheSize = size in bytes 401 */ 402 public void setPageCacheSize(size_t cacheSize) 403 { 404 ev_view_set_page_cache_size(evView, cacheSize); 405 } 406 407 /** */ 408 public void showCursor() 409 { 410 ev_view_show_cursor(evView); 411 } 412 413 /** 414 * Returns: whether the document supports caret navigation 415 * 416 * Since: 3.10 417 */ 418 public bool supportsCaretNavigation() 419 { 420 return ev_view_supports_caret_navigation(evView) != 0; 421 } 422 423 /** */ 424 public void zoomIn() 425 { 426 ev_view_zoom_in(evView); 427 } 428 429 /** */ 430 public void zoomOut() 431 { 432 ev_view_zoom_out(evView); 433 } 434 435 /** */ 436 gulong addOnActivate(void delegate(View) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 437 { 438 return Signals.connect(this, "activate", dlg, connectFlags ^ ConnectFlags.SWAPPED); 439 } 440 441 /** */ 442 gulong addOnAnnotAdded(void delegate(Annotation, View) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 443 { 444 return Signals.connect(this, "annot-added", dlg, connectFlags ^ ConnectFlags.SWAPPED); 445 } 446 447 /** */ 448 gulong addOnAnnotRemoved(void delegate(Annotation, View) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 449 { 450 return Signals.connect(this, "annot-removed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 451 } 452 453 /** */ 454 gulong addOnCursorMoved(void delegate(int, int, View) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 455 { 456 return Signals.connect(this, "cursor-moved", dlg, connectFlags ^ ConnectFlags.SWAPPED); 457 } 458 459 /** */ 460 gulong addOnExternalLink(void delegate(ObjectG, View) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 461 { 462 return Signals.connect(this, "external-link", dlg, connectFlags ^ ConnectFlags.SWAPPED); 463 } 464 465 /** */ 466 gulong addOnHandleLink(void delegate(int, ObjectG, View) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 467 { 468 return Signals.connect(this, "handle-link", dlg, connectFlags ^ ConnectFlags.SWAPPED); 469 } 470 471 /** */ 472 gulong addOnLayersChanged(void delegate(View) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 473 { 474 return Signals.connect(this, "layers-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 475 } 476 477 /** */ 478 gulong addOnMoveCursor(bool delegate(GtkMovementStep, int, bool, View) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 479 { 480 return Signals.connect(this, "move-cursor", dlg, connectFlags ^ ConnectFlags.SWAPPED); 481 } 482 483 /** */ 484 gulong addOnPopup(void delegate(void*, View) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 485 { 486 return Signals.connect(this, "popup", dlg, connectFlags ^ ConnectFlags.SWAPPED); 487 } 488 489 /** */ 490 gulong addOnScroll(void delegate(GtkScrollType, GtkOrientation, View) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 491 { 492 return Signals.connect(this, "scroll", dlg, connectFlags ^ ConnectFlags.SWAPPED); 493 } 494 495 /** */ 496 gulong addOnSelectionChanged(void delegate(View) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 497 { 498 return Signals.connect(this, "selection-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 499 } 500 501 /** */ 502 gulong addOnSyncSource(void delegate(SourceLink, View) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 503 { 504 return Signals.connect(this, "sync-source", dlg, connectFlags ^ ConnectFlags.SWAPPED); 505 } 506 }