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