root/trunk/src/gio/ContentType.d

Revision 938, 7.9 kB (checked in by Mike Wey, 3 months ago)

Update Gio to 2.28.

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