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