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 * Description 80 * A content type is a platform specific string that defines the type 81 * of a file. On unix it is a mime type, on win32 it is an extension string 82 * like ".doc", ".txt" or a percieved string like "audio". Such strings 83 * can be looked up in the registry at 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 * Checks if a content type can be executable. Note that for instance 176 * things like text files can be executables (i.e. scripts and batch files). 177 * Params: 178 * type = a content type string 179 * Returns: TRUE if the file type corresponds to a type that can be executable, FALSE otherwise. 180 */ 181 public static int canBeExecutable(string type) 182 { 183 // gboolean g_content_type_can_be_executable (const gchar *type); 184 return g_content_type_can_be_executable(Str.toStringz(type)); 185 } 186 187 /** 188 * Tries to find a content type based on the mime type name. 189 * Since 2.18 190 * Params: 191 * mimeType = a mime type string 192 * Returns: Newly allocated string with content type or NULL. Free with g_free(). [allow-none] 193 */ 194 public static string fromMimeType(string mimeType) 195 { 196 // gchar * g_content_type_from_mime_type (const gchar *mime_type); 197 return Str.toString(g_content_type_from_mime_type(Str.toStringz(mimeType))); 198 } 199 200 /** 201 * Guesses the content type based on example data. If the function is 202 * uncertain, result_uncertain will be set to TRUE. Either filename 203 * or data may be NULL, in which case the guess will be based solely 204 * on the other argument. 205 * Params: 206 * filename = a string, or NULL. [allow-none] 207 * data = a stream of data, or NULL. [allow-none][array length=data_size] 208 * resultUncertain = return location for the certainty 209 * of the result, or NULL. [allow-none][out] 210 * Returns: a string indicating a guessed content type for the given data. Free with g_free() 211 */ 212 public static string guess(string filename, char[] data, out int resultUncertain) 213 { 214 // gchar * g_content_type_guess (const gchar *filename, const guchar *data, gsize data_size, gboolean *result_uncertain); 215 return Str.toString(g_content_type_guess(Str.toStringz(filename), data.ptr, cast(int) data.length, &resultUncertain)); 216 } 217 218 /** 219 * Tries to guess the type of the tree with root root, by 220 * looking at the files it contains. The result is an array 221 * of content types, with the best guess coming first. 222 * The types returned all have the form x-content/foo, e.g. 223 * x-content/audio-cdda (for audio CDs) or x-content/image-dcf 224 * (for a camera memory card). See the shared-mime-info 225 * specification for more on x-content types. 226 * This function is useful in the implementation of 227 * g_mount_guess_content_type(). 228 * Since 2.18 229 * Params: 230 * root = the root of the tree to guess a type for 231 * Returns: an NULL-terminated array of zero or more content types, or NULL. Free with g_strfreev(). [transfer full][array zero-terminated=1] 232 */ 233 public static string[] guessForTree(File root) 234 { 235 // gchar ** g_content_type_guess_for_tree (GFile *root); 236 return Str.toStringArray(g_content_type_guess_for_tree((root is null) ? null : root.getFileStruct())); 237 } 238 239 /** 240 * Gets a list of strings containing all the registered content types 241 * known to the system. The list and its data should be freed using 242 * g_list_foreach (list, g_free, NULL); 243 * g_list_free (list); 244 * Returns: GList of the registered content types. [element-type utf8][transfer full] 245 */ 246 public static ListG gContentTypesGetRegistered() 247 { 248 // GList * g_content_types_get_registered (void); 249 auto p = g_content_types_get_registered(); 250 251 if(p is null) 252 { 253 return null; 254 } 255 256 return ObjectG.getDObject!(ListG)(cast(GList*) p); 257 } 258 }