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