1 module webkit2webextension.DOMText;
2 
3 private import glib.ErrorG;
4 private import glib.GException;
5 private import glib.Str;
6 private import gobject.ObjectG;
7 private import webkit2webextension.DOMCharacterData;
8 private import webkit2webextension.c.functions;
9 public  import webkit2webextension.c.types;
10 
11 
12 /** */
13 public class DOMText : DOMCharacterData
14 {
15 	/** the main Gtk struct */
16 	protected WebKitDOMText* webKitDOMText;
17 
18 	/** Get the main Gtk struct */
19 	public WebKitDOMText* getDOMTextStruct(bool transferOwnership = false)
20 	{
21 		if (transferOwnership)
22 			ownedRef = false;
23 		return webKitDOMText;
24 	}
25 
26 	/** the main Gtk struct as a void* */
27 	protected override void* getStruct()
28 	{
29 		return cast(void*)webKitDOMText;
30 	}
31 
32 	/**
33 	 * Sets our main struct and passes it to the parent class.
34 	 */
35 	public this (WebKitDOMText* webKitDOMText, bool ownedRef = false)
36 	{
37 		this.webKitDOMText = webKitDOMText;
38 		super(cast(WebKitDOMCharacterData*)webKitDOMText, ownedRef);
39 	}
40 
41 
42 	/** */
43 	public static GType getType()
44 	{
45 		return webkit_dom_text_get_type();
46 	}
47 
48 	/**
49 	 *
50 	 *
51 	 * Deprecated: Use JavaScriptCore API instead
52 	 *
53 	 * Returns: A #gchar
54 	 */
55 	public string getWholeText()
56 	{
57 		auto retStr = webkit_dom_text_get_whole_text(webKitDOMText);
58 
59 		scope(exit) Str.freeString(retStr);
60 		return Str.toString(retStr);
61 	}
62 
63 	/**
64 	 *
65 	 * Params:
66 	 *     content = A #gchar
67 	 * Returns: A #WebKitDOMText
68 	 *
69 	 * Throws: GException on failure.
70 	 */
71 	public DOMText replaceWholeText(string content)
72 	{
73 		GError* err = null;
74 
75 		auto __p = webkit_dom_text_replace_whole_text(webKitDOMText, Str.toStringz(content), &err);
76 
77 		if (err !is null)
78 		{
79 			throw new GException( new ErrorG(err) );
80 		}
81 
82 		if(__p is null)
83 		{
84 			return null;
85 		}
86 
87 		return ObjectG.getDObject!(DOMText)(cast(WebKitDOMText*) __p);
88 	}
89 
90 	/**
91 	 *
92 	 *
93 	 * Deprecated: Use JavaScriptCore API instead
94 	 *
95 	 * Params:
96 	 *     offset = A #gulong
97 	 *
98 	 * Returns: A #WebKitDOMText
99 	 *
100 	 * Throws: GException on failure.
101 	 */
102 	public DOMText splitText(gulong offset)
103 	{
104 		GError* err = null;
105 
106 		auto __p = webkit_dom_text_split_text(webKitDOMText, offset, &err);
107 
108 		if (err !is null)
109 		{
110 			throw new GException( new ErrorG(err) );
111 		}
112 
113 		if(__p is null)
114 		{
115 			return null;
116 		}
117 
118 		return ObjectG.getDObject!(DOMText)(cast(WebKitDOMText*) __p);
119 	}
120 }