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 = GtkSourceLanguageManager.html 27 * outPack = gsv 28 * outFile = SourceLanguageManager 29 * strct = GtkSourceLanguageManager 30 * realStrct= 31 * ctorStrct= 32 * clss = SourceLanguageManager 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_source_language_manager_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - gsv.SourceLanguage 48 * - gsv.SourceLanguageManager 49 * structWrap: 50 * - GtkSourceLanguage* -> SourceLanguage 51 * - GtkSourceLanguageManager* -> SourceLanguageManager 52 * module aliases: 53 * local aliases: 54 * overrides: 55 */ 56 57 module gsv.SourceLanguageManager; 58 59 public import gsvc.gsvtypes; 60 61 private import gsvc.gsv; 62 private import glib.ConstructionException; 63 private import gobject.ObjectG; 64 65 66 private import glib.Str; 67 private import gsv.SourceLanguage; 68 private import gsv.SourceLanguageManager; 69 70 71 72 private import gobject.ObjectG; 73 74 /** 75 * Description 76 * GtkSourceLanguageManager is an object which processes language description 77 * files and creates and stores GtkSourceLanguage objects, and provides API to 78 * access them. 79 * Use gtk_source_language_manager_get_default() to retrieve the default 80 * instance of GtkSourceLanguageManager, and 81 * gtk_source_language_manager_guess_language() to get a GtkSourceLanguage for 82 * given file name and content type. 83 */ 84 public class SourceLanguageManager : ObjectG 85 { 86 87 /** the main Gtk struct */ 88 protected GtkSourceLanguageManager* gtkSourceLanguageManager; 89 90 91 public GtkSourceLanguageManager* getSourceLanguageManagerStruct() 92 { 93 return gtkSourceLanguageManager; 94 } 95 96 97 /** the main Gtk struct as a void* */ 98 protected override void* getStruct() 99 { 100 return cast(void*)gtkSourceLanguageManager; 101 } 102 103 /** 104 * Sets our main struct and passes it to the parent class 105 */ 106 public this (GtkSourceLanguageManager* gtkSourceLanguageManager) 107 { 108 super(cast(GObject*)gtkSourceLanguageManager); 109 this.gtkSourceLanguageManager = gtkSourceLanguageManager; 110 } 111 112 protected override void setStruct(GObject* obj) 113 { 114 super.setStruct(obj); 115 gtkSourceLanguageManager = cast(GtkSourceLanguageManager*)obj; 116 } 117 118 /** 119 */ 120 121 /** 122 * Creates a new language manager. If you do not need more than one language 123 * manager or a private language manager instance then use 124 * gtk_source_language_manager_get_default() instead. 125 * Throws: ConstructionException GTK+ fails to create the object. 126 */ 127 public this () 128 { 129 // GtkSourceLanguageManager * gtk_source_language_manager_new (void); 130 auto p = gtk_source_language_manager_new(); 131 if(p is null) 132 { 133 throw new ConstructionException("null returned by gtk_source_language_manager_new()"); 134 } 135 this(cast(GtkSourceLanguageManager*) p); 136 } 137 138 /** 139 * Returns the default GtkSourceLanguageManager instance. 140 * Returns: a GtkSourceLanguageManager. Return value is owned by GtkSourceView library and must not be unref'ed. 141 */ 142 public static SourceLanguageManager getDefault() 143 { 144 // GtkSourceLanguageManager * gtk_source_language_manager_get_default (void); 145 auto p = gtk_source_language_manager_get_default(); 146 147 if(p is null) 148 { 149 return null; 150 } 151 152 return ObjectG.getDObject!(SourceLanguageManager)(cast(GtkSourceLanguageManager*) p); 153 } 154 155 /** 156 * Sets the list of directories where the lm looks for 157 * language files. 158 * If dirs is NULL, the search path is reset to default. 159 * Note 160 * At the moment this function can be called only before the 161 * language files are loaded for the first time. In practice 162 * to set a custom search path for a GtkSourceLanguageManager, 163 * you have to call this function right after creating it. 164 * Params: 165 * dirs = a NULL-terminated array of strings or NULL. 166 */ 167 public void setSearchPath(string[] dirs) 168 { 169 // void gtk_source_language_manager_set_search_path (GtkSourceLanguageManager *lm, gchar **dirs); 170 gtk_source_language_manager_set_search_path(gtkSourceLanguageManager, Str.toStringzArray(dirs)); 171 } 172 173 /** 174 * Gets the list directories where lm looks for language files. 175 * Returns: NULL-terminated array containg a list of language files directories. The array is owned by lm and must not be modified. 176 */ 177 public string[] getSearchPath() 178 { 179 // const gchar * const * gtk_source_language_manager_get_search_path (GtkSourceLanguageManager *lm); 180 return Str.toStringArray(gtk_source_language_manager_get_search_path(gtkSourceLanguageManager)); 181 } 182 183 /** 184 * Returns the ids of the available languages. 185 * Returns: a NULL-terminated array of string containing the ids of the available languages or NULL if no language is available. The array is owned by lm and must not be modified. 186 */ 187 public string[] getLanguageIds() 188 { 189 // const gchar * const * gtk_source_language_manager_get_language_ids (GtkSourceLanguageManager *lm); 190 return Str.toStringArray(gtk_source_language_manager_get_language_ids(gtkSourceLanguageManager)); 191 } 192 193 /** 194 * Gets the GtkSourceLanguage identified by the given id in the language 195 * manager. 196 * Params: 197 * id = a language id. 198 * Returns: a GtkSourceLanguage, or NULL if there is no language identified by the given id. Return value is owned by lm and should not be freed. 199 */ 200 public SourceLanguage getLanguage(string id) 201 { 202 // GtkSourceLanguage * gtk_source_language_manager_get_language (GtkSourceLanguageManager *lm, const gchar *id); 203 auto p = gtk_source_language_manager_get_language(gtkSourceLanguageManager, Str.toStringz(id)); 204 205 if(p is null) 206 { 207 return null; 208 } 209 210 return ObjectG.getDObject!(SourceLanguage)(cast(GtkSourceLanguage*) p); 211 } 212 213 /** 214 * Picks a GtkSourceLanguage for given file name and content type, 215 * according to the information in lang files. Either filename or 216 * Since 2.4 217 * Params: 218 * filename = a filename in Glib filename encoding, or NULL. 219 * contentType = a content type (as in GIO API), or NULL. 220 * Returns: a GtkSourceLanguage, or NULL if there is no suitable language for given filename and/or content_type. Return value is owned by lm and should not be freed. 221 */ 222 public SourceLanguage guessLanguage(string filename, string contentType) 223 { 224 // GtkSourceLanguage * gtk_source_language_manager_guess_language (GtkSourceLanguageManager *lm, const gchar *filename, const gchar *content_type); 225 auto p = gtk_source_language_manager_guess_language(gtkSourceLanguageManager, Str.toStringz(filename), Str.toStringz(contentType)); 226 227 if(p is null) 228 { 229 return null; 230 } 231 232 return ObjectG.getDObject!(SourceLanguage)(cast(GtkSourceLanguage*) p); 233 } 234 }