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