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 gsv.SourceEncoding;
26 
27 private import glib.ListSG;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gsv.c.functions;
31 public  import gsv.c.types;
32 public  import gsvc.gsvtypes;
33 private import gtkd.Loader;
34 
35 
36 /** */
37 public class SourceEncoding
38 {
39 	/** the main Gtk struct */
40 	protected GtkSourceEncoding* gtkSourceEncoding;
41 	protected bool ownedRef;
42 
43 	/** Get the main Gtk struct */
44 	public GtkSourceEncoding* getSourceEncodingStruct(bool transferOwnership = false)
45 	{
46 		if (transferOwnership)
47 			ownedRef = false;
48 		return gtkSourceEncoding;
49 	}
50 
51 	/** the main Gtk struct as a void* */
52 	protected void* getStruct()
53 	{
54 		return cast(void*)gtkSourceEncoding;
55 	}
56 
57 	/**
58 	 * Sets our main struct and passes it to the parent class.
59 	 */
60 	public this (GtkSourceEncoding* gtkSourceEncoding, bool ownedRef = false)
61 	{
62 		this.gtkSourceEncoding = gtkSourceEncoding;
63 		this.ownedRef = ownedRef;
64 	}
65 
66 	~this ()
67 	{
68 		if ( Linker.isLoaded(LIBRARY_GSV) && ownedRef )
69 			gtk_source_encoding_free(gtkSourceEncoding);
70 	}
71 
72 
73 	/** */
74 	public static GType getType()
75 	{
76 		return gtk_source_encoding_get_type();
77 	}
78 
79 	/**
80 	 * Used by language bindings.
81 	 *
82 	 * Returns: a copy of @enc.
83 	 *
84 	 * Since: 3.14
85 	 */
86 	public SourceEncoding copy()
87 	{
88 		auto p = gtk_source_encoding_copy(gtkSourceEncoding);
89 
90 		if(p is null)
91 		{
92 			return null;
93 		}
94 
95 		return ObjectG.getDObject!(SourceEncoding)(cast(GtkSourceEncoding*) p, true);
96 	}
97 
98 	/**
99 	 * Used by language bindings.
100 	 *
101 	 * Since: 3.14
102 	 */
103 	public void free()
104 	{
105 		gtk_source_encoding_free(gtkSourceEncoding);
106 		ownedRef = false;
107 	}
108 
109 	/**
110 	 * Gets the character set of the #GtkSourceEncoding, such as "UTF-8" or
111 	 * "ISO-8859-1".
112 	 *
113 	 * Returns: the character set of the #GtkSourceEncoding.
114 	 *
115 	 * Since: 3.14
116 	 */
117 	public string getCharset()
118 	{
119 		return Str.toString(gtk_source_encoding_get_charset(gtkSourceEncoding));
120 	}
121 
122 	/**
123 	 * Gets the name of the #GtkSourceEncoding such as "Unicode" or "Western".
124 	 *
125 	 * Returns: the name of the #GtkSourceEncoding.
126 	 *
127 	 * Since: 3.14
128 	 */
129 	public string getName()
130 	{
131 		return Str.toString(gtk_source_encoding_get_name(gtkSourceEncoding));
132 	}
133 
134 	/**
135 	 * Returns: a string representation. Free with g_free() when no longer needed.
136 	 *
137 	 * Since: 3.14
138 	 */
139 	public override string toString()
140 	{
141 		auto retStr = gtk_source_encoding_to_string(gtkSourceEncoding);
142 
143 		scope(exit) Str.freeString(retStr);
144 		return Str.toString(retStr);
145 	}
146 
147 	/**
148 	 * Gets all encodings.
149 	 *
150 	 * Returns: a list of
151 	 *     all #GtkSourceEncoding's. Free with g_slist_free().
152 	 *
153 	 * Since: 3.14
154 	 */
155 	public static ListSG getAll()
156 	{
157 		auto p = gtk_source_encoding_get_all();
158 
159 		if(p is null)
160 		{
161 			return null;
162 		}
163 
164 		return new ListSG(cast(GSList*) p);
165 	}
166 
167 	/**
168 	 * Gets the #GtkSourceEncoding for the current locale. See also g_get_charset().
169 	 *
170 	 * Returns: the current locale encoding.
171 	 *
172 	 * Since: 3.14
173 	 */
174 	public static SourceEncoding getCurrent()
175 	{
176 		auto p = gtk_source_encoding_get_current();
177 
178 		if(p is null)
179 		{
180 			return null;
181 		}
182 
183 		return ObjectG.getDObject!(SourceEncoding)(cast(GtkSourceEncoding*) p);
184 	}
185 
186 	/**
187 	 * Gets the list of default candidate encodings to try when loading a file. See
188 	 * gtk_source_file_loader_set_candidate_encodings().
189 	 *
190 	 * This function returns a different list depending on the current locale (i.e.
191 	 * language, country and default encoding). The UTF-8 encoding and the current
192 	 * locale encoding are guaranteed to be present in the returned list.
193 	 *
194 	 * Returns: the list of
195 	 *     default candidate encodings. Free with g_slist_free().
196 	 *
197 	 * Since: 3.18
198 	 */
199 	public static ListSG getDefaultCandidates()
200 	{
201 		auto p = gtk_source_encoding_get_default_candidates();
202 
203 		if(p is null)
204 		{
205 			return null;
206 		}
207 
208 		return new ListSG(cast(GSList*) p);
209 	}
210 
211 	/**
212 	 * Gets a #GtkSourceEncoding from a character set such as "UTF-8" or
213 	 * "ISO-8859-1".
214 	 *
215 	 * Params:
216 	 *     charset = a character set.
217 	 *
218 	 * Returns: the corresponding #GtkSourceEncoding, or %NULL
219 	 *     if not found.
220 	 *
221 	 * Since: 3.14
222 	 */
223 	public static SourceEncoding getFromCharset(string charset)
224 	{
225 		auto p = gtk_source_encoding_get_from_charset(Str.toStringz(charset));
226 
227 		if(p is null)
228 		{
229 			return null;
230 		}
231 
232 		return ObjectG.getDObject!(SourceEncoding)(cast(GtkSourceEncoding*) p);
233 	}
234 
235 	/**
236 	 * Returns: the UTF-8 encoding.
237 	 *
238 	 * Since: 3.14
239 	 */
240 	public static SourceEncoding getUtf8()
241 	{
242 		auto p = gtk_source_encoding_get_utf8();
243 
244 		if(p is null)
245 		{
246 			return null;
247 		}
248 
249 		return ObjectG.getDObject!(SourceEncoding)(cast(GtkSourceEncoding*) p);
250 	}
251 }