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  * Conversion parameters:
26  * inFile  = gio-GContentType.html
27  * outPack = gio
28  * outFile = ContentType
29  * strct   = 
30  * realStrct=
31  * ctorStrct=
32  * clss    = ContentType
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_content_type_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- glib.ListG
48  * 	- gio.File
49  * 	- gio.Icon
50  * 	- gio.IconIF
51  * structWrap:
52  * 	- GFile* -> File
53  * 	- GIcon* -> IconIF
54  * 	- GList* -> ListG
55  * module aliases:
56  * local aliases:
57  * overrides:
58  */
59 
60 module gio.ContentType;
61 
62 public  import gtkc.giotypes;
63 
64 private import gtkc.gio;
65 private import glib.ConstructionException;
66 private import gobject.ObjectG;
67 
68 private import glib.Str;
69 private import glib.ListG;
70 private import gio.File;
71 private import gio.Icon;
72 private import gio.IconIF;
73 
74 
75 
76 /**
77  * A content type is a platform specific string that defines the type
78  * of a file. On UNIX it is a mime type like "text/plain" or "image/png".
79  * On Win32 it is an extension string like ".doc", ".txt" or a perceived
80  * string like "audio". Such strings can be looked up in the registry at
81  * HKEY_CLASSES_ROOT.
82  */
83 public class ContentType
84 {
85 	
86 	/**
87 	 */
88 	
89 	/**
90 	 * Compares two content types for equality.
91 	 * Params:
92 	 * type1 = a content type string
93 	 * type2 = a content type string
94 	 * Returns: TRUE if the two strings are identical or equivalent, FALSE otherwise.
95 	 */
96 	public static int equals(string type1, string type2)
97 	{
98 		// gboolean g_content_type_equals (const gchar *type1,  const gchar *type2);
99 		return g_content_type_equals(Str.toStringz(type1), Str.toStringz(type2));
100 	}
101 	
102 	/**
103 	 * Determines if type is a subset of supertype.
104 	 * Params:
105 	 * type = a content type string
106 	 * supertype = a content type string
107 	 * Returns: TRUE if type is a kind of supertype, FALSE otherwise.
108 	 */
109 	public static int isA(string type, string supertype)
110 	{
111 		// gboolean g_content_type_is_a (const gchar *type,  const gchar *supertype);
112 		return g_content_type_is_a(Str.toStringz(type), Str.toStringz(supertype));
113 	}
114 	
115 	/**
116 	 * Checks if the content type is the generic "unknown" type.
117 	 * On UNIX this is the "application/octet-stream" mimetype,
118 	 * while on win32 it is "*".
119 	 * Params:
120 	 * type = a content type string
121 	 * Returns: TRUE if the type is the unknown type.
122 	 */
123 	public static int isUnknown(string type)
124 	{
125 		// gboolean g_content_type_is_unknown (const gchar *type);
126 		return g_content_type_is_unknown(Str.toStringz(type));
127 	}
128 	
129 	/**
130 	 * Gets the human readable description of the content type.
131 	 * Params:
132 	 * type = a content type string
133 	 * Returns: a short description of the content type type. Free the returned string with g_free()
134 	 */
135 	public static string getDescription(string type)
136 	{
137 		// gchar * g_content_type_get_description (const gchar *type);
138 		return Str.toString(g_content_type_get_description(Str.toStringz(type)));
139 	}
140 	
141 	/**
142 	 * Gets the mime type for the content type, if one is registered.
143 	 * Params:
144 	 * type = a content type string
145 	 * Returns: the registered mime type for the given type, or NULL if unknown. [allow-none]
146 	 */
147 	public static string getMimeType(string type)
148 	{
149 		// gchar * g_content_type_get_mime_type (const gchar *type);
150 		return Str.toString(g_content_type_get_mime_type(Str.toStringz(type)));
151 	}
152 	
153 	/**
154 	 * Gets the icon for a content type.
155 	 * Params:
156 	 * type = a content type string
157 	 * Returns: GIcon corresponding to the content type. Free the returned object with g_object_unref(). [transfer full]
158 	 */
159 	public static IconIF getIcon(string type)
160 	{
161 		// GIcon * g_content_type_get_icon (const gchar *type);
162 		auto p = g_content_type_get_icon(Str.toStringz(type));
163 		
164 		if(p is null)
165 		{
166 			return null;
167 		}
168 		
169 		return ObjectG.getDObject!(Icon, IconIF)(cast(GIcon*) p);
170 	}
171 	
172 	/**
173 	 * Gets the symbolic icon for a content type.
174 	 * Since 2.34
175 	 * Params:
176 	 * type = a content type string
177 	 * Returns: symbolic GIcon corresponding to the content type. Free the returned object with g_object_unref(). [transfer full]
178 	 */
179 	public static IconIF getSymbolicIcon(string type)
180 	{
181 		// GIcon * g_content_type_get_symbolic_icon (const gchar *type);
182 		auto p = g_content_type_get_symbolic_icon(Str.toStringz(type));
183 		
184 		if(p is null)
185 		{
186 			return null;
187 		}
188 		
189 		return ObjectG.getDObject!(Icon, IconIF)(cast(GIcon*) p);
190 	}
191 	
192 	/**
193 	 * Gets the generic icon name for a content type.
194 	 * See the shared-mime-info
195 	 * specification for more on the generic icon name.
196 	 * Since 2.34
197 	 * Params:
198 	 * type = a content type string
199 	 * Returns: the registered generic icon name for the given type, or NULL if unknown. Free with g_free(). [allow-none]
200 	 */
201 	public static string getGenericIconName(string type)
202 	{
203 		// gchar * g_content_type_get_generic_icon_name  (const gchar *type);
204 		return Str.toString(g_content_type_get_generic_icon_name(Str.toStringz(type)));
205 	}
206 	
207 	/**
208 	 * Checks if a content type can be executable. Note that for instance
209 	 * things like text files can be executables (i.e. scripts and batch files).
210 	 * Params:
211 	 * type = a content type string
212 	 * Returns: TRUE if the file type corresponds to a type that can be executable, FALSE otherwise.
213 	 */
214 	public static int canBeExecutable(string type)
215 	{
216 		// gboolean g_content_type_can_be_executable (const gchar *type);
217 		return g_content_type_can_be_executable(Str.toStringz(type));
218 	}
219 	
220 	/**
221 	 * Tries to find a content type based on the mime type name.
222 	 * Since 2.18
223 	 * Params:
224 	 * mimeType = a mime type string
225 	 * Returns: Newly allocated string with content type or NULL. Free with g_free(). [allow-none]
226 	 */
227 	public static string fromMimeType(string mimeType)
228 	{
229 		// gchar * g_content_type_from_mime_type (const gchar *mime_type);
230 		return Str.toString(g_content_type_from_mime_type(Str.toStringz(mimeType)));
231 	}
232 	
233 	/**
234 	 * Guesses the content type based on example data. If the function is
235 	 * uncertain, result_uncertain will be set to TRUE. Either filename
236 	 * or data may be NULL, in which case the guess will be based solely
237 	 * on the other argument.
238 	 * Params:
239 	 * filename = a string, or NULL. [allow-none]
240 	 * data = a stream of data, or NULL. [allow-none][array length=data_size]
241 	 * resultUncertain = return location for the certainty
242 	 * of the result, or NULL. [allow-none][out]
243 	 * Returns: a string indicating a guessed content type for the given data. Free with g_free()
244 	 */
245 	public static string guess(string filename, char[] data, out int resultUncertain)
246 	{
247 		// gchar * g_content_type_guess (const gchar *filename,  const guchar *data,  gsize data_size,  gboolean *result_uncertain);
248 		return Str.toString(g_content_type_guess(Str.toStringz(filename), data.ptr, cast(int) data.length, &resultUncertain));
249 	}
250 	
251 	/**
252 	 * Tries to guess the type of the tree with root root, by
253 	 * looking at the files it contains. The result is an array
254 	 * of content types, with the best guess coming first.
255 	 * The types returned all have the form x-content/foo, e.g.
256 	 * x-content/audio-cdda (for audio CDs) or x-content/image-dcf
257 	 * (for a camera memory card). See the shared-mime-info
258 	 * specification for more on x-content types.
259 	 * This function is useful in the implementation of
260 	 * g_mount_guess_content_type().
261 	 * Since 2.18
262 	 * Params:
263 	 * root = the root of the tree to guess a type for
264 	 * Returns: an NULL-terminated array of zero or more content types. Free with g_strfreev(). [transfer full][array zero-terminated=1]
265 	 */
266 	public static string[] guessForTree(File root)
267 	{
268 		// gchar ** g_content_type_guess_for_tree (GFile *root);
269 		return Str.toStringArray(g_content_type_guess_for_tree((root is null) ? null : root.getFileStruct()));
270 	}
271 	
272 	/**
273 	 * Gets a list of strings containing all the registered content types
274 	 * known to the system. The list and its data should be freed using
275 	 * g_list_free_full (list, g_free);
276 	 * Returns: GList of the registered content types. [element-type utf8][transfer full]
277 	 */
278 	public static ListG gContentTypesGetRegistered()
279 	{
280 		// GList * g_content_types_get_registered (void);
281 		auto p = g_content_types_get_registered();
282 		
283 		if(p is null)
284 		{
285 			return null;
286 		}
287 		
288 		return ObjectG.getDObject!(ListG)(cast(GList*) p);
289 	}
290 }