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