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