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 module gio.Settings; 26 27 private import gio.ActionIF; 28 private import gio.SettingsBackend; 29 private import gio.SettingsSchema; 30 private import gio.c.functions; 31 public import gio.c.types; 32 private import glib.ConstructionException; 33 private import glib.Str; 34 private import glib.Variant; 35 private import gobject.ObjectG; 36 private import gobject.Signals; 37 public import gtkc.giotypes; 38 private import std.algorithm; 39 40 41 /** 42 * The #GSettings class provides a convenient API for storing and retrieving 43 * application settings. 44 * 45 * Reads and writes can be considered to be non-blocking. Reading 46 * settings with #GSettings is typically extremely fast: on 47 * approximately the same order of magnitude (but slower than) a 48 * #GHashTable lookup. Writing settings is also extremely fast in terms 49 * of time to return to your application, but can be extremely expensive 50 * for other threads and other processes. Many settings backends 51 * (including dconf) have lazy initialisation which means in the common 52 * case of the user using their computer without modifying any settings 53 * a lot of work can be avoided. For dconf, the D-Bus service doesn't 54 * even need to be started in this case. For this reason, you should 55 * only ever modify #GSettings keys in response to explicit user action. 56 * Particular care should be paid to ensure that modifications are not 57 * made during startup -- for example, when setting the initial value 58 * of preferences widgets. The built-in g_settings_bind() functionality 59 * is careful not to write settings in response to notify signals as a 60 * result of modifications that it makes to widgets. 61 * 62 * When creating a GSettings instance, you have to specify a schema 63 * that describes the keys in your settings and their types and default 64 * values, as well as some other information. 65 * 66 * Normally, a schema has a fixed path that determines where the settings 67 * are stored in the conceptual global tree of settings. However, schemas 68 * can also be '[relocatable][gsettings-relocatable]', i.e. not equipped with 69 * a fixed path. This is 70 * useful e.g. when the schema describes an 'account', and you want to be 71 * able to store a arbitrary number of accounts. 72 * 73 * Paths must start with and end with a forward slash character ('/') 74 * and must not contain two sequential slash characters. Paths should 75 * be chosen based on a domain name associated with the program or 76 * library to which the settings belong. Examples of paths are 77 * "/org/gtk/settings/file-chooser/" and "/ca/desrt/dconf-editor/". 78 * Paths should not start with "/apps/", "/desktop/" or "/system/" as 79 * they often did in GConf. 80 * 81 * Unlike other configuration systems (like GConf), GSettings does not 82 * restrict keys to basic types like strings and numbers. GSettings stores 83 * values as #GVariant, and allows any #GVariantType for keys. Key names 84 * are restricted to lowercase characters, numbers and '-'. Furthermore, 85 * the names must begin with a lowercase character, must not end 86 * with a '-', and must not contain consecutive dashes. 87 * 88 * Similar to GConf, the default values in GSettings schemas can be 89 * localized, but the localized values are stored in gettext catalogs 90 * and looked up with the domain that is specified in the 91 * `gettext-domain` attribute of the <schemalist> or <schema> 92 * elements and the category that is specified in the `l10n` attribute of 93 * the <default> element. The string which is translated includes all text in 94 * the <default> element, including any surrounding quotation marks. 95 * 96 * The `l10n` attribute must be set to `messages` or `time`, and sets the 97 * [locale category for 98 * translation](https://www.gnu.org/software/gettext/manual/html_node/Aspects.html#index-locale-categories-1). 99 * The `messages` category should be used by default; use `time` for 100 * translatable date or time formats. A translation comment can be added as an 101 * XML comment immediately above the <default> element — it is recommended to 102 * add these comments to aid translators understand the meaning and 103 * implications of the default value. An optional translation `context` 104 * attribute can be set on the <default> element to disambiguate multiple 105 * defaults which use the same string. 106 * 107 * For example: 108 * |[ 109 * <!-- Translators: A list of words which are not allowed to be typed, in 110 * GVariant serialization syntax. 111 * See: https://developer.gnome.org/glib/stable/gvariant-text.html --> 112 * <default l10n='messages' context='Banned words'>['bad', 'words']</default> 113 * ]| 114 * 115 * Translations of default values must remain syntactically valid serialized 116 * #GVariants (e.g. retaining any surrounding quotation marks) or runtime 117 * errors will occur. 118 * 119 * GSettings uses schemas in a compact binary form that is created 120 * by the [glib-compile-schemas][glib-compile-schemas] 121 * utility. The input is a schema description in an XML format. 122 * 123 * A DTD for the gschema XML format can be found here: 124 * [gschema.dtd](https://git.gnome.org/browse/glib/tree/gio/gschema.dtd) 125 * 126 * The [glib-compile-schemas][glib-compile-schemas] tool expects schema 127 * files to have the extension `.gschema.xml`. 128 * 129 * At runtime, schemas are identified by their id (as specified in the 130 * id attribute of the <schema> element). The convention for schema 131 * ids is to use a dotted name, similar in style to a D-Bus bus name, 132 * e.g. "org.gnome.SessionManager". In particular, if the settings are 133 * for a specific service that owns a D-Bus bus name, the D-Bus bus name 134 * and schema id should match. For schemas which deal with settings not 135 * associated with one named application, the id should not use 136 * StudlyCaps, e.g. "org.gnome.font-rendering". 137 * 138 * In addition to #GVariant types, keys can have types that have 139 * enumerated types. These can be described by a <choice>, 140 * <enum> or <flags> element, as seen in the 141 * [example][schema-enumerated]. The underlying type of such a key 142 * is string, but you can use g_settings_get_enum(), g_settings_set_enum(), 143 * g_settings_get_flags(), g_settings_set_flags() access the numeric values 144 * corresponding to the string value of enum and flags keys. 145 * 146 * An example for default value: 147 * |[ 148 * <schemalist> 149 * <schema id="org.gtk.Test" path="/org/gtk/Test/" gettext-domain="test"> 150 * 151 * <key name="greeting" type="s"> 152 * <default l10n="messages">"Hello, earthlings"</default> 153 * <summary>A greeting</summary> 154 * <description> 155 * Greeting of the invading martians 156 * </description> 157 * </key> 158 * 159 * <key name="box" type="(ii)"> 160 * <default>(20,30)</default> 161 * </key> 162 * 163 * </schema> 164 * </schemalist> 165 * ]| 166 * 167 * An example for ranges, choices and enumerated types: 168 * |[ 169 * <schemalist> 170 * 171 * <enum id="org.gtk.Test.myenum"> 172 * <value nick="first" value="1"/> 173 * <value nick="second" value="2"/> 174 * </enum> 175 * 176 * <flags id="org.gtk.Test.myflags"> 177 * <value nick="flag1" value="1"/> 178 * <value nick="flag2" value="2"/> 179 * <value nick="flag3" value="4"/> 180 * </flags> 181 * 182 * <schema id="org.gtk.Test"> 183 * 184 * <key name="key-with-range" type="i"> 185 * <range min="1" max="100"/> 186 * <default>10</default> 187 * </key> 188 * 189 * <key name="key-with-choices" type="s"> 190 * <choices> 191 * <choice value='Elisabeth'/> 192 * <choice value='Annabeth'/> 193 * <choice value='Joe'/> 194 * </choices> 195 * <aliases> 196 * <alias value='Anna' target='Annabeth'/> 197 * <alias value='Beth' target='Elisabeth'/> 198 * </aliases> 199 * <default>'Joe'</default> 200 * </key> 201 * 202 * <key name='enumerated-key' enum='org.gtk.Test.myenum'> 203 * <default>'first'</default> 204 * </key> 205 * 206 * <key name='flags-key' flags='org.gtk.Test.myflags'> 207 * <default>["flag1","flag2"]</default> 208 * </key> 209 * </schema> 210 * </schemalist> 211 * ]| 212 * 213 * ## Vendor overrides 214 * 215 * Default values are defined in the schemas that get installed by 216 * an application. Sometimes, it is necessary for a vendor or distributor 217 * to adjust these defaults. Since patching the XML source for the schema 218 * is inconvenient and error-prone, 219 * [glib-compile-schemas][glib-compile-schemas] reads so-called vendor 220 * override' files. These are keyfiles in the same directory as the XML 221 * schema sources which can override default values. The schema id serves 222 * as the group name in the key file, and the values are expected in 223 * serialized GVariant form, as in the following example: 224 * |[ 225 * [org.gtk.Example] 226 * key1='string' 227 * key2=1.5 228 * ]| 229 * 230 * glib-compile-schemas expects schema files to have the extension 231 * `.gschema.override`. 232 * 233 * ## Binding 234 * 235 * A very convenient feature of GSettings lets you bind #GObject properties 236 * directly to settings, using g_settings_bind(). Once a GObject property 237 * has been bound to a setting, changes on either side are automatically 238 * propagated to the other side. GSettings handles details like mapping 239 * between GObject and GVariant types, and preventing infinite cycles. 240 * 241 * This makes it very easy to hook up a preferences dialog to the 242 * underlying settings. To make this even more convenient, GSettings 243 * looks for a boolean property with the name "sensitivity" and 244 * automatically binds it to the writability of the bound setting. 245 * If this 'magic' gets in the way, it can be suppressed with the 246 * #G_SETTINGS_BIND_NO_SENSITIVITY flag. 247 * 248 * ## Relocatable schemas # {#gsettings-relocatable} 249 * 250 * A relocatable schema is one with no `path` attribute specified on its 251 * <schema> element. By using g_settings_new_with_path(), a #GSettings object 252 * can be instantiated for a relocatable schema, assigning a path to the 253 * instance. Paths passed to g_settings_new_with_path() will typically be 254 * constructed dynamically from a constant prefix plus some form of instance 255 * identifier; but they must still be valid GSettings paths. Paths could also 256 * be constant and used with a globally installed schema originating from a 257 * dependency library. 258 * 259 * For example, a relocatable schema could be used to store geometry information 260 * for different windows in an application. If the schema ID was 261 * `org.foo.MyApp.Window`, it could be instantiated for paths 262 * `/org/foo/MyApp/main/`, `/org/foo/MyApp/document-1/`, 263 * `/org/foo/MyApp/document-2/`, etc. If any of the paths are well-known 264 * they can be specified as <child> elements in the parent schema, e.g.: 265 * |[ 266 * <schema id="org.foo.MyApp" path="/org/foo/MyApp/"> 267 * <child name="main" schema="org.foo.MyApp.Window"/> 268 * </schema> 269 * ]| 270 * 271 * ## Build system integration # {#gsettings-build-system} 272 * 273 * GSettings comes with autotools integration to simplify compiling and 274 * installing schemas. To add GSettings support to an application, add the 275 * following to your `configure.ac`: 276 * |[ 277 * GLIB_GSETTINGS 278 * ]| 279 * 280 * In the appropriate `Makefile.am`, use the following snippet to compile and 281 * install the named schema: 282 * |[ 283 * gsettings_SCHEMAS = org.foo.MyApp.gschema.xml 284 * EXTRA_DIST = $(gsettings_SCHEMAS) 285 * 286 * @GSETTINGS_RULES@ 287 * ]| 288 * 289 * No changes are needed to the build system to mark a schema XML file for 290 * translation. Assuming it sets the `gettext-domain` attribute, a schema may 291 * be marked for translation by adding it to `POTFILES.in`, assuming gettext 292 * 0.19 is in use (the preferred method for translation): 293 * |[ 294 * data/org.foo.MyApp.gschema.xml 295 * ]| 296 * 297 * Alternatively, if intltool 0.50.1 is in use: 298 * |[ 299 * [type: gettext/gsettings]data/org.foo.MyApp.gschema.xml 300 * ]| 301 * 302 * GSettings will use gettext to look up translations for the <summary> and 303 * <description> elements, and also any <default> elements which have a `l10n` 304 * attribute set. Translations must not be included in the `.gschema.xml` file 305 * by the build system, for example by using intltool XML rules with a 306 * `.gschema.xml.in` template. 307 * 308 * If an enumerated type defined in a C header file is to be used in a GSettings 309 * schema, it can either be defined manually using an <enum> element in the 310 * schema XML, or it can be extracted automatically from the C header. This 311 * approach is preferred, as it ensures the two representations are always 312 * synchronised. To do so, add the following to the relevant `Makefile.am`: 313 * |[ 314 * gsettings_ENUM_NAMESPACE = org.foo.MyApp 315 * gsettings_ENUM_FILES = my-app-enums.h my-app-misc.h 316 * ]| 317 * 318 * `gsettings_ENUM_NAMESPACE` specifies the schema namespace for the enum files, 319 * which are specified in `gsettings_ENUM_FILES`. This will generate a 320 * `org.foo.MyApp.enums.xml` file containing the extracted enums, which will be 321 * automatically included in the schema compilation, install and uninstall 322 * rules. It should not be committed to version control or included in 323 * `EXTRA_DIST`. 324 */ 325 public class Settings : ObjectG 326 { 327 /** the main Gtk struct */ 328 protected GSettings* gSettings; 329 330 /** Get the main Gtk struct */ 331 public GSettings* getSettingsStruct(bool transferOwnership = false) 332 { 333 if (transferOwnership) 334 ownedRef = false; 335 return gSettings; 336 } 337 338 /** the main Gtk struct as a void* */ 339 protected override void* getStruct() 340 { 341 return cast(void*)gSettings; 342 } 343 344 /** 345 * Sets our main struct and passes it to the parent class. 346 */ 347 public this (GSettings* gSettings, bool ownedRef = false) 348 { 349 this.gSettings = gSettings; 350 super(cast(GObject*)gSettings, ownedRef); 351 } 352 353 354 /** */ 355 public static GType getType() 356 { 357 return g_settings_get_type(); 358 } 359 360 /** 361 * Creates a new #GSettings object with the schema specified by 362 * @schema_id. 363 * 364 * Signals on the newly created #GSettings object will be dispatched 365 * via the thread-default #GMainContext in effect at the time of the 366 * call to g_settings_new(). The new #GSettings will hold a reference 367 * on the context. See g_main_context_push_thread_default(). 368 * 369 * Params: 370 * schemaId = the id of the schema 371 * 372 * Returns: a new #GSettings object 373 * 374 * Since: 2.26 375 * 376 * Throws: ConstructionException GTK+ fails to create the object. 377 */ 378 public this(string schemaId) 379 { 380 auto p = g_settings_new(Str.toStringz(schemaId)); 381 382 if(p is null) 383 { 384 throw new ConstructionException("null returned by new"); 385 } 386 387 this(cast(GSettings*) p, true); 388 } 389 390 /** 391 * Creates a new #GSettings object with a given schema, backend and 392 * path. 393 * 394 * It should be extremely rare that you ever want to use this function. 395 * It is made available for advanced use-cases (such as plugin systems 396 * that want to provide access to schemas loaded from custom locations, 397 * etc). 398 * 399 * At the most basic level, a #GSettings object is a pure composition of 400 * 4 things: a #GSettingsSchema, a #GSettingsBackend, a path within that 401 * backend, and a #GMainContext to which signals are dispatched. 402 * 403 * This constructor therefore gives you full control over constructing 404 * #GSettings instances. The first 3 parameters are given directly as 405 * @schema, @backend and @path, and the main context is taken from the 406 * thread-default (as per g_settings_new()). 407 * 408 * If @backend is %NULL then the default backend is used. 409 * 410 * If @path is %NULL then the path from the schema is used. It is an 411 * error if @path is %NULL and the schema has no path of its own or if 412 * @path is non-%NULL and not equal to the path that the schema does 413 * have. 414 * 415 * Params: 416 * schema = a #GSettingsSchema 417 * backend = a #GSettingsBackend 418 * path = the path to use 419 * 420 * Returns: a new #GSettings object 421 * 422 * Since: 2.32 423 * 424 * Throws: ConstructionException GTK+ fails to create the object. 425 */ 426 public this(SettingsSchema schema, SettingsBackend backend, string path) 427 { 428 auto p = g_settings_new_full((schema is null) ? null : schema.getSettingsSchemaStruct(), (backend is null) ? null : backend.getSettingsBackendStruct(), Str.toStringz(path)); 429 430 if(p is null) 431 { 432 throw new ConstructionException("null returned by new_full"); 433 } 434 435 this(cast(GSettings*) p, true); 436 } 437 438 /** 439 * Creates a new #GSettings object with the schema specified by 440 * @schema_id and a given #GSettingsBackend. 441 * 442 * Creating a #GSettings object with a different backend allows accessing 443 * settings from a database other than the usual one. For example, it may make 444 * sense to pass a backend corresponding to the "defaults" settings database on 445 * the system to get a settings object that modifies the system default 446 * settings instead of the settings for this user. 447 * 448 * Params: 449 * schemaId = the id of the schema 450 * backend = the #GSettingsBackend to use 451 * 452 * Returns: a new #GSettings object 453 * 454 * Since: 2.26 455 * 456 * Throws: ConstructionException GTK+ fails to create the object. 457 */ 458 public this(string schemaId, SettingsBackend backend) 459 { 460 auto p = g_settings_new_with_backend(Str.toStringz(schemaId), (backend is null) ? null : backend.getSettingsBackendStruct()); 461 462 if(p is null) 463 { 464 throw new ConstructionException("null returned by new_with_backend"); 465 } 466 467 this(cast(GSettings*) p, true); 468 } 469 470 /** 471 * Creates a new #GSettings object with the schema specified by 472 * @schema_id and a given #GSettingsBackend and path. 473 * 474 * This is a mix of g_settings_new_with_backend() and 475 * g_settings_new_with_path(). 476 * 477 * Params: 478 * schemaId = the id of the schema 479 * backend = the #GSettingsBackend to use 480 * path = the path to use 481 * 482 * Returns: a new #GSettings object 483 * 484 * Since: 2.26 485 * 486 * Throws: ConstructionException GTK+ fails to create the object. 487 */ 488 public this(string schemaId, SettingsBackend backend, string path) 489 { 490 auto p = g_settings_new_with_backend_and_path(Str.toStringz(schemaId), (backend is null) ? null : backend.getSettingsBackendStruct(), Str.toStringz(path)); 491 492 if(p is null) 493 { 494 throw new ConstructionException("null returned by new_with_backend_and_path"); 495 } 496 497 this(cast(GSettings*) p, true); 498 } 499 500 /** 501 * Creates a new #GSettings object with the relocatable schema specified 502 * by @schema_id and a given path. 503 * 504 * You only need to do this if you want to directly create a settings 505 * object with a schema that doesn't have a specified path of its own. 506 * That's quite rare. 507 * 508 * It is a programmer error to call this function for a schema that 509 * has an explicitly specified path. 510 * 511 * It is a programmer error if @path is not a valid path. A valid path 512 * begins and ends with '/' and does not contain two consecutive '/' 513 * characters. 514 * 515 * Params: 516 * schemaId = the id of the schema 517 * path = the path to use 518 * 519 * Returns: a new #GSettings object 520 * 521 * Since: 2.26 522 * 523 * Throws: ConstructionException GTK+ fails to create the object. 524 */ 525 public this(string schemaId, string path) 526 { 527 auto p = g_settings_new_with_path(Str.toStringz(schemaId), Str.toStringz(path)); 528 529 if(p is null) 530 { 531 throw new ConstructionException("null returned by new_with_path"); 532 } 533 534 this(cast(GSettings*) p, true); 535 } 536 537 /** 538 * Deprecated. 539 * 540 * Deprecated: Use g_settings_schema_source_list_schemas() instead 541 * 542 * Returns: a list of relocatable 543 * #GSettings schemas that are available. The list must not be 544 * modified or freed. 545 * 546 * Since: 2.28 547 */ 548 public static string[] listRelocatableSchemas() 549 { 550 return Str.toStringArray(g_settings_list_relocatable_schemas()); 551 } 552 553 /** 554 * Deprecated. 555 * 556 * Deprecated: Use g_settings_schema_source_list_schemas() instead. 557 * If you used g_settings_list_schemas() to check for the presence of 558 * a particular schema, use g_settings_schema_source_lookup() instead 559 * of your whole loop. 560 * 561 * Returns: a list of #GSettings 562 * schemas that are available. The list must not be modified or 563 * freed. 564 * 565 * Since: 2.26 566 */ 567 public static string[] listSchemas() 568 { 569 return Str.toStringArray(g_settings_list_schemas()); 570 } 571 572 /** 573 * Ensures that all pending operations are complete for the default backend. 574 * 575 * Writes made to a #GSettings are handled asynchronously. For this 576 * reason, it is very unlikely that the changes have it to disk by the 577 * time g_settings_set() returns. 578 * 579 * This call will block until all of the writes have made it to the 580 * backend. Since the mainloop is not running, no change notifications 581 * will be dispatched during this call (but some may be queued by the 582 * time the call is done). 583 */ 584 public static void sync() 585 { 586 g_settings_sync(); 587 } 588 589 /** 590 * Removes an existing binding for @property on @object. 591 * 592 * Note that bindings are automatically removed when the 593 * object is finalized, so it is rarely necessary to call this 594 * function. 595 * 596 * Params: 597 * object = the object 598 * property = the property whose binding is removed 599 * 600 * Since: 2.26 601 */ 602 public static void unbind(ObjectG object, string property) 603 { 604 g_settings_unbind((object is null) ? null : object.getObjectGStruct(), Str.toStringz(property)); 605 } 606 607 /** 608 * Applies any changes that have been made to the settings. This 609 * function does nothing unless @settings is in 'delay-apply' mode; 610 * see g_settings_delay(). In the normal case settings are always 611 * applied immediately. 612 */ 613 public void apply() 614 { 615 g_settings_apply(gSettings); 616 } 617 618 /** 619 * Create a binding between the @key in the @settings object 620 * and the property @property of @object. 621 * 622 * The binding uses the default GIO mapping functions to map 623 * between the settings and property values. These functions 624 * handle booleans, numeric types and string types in a 625 * straightforward way. Use g_settings_bind_with_mapping() if 626 * you need a custom mapping, or map between types that are not 627 * supported by the default mapping functions. 628 * 629 * Unless the @flags include %G_SETTINGS_BIND_NO_SENSITIVITY, this 630 * function also establishes a binding between the writability of 631 * @key and the "sensitive" property of @object (if @object has 632 * a boolean property by that name). See g_settings_bind_writable() 633 * for more details about writable bindings. 634 * 635 * Note that the lifecycle of the binding is tied to @object, 636 * and that you can have only one binding per object property. 637 * If you bind the same property twice on the same object, the second 638 * binding overrides the first one. 639 * 640 * Params: 641 * key = the key to bind 642 * object = a #GObject 643 * property = the name of the property to bind 644 * flags = flags for the binding 645 * 646 * Since: 2.26 647 */ 648 public void bind(string key, ObjectG object, string property, GSettingsBindFlags flags) 649 { 650 g_settings_bind(gSettings, Str.toStringz(key), (object is null) ? null : object.getObjectGStruct(), Str.toStringz(property), flags); 651 } 652 653 /** 654 * Create a binding between the @key in the @settings object 655 * and the property @property of @object. 656 * 657 * The binding uses the provided mapping functions to map between 658 * settings and property values. 659 * 660 * Note that the lifecycle of the binding is tied to @object, 661 * and that you can have only one binding per object property. 662 * If you bind the same property twice on the same object, the second 663 * binding overrides the first one. 664 * 665 * Params: 666 * key = the key to bind 667 * object = a #GObject 668 * property = the name of the property to bind 669 * flags = flags for the binding 670 * getMapping = a function that gets called to convert values 671 * from @settings to @object, or %NULL to use the default GIO mapping 672 * setMapping = a function that gets called to convert values 673 * from @object to @settings, or %NULL to use the default GIO mapping 674 * userData = data that gets passed to @get_mapping and @set_mapping 675 * destroy = #GDestroyNotify function for @user_data 676 * 677 * Since: 2.26 678 */ 679 public void bindWithMapping(string key, ObjectG object, string property, GSettingsBindFlags flags, GSettingsBindGetMapping getMapping, GSettingsBindSetMapping setMapping, void* userData, GDestroyNotify destroy) 680 { 681 g_settings_bind_with_mapping(gSettings, Str.toStringz(key), (object is null) ? null : object.getObjectGStruct(), Str.toStringz(property), flags, getMapping, setMapping, userData, destroy); 682 } 683 684 /** 685 * Create a binding between the writability of @key in the 686 * @settings object and the property @property of @object. 687 * The property must be boolean; "sensitive" or "visible" 688 * properties of widgets are the most likely candidates. 689 * 690 * Writable bindings are always uni-directional; changes of the 691 * writability of the setting will be propagated to the object 692 * property, not the other way. 693 * 694 * When the @inverted argument is %TRUE, the binding inverts the 695 * value as it passes from the setting to the object, i.e. @property 696 * will be set to %TRUE if the key is not writable. 697 * 698 * Note that the lifecycle of the binding is tied to @object, 699 * and that you can have only one binding per object property. 700 * If you bind the same property twice on the same object, the second 701 * binding overrides the first one. 702 * 703 * Params: 704 * key = the key to bind 705 * object = a #GObject 706 * property = the name of a boolean property to bind 707 * inverted = whether to 'invert' the value 708 * 709 * Since: 2.26 710 */ 711 public void bindWritable(string key, ObjectG object, string property, bool inverted) 712 { 713 g_settings_bind_writable(gSettings, Str.toStringz(key), (object is null) ? null : object.getObjectGStruct(), Str.toStringz(property), inverted); 714 } 715 716 /** 717 * Creates a #GAction corresponding to a given #GSettings key. 718 * 719 * The action has the same name as the key. 720 * 721 * The value of the key becomes the state of the action and the action 722 * is enabled when the key is writable. Changing the state of the 723 * action results in the key being written to. Changes to the value or 724 * writability of the key cause appropriate change notifications to be 725 * emitted for the action. 726 * 727 * For boolean-valued keys, action activations take no parameter and 728 * result in the toggling of the value. For all other types, 729 * activations take the new value for the key (which must have the 730 * correct type). 731 * 732 * Params: 733 * key = the name of a key in @settings 734 * 735 * Returns: a new #GAction 736 * 737 * Since: 2.32 738 */ 739 public ActionIF createAction(string key) 740 { 741 auto p = g_settings_create_action(gSettings, Str.toStringz(key)); 742 743 if(p is null) 744 { 745 return null; 746 } 747 748 return ObjectG.getDObject!(ActionIF)(cast(GAction*) p, true); 749 } 750 751 /** 752 * Changes the #GSettings object into 'delay-apply' mode. In this 753 * mode, changes to @settings are not immediately propagated to the 754 * backend, but kept locally until g_settings_apply() is called. 755 * 756 * Since: 2.26 757 */ 758 public void delay() 759 { 760 g_settings_delay(gSettings); 761 } 762 763 /** 764 * Gets the value that is stored at @key in @settings. 765 * 766 * A convenience variant of g_settings_get() for booleans. 767 * 768 * It is a programmer error to give a @key that isn't specified as 769 * having a boolean type in the schema for @settings. 770 * 771 * Params: 772 * key = the key to get the value for 773 * 774 * Returns: a boolean 775 * 776 * Since: 2.26 777 */ 778 public bool getBoolean(string key) 779 { 780 return g_settings_get_boolean(gSettings, Str.toStringz(key)) != 0; 781 } 782 783 /** 784 * Creates a child settings object which has a base path of 785 * `base-path/@name`, where `base-path` is the base path of 786 * @settings. 787 * 788 * The schema for the child settings object must have been declared 789 * in the schema of @settings using a <child> element. 790 * 791 * Params: 792 * name = the name of the child schema 793 * 794 * Returns: a 'child' settings object 795 * 796 * Since: 2.26 797 */ 798 public Settings getChild(string name) 799 { 800 auto p = g_settings_get_child(gSettings, Str.toStringz(name)); 801 802 if(p is null) 803 { 804 return null; 805 } 806 807 return ObjectG.getDObject!(Settings)(cast(GSettings*) p, true); 808 } 809 810 /** 811 * Gets the "default value" of a key. 812 * 813 * This is the value that would be read if g_settings_reset() were to be 814 * called on the key. 815 * 816 * Note that this may be a different value than returned by 817 * g_settings_schema_key_get_default_value() if the system administrator 818 * has provided a default value. 819 * 820 * Comparing the return values of g_settings_get_default_value() and 821 * g_settings_get_value() is not sufficient for determining if a value 822 * has been set because the user may have explicitly set the value to 823 * something that happens to be equal to the default. The difference 824 * here is that if the default changes in the future, the user's key 825 * will still be set. 826 * 827 * This function may be useful for adding an indication to a UI of what 828 * the default value was before the user set it. 829 * 830 * It is a programmer error to give a @key that isn't contained in the 831 * schema for @settings. 832 * 833 * Params: 834 * key = the key to get the default value for 835 * 836 * Returns: the default value 837 * 838 * Since: 2.40 839 */ 840 public Variant getDefaultValue(string key) 841 { 842 auto p = g_settings_get_default_value(gSettings, Str.toStringz(key)); 843 844 if(p is null) 845 { 846 return null; 847 } 848 849 return new Variant(cast(GVariant*) p, true); 850 } 851 852 /** 853 * Gets the value that is stored at @key in @settings. 854 * 855 * A convenience variant of g_settings_get() for doubles. 856 * 857 * It is a programmer error to give a @key that isn't specified as 858 * having a 'double' type in the schema for @settings. 859 * 860 * Params: 861 * key = the key to get the value for 862 * 863 * Returns: a double 864 * 865 * Since: 2.26 866 */ 867 public double getDouble(string key) 868 { 869 return g_settings_get_double(gSettings, Str.toStringz(key)); 870 } 871 872 /** 873 * Gets the value that is stored in @settings for @key and converts it 874 * to the enum value that it represents. 875 * 876 * In order to use this function the type of the value must be a string 877 * and it must be marked in the schema file as an enumerated type. 878 * 879 * It is a programmer error to give a @key that isn't contained in the 880 * schema for @settings or is not marked as an enumerated type. 881 * 882 * If the value stored in the configuration database is not a valid 883 * value for the enumerated type then this function will return the 884 * default value. 885 * 886 * Params: 887 * key = the key to get the value for 888 * 889 * Returns: the enum value 890 * 891 * Since: 2.26 892 */ 893 public int getEnum(string key) 894 { 895 return g_settings_get_enum(gSettings, Str.toStringz(key)); 896 } 897 898 /** 899 * Gets the value that is stored in @settings for @key and converts it 900 * to the flags value that it represents. 901 * 902 * In order to use this function the type of the value must be an array 903 * of strings and it must be marked in the schema file as an flags type. 904 * 905 * It is a programmer error to give a @key that isn't contained in the 906 * schema for @settings or is not marked as a flags type. 907 * 908 * If the value stored in the configuration database is not a valid 909 * value for the flags type then this function will return the default 910 * value. 911 * 912 * Params: 913 * key = the key to get the value for 914 * 915 * Returns: the flags value 916 * 917 * Since: 2.26 918 */ 919 public uint getFlags(string key) 920 { 921 return g_settings_get_flags(gSettings, Str.toStringz(key)); 922 } 923 924 /** 925 * Returns whether the #GSettings object has any unapplied 926 * changes. This can only be the case if it is in 'delayed-apply' mode. 927 * 928 * Returns: %TRUE if @settings has unapplied changes 929 * 930 * Since: 2.26 931 */ 932 public bool getHasUnapplied() 933 { 934 return g_settings_get_has_unapplied(gSettings) != 0; 935 } 936 937 /** 938 * Gets the value that is stored at @key in @settings. 939 * 940 * A convenience variant of g_settings_get() for 32-bit integers. 941 * 942 * It is a programmer error to give a @key that isn't specified as 943 * having a int32 type in the schema for @settings. 944 * 945 * Params: 946 * key = the key to get the value for 947 * 948 * Returns: an integer 949 * 950 * Since: 2.26 951 */ 952 public int getInt(string key) 953 { 954 return g_settings_get_int(gSettings, Str.toStringz(key)); 955 } 956 957 /** 958 * Gets the value that is stored at @key in @settings. 959 * 960 * A convenience variant of g_settings_get() for 64-bit integers. 961 * 962 * It is a programmer error to give a @key that isn't specified as 963 * having a int64 type in the schema for @settings. 964 * 965 * Params: 966 * key = the key to get the value for 967 * 968 * Returns: a 64-bit integer 969 * 970 * Since: 2.50 971 */ 972 public long getInt64(string key) 973 { 974 return g_settings_get_int64(gSettings, Str.toStringz(key)); 975 } 976 977 /** 978 * Gets the value that is stored at @key in @settings, subject to 979 * application-level validation/mapping. 980 * 981 * You should use this function when the application needs to perform 982 * some processing on the value of the key (for example, parsing). The 983 * @mapping function performs that processing. If the function 984 * indicates that the processing was unsuccessful (due to a parse error, 985 * for example) then the mapping is tried again with another value. 986 * 987 * This allows a robust 'fall back to defaults' behaviour to be 988 * implemented somewhat automatically. 989 * 990 * The first value that is tried is the user's setting for the key. If 991 * the mapping function fails to map this value, other values may be 992 * tried in an unspecified order (system or site defaults, translated 993 * schema default values, untranslated schema default values, etc). 994 * 995 * If the mapping function fails for all possible values, one additional 996 * attempt is made: the mapping function is called with a %NULL value. 997 * If the mapping function still indicates failure at this point then 998 * the application will be aborted. 999 * 1000 * The result parameter for the @mapping function is pointed to a 1001 * #gpointer which is initially set to %NULL. The same pointer is given 1002 * to each invocation of @mapping. The final value of that #gpointer is 1003 * what is returned by this function. %NULL is valid; it is returned 1004 * just as any other value would be. 1005 * 1006 * Params: 1007 * key = the key to get the value for 1008 * mapping = the function to map the value in the 1009 * settings database to the value used by the application 1010 * userData = user data for @mapping 1011 * 1012 * Returns: the result, which may be %NULL 1013 */ 1014 public void* getMapped(string key, GSettingsGetMapping mapping, void* userData) 1015 { 1016 return g_settings_get_mapped(gSettings, Str.toStringz(key), mapping, userData); 1017 } 1018 1019 /** 1020 * Queries the range of a key. 1021 * 1022 * Deprecated: Use g_settings_schema_key_get_range() instead. 1023 * 1024 * Params: 1025 * key = the key to query the range of 1026 * 1027 * Since: 2.28 1028 */ 1029 public Variant getRange(string key) 1030 { 1031 auto p = g_settings_get_range(gSettings, Str.toStringz(key)); 1032 1033 if(p is null) 1034 { 1035 return null; 1036 } 1037 1038 return new Variant(cast(GVariant*) p, true); 1039 } 1040 1041 /** 1042 * Gets the value that is stored at @key in @settings. 1043 * 1044 * A convenience variant of g_settings_get() for strings. 1045 * 1046 * It is a programmer error to give a @key that isn't specified as 1047 * having a string type in the schema for @settings. 1048 * 1049 * Params: 1050 * key = the key to get the value for 1051 * 1052 * Returns: a newly-allocated string 1053 * 1054 * Since: 2.26 1055 */ 1056 public string getString(string key) 1057 { 1058 auto retStr = g_settings_get_string(gSettings, Str.toStringz(key)); 1059 1060 scope(exit) Str.freeString(retStr); 1061 return Str.toString(retStr); 1062 } 1063 1064 /** 1065 * A convenience variant of g_settings_get() for string arrays. 1066 * 1067 * It is a programmer error to give a @key that isn't specified as 1068 * having an array of strings type in the schema for @settings. 1069 * 1070 * Params: 1071 * key = the key to get the value for 1072 * 1073 * Returns: a 1074 * newly-allocated, %NULL-terminated array of strings, the value that 1075 * is stored at @key in @settings. 1076 * 1077 * Since: 2.26 1078 */ 1079 public string[] getStrv(string key) 1080 { 1081 auto retStr = g_settings_get_strv(gSettings, Str.toStringz(key)); 1082 1083 scope(exit) Str.freeStringArray(retStr); 1084 return Str.toStringArray(retStr); 1085 } 1086 1087 /** 1088 * Gets the value that is stored at @key in @settings. 1089 * 1090 * A convenience variant of g_settings_get() for 32-bit unsigned 1091 * integers. 1092 * 1093 * It is a programmer error to give a @key that isn't specified as 1094 * having a uint32 type in the schema for @settings. 1095 * 1096 * Params: 1097 * key = the key to get the value for 1098 * 1099 * Returns: an unsigned integer 1100 * 1101 * Since: 2.30 1102 */ 1103 public uint getUint(string key) 1104 { 1105 return g_settings_get_uint(gSettings, Str.toStringz(key)); 1106 } 1107 1108 /** 1109 * Gets the value that is stored at @key in @settings. 1110 * 1111 * A convenience variant of g_settings_get() for 64-bit unsigned 1112 * integers. 1113 * 1114 * It is a programmer error to give a @key that isn't specified as 1115 * having a uint64 type in the schema for @settings. 1116 * 1117 * Params: 1118 * key = the key to get the value for 1119 * 1120 * Returns: a 64-bit unsigned integer 1121 * 1122 * Since: 2.50 1123 */ 1124 public ulong getUint64(string key) 1125 { 1126 return g_settings_get_uint64(gSettings, Str.toStringz(key)); 1127 } 1128 1129 /** 1130 * Checks the "user value" of a key, if there is one. 1131 * 1132 * The user value of a key is the last value that was set by the user. 1133 * 1134 * After calling g_settings_reset() this function should always return 1135 * %NULL (assuming something is not wrong with the system 1136 * configuration). 1137 * 1138 * It is possible that g_settings_get_value() will return a different 1139 * value than this function. This can happen in the case that the user 1140 * set a value for a key that was subsequently locked down by the system 1141 * administrator -- this function will return the user's old value. 1142 * 1143 * This function may be useful for adding a "reset" option to a UI or 1144 * for providing indication that a particular value has been changed. 1145 * 1146 * It is a programmer error to give a @key that isn't contained in the 1147 * schema for @settings. 1148 * 1149 * Params: 1150 * key = the key to get the user value for 1151 * 1152 * Returns: the user's value, if set 1153 * 1154 * Since: 2.40 1155 */ 1156 public Variant getUserValue(string key) 1157 { 1158 auto p = g_settings_get_user_value(gSettings, Str.toStringz(key)); 1159 1160 if(p is null) 1161 { 1162 return null; 1163 } 1164 1165 return new Variant(cast(GVariant*) p, true); 1166 } 1167 1168 /** 1169 * Gets the value that is stored in @settings for @key. 1170 * 1171 * It is a programmer error to give a @key that isn't contained in the 1172 * schema for @settings. 1173 * 1174 * Params: 1175 * key = the key to get the value for 1176 * 1177 * Returns: a new #GVariant 1178 * 1179 * Since: 2.26 1180 */ 1181 public Variant getValue(string key) 1182 { 1183 auto p = g_settings_get_value(gSettings, Str.toStringz(key)); 1184 1185 if(p is null) 1186 { 1187 return null; 1188 } 1189 1190 return new Variant(cast(GVariant*) p, true); 1191 } 1192 1193 /** 1194 * Finds out if a key can be written or not 1195 * 1196 * Params: 1197 * name = the name of a key 1198 * 1199 * Returns: %TRUE if the key @name is writable 1200 * 1201 * Since: 2.26 1202 */ 1203 public bool isWritable(string name) 1204 { 1205 return g_settings_is_writable(gSettings, Str.toStringz(name)) != 0; 1206 } 1207 1208 /** 1209 * Gets the list of children on @settings. 1210 * 1211 * The list is exactly the list of strings for which it is not an error 1212 * to call g_settings_get_child(). 1213 * 1214 * For GSettings objects that are lists, this value can change at any 1215 * time and you should connect to the "children-changed" signal to watch 1216 * for those changes. Note that there is a race condition here: you may 1217 * request a child after listing it only for it to have been destroyed 1218 * in the meantime. For this reason, g_settings_get_child() may return 1219 * %NULL even for a child that was listed by this function. 1220 * 1221 * For GSettings objects that are not lists, you should probably not be 1222 * calling this function from "normal" code (since you should already 1223 * know what children are in your schema). This function may still be 1224 * useful there for introspection reasons, however. 1225 * 1226 * You should free the return value with g_strfreev() when you are done 1227 * with it. 1228 * 1229 * Returns: a list of the children on @settings 1230 */ 1231 public string[] listChildren() 1232 { 1233 auto retStr = g_settings_list_children(gSettings); 1234 1235 scope(exit) Str.freeStringArray(retStr); 1236 return Str.toStringArray(retStr); 1237 } 1238 1239 /** 1240 * Introspects the list of keys on @settings. 1241 * 1242 * You should probably not be calling this function from "normal" code 1243 * (since you should already know what keys are in your schema). This 1244 * function is intended for introspection reasons. 1245 * 1246 * You should free the return value with g_strfreev() when you are done 1247 * with it. 1248 * 1249 * Returns: a list of the keys on @settings 1250 */ 1251 public string[] listKeys() 1252 { 1253 auto retStr = g_settings_list_keys(gSettings); 1254 1255 scope(exit) Str.freeStringArray(retStr); 1256 return Str.toStringArray(retStr); 1257 } 1258 1259 /** 1260 * Checks if the given @value is of the correct type and within the 1261 * permitted range for @key. 1262 * 1263 * Deprecated: Use g_settings_schema_key_range_check() instead. 1264 * 1265 * Params: 1266 * key = the key to check 1267 * value = the value to check 1268 * 1269 * Returns: %TRUE if @value is valid for @key 1270 * 1271 * Since: 2.28 1272 */ 1273 public bool rangeCheck(string key, Variant value) 1274 { 1275 return g_settings_range_check(gSettings, Str.toStringz(key), (value is null) ? null : value.getVariantStruct()) != 0; 1276 } 1277 1278 /** 1279 * Resets @key to its default value. 1280 * 1281 * This call resets the key, as much as possible, to its default value. 1282 * That might the value specified in the schema or the one set by the 1283 * administrator. 1284 * 1285 * Params: 1286 * key = the name of a key 1287 */ 1288 public void reset(string key) 1289 { 1290 g_settings_reset(gSettings, Str.toStringz(key)); 1291 } 1292 1293 /** 1294 * Reverts all non-applied changes to the settings. This function 1295 * does nothing unless @settings is in 'delay-apply' mode; see 1296 * g_settings_delay(). In the normal case settings are always applied 1297 * immediately. 1298 * 1299 * Change notifications will be emitted for affected keys. 1300 */ 1301 public void revert() 1302 { 1303 g_settings_revert(gSettings); 1304 } 1305 1306 /** 1307 * Sets @key in @settings to @value. 1308 * 1309 * A convenience variant of g_settings_set() for booleans. 1310 * 1311 * It is a programmer error to give a @key that isn't specified as 1312 * having a boolean type in the schema for @settings. 1313 * 1314 * Params: 1315 * key = the name of the key to set 1316 * value = the value to set it to 1317 * 1318 * Returns: %TRUE if setting the key succeeded, 1319 * %FALSE if the key was not writable 1320 * 1321 * Since: 2.26 1322 */ 1323 public bool setBoolean(string key, bool value) 1324 { 1325 return g_settings_set_boolean(gSettings, Str.toStringz(key), value) != 0; 1326 } 1327 1328 /** 1329 * Sets @key in @settings to @value. 1330 * 1331 * A convenience variant of g_settings_set() for doubles. 1332 * 1333 * It is a programmer error to give a @key that isn't specified as 1334 * having a 'double' type in the schema for @settings. 1335 * 1336 * Params: 1337 * key = the name of the key to set 1338 * value = the value to set it to 1339 * 1340 * Returns: %TRUE if setting the key succeeded, 1341 * %FALSE if the key was not writable 1342 * 1343 * Since: 2.26 1344 */ 1345 public bool setDouble(string key, double value) 1346 { 1347 return g_settings_set_double(gSettings, Str.toStringz(key), value) != 0; 1348 } 1349 1350 /** 1351 * Looks up the enumerated type nick for @value and writes it to @key, 1352 * within @settings. 1353 * 1354 * It is a programmer error to give a @key that isn't contained in the 1355 * schema for @settings or is not marked as an enumerated type, or for 1356 * @value not to be a valid value for the named type. 1357 * 1358 * After performing the write, accessing @key directly with 1359 * g_settings_get_string() will return the 'nick' associated with 1360 * @value. 1361 * 1362 * Params: 1363 * key = a key, within @settings 1364 * value = an enumerated value 1365 * 1366 * Returns: %TRUE, if the set succeeds 1367 */ 1368 public bool setEnum(string key, int value) 1369 { 1370 return g_settings_set_enum(gSettings, Str.toStringz(key), value) != 0; 1371 } 1372 1373 /** 1374 * Looks up the flags type nicks for the bits specified by @value, puts 1375 * them in an array of strings and writes the array to @key, within 1376 * @settings. 1377 * 1378 * It is a programmer error to give a @key that isn't contained in the 1379 * schema for @settings or is not marked as a flags type, or for @value 1380 * to contain any bits that are not value for the named type. 1381 * 1382 * After performing the write, accessing @key directly with 1383 * g_settings_get_strv() will return an array of 'nicks'; one for each 1384 * bit in @value. 1385 * 1386 * Params: 1387 * key = a key, within @settings 1388 * value = a flags value 1389 * 1390 * Returns: %TRUE, if the set succeeds 1391 */ 1392 public bool setFlags(string key, uint value) 1393 { 1394 return g_settings_set_flags(gSettings, Str.toStringz(key), value) != 0; 1395 } 1396 1397 /** 1398 * Sets @key in @settings to @value. 1399 * 1400 * A convenience variant of g_settings_set() for 32-bit integers. 1401 * 1402 * It is a programmer error to give a @key that isn't specified as 1403 * having a int32 type in the schema for @settings. 1404 * 1405 * Params: 1406 * key = the name of the key to set 1407 * value = the value to set it to 1408 * 1409 * Returns: %TRUE if setting the key succeeded, 1410 * %FALSE if the key was not writable 1411 * 1412 * Since: 2.26 1413 */ 1414 public bool setInt(string key, int value) 1415 { 1416 return g_settings_set_int(gSettings, Str.toStringz(key), value) != 0; 1417 } 1418 1419 /** 1420 * Sets @key in @settings to @value. 1421 * 1422 * A convenience variant of g_settings_set() for 64-bit integers. 1423 * 1424 * It is a programmer error to give a @key that isn't specified as 1425 * having a int64 type in the schema for @settings. 1426 * 1427 * Params: 1428 * key = the name of the key to set 1429 * value = the value to set it to 1430 * 1431 * Returns: %TRUE if setting the key succeeded, 1432 * %FALSE if the key was not writable 1433 * 1434 * Since: 2.50 1435 */ 1436 public bool setInt64(string key, long value) 1437 { 1438 return g_settings_set_int64(gSettings, Str.toStringz(key), value) != 0; 1439 } 1440 1441 /** 1442 * Sets @key in @settings to @value. 1443 * 1444 * A convenience variant of g_settings_set() for strings. 1445 * 1446 * It is a programmer error to give a @key that isn't specified as 1447 * having a string type in the schema for @settings. 1448 * 1449 * Params: 1450 * key = the name of the key to set 1451 * value = the value to set it to 1452 * 1453 * Returns: %TRUE if setting the key succeeded, 1454 * %FALSE if the key was not writable 1455 * 1456 * Since: 2.26 1457 */ 1458 public bool setString(string key, string value) 1459 { 1460 return g_settings_set_string(gSettings, Str.toStringz(key), Str.toStringz(value)) != 0; 1461 } 1462 1463 /** 1464 * Sets @key in @settings to @value. 1465 * 1466 * A convenience variant of g_settings_set() for string arrays. If 1467 * @value is %NULL, then @key is set to be the empty array. 1468 * 1469 * It is a programmer error to give a @key that isn't specified as 1470 * having an array of strings type in the schema for @settings. 1471 * 1472 * Params: 1473 * key = the name of the key to set 1474 * value = the value to set it to, or %NULL 1475 * 1476 * Returns: %TRUE if setting the key succeeded, 1477 * %FALSE if the key was not writable 1478 * 1479 * Since: 2.26 1480 */ 1481 public bool setStrv(string key, string[] value) 1482 { 1483 return g_settings_set_strv(gSettings, Str.toStringz(key), Str.toStringzArray(value)) != 0; 1484 } 1485 1486 /** 1487 * Sets @key in @settings to @value. 1488 * 1489 * A convenience variant of g_settings_set() for 32-bit unsigned 1490 * integers. 1491 * 1492 * It is a programmer error to give a @key that isn't specified as 1493 * having a uint32 type in the schema for @settings. 1494 * 1495 * Params: 1496 * key = the name of the key to set 1497 * value = the value to set it to 1498 * 1499 * Returns: %TRUE if setting the key succeeded, 1500 * %FALSE if the key was not writable 1501 * 1502 * Since: 2.30 1503 */ 1504 public bool setUint(string key, uint value) 1505 { 1506 return g_settings_set_uint(gSettings, Str.toStringz(key), value) != 0; 1507 } 1508 1509 /** 1510 * Sets @key in @settings to @value. 1511 * 1512 * A convenience variant of g_settings_set() for 64-bit unsigned 1513 * integers. 1514 * 1515 * It is a programmer error to give a @key that isn't specified as 1516 * having a uint64 type in the schema for @settings. 1517 * 1518 * Params: 1519 * key = the name of the key to set 1520 * value = the value to set it to 1521 * 1522 * Returns: %TRUE if setting the key succeeded, 1523 * %FALSE if the key was not writable 1524 * 1525 * Since: 2.50 1526 */ 1527 public bool setUint64(string key, ulong value) 1528 { 1529 return g_settings_set_uint64(gSettings, Str.toStringz(key), value) != 0; 1530 } 1531 1532 /** 1533 * Sets @key in @settings to @value. 1534 * 1535 * It is a programmer error to give a @key that isn't contained in the 1536 * schema for @settings or for @value to have the incorrect type, per 1537 * the schema. 1538 * 1539 * If @value is floating then this function consumes the reference. 1540 * 1541 * Params: 1542 * key = the name of the key to set 1543 * value = a #GVariant of the correct type 1544 * 1545 * Returns: %TRUE if setting the key succeeded, 1546 * %FALSE if the key was not writable 1547 * 1548 * Since: 2.26 1549 */ 1550 public bool setValue(string key, Variant value) 1551 { 1552 return g_settings_set_value(gSettings, Str.toStringz(key), (value is null) ? null : value.getVariantStruct()) != 0; 1553 } 1554 1555 /** 1556 * The "change-event" signal is emitted once per change event that 1557 * affects this settings object. You should connect to this signal 1558 * only if you are interested in viewing groups of changes before they 1559 * are split out into multiple emissions of the "changed" signal. 1560 * For most use cases it is more appropriate to use the "changed" signal. 1561 * 1562 * In the event that the change event applies to one or more specified 1563 * keys, @keys will be an array of #GQuark of length @n_keys. In the 1564 * event that the change event applies to the #GSettings object as a 1565 * whole (ie: potentially every key has been changed) then @keys will 1566 * be %NULL and @n_keys will be 0. 1567 * 1568 * The default handler for this signal invokes the "changed" signal 1569 * for each affected key. If any other connected handler returns 1570 * %TRUE then this default functionality will be suppressed. 1571 * 1572 * Params: 1573 * keys = an array of #GQuarks for the changed keys, or %NULL 1574 * nKeys = the length of the @keys array, or 0 1575 * 1576 * Returns: %TRUE to stop other handlers from being invoked for the 1577 * event. FALSE to propagate the event further. 1578 */ 1579 gulong addOnChange(bool delegate(void*, int, Settings) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1580 { 1581 return Signals.connect(this, "change-event", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1582 } 1583 1584 /** 1585 * The "changed" signal is emitted when a key has potentially changed. 1586 * You should call one of the g_settings_get() calls to check the new 1587 * value. 1588 * 1589 * This signal supports detailed connections. You can connect to the 1590 * detailed signal "changed::x" in order to only receive callbacks 1591 * when key "x" changes. 1592 * 1593 * Note that @settings only emits this signal if you have read @key at 1594 * least once while a signal handler was already connected for @key. 1595 * 1596 * Params: 1597 * key = the name of the key that changed 1598 */ 1599 gulong addOnChanged(void delegate(string, Settings) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1600 { 1601 return Signals.connect(this, "changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1602 } 1603 1604 /** 1605 * The "writable-change-event" signal is emitted once per writability 1606 * change event that affects this settings object. You should connect 1607 * to this signal if you are interested in viewing groups of changes 1608 * before they are split out into multiple emissions of the 1609 * "writable-changed" signal. For most use cases it is more 1610 * appropriate to use the "writable-changed" signal. 1611 * 1612 * In the event that the writability change applies only to a single 1613 * key, @key will be set to the #GQuark for that key. In the event 1614 * that the writability change affects the entire settings object, 1615 * @key will be 0. 1616 * 1617 * The default handler for this signal invokes the "writable-changed" 1618 * and "changed" signals for each affected key. This is done because 1619 * changes in writability might also imply changes in value (if for 1620 * example, a new mandatory setting is introduced). If any other 1621 * connected handler returns %TRUE then this default functionality 1622 * will be suppressed. 1623 * 1624 * Params: 1625 * key = the quark of the key, or 0 1626 * 1627 * Returns: %TRUE to stop other handlers from being invoked for the 1628 * event. FALSE to propagate the event further. 1629 */ 1630 gulong addOnWritableChange(bool delegate(uint, Settings) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1631 { 1632 return Signals.connect(this, "writable-change-event", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1633 } 1634 1635 /** 1636 * The "writable-changed" signal is emitted when the writability of a 1637 * key has potentially changed. You should call 1638 * g_settings_is_writable() in order to determine the new status. 1639 * 1640 * This signal supports detailed connections. You can connect to the 1641 * detailed signal "writable-changed::x" in order to only receive 1642 * callbacks when the writability of "x" changes. 1643 * 1644 * Params: 1645 * key = the key 1646 */ 1647 gulong addOnWritableChanged(void delegate(string, Settings) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1648 { 1649 return Signals.connect(this, "writable-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1650 } 1651 }