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  = 
27  * outPack = gio
28  * outFile = SettingsSchemaSource
29  * strct   = GSettingsSchemaSource
30  * realStrct=
31  * ctorStrct=
32  * clss    = SettingsSchemaSource
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_settings_schema_source_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- glib.ErrorG
48  * 	- glib.GException
49  * 	- gio.SettingsSchema
50  * 	- gtkc.paths
51  * 	- gtkc.Loader
52  * structWrap:
53  * 	- GSettingsSchema* -> SettingsSchema
54  * 	- GSettingsSchemaSource* -> SettingsSchemaSource
55  * module aliases:
56  * local aliases:
57  * overrides:
58  */
59 
60 module gio.SettingsSchemaSource;
61 
62 public  import gtkc.giotypes;
63 
64 private import gtkc.gio;
65 private import glib.ConstructionException;
66 private import gobject.ObjectG;
67 
68 private import glib.Str;
69 private import glib.ErrorG;
70 private import glib.GException;
71 private import gio.SettingsSchema;
72 private import gtkc.paths;
73 private import gtkc.Loader;
74 
75 
76 
77 /**
78  * The GSettingsSchemaSource and GSettingsSchema APIs provide a
79  * mechanism for advanced control over the loading of schemas and a
80  * mechanism for introspecting their content.
81  *
82  * Plugin loading systems that wish to provide plugins a way to access
83  * settings face the problem of how to make the schemas for these
84  * settings visible to GSettings. Typically, a plugin will want to ship
85  * the schema along with itself and it won't be installed into the
86  * standard system directories for schemas.
87  *
88  * GSettingsSchemaSource provides a mechanism for dealing with this by
89  * allowing the creation of a new 'schema source' from which schemas can
90  * be acquired. This schema source can then become part of the metadata
91  * associated with the plugin and queried whenever the plugin requires
92  * access to some settings.
93  *
94  * Consider the following example:
95  *
96  * $(DDOC_COMMENT example)
97  *
98  * The code above shows how hooks should be added to the code that
99  * initialises (or enables) the plugin to create the schema source and
100  * how an API can be added to the plugin system to provide a convenient
101  * way for the plugin to access its settings, using the schemas that it
102  * ships.
103  *
104  * From the standpoint of the plugin, it would need to ensure that it
105  * ships a gschemas.compiled file as part of itself, and then simply do
106  * the following:
107  *
108  * $(DDOC_COMMENT example)
109  *
110  * It's also possible that the plugin system expects the schema source
111  * files (ie: .gschema.xml files) instead of a gschemas.compiled file.
112  * In that case, the plugin loading system must compile the schemas for
113  * itself before attempting to create the settings source.
114  */
115 public class SettingsSchemaSource
116 {
117 	
118 	/** the main Gtk struct */
119 	protected GSettingsSchemaSource* gSettingsSchemaSource;
120 	
121 	
122 	/** Get the main Gtk struct */
123 	public GSettingsSchemaSource* getSettingsSchemaSourceStruct()
124 	{
125 		return gSettingsSchemaSource;
126 	}
127 	
128 	
129 	/** the main Gtk struct as a void* */
130 	protected void* getStruct()
131 	{
132 		return cast(void*)gSettingsSchemaSource;
133 	}
134 	
135 	/**
136 	 * Sets our main struct and passes it to the parent class
137 	 */
138 	public this (GSettingsSchemaSource* gSettingsSchemaSource)
139 	{
140 		this.gSettingsSchemaSource = gSettingsSchemaSource;
141 	}
142 	
143 	~this ()
144 	{
145 		if ( Linker.isLoaded(LIBRARY.GTK) && gSettingsSchemaSource !is null )
146 		{
147 			g_settings_schema_source_unref(gSettingsSchemaSource);
148 		}
149 	}
150 	
151 	/**
152 	 */
153 	
154 	/**
155 	 * Gets the default system schema source.
156 	 * This function is not required for normal uses of GSettings but it
157 	 * may be useful to authors of plugin management systems or to those who
158 	 * want to introspect the content of schemas.
159 	 * If no schemas are installed, NULL will be returned.
160 	 * The returned source may actually consist of multiple schema sources
161 	 * from different directories, depending on which directories were given
162 	 * in XDG_DATA_DIRS and
163 	 * GSETTINGS_SCHEMA_DIR. For this reason, all lookups
164 	 * performed against the default source should probably be done
165 	 * recursively.
166 	 * Since 2.32
167 	 * Returns: the default schema source. [transfer none]
168 	 */
169 	public static SettingsSchemaSource getDefault()
170 	{
171 		// GSettingsSchemaSource * g_settings_schema_source_get_default  (void);
172 		auto p = g_settings_schema_source_get_default();
173 		
174 		if(p is null)
175 		{
176 			return null;
177 		}
178 		
179 		return ObjectG.getDObject!(SettingsSchemaSource)(cast(GSettingsSchemaSource*) p);
180 	}
181 	
182 	/**
183 	 * Increase the reference count of source, returning a new reference.
184 	 * Since 2.32
185 	 * Returns: a new reference to source
186 	 */
187 	public SettingsSchemaSource doref()
188 	{
189 		// GSettingsSchemaSource * g_settings_schema_source_ref (GSettingsSchemaSource *source);
190 		auto p = g_settings_schema_source_ref(gSettingsSchemaSource);
191 		
192 		if(p is null)
193 		{
194 			return null;
195 		}
196 		
197 		return ObjectG.getDObject!(SettingsSchemaSource)(cast(GSettingsSchemaSource*) p);
198 	}
199 	
200 	/**
201 	 * Decrease the reference count of source, possibly freeing it.
202 	 * Since 2.32
203 	 */
204 	public void unref()
205 	{
206 		// void g_settings_schema_source_unref (GSettingsSchemaSource *source);
207 		g_settings_schema_source_unref(gSettingsSchemaSource);
208 	}
209 	
210 	/**
211 	 * Attempts to create a new schema source corresponding to the contents
212 	 * of the given directory.
213 	 * This function is not required for normal uses of GSettings but it
214 	 * may be useful to authors of plugin management systems.
215 	 * The directory should contain a file called
216 	 * gschemas.compiled as produced by
217 	 * glib-compile-schemas.
218 	 * If trusted is TRUE then gschemas.compiled is
219 	 * trusted not to be corrupted. This assumption has a performance
220 	 * advantage, but can result in crashes or inconsistent behaviour in the
221 	 * case of a corrupted file. Generally, you should set trusted to
222 	 * TRUE for files installed by the system and to FALSE for files in
223 	 * the home directory.
224 	 * If parent is non-NULL then there are two effects.
225 	 * First, if g_settings_schema_source_lookup() is called with the
226 	 * recursive flag set to TRUE and the schema can not be found in the
227 	 * source, the lookup will recurse to the parent.
228 	 * Second, any references to other schemas specified within this
229 	 * source (ie: child or extends)
230 	 * references may be resolved from the parent.
231 	 * For this second reason, except in very unusual situations, the
232 	 * parent should probably be given as the default schema source, as
233 	 * returned by g_settings_schema_source_get_default().
234 	 * Since 2.32
235 	 * Params:
236 	 * directory = the filename of a directory
237 	 * parent = a GSettingsSchemaSource, or NULL. [allow-none]
238 	 * trusted = TRUE, if the directory is trusted
239 	 * Throws: GException on failure.
240 	 * Throws: ConstructionException GTK+ fails to create the object.
241 	 */
242 	public this (string directory, SettingsSchemaSource parent, int trusted)
243 	{
244 		// GSettingsSchemaSource * g_settings_schema_source_new_from_directory  (const gchar *directory,  GSettingsSchemaSource *parent,  gboolean trusted,  GError **error);
245 		GError* err = null;
246 		
247 		auto p = g_settings_schema_source_new_from_directory(Str.toStringz(directory), (parent is null) ? null : parent.getSettingsSchemaSourceStruct(), trusted, &err);
248 		
249 		if (err !is null)
250 		{
251 			throw new GException( new ErrorG(err) );
252 		}
253 		
254 		if(p is null)
255 		{
256 			throw new ConstructionException("null returned by g_settings_schema_source_new_from_directory(Str.toStringz(directory), (parent is null) ? null : parent.getSettingsSchemaSourceStruct(), trusted, &err)");
257 		}
258 		this(cast(GSettingsSchemaSource*) p);
259 	}
260 	
261 	/**
262 	 * Looks up a schema with the identifier schema_id in source.
263 	 * This function is not required for normal uses of GSettings but it
264 	 * may be useful to authors of plugin management systems or to those who
265 	 * want to introspect the content of schemas.
266 	 * If the schema isn't found directly in source and recursive is TRUE
267 	 * then the parent sources will also be checked.
268 	 * If the schema isn't found, NULL is returned.
269 	 * Since 2.32
270 	 * Params:
271 	 * schemaId = a schema ID
272 	 * recursive = TRUE if the lookup should be recursive
273 	 * Returns: a new GSettingsSchema. [transfer full]
274 	 */
275 	public SettingsSchema lookup(string schemaId, int recursive)
276 	{
277 		// GSettingsSchema * g_settings_schema_source_lookup (GSettingsSchemaSource *source,  const gchar *schema_id,  gboolean recursive);
278 		auto p = g_settings_schema_source_lookup(gSettingsSchemaSource, Str.toStringz(schemaId), recursive);
279 		
280 		if(p is null)
281 		{
282 			return null;
283 		}
284 		
285 		return ObjectG.getDObject!(SettingsSchema)(cast(GSettingsSchema*) p);
286 	}
287 }