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