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  = GSettingsBackend.html
27  * outPack = gio
28  * outFile = SettingsBackend
29  * strct   = GSettingsBackend
30  * realStrct=
31  * ctorStrct=
32  * clss    = SettingsBackend
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_settings_backend_
41  * 	- g_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- glib.BBTree
49  * 	- glib.Variant
50  * structWrap:
51  * 	- GSettingsBackend* -> SettingsBackend
52  * 	- GTree* -> BBTree
53  * 	- GVariant* -> Variant
54  * module aliases:
55  * local aliases:
56  * overrides:
57  */
58 
59 module gio.SettingsBackend;
60 
61 public  import gtkc.giotypes;
62 
63 private import gtkc.gio;
64 private import glib.ConstructionException;
65 private import gobject.ObjectG;
66 
67 
68 private import glib.Str;
69 private import glib.BBTree;
70 private import glib.Variant;
71 
72 
73 
74 private import gobject.ObjectG;
75 
76 /**
77  * Description
78  * The GSettingsBackend interface defines a generic interface for
79  * non-strictly-typed data that is stored in a hierarchy. To implement
80  * an alternative storage backend for GSettings, you need to implement
81  * the GSettingsBackend interface and then make it implement the
82  * extension point G_SETTINGS_BACKEND_EXTENSION_POINT_NAME.
83  * The interface defines methods for reading and writing values, a
84  * method for determining if writing of certain values will fail
85  * (lockdown) and a change notification mechanism.
86  * The semantics of the interface are very precisely defined and
87  * implementations must carefully adhere to the expectations of
88  * callers that are documented on each of the interface methods.
89  * Some of the GSettingsBackend functions accept or return a GTree.
90  * These trees always have strings as keys and GVariant as values.
91  * g_settings_backend_create_tree() is a convenience function to create
92  * suitable trees.
93  * Note
94  * The GSettingsBackend API is exported to allow third-party
95  * implementations, but does not carry the same stability guarantees
96  * as the public GIO API. For this reason, you have to define the
97  * C preprocessor symbol G_SETTINGS_ENABLE_BACKEND before including
98  * gio/gsettingsbackend.h
99  */
100 public class SettingsBackend : ObjectG
101 {
102 	
103 	/** the main Gtk struct */
104 	protected GSettingsBackend* gSettingsBackend;
105 	
106 	
107 	public GSettingsBackend* getSettingsBackendStruct()
108 	{
109 		return gSettingsBackend;
110 	}
111 	
112 	
113 	/** the main Gtk struct as a void* */
114 	protected override void* getStruct()
115 	{
116 		return cast(void*)gSettingsBackend;
117 	}
118 	
119 	/**
120 	 * Sets our main struct and passes it to the parent class
121 	 */
122 	public this (GSettingsBackend* gSettingsBackend)
123 	{
124 		super(cast(GObject*)gSettingsBackend);
125 		this.gSettingsBackend = gSettingsBackend;
126 	}
127 	
128 	protected override void setStruct(GObject* obj)
129 	{
130 		super.setStruct(obj);
131 		gSettingsBackend = cast(GSettingsBackend*)obj;
132 	}
133 	
134 	/**
135 	 */
136 	
137 	/**
138 	 * Returns the default GSettingsBackend. It is possible to override
139 	 * the default by setting the GSETTINGS_BACKEND
140 	 * environment variable to the name of a settings backend.
141 	 * The user gets a reference to the backend.
142 	 * Since 2.28
143 	 * Returns: the default GSettingsBackend. [transfer full]
144 	 */
145 	public static SettingsBackend getDefault()
146 	{
147 		// GSettingsBackend * g_settings_backend_get_default (void);
148 		auto p = g_settings_backend_get_default();
149 		
150 		if(p is null)
151 		{
152 			return null;
153 		}
154 		
155 		return ObjectG.getDObject!(SettingsBackend)(cast(GSettingsBackend*) p);
156 	}
157 	
158 	/**
159 	 * Signals that a single key has possibly changed. Backend
160 	 * implementations should call this if a key has possibly changed its
161 	 * value.
162 	 * key must be a valid key (ie starting with a slash, not containing
163 	 * '//', and not ending with a slash).
164 	 * The implementation must call this function during any call to
165 	 * g_settings_backend_write(), before the call returns (except in the
166 	 * case that no keys are actually changed and it cares to detect this
167 	 * fact). It may not rely on the existence of a mainloop for
168 	 * dispatching the signal later.
169 	 * The implementation may call this function at any other time it likes
170 	 * in response to other events (such as changes occuring outside of the
171 	 * program). These calls may originate from a mainloop or may originate
172 	 * in response to any other action (including from calls to
173 	 * g_settings_backend_write()).
174 	 * In the case that this call is in response to a call to
175 	 * g_settings_backend_write() then origin_tag must be set to the same
176 	 * value that was passed to that call.
177 	 * Since 2.26
178 	 * Params:
179 	 * key = the name of the key
180 	 * originTag = the origin tag
181 	 */
182 	public void changed(string key, void* originTag)
183 	{
184 		// void g_settings_backend_changed (GSettingsBackend *backend,  const gchar *key,  gpointer origin_tag);
185 		g_settings_backend_changed(gSettingsBackend, Str.toStringz(key), originTag);
186 	}
187 	
188 	/**
189 	 * Signals that all keys below a given path may have possibly changed.
190 	 * Backend implementations should call this if an entire path of keys
191 	 * have possibly changed their values.
192 	 * path must be a valid path (ie starting and ending with a slash and
193 	 * not containing '//').
194 	 * The meaning of this signal is that any of the key which has a name
195 	 * starting with path may have changed.
196 	 * The same rules for when notifications must occur apply as per
197 	 * g_settings_backend_changed(). This call might be an appropriate
198 	 * reasponse to a 'reset' call but implementations are also free to
199 	 * explicitly list the keys that were affected by that call if they can
200 	 * easily do so.
201 	 * For efficiency reasons, the implementation should strive for path to
202 	 * be as long as possible (ie: the longest common prefix of all of the
203 	 * keys that were changed) but this is not strictly required. As an
204 	 * example, if this function is called with the path of "/" then every
205 	 * single key in the application will be notified of a possible change.
206 	 * Since 2.26
207 	 * Params:
208 	 * path = the path containing the changes
209 	 * originTag = the origin tag
210 	 */
211 	public void pathChanged(string path, void* originTag)
212 	{
213 		// void g_settings_backend_path_changed (GSettingsBackend *backend,  const gchar *path,  gpointer origin_tag);
214 		g_settings_backend_path_changed(gSettingsBackend, Str.toStringz(path), originTag);
215 	}
216 	
217 	/**
218 	 * Signals that a list of keys have possibly changed. Backend
219 	 * implementations should call this if keys have possibly changed their
220 	 * values.
221 	 * path must be a valid path (ie starting and ending with a slash and
222 	 * not containing '//'). Each string in items must form a valid key
223 	 * name when path is prefixed to it (ie: each item must not start or
224 	 * end with '/' and must not contain '//').
225 	 * The meaning of this signal is that any of the key names resulting
226 	 * from the contatenation of path with each item in items may have
227 	 * changed.
228 	 * The same rules for when notifications must occur apply as per
229 	 * g_settings_backend_changed(). These two calls can be used
230 	 * interchangeably if exactly one item has changed (although in that
231 	 * case g_settings_backend_changed() is definitely preferred).
232 	 * For efficiency reasons, the implementation should strive for path to
233 	 * be as long as possible (ie: the longest common prefix of all of the
234 	 * keys that were changed) but this is not strictly required.
235 	 * Since 2.26
236 	 * Params:
237 	 * path = the path containing the changes
238 	 * items = the NULL-terminated list of changed keys. [array zero-terminated=1]
239 	 * originTag = the origin tag
240 	 */
241 	public void keysChanged(string path, char** items, void* originTag)
242 	{
243 		// void g_settings_backend_keys_changed (GSettingsBackend *backend,  const gchar *path,  gchar const * const *items,  gpointer origin_tag);
244 		g_settings_backend_keys_changed(gSettingsBackend, Str.toStringz(path), items, originTag);
245 	}
246 	
247 	/**
248 	 * Signals that the writability of all keys below a given path may have
249 	 * changed.
250 	 * Since GSettings performs no locking operations for itself, this call
251 	 * will always be made in response to external events.
252 	 * Since 2.26
253 	 * Params:
254 	 * path = the name of the path
255 	 */
256 	public void pathWritableChanged(string path)
257 	{
258 		// void g_settings_backend_path_writable_changed  (GSettingsBackend *backend,  const gchar *path);
259 		g_settings_backend_path_writable_changed(gSettingsBackend, Str.toStringz(path));
260 	}
261 	
262 	/**
263 	 * Signals that the writability of a single key has possibly changed.
264 	 * Since GSettings performs no locking operations for itself, this call
265 	 * will always be made in response to external events.
266 	 * Since 2.26
267 	 * Params:
268 	 * key = the name of the key
269 	 */
270 	public void writableChanged(string key)
271 	{
272 		// void g_settings_backend_writable_changed (GSettingsBackend *backend,  const gchar *key);
273 		g_settings_backend_writable_changed(gSettingsBackend, Str.toStringz(key));
274 	}
275 	
276 	/**
277 	 * This call is a convenience wrapper. It gets the list of changes from
278 	 * tree, computes the longest common prefix and calls
279 	 * g_settings_backend_changed().
280 	 * Since 2.26
281 	 * Params:
282 	 * tree = a GTree containing the changes
283 	 * originTag = the origin tag
284 	 */
285 	public void changedTree(BBTree tree, void* originTag)
286 	{
287 		// void g_settings_backend_changed_tree (GSettingsBackend *backend,  GTree *tree,  gpointer origin_tag);
288 		g_settings_backend_changed_tree(gSettingsBackend, (tree is null) ? null : tree.getBBTreeStruct(), originTag);
289 	}
290 	
291 	/**
292 	 * Calculate the longest common prefix of all keys in a tree and write
293 	 * out an array of the key names relative to that prefix and,
294 	 * optionally, the value to store at each of those keys.
295 	 * You must free the value returned in path, keys and values using
296 	 * g_free(). You should not attempt to free or unref the contents of
297 	 * keys or values.
298 	 * Since 2.26
299 	 * Params:
300 	 * tree = a GTree containing the changes
301 	 * path = the location to save the path. [out]
302 	 * keys = the
303 	 * location to save the relative keys. [out][transfer container][array zero-terminated=1]
304 	 * values = the location to save the values, or NULL. [out][allow-none][transfer container][array zero-terminated=1]
305 	 */
306 	public static void flattenTree(BBTree tree, out string path, out string[] keys, out Variant[] values)
307 	{
308 		// void g_settings_backend_flatten_tree (GTree *tree,  gchar **path,  const gchar ***keys,  GVariant ***values);
309 		char* outpath = null;
310 		char** outkeys = null;
311 		GVariant** outvalues = null;
312 		
313 		g_settings_backend_flatten_tree((tree is null) ? null : tree.getBBTreeStruct(), &outpath, &outkeys, &outvalues);
314 		
315 		path = Str.toString(outpath);
316 		keys = Str.toStringArray(outkeys);
317 		
318 		values = new Variant[keys.length];
319 		for(int i = 0; i < keys.length; i++)
320 		{
321 			values[i] = ObjectG.getDObject!(Variant)(cast(GVariant*) outvalues[i]);
322 		}
323 	}
324 	
325 	/**
326 	 * Creates a keyfile-backed GSettingsBackend.
327 	 * The filename of the keyfile to use is given by filename.
328 	 * All settings read to or written from the backend must fall under the
329 	 * path given in root_path (which must start and end with a slash and
330 	 * not contain two consecutive slashes). root_path may be "/".
331 	 * If root_group is non-NULL then it specifies the name of the keyfile
332 	 * group used for keys that are written directly below root_path. For
333 	 * example, if root_path is "/apps/example/" and root_group is
334 	 * "toplevel", then settings the key "/apps/example/enabled" to a value
335 	 * Params:
336 	 * filename = the filename of the keyfile
337 	 * rootPath = the path under which all settings keys appear
338 	 * rootGroup = the group name corresponding to
339 	 * root_path, or NULL. [allow-none]
340 	 * Returns: a keyfile-backed GSettingsBackend. [transfer full]
341 	 */
342 	public static SettingsBackend keyfileSettingsBackendNew(string filename, string rootPath, string rootGroup)
343 	{
344 		// GSettingsBackend * g_keyfile_settings_backend_new (const gchar *filename,  const gchar *root_path,  const gchar *root_group);
345 		auto p = g_keyfile_settings_backend_new(Str.toStringz(filename), Str.toStringz(rootPath), Str.toStringz(rootGroup));
346 		
347 		if(p is null)
348 		{
349 			return null;
350 		}
351 		
352 		return ObjectG.getDObject!(SettingsBackend)(cast(GSettingsBackend*) p);
353 	}
354 	
355 	/**
356 	 * Creates a memory-backed GSettingsBackend.
357 	 * This backend allows changes to settings, but does not write them
358 	 * to any backing storage, so the next time you run your application,
359 	 * the memory backend will start out with the default values again.
360 	 * Since 2.28
361 	 * Returns: a newly created GSettingsBackend. [transfer full]
362 	 */
363 	public static SettingsBackend memorySettingsBackendNew()
364 	{
365 		// GSettingsBackend * g_memory_settings_backend_new (void);
366 		auto p = g_memory_settings_backend_new();
367 		
368 		if(p is null)
369 		{
370 			return null;
371 		}
372 		
373 		return ObjectG.getDObject!(SettingsBackend)(cast(GSettingsBackend*) p);
374 	}
375 	
376 	/**
377 	 * Creates a readonly GSettingsBackend.
378 	 * This backend does not allow changes to settings, so all settings
379 	 * will always have their default values.
380 	 * Since 2.28
381 	 * Returns: a newly created GSettingsBackend. [transfer full]
382 	 */
383 	public static SettingsBackend nullSettingsBackendNew()
384 	{
385 		// GSettingsBackend * g_null_settings_backend_new (void);
386 		auto p = g_null_settings_backend_new();
387 		
388 		if(p is null)
389 		{
390 			return null;
391 		}
392 		
393 		return ObjectG.getDObject!(SettingsBackend)(cast(GSettingsBackend*) p);
394 	}
395 }