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