source: appstream-generator/build/girepo/gio/Settings.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 53.9 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module gio.Settings;
22
23private import gi.gio;
24public  import gi.giotypes;
25private import gio.Action;
26private import gio.ActionIF;
27private import gio.SettingsSchema;
28private import glib.ConstructionException;
29private import glib.Str;
30private import glib.Variant;
31private import gobject.ObjectG;
32private import gobject.Signals;
33private import std.algorithm;
34
35
36/**
37 * The #GSettings class provides a convenient API for storing and retrieving
38 * application settings.
39 *
40 * Reads and writes can be considered to be non-blocking.  Reading
41 * settings with #GSettings is typically extremely fast: on
42 * approximately the same order of magnitude (but slower than) a
43 * #GHashTable lookup.  Writing settings is also extremely fast in terms
44 * of time to return to your application, but can be extremely expensive
45 * for other threads and other processes.  Many settings backends
46 * (including dconf) have lazy initialisation which means in the common
47 * case of the user using their computer without modifying any settings
48 * a lot of work can be avoided.  For dconf, the D-Bus service doesn't
49 * even need to be started in this case.  For this reason, you should
50 * only ever modify #GSettings keys in response to explicit user action.
51 * Particular care should be paid to ensure that modifications are not
52 * made during startup -- for example, when setting the initial value
53 * of preferences widgets.  The built-in g_settings_bind() functionality
54 * is careful not to write settings in response to notify signals as a
55 * result of modifications that it makes to widgets.
56 *
57 * When creating a GSettings instance, you have to specify a schema
58 * that describes the keys in your settings and their types and default
59 * values, as well as some other information.
60 *
61 * Normally, a schema has as fixed path that determines where the settings
62 * are stored in the conceptual global tree of settings. However, schemas
63 * can also be '[relocatable][gsettings-relocatable]', i.e. not equipped with
64 * a fixed path. This is
65 * useful e.g. when the schema describes an 'account', and you want to be
66 * able to store a arbitrary number of accounts.
67 *
68 * Paths must start with and end with a forward slash character ('/')
69 * and must not contain two sequential slash characters.  Paths should
70 * be chosen based on a domain name associated with the program or
71 * library to which the settings belong.  Examples of paths are
72 * "/org/gtk/settings/file-chooser/" and "/ca/desrt/dconf-editor/".
73 * Paths should not start with "/apps/", "/desktop/" or "/system/" as
74 * they often did in GConf.
75 *
76 * Unlike other configuration systems (like GConf), GSettings does not
77 * restrict keys to basic types like strings and numbers. GSettings stores
78 * values as #GVariant, and allows any #GVariantType for keys. Key names
79 * are restricted to lowercase characters, numbers and '-'. Furthermore,
80 * the names must begin with a lowercase character, must not end
81 * with a '-', and must not contain consecutive dashes.
82 *
83 * Similar to GConf, the default values in GSettings schemas can be
84 * localized, but the localized values are stored in gettext catalogs
85 * and looked up with the domain that is specified in the
86 * `gettext-domain` attribute of the <schemalist> or <schema>
87 * elements and the category that is specified in the `l10n` attribute of
88 * the <default> element. The string which is translated includes all text in
89 * the <default> element, including any surrounding quotation marks.
90 *
91 * The `l10n` attribute must be set to `messages` or `time`, and sets the
92 * [locale category for
93 * translation](https://www.gnu.org/software/gettext/manual/html_node/Aspects.html#index-locale-categories-1).
94 * The `messages` category should be used by default; use `time` for
95 * translatable date or time formats. A translation comment can be added as an
96 * XML comment immediately above the <default> element — it is recommended to
97 * add these comments to aid translators understand the meaning and
98 * implications of the default value. An optional translation `context`
99 * attribute can be set on the <default> element to disambiguate multiple
100 * defaults which use the same string.
101 *
102 * For example:
103 * |[
104 * <!-- Translators: A list of words which are not allowed to be typed, in
105 * GVariant serialization syntax.
106 * See: https://developer.gnome.org/glib/stable/gvariant-text.html -->
107 * <default l10n='messages' context='Banned words'>['bad', 'words']</default>
108 * ]|
109 *
110 * Translations of default values must remain syntactically valid serialized
111 * #GVariants (e.g. retaining any surrounding quotation marks) or runtime
112 * errors will occur.
113 *
114 * GSettings uses schemas in a compact binary form that is created
115 * by the [glib-compile-schemas][glib-compile-schemas]
116 * utility. The input is a schema description in an XML format.
117 *
118 * A DTD for the gschema XML format can be found here:
119 * [gschema.dtd](https://git.gnome.org/browse/glib/tree/gio/gschema.dtd)
120 *
121 * The [glib-compile-schemas][glib-compile-schemas] tool expects schema
122 * files to have the extension `.gschema.xml`.
123 *
124 * At runtime, schemas are identified by their id (as specified in the
125 * id attribute of the <schema> element). The convention for schema
126 * ids is to use a dotted name, similar in style to a D-Bus bus name,
127 * e.g. "org.gnome.SessionManager". In particular, if the settings are
128 * for a specific service that owns a D-Bus bus name, the D-Bus bus name
129 * and schema id should match. For schemas which deal with settings not
130 * associated with one named application, the id should not use
131 * StudlyCaps, e.g. "org.gnome.font-rendering".
132 *
133 * In addition to #GVariant types, keys can have types that have
134 * enumerated types. These can be described by a <choice>,
135 * <enum> or <flags> element, as seen in the
136 * [example][schema-enumerated]. The underlying type of such a key
137 * is string, but you can use g_settings_get_enum(), g_settings_set_enum(),
138 * g_settings_get_flags(), g_settings_set_flags() access the numeric values
139 * corresponding to the string value of enum and flags keys.
140 *
141 * An example for default value:
142 * |[
143 * <schemalist>
144 * <schema id="org.gtk.Test" path="/org/gtk/Test/" gettext-domain="test">
145 *
146 * <key name="greeting" type="s">
147 * <default l10n="messages">"Hello, earthlings"</default>
148 * <summary>A greeting</summary>
149 * <description>
150 * Greeting of the invading martians
151 * </description>
152 * </key>
153 *
154 * <key name="box" type="(ii)">
155 * <default>(20,30)</default>
156 * </key>
157 *
158 * </schema>
159 * </schemalist>
160 * ]|
161 *
162 * An example for ranges, choices and enumerated types:
163 * |[
164 * <schemalist>
165 *
166 * <enum id="org.gtk.Test.myenum">
167 * <value nick="first" value="1"/>
168 * <value nick="second" value="2"/>
169 * </enum>
170 *
171 * <flags id="org.gtk.Test.myflags">
172 * <value nick="flag1" value="1"/>
173 * <value nick="flag2" value="2"/>
174 * <value nick="flag3" value="4"/>
175 * </flags>
176 *
177 * <schema id="org.gtk.Test">
178 *
179 * <key name="key-with-range" type="i">
180 * <range min="1" max="100"/>
181 * <default>10</default>
182 * </key>
183 *
184 * <key name="key-with-choices" type="s">
185 * <choices>
186 * <choice value='Elisabeth'/>
187 * <choice value='Annabeth'/>
188 * <choice value='Joe'/>
189 * </choices>
190 * <aliases>
191 * <alias value='Anna' target='Annabeth'/>
192 * <alias value='Beth' target='Elisabeth'/>
193 * </aliases>
194 * <default>'Joe'</default>
195 * </key>
196 *
197 * <key name='enumerated-key' enum='org.gtk.Test.myenum'>
198 * <default>'first'</default>
199 * </key>
200 *
201 * <key name='flags-key' flags='org.gtk.Test.myflags'>
202 * <default>["flag1","flag2"]</default>
203 * </key>
204 * </schema>
205 * </schemalist>
206 * ]|
207 *
208 * ## Vendor overrides
209 *
210 * Default values are defined in the schemas that get installed by
211 * an application. Sometimes, it is necessary for a vendor or distributor
212 * to adjust these defaults. Since patching the XML source for the schema
213 * is inconvenient and error-prone,
214 * [glib-compile-schemas][glib-compile-schemas] reads so-called vendor
215 * override' files. These are keyfiles in the same directory as the XML
216 * schema sources which can override default values. The schema id serves
217 * as the group name in the key file, and the values are expected in
218 * serialized GVariant form, as in the following example:
219 * |[
220 * [org.gtk.Example]
221 * key1='string'
222 * key2=1.5
223 * ]|
224 *
225 * glib-compile-schemas expects schema files to have the extension
226 * `.gschema.override`.
227 *
228 * ## Binding
229 *
230 * A very convenient feature of GSettings lets you bind #GObject properties
231 * directly to settings, using g_settings_bind(). Once a GObject property
232 * has been bound to a setting, changes on either side are automatically
233 * propagated to the other side. GSettings handles details like mapping
234 * between GObject and GVariant types, and preventing infinite cycles.
235 *
236 * This makes it very easy to hook up a preferences dialog to the
237 * underlying settings. To make this even more convenient, GSettings
238 * looks for a boolean property with the name "sensitivity" and
239 * automatically binds it to the writability of the bound setting.
240 * If this 'magic' gets in the way, it can be suppressed with the
241 * #G_SETTINGS_BIND_NO_SENSITIVITY flag.
242 *
243 * ## Relocatable schemas # {#gsettings-relocatable}
244 *
245 * A relocatable schema is one with no `path` attribute specified on its
246 * <schema> element. By using g_settings_new_with_path(), a #GSettings object
247 * can be instantiated for a relocatable schema, assigning a path to the
248 * instance. Paths passed to g_settings_new_with_path() will typically be
249 * constructed dynamically from a constant prefix plus some form of instance
250 * identifier; but they must still be valid GSettings paths. Paths could also
251 * be constant and used with a globally installed schema originating from a
252 * dependency library.
253 *
254 * For example, a relocatable schema could be used to store geometry information
255 * for different windows in an application. If the schema ID was
256 * `org.foo.MyApp.Window`, it could be instantiated for paths
257 * `/org/foo/MyApp/main/`, `/org/foo/MyApp/document-1/`,
258 * `/org/foo/MyApp/document-2/`, etc. If any of the paths are well-known
259 * they can be specified as <child> elements in the parent schema, e.g.:
260 * |[
261 * <schema id="org.foo.MyApp" path="/org/foo/MyApp/">
262 * <child name="main" schema="org.foo.MyApp.Window"/>
263 * </schema>
264 * ]|
265 *
266 * ## Build system integration # {#gsettings-build-system}
267 *
268 * GSettings comes with autotools integration to simplify compiling and
269 * installing schemas. To add GSettings support to an application, add the
270 * following to your `configure.ac`:
271 * |[
272 * GLIB_GSETTINGS
273 * ]|
274 *
275 * In the appropriate `Makefile.am`, use the following snippet to compile and
276 * install the named schema:
277 * |[
278 * gsettings_SCHEMAS = org.foo.MyApp.gschema.xml
279 * EXTRA_DIST = $(gsettings_SCHEMAS)
280 *
281 * @GSETTINGS_RULES@
282 * ]|
283 *
284 * No changes are needed to the build system to mark a schema XML file for
285 * translation. Assuming it sets the `gettext-domain` attribute, a schema may
286 * be marked for translation by adding it to `POTFILES.in`, assuming gettext
287 * 0.19 is in use (the preferred method for translation):
288 * |[
289 * data/org.foo.MyApp.gschema.xml
290 * ]|
291 *
292 * Alternatively, if intltool 0.50.1 is in use:
293 * |[
294 * [type: gettext/gsettings]data/org.foo.MyApp.gschema.xml
295 * ]|
296 *
297 * GSettings will use gettext to look up translations for the <summary> and
298 * <description> elements, and also any <default> elements which have a `l10n`
299 * attribute set. Translations must not be included in the `.gschema.xml` file
300 * by the build system, for example by using intltool XML rules with a
301 * `.gschema.xml.in` template.
302 *
303 * If an enumerated type defined in a C header file is to be used in a GSettings
304 * schema, it can either be defined manually using an <enum> element in the
305 * schema XML, or it can be extracted automatically from the C header. This
306 * approach is preferred, as it ensures the two representations are always
307 * synchronised. To do so, add the following to the relevant `Makefile.am`:
308 * |[
309 * gsettings_ENUM_NAMESPACE = org.foo.MyApp
310 * gsettings_ENUM_FILES = my-app-enums.h my-app-misc.h
311 * ]|
312 *
313 * `gsettings_ENUM_NAMESPACE` specifies the schema namespace for the enum files,
314 * which are specified in `gsettings_ENUM_FILES`. This will generate a
315 * `org.foo.MyApp.enums.xml` file containing the extracted enums, which will be
316 * automatically included in the schema compilation, install and uninstall
317 * rules. It should not be committed to version control or included in
318 * `EXTRA_DIST`.
319 */
320public class Settings : ObjectG
321{
322        /** the main Gtk struct */
323        protected GSettings* gSettings;
324
325        /** Get the main Gtk struct */
326        public GSettings* getSettingsStruct()
327        {
328                return gSettings;
329        }
330
331        /** the main Gtk struct as a void* */
332        protected override void* getStruct()
333        {
334                return cast(void*)gSettings;
335        }
336
337        protected override void setStruct(GObject* obj)
338        {
339                gSettings = cast(GSettings*)obj;
340                super.setStruct(obj);
341        }
342
343        /**
344         * Sets our main struct and passes it to the parent class.
345         */
346        public this (GSettings* gSettings, bool ownedRef = false)
347        {
348                this.gSettings = gSettings;
349                super(cast(GObject*)gSettings, ownedRef);
350        }
351
352
353        /** */
354        public static GType getType()
355        {
356                return g_settings_get_type();
357        }
358
359        /**
360         * Creates a new #GSettings object with the schema specified by
361         * @schema_id.
362         *
363         * Signals on the newly created #GSettings object will be dispatched
364         * via the thread-default #GMainContext in effect at the time of the
365         * call to g_settings_new().  The new #GSettings will hold a reference
366         * on the context.  See g_main_context_push_thread_default().
367         *
368         * Params:
369         *     schemaId = the id of the schema
370         *
371         * Returns: a new #GSettings object
372         *
373         * Since: 2.26
374         *
375         * Throws: ConstructionException GTK+ fails to create the object.
376         */
377        public this(string schemaId)
378        {
379                auto p = g_settings_new(Str.toStringz(schemaId));
380               
381                if(p is null)
382                {
383                        throw new ConstructionException("null returned by new");
384                }
385               
386                this(cast(GSettings*) p, true);
387        }
388
389        /**
390         * Creates a new #GSettings object with a given schema, backend and
391         * path.
392         *
393         * It should be extremely rare that you ever want to use this function.
394         * It is made available for advanced use-cases (such as plugin systems
395         * that want to provide access to schemas loaded from custom locations,
396         * etc).
397         *
398         * At the most basic level, a #GSettings object is a pure composition of
399         * 4 things: a #GSettingsSchema, a #GSettingsBackend, a path within that
400         * backend, and a #GMainContext to which signals are dispatched.
401         *
402         * This constructor therefore gives you full control over constructing
403         * #GSettings instances.  The first 3 parameters are given directly as
404         * @schema, @backend and @path, and the main context is taken from the
405         * thread-default (as per g_settings_new()).
406         *
407         * If @backend is %NULL then the default backend is used.
408         *
409         * If @path is %NULL then the path from the schema is used.  It is an
410         * error if @path is %NULL and the schema has no path of its own or if
411         * @path is non-%NULL and not equal to the path that the schema does
412         * have.
413         *
414         * Params:
415         *     schema = a #GSettingsSchema
416         *     backend = a #GSettingsBackend
417         *     path = the path to use
418         *
419         * Returns: a new #GSettings object
420         *
421         * Since: 2.32
422         *
423         * Throws: ConstructionException GTK+ fails to create the object.
424         */
425        public this(SettingsSchema schema, GSettingsBackend* backend, string path)
426        {
427                auto p = g_settings_new_full((schema is null) ? null : schema.getSettingsSchemaStruct(), backend, Str.toStringz(path));
428               
429                if(p is null)
430                {
431                        throw new ConstructionException("null returned by new_full");
432                }
433               
434                this(cast(GSettings*) p, true);
435        }
436
437        /**
438         * Creates a new #GSettings object with the schema specified by
439         * @schema_id and a given #GSettingsBackend.
440         *
441         * Creating a #GSettings object with a different backend allows accessing
442         * settings from a database other than the usual one. For example, it may make
443         * sense to pass a backend corresponding to the "defaults" settings database on
444         * the system to get a settings object that modifies the system default
445         * settings instead of the settings for this user.
446         *
447         * Params:
448         *     schemaId = the id of the schema
449         *     backend = the #GSettingsBackend to use
450         *
451         * Returns: a new #GSettings object
452         *
453         * Since: 2.26
454         *
455         * Throws: ConstructionException GTK+ fails to create the object.
456         */
457        public this(string schemaId, GSettingsBackend* backend)
458        {
459                auto p = g_settings_new_with_backend(Str.toStringz(schemaId), backend);
460               
461                if(p is null)
462                {
463                        throw new ConstructionException("null returned by new_with_backend");
464                }
465               
466                this(cast(GSettings*) p, true);
467        }
468
469        /**
470         * Creates a new #GSettings object with the schema specified by
471         * @schema_id and a given #GSettingsBackend and path.
472         *
473         * This is a mix of g_settings_new_with_backend() and
474         * g_settings_new_with_path().
475         *
476         * Params:
477         *     schemaId = the id of the schema
478         *     backend = the #GSettingsBackend to use
479         *     path = the path to use
480         *
481         * Returns: a new #GSettings object
482         *
483         * Since: 2.26
484         *
485         * Throws: ConstructionException GTK+ fails to create the object.
486         */
487        public this(string schemaId, GSettingsBackend* backend, string path)
488        {
489                auto p = g_settings_new_with_backend_and_path(Str.toStringz(schemaId), backend, Str.toStringz(path));
490               
491                if(p is null)
492                {
493                        throw new ConstructionException("null returned by new_with_backend_and_path");
494                }
495               
496                this(cast(GSettings*) p, true);
497        }
498
499        /**
500         * Creates a new #GSettings object with the relocatable schema specified
501         * by @schema_id and a given path.
502         *
503         * You only need to do this if you want to directly create a settings
504         * object with a schema that doesn't have a specified path of its own.
505         * That's quite rare.
506         *
507         * It is a programmer error to call this function for a schema that
508         * has an explicitly specified path.
509         *
510         * It is a programmer error if @path is not a valid path.  A valid path
511         * begins and ends with '/' and does not contain two consecutive '/'
512         * characters.
513         *
514         * Params:
515         *     schemaId = the id of the schema
516         *     path = the path to use
517         *
518         * Returns: a new #GSettings object
519         *
520         * Since: 2.26
521         *
522         * Throws: ConstructionException GTK+ fails to create the object.
523         */
524        public this(string schemaId, string path)
525        {
526                auto p = g_settings_new_with_path(Str.toStringz(schemaId), Str.toStringz(path));
527               
528                if(p is null)
529                {
530                        throw new ConstructionException("null returned by new_with_path");
531                }
532               
533                this(cast(GSettings*) p, true);
534        }
535
536        /**
537         * <!-- -->
538         *
539         * Deprecated: Use g_settings_schema_source_list_schemas() instead
540         *
541         * Returns: a list of relocatable
542         *     #GSettings schemas that are available.  The list must not be
543         *     modified or freed.
544         *
545         * Since: 2.28
546         */
547        public static string[] listRelocatableSchemas()
548        {
549                return Str.toStringArray(g_settings_list_relocatable_schemas());
550        }
551
552        /**
553         * <!-- -->
554         *
555         * Deprecated: Use g_settings_schema_source_list_schemas() instead.
556         * If you used g_settings_list_schemas() to check for the presence of
557         * a particular schema, use g_settings_schema_source_lookup() instead
558         * of your whole loop.
559         *
560         * Returns: a list of #GSettings
561         *     schemas that are available.  The list must not be modified or
562         *     freed.
563         *
564         * Since: 2.26
565         */
566        public static string[] listSchemas()
567        {
568                return Str.toStringArray(g_settings_list_schemas());
569        }
570
571        /**
572         * Ensures that all pending operations for the given are complete for
573         * 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 the 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 the 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 the 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!(Action, 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, subject to
959         * application-level validation/mapping.
960         *
961         * You should use this function when the application needs to perform
962         * some processing on the value of the key (for example, parsing).  The
963         * @mapping function performs that processing.  If the function
964         * indicates that the processing was unsuccessful (due to a parse error,
965         * for example) then the mapping is tried again with another value.
966         *
967         * This allows a robust 'fall back to defaults' behaviour to be
968         * implemented somewhat automatically.
969         *
970         * The first value that is tried is the user's setting for the key.  If
971         * the mapping function fails to map this value, other values may be
972         * tried in an unspecified order (system or site defaults, translated
973         * schema default values, untranslated schema default values, etc).
974         *
975         * If the mapping function fails for all possible values, one additional
976         * attempt is made: the mapping function is called with a %NULL value.
977         * If the mapping function still indicates failure at this point then
978         * the application will be aborted.
979         *
980         * The result parameter for the @mapping function is pointed to a
981         * #gpointer which is initially set to %NULL.  The same pointer is given
982         * to each invocation of @mapping.  The final value of that #gpointer is
983         * what is returned by this function.  %NULL is valid; it is returned
984         * just as any other value would be.
985         *
986         * Params:
987         *     key = the key to get the value for
988         *     mapping = the function to map the value in the
989         *         settings database to the value used by the application
990         *     userData = user data for @mapping
991         *
992         * Returns: the result, which may be %NULL
993         */
994        public void* getMapped(string key, GSettingsGetMapping mapping, void* userData)
995        {
996                return g_settings_get_mapped(gSettings, Str.toStringz(key), mapping, userData);
997        }
998
999        /**
1000         * Queries the range of a key.
1001         *
1002         * Deprecated: Use g_settings_schema_key_get_range() instead.
1003         *
1004         * Params:
1005         *     key = the key to query the range of
1006         *
1007         * Since: 2.28
1008         */
1009        public Variant getRange(string key)
1010        {
1011                auto p = g_settings_get_range(gSettings, Str.toStringz(key));
1012               
1013                if(p is null)
1014                {
1015                        return null;
1016                }
1017               
1018                return new Variant(cast(GVariant*) p, true);
1019        }
1020
1021        /**
1022         * Gets the value that is stored at @key in @settings.
1023         *
1024         * A convenience variant of g_settings_get() for strings.
1025         *
1026         * It is a programmer error to give a @key that isn't specified as
1027         * having a string type in the schema for @settings.
1028         *
1029         * Params:
1030         *     key = the key to get the value for
1031         *
1032         * Returns: a newly-allocated string
1033         *
1034         * Since: 2.26
1035         */
1036        public string getString(string key)
1037        {
1038                auto retStr = g_settings_get_string(gSettings, Str.toStringz(key));
1039               
1040                scope(exit) Str.freeString(retStr);
1041                return Str.toString(retStr);
1042        }
1043
1044        /**
1045         * A convenience variant of g_settings_get() for string arrays.
1046         *
1047         * It is a programmer error to give a @key that isn't specified as
1048         * having an array of strings type in the schema for @settings.
1049         *
1050         * Params:
1051         *     key = the key to get the value for
1052         *
1053         * Returns: a
1054         *     newly-allocated, %NULL-terminated array of strings, the value that
1055         *     is stored at @key in @settings.
1056         *
1057         * Since: 2.26
1058         */
1059        public string[] getStrv(string key)
1060        {
1061                auto retStr = g_settings_get_strv(gSettings, Str.toStringz(key));
1062               
1063                scope(exit) Str.freeStringArray(retStr);
1064                return Str.toStringArray(retStr);
1065        }
1066
1067        /**
1068         * Gets the value that is stored at @key in @settings.
1069         *
1070         * A convenience variant of g_settings_get() for 32-bit unsigned
1071         * integers.
1072         *
1073         * It is a programmer error to give a @key that isn't specified as
1074         * having a uint32 type in the schema for @settings.
1075         *
1076         * Params:
1077         *     key = the key to get the value for
1078         *
1079         * Returns: an unsigned integer
1080         *
1081         * Since: 2.30
1082         */
1083        public uint getUint(string key)
1084        {
1085                return g_settings_get_uint(gSettings, Str.toStringz(key));
1086        }
1087
1088        /**
1089         * Checks the "user value" of a key, if there is one.
1090         *
1091         * The user value of a key is the last value that was set by the user.
1092         *
1093         * After calling g_settings_reset() this function should always return
1094         * %NULL (assuming something is not wrong with the system
1095         * configuration).
1096         *
1097         * It is possible that g_settings_get_value() will return a different
1098         * value than this function.  This can happen in the case that the user
1099         * set a value for a key that was subsequently locked down by the system
1100         * administrator -- this function will return the user's old value.
1101         *
1102         * This function may be useful for adding a "reset" option to a UI or
1103         * for providing indication that a particular value has been changed.
1104         *
1105         * It is a programmer error to give a @key that isn't contained in the
1106         * schema for @settings.
1107         *
1108         * Params:
1109         *     key = the key to get the user value for
1110         *
1111         * Returns: the user's value, if set
1112         *
1113         * Since: 2.40
1114         */
1115        public Variant getUserValue(string key)
1116        {
1117                auto p = g_settings_get_user_value(gSettings, Str.toStringz(key));
1118               
1119                if(p is null)
1120                {
1121                        return null;
1122                }
1123               
1124                return new Variant(cast(GVariant*) p, true);
1125        }
1126
1127        /**
1128         * Gets the value that is stored in @settings for @key.
1129         *
1130         * It is a programmer error to give a @key that isn't contained in the
1131         * schema for @settings.
1132         *
1133         * Params:
1134         *     key = the key to get the value for
1135         *
1136         * Returns: a new #GVariant
1137         *
1138         * Since: 2.26
1139         */
1140        public Variant getValue(string key)
1141        {
1142                auto p = g_settings_get_value(gSettings, Str.toStringz(key));
1143               
1144                if(p is null)
1145                {
1146                        return null;
1147                }
1148               
1149                return new Variant(cast(GVariant*) p, true);
1150        }
1151
1152        /**
1153         * Finds out if a key can be written or not
1154         *
1155         * Params:
1156         *     name = the name of a key
1157         *
1158         * Returns: %TRUE if the key @name is writable
1159         *
1160         * Since: 2.26
1161         */
1162        public bool isWritable(string name)
1163        {
1164                return g_settings_is_writable(gSettings, Str.toStringz(name)) != 0;
1165        }
1166
1167        /**
1168         * Gets the list of children on @settings.
1169         *
1170         * The list is exactly the list of strings for which it is not an error
1171         * to call g_settings_get_child().
1172         *
1173         * For GSettings objects that are lists, this value can change at any
1174         * time and you should connect to the "children-changed" signal to watch
1175         * for those changes.  Note that there is a race condition here: you may
1176         * request a child after listing it only for it to have been destroyed
1177         * in the meantime.  For this reason, g_settings_get_child() may return
1178         * %NULL even for a child that was listed by this function.
1179         *
1180         * For GSettings objects that are not lists, you should probably not be
1181         * calling this function from "normal" code (since you should already
1182         * know what children are in your schema).  This function may still be
1183         * useful there for introspection reasons, however.
1184         *
1185         * You should free the return value with g_strfreev() when you are done
1186         * with it.
1187         *
1188         * Returns: a list of the children on @settings
1189         */
1190        public string[] listChildren()
1191        {
1192                auto retStr = g_settings_list_children(gSettings);
1193               
1194                scope(exit) Str.freeStringArray(retStr);
1195                return Str.toStringArray(retStr);
1196        }
1197
1198        /**
1199         * Introspects the list of keys on @settings.
1200         *
1201         * You should probably not be calling this function from "normal" code
1202         * (since you should already know what keys are in your schema).  This
1203         * function is intended for introspection reasons.
1204         *
1205         * You should free the return value with g_strfreev() when you are done
1206         * with it.
1207         *
1208         * Returns: a list of the keys on @settings
1209         */
1210        public string[] listKeys()
1211        {
1212                auto retStr = g_settings_list_keys(gSettings);
1213               
1214                scope(exit) Str.freeStringArray(retStr);
1215                return Str.toStringArray(retStr);
1216        }
1217
1218        /**
1219         * Checks if the given @value is of the correct type and within the
1220         * permitted range for @key.
1221         *
1222         * Deprecated: Use g_settings_schema_key_range_check() instead.
1223         *
1224         * Params:
1225         *     key = the key to check
1226         *     value = the value to check
1227         *
1228         * Returns: %TRUE if @value is valid for @key
1229         *
1230         * Since: 2.28
1231         */
1232        public bool rangeCheck(string key, Variant value)
1233        {
1234                return g_settings_range_check(gSettings, Str.toStringz(key), (value is null) ? null : value.getVariantStruct()) != 0;
1235        }
1236
1237        /**
1238         * Resets @key to its default value.
1239         *
1240         * This call resets the key, as much as possible, to its default value.
1241         * That might the value specified in the schema or the one set by the
1242         * administrator.
1243         *
1244         * Params:
1245         *     key = the name of a key
1246         */
1247        public void reset(string key)
1248        {
1249                g_settings_reset(gSettings, Str.toStringz(key));
1250        }
1251
1252        /**
1253         * Reverts all non-applied changes to the settings.  This function
1254         * does nothing unless @settings is in 'delay-apply' mode; see
1255         * g_settings_delay().  In the normal case settings are always applied
1256         * immediately.
1257         *
1258         * Change notifications will be emitted for affected keys.
1259         */
1260        public void revert()
1261        {
1262                g_settings_revert(gSettings);
1263        }
1264
1265        /**
1266         * Sets @key in @settings to @value.
1267         *
1268         * A convenience variant of g_settings_set() for booleans.
1269         *
1270         * It is a programmer error to give a @key that isn't specified as
1271         * having a boolean type in the schema for @settings.
1272         *
1273         * Params:
1274         *     key = the name of the key to set
1275         *     value = the value to set it to
1276         *
1277         * Returns: %TRUE if setting the key succeeded,
1278         *     %FALSE if the key was not writable
1279         *
1280         * Since: 2.26
1281         */
1282        public bool setBoolean(string key, bool value)
1283        {
1284                return g_settings_set_boolean(gSettings, Str.toStringz(key), value) != 0;
1285        }
1286
1287        /**
1288         * Sets @key in @settings to @value.
1289         *
1290         * A convenience variant of g_settings_set() for doubles.
1291         *
1292         * It is a programmer error to give a @key that isn't specified as
1293         * having a 'double' type in the schema for @settings.
1294         *
1295         * Params:
1296         *     key = the name of the key to set
1297         *     value = the value to set it to
1298         *
1299         * Returns: %TRUE if setting the key succeeded,
1300         *     %FALSE if the key was not writable
1301         *
1302         * Since: 2.26
1303         */
1304        public bool setDouble(string key, double value)
1305        {
1306                return g_settings_set_double(gSettings, Str.toStringz(key), value) != 0;
1307        }
1308
1309        /**
1310         * Looks up the enumerated type nick for @value and writes it to @key,
1311         * within @settings.
1312         *
1313         * It is a programmer error to give a @key that isn't contained in the
1314         * schema for @settings or is not marked as an enumerated type, or for
1315         * @value not to be a valid value for the named type.
1316         *
1317         * After performing the write, accessing @key directly with
1318         * g_settings_get_string() will return the 'nick' associated with
1319         * @value.
1320         *
1321         * Params:
1322         *     key = a key, within @settings
1323         *     value = an enumerated value
1324         *
1325         * Returns: %TRUE, if the set succeeds
1326         */
1327        public bool setEnum(string key, int value)
1328        {
1329                return g_settings_set_enum(gSettings, Str.toStringz(key), value) != 0;
1330        }
1331
1332        /**
1333         * Looks up the flags type nicks for the bits specified by @value, puts
1334         * them in an array of strings and writes the array to @key, within
1335         * @settings.
1336         *
1337         * It is a programmer error to give a @key that isn't contained in the
1338         * schema for @settings or is not marked as a flags type, or for @value
1339         * to contain any bits that are not value for the named type.
1340         *
1341         * After performing the write, accessing @key directly with
1342         * g_settings_get_strv() will return an array of 'nicks'; one for each
1343         * bit in @value.
1344         *
1345         * Params:
1346         *     key = a key, within @settings
1347         *     value = a flags value
1348         *
1349         * Returns: %TRUE, if the set succeeds
1350         */
1351        public bool setFlags(string key, uint value)
1352        {
1353                return g_settings_set_flags(gSettings, Str.toStringz(key), value) != 0;
1354        }
1355
1356        /**
1357         * Sets @key in @settings to @value.
1358         *
1359         * A convenience variant of g_settings_set() for 32-bit integers.
1360         *
1361         * It is a programmer error to give a @key that isn't specified as
1362         * having a int32 type in the schema for @settings.
1363         *
1364         * Params:
1365         *     key = the name of the key to set
1366         *     value = the value to set it to
1367         *
1368         * Returns: %TRUE if setting the key succeeded,
1369         *     %FALSE if the key was not writable
1370         *
1371         * Since: 2.26
1372         */
1373        public bool setInt(string key, int value)
1374        {
1375                return g_settings_set_int(gSettings, Str.toStringz(key), value) != 0;
1376        }
1377
1378        /**
1379         * Sets @key in @settings to @value.
1380         *
1381         * A convenience variant of g_settings_set() for strings.
1382         *
1383         * It is a programmer error to give a @key that isn't specified as
1384         * having a string type in the schema for @settings.
1385         *
1386         * Params:
1387         *     key = the name of the key to set
1388         *     value = the value to set it to
1389         *
1390         * Returns: %TRUE if setting the key succeeded,
1391         *     %FALSE if the key was not writable
1392         *
1393         * Since: 2.26
1394         */
1395        public bool setString(string key, string value)
1396        {
1397                return g_settings_set_string(gSettings, Str.toStringz(key), Str.toStringz(value)) != 0;
1398        }
1399
1400        /**
1401         * Sets @key in @settings to @value.
1402         *
1403         * A convenience variant of g_settings_set() for string arrays.  If
1404         * @value is %NULL, then @key is set to be the empty array.
1405         *
1406         * It is a programmer error to give a @key that isn't specified as
1407         * having an array of strings type in the schema for @settings.
1408         *
1409         * Params:
1410         *     key = the name of the key to set
1411         *     value = the value to set it to, or %NULL
1412         *
1413         * Returns: %TRUE if setting the key succeeded,
1414         *     %FALSE if the key was not writable
1415         *
1416         * Since: 2.26
1417         */
1418        public bool setStrv(string key, string[] value)
1419        {
1420                return g_settings_set_strv(gSettings, Str.toStringz(key), Str.toStringzArray(value)) != 0;
1421        }
1422
1423        /**
1424         * Sets @key in @settings to @value.
1425         *
1426         * A convenience variant of g_settings_set() for 32-bit unsigned
1427         * integers.
1428         *
1429         * It is a programmer error to give a @key that isn't specified as
1430         * having a uint32 type in the schema for @settings.
1431         *
1432         * Params:
1433         *     key = the name of the key to set
1434         *     value = the value to set it to
1435         *
1436         * Returns: %TRUE if setting the key succeeded,
1437         *     %FALSE if the key was not writable
1438         *
1439         * Since: 2.30
1440         */
1441        public bool setUint(string key, uint value)
1442        {
1443                return g_settings_set_uint(gSettings, Str.toStringz(key), value) != 0;
1444        }
1445
1446        /**
1447         * Sets @key in @settings to @value.
1448         *
1449         * It is a programmer error to give a @key that isn't contained in the
1450         * schema for @settings or for @value to have the incorrect type, per
1451         * the schema.
1452         *
1453         * If @value is floating then this function consumes the reference.
1454         *
1455         * Params:
1456         *     key = the name of the key to set
1457         *     value = a #GVariant of the correct type
1458         *
1459         * Returns: %TRUE if setting the key succeeded,
1460         *     %FALSE if the key was not writable
1461         *
1462         * Since: 2.26
1463         */
1464        public bool setValue(string key, Variant value)
1465        {
1466                return g_settings_set_value(gSettings, Str.toStringz(key), (value is null) ? null : value.getVariantStruct()) != 0;
1467        }
1468
1469        protected class OnChangeDelegateWrapper
1470        {
1471                static OnChangeDelegateWrapper[] listeners;
1472                bool delegate(void*, int, Settings) dlg;
1473                gulong handlerId;
1474               
1475                this(bool delegate(void*, int, Settings) dlg)
1476                {
1477                        this.dlg = dlg;
1478                        this.listeners ~= this;
1479                }
1480               
1481                void remove(OnChangeDelegateWrapper source)
1482                {
1483                        foreach(index, wrapper; listeners)
1484                        {
1485                                if (wrapper.handlerId == source.handlerId)
1486                                {
1487                                        listeners[index] = null;
1488                                        listeners = std.algorithm.remove(listeners, index);
1489                                        break;
1490                                }
1491                        }
1492                }
1493        }
1494
1495        /**
1496         * The "change-event" signal is emitted once per change event that
1497         * affects this settings object.  You should connect to this signal
1498         * only if you are interested in viewing groups of changes before they
1499         * are split out into multiple emissions of the "changed" signal.
1500         * For most use cases it is more appropriate to use the "changed" signal.
1501         *
1502         * In the event that the change event applies to one or more specified
1503         * keys, @keys will be an array of #GQuark of length @n_keys.  In the
1504         * event that the change event applies to the #GSettings object as a
1505         * whole (ie: potentially every key has been changed) then @keys will
1506         * be %NULL and @n_keys will be 0.
1507         *
1508         * The default handler for this signal invokes the "changed" signal
1509         * for each affected key.  If any other connected handler returns
1510         * %TRUE then this default functionality will be suppressed.
1511         *
1512         * Params:
1513         *     keys = an array of #GQuarks for the changed keys, or %NULL
1514         *     nKeys = the length of the @keys array, or 0
1515         *
1516         * Returns: %TRUE to stop other handlers from being invoked for the
1517         *     event. FALSE to propagate the event further.
1518         */
1519        gulong addOnChange(bool delegate(void*, int, Settings) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1520        {
1521                auto wrapper = new OnChangeDelegateWrapper(dlg);
1522                wrapper.handlerId = Signals.connectData(
1523                        this,
1524                        "change-event",
1525                        cast(GCallback)&callBackChange,
1526                        cast(void*)wrapper,
1527                        cast(GClosureNotify)&callBackChangeDestroy,
1528                        connectFlags);
1529                return wrapper.handlerId;
1530        }
1531       
1532        extern(C) static int callBackChange(GSettings* settingsStruct, void* keys, int nKeys, OnChangeDelegateWrapper wrapper)
1533        {
1534                return wrapper.dlg(keys, nKeys, wrapper.outer);
1535        }
1536       
1537        extern(C) static void callBackChangeDestroy(OnChangeDelegateWrapper wrapper, GClosure* closure)
1538        {
1539                wrapper.remove(wrapper);
1540        }
1541
1542        protected class OnChangedDelegateWrapper
1543        {
1544                static OnChangedDelegateWrapper[] listeners;
1545                void delegate(string, Settings) dlg;
1546                gulong handlerId;
1547               
1548                this(void delegate(string, Settings) dlg)
1549                {
1550                        this.dlg = dlg;
1551                        this.listeners ~= this;
1552                }
1553               
1554                void remove(OnChangedDelegateWrapper source)
1555                {
1556                        foreach(index, wrapper; listeners)
1557                        {
1558                                if (wrapper.handlerId == source.handlerId)
1559                                {
1560                                        listeners[index] = null;
1561                                        listeners = std.algorithm.remove(listeners, index);
1562                                        break;
1563                                }
1564                        }
1565                }
1566        }
1567
1568        /**
1569         * The "changed" signal is emitted when a key has potentially changed.
1570         * You should call one of the g_settings_get() calls to check the new
1571         * value.
1572         *
1573         * This signal supports detailed connections.  You can connect to the
1574         * detailed signal "changed::x" in order to only receive callbacks
1575         * when key "x" changes.
1576         *
1577         * Params:
1578         *     key = the name of the key that changed
1579         */
1580        gulong addOnChanged(void delegate(string, Settings) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1581        {
1582                auto wrapper = new OnChangedDelegateWrapper(dlg);
1583                wrapper.handlerId = Signals.connectData(
1584                        this,
1585                        "changed",
1586                        cast(GCallback)&callBackChanged,
1587                        cast(void*)wrapper,
1588                        cast(GClosureNotify)&callBackChangedDestroy,
1589                        connectFlags);
1590                return wrapper.handlerId;
1591        }
1592       
1593        extern(C) static void callBackChanged(GSettings* settingsStruct, char* key, OnChangedDelegateWrapper wrapper)
1594        {
1595                wrapper.dlg(Str.toString(key), wrapper.outer);
1596        }
1597       
1598        extern(C) static void callBackChangedDestroy(OnChangedDelegateWrapper wrapper, GClosure* closure)
1599        {
1600                wrapper.remove(wrapper);
1601        }
1602
1603        protected class OnWritableChangeDelegateWrapper
1604        {
1605                static OnWritableChangeDelegateWrapper[] listeners;
1606                bool delegate(uint, Settings) dlg;
1607                gulong handlerId;
1608               
1609                this(bool delegate(uint, Settings) dlg)
1610                {
1611                        this.dlg = dlg;
1612                        this.listeners ~= this;
1613                }
1614               
1615                void remove(OnWritableChangeDelegateWrapper source)
1616                {
1617                        foreach(index, wrapper; listeners)
1618                        {
1619                                if (wrapper.handlerId == source.handlerId)
1620                                {
1621                                        listeners[index] = null;
1622                                        listeners = std.algorithm.remove(listeners, index);
1623                                        break;
1624                                }
1625                        }
1626                }
1627        }
1628
1629        /**
1630         * The "writable-change-event" signal is emitted once per writability
1631         * change event that affects this settings object.  You should connect
1632         * to this signal if you are interested in viewing groups of changes
1633         * before they are split out into multiple emissions of the
1634         * "writable-changed" signal.  For most use cases it is more
1635         * appropriate to use the "writable-changed" signal.
1636         *
1637         * In the event that the writability change applies only to a single
1638         * key, @key will be set to the #GQuark for that key.  In the event
1639         * that the writability change affects the entire settings object,
1640         * @key will be 0.
1641         *
1642         * The default handler for this signal invokes the "writable-changed"
1643         * and "changed" signals for each affected key.  This is done because
1644         * changes in writability might also imply changes in value (if for
1645         * example, a new mandatory setting is introduced).  If any other
1646         * connected handler returns %TRUE then this default functionality
1647         * will be suppressed.
1648         *
1649         * Params:
1650         *     key = the quark of the key, or 0
1651         *
1652         * Returns: %TRUE to stop other handlers from being invoked for the
1653         *     event. FALSE to propagate the event further.
1654         */
1655        gulong addOnWritableChange(bool delegate(uint, Settings) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1656        {
1657                auto wrapper = new OnWritableChangeDelegateWrapper(dlg);
1658                wrapper.handlerId = Signals.connectData(
1659                        this,
1660                        "writable-change-event",
1661                        cast(GCallback)&callBackWritableChange,
1662                        cast(void*)wrapper,
1663                        cast(GClosureNotify)&callBackWritableChangeDestroy,
1664                        connectFlags);
1665                return wrapper.handlerId;
1666        }
1667       
1668        extern(C) static int callBackWritableChange(GSettings* settingsStruct, uint key, OnWritableChangeDelegateWrapper wrapper)
1669        {
1670                return wrapper.dlg(key, wrapper.outer);
1671        }
1672       
1673        extern(C) static void callBackWritableChangeDestroy(OnWritableChangeDelegateWrapper wrapper, GClosure* closure)
1674        {
1675                wrapper.remove(wrapper);
1676        }
1677
1678        protected class OnWritableChangedDelegateWrapper
1679        {
1680                static OnWritableChangedDelegateWrapper[] listeners;
1681                void delegate(string, Settings) dlg;
1682                gulong handlerId;
1683               
1684                this(void delegate(string, Settings) dlg)
1685                {
1686                        this.dlg = dlg;
1687                        this.listeners ~= this;
1688                }
1689               
1690                void remove(OnWritableChangedDelegateWrapper source)
1691                {
1692                        foreach(index, wrapper; listeners)
1693                        {
1694                                if (wrapper.handlerId == source.handlerId)
1695                                {
1696                                        listeners[index] = null;
1697                                        listeners = std.algorithm.remove(listeners, index);
1698                                        break;
1699                                }
1700                        }
1701                }
1702        }
1703
1704        /**
1705         * The "writable-changed" signal is emitted when the writability of a
1706         * key has potentially changed.  You should call
1707         * g_settings_is_writable() in order to determine the new status.
1708         *
1709         * This signal supports detailed connections.  You can connect to the
1710         * detailed signal "writable-changed::x" in order to only receive
1711         * callbacks when the writability of "x" changes.
1712         *
1713         * Params:
1714         *     key = the key
1715         */
1716        gulong addOnWritableChanged(void delegate(string, Settings) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1717        {
1718                auto wrapper = new OnWritableChangedDelegateWrapper(dlg);
1719                wrapper.handlerId = Signals.connectData(
1720                        this,
1721                        "writable-changed",
1722                        cast(GCallback)&callBackWritableChanged,
1723                        cast(void*)wrapper,
1724                        cast(GClosureNotify)&callBackWritableChangedDestroy,
1725                        connectFlags);
1726                return wrapper.handlerId;
1727        }
1728       
1729        extern(C) static void callBackWritableChanged(GSettings* settingsStruct, char* key, OnWritableChangedDelegateWrapper wrapper)
1730        {
1731                wrapper.dlg(Str.toString(key), wrapper.outer);
1732        }
1733       
1734        extern(C) static void callBackWritableChangedDestroy(OnWritableChangedDelegateWrapper wrapper, GClosure* closure)
1735        {
1736                wrapper.remove(wrapper);
1737        }
1738}
Note: See TracBrowser for help on using the repository browser.