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