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