1 module webkit2webextension.WebEditor; 2 3 private import gobject.ObjectG; 4 private import gobject.Signals; 5 private import std.algorithm; 6 private import webkit2webextension.WebPage; 7 private import webkit2webextension.c.functions; 8 public import webkit2webextension.c.types; 9 10 11 /** 12 * The WebKitWebEditor provides access to various editing capabilities of 13 * a #WebKitWebPage such as a possibility to react to the current selection in 14 * #WebKitWebPage. 15 * 16 * Since: 2.10 17 */ 18 public class WebEditor : ObjectG 19 { 20 /** the main Gtk struct */ 21 protected WebKitWebEditor* webKitWebEditor; 22 23 /** Get the main Gtk struct */ 24 public WebKitWebEditor* getWebEditorStruct(bool transferOwnership = false) 25 { 26 if (transferOwnership) 27 ownedRef = false; 28 return webKitWebEditor; 29 } 30 31 /** the main Gtk struct as a void* */ 32 protected override void* getStruct() 33 { 34 return cast(void*)webKitWebEditor; 35 } 36 37 /** 38 * Sets our main struct and passes it to the parent class. 39 */ 40 public this (WebKitWebEditor* webKitWebEditor, bool ownedRef = false) 41 { 42 this.webKitWebEditor = webKitWebEditor; 43 super(cast(GObject*)webKitWebEditor, ownedRef); 44 } 45 46 47 /** */ 48 public static GType getType() 49 { 50 return webkit_web_editor_get_type(); 51 } 52 53 /** 54 * Gets the #WebKitWebPage that is associated with the #WebKitWebEditor that can 55 * be used to access the #WebKitDOMDocument currently loaded into it. 56 * 57 * Returns: the associated #WebKitWebPage 58 * 59 * Since: 2.10 60 */ 61 public WebPage getPage() 62 { 63 auto __p = webkit_web_editor_get_page(webKitWebEditor); 64 65 if(__p is null) 66 { 67 return null; 68 } 69 70 return ObjectG.getDObject!(WebPage)(cast(WebKitWebPage*) __p); 71 } 72 73 /** 74 * This signal is emitted for every selection change inside a #WebKitWebPage 75 * as well as for every caret position change as the caret is a collapsed 76 * selection. 77 * 78 * Since: 2.10 79 */ 80 gulong addOnSelectionChanged(void delegate(WebEditor) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 81 { 82 return Signals.connect(this, "selection-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 83 } 84 }