| 1 |
/* |
|---|
| 2 |
* This file is part of gtkD. |
|---|
| 3 |
* |
|---|
| 4 |
* gtkD is free software; you can redistribute it and/or modify |
|---|
| 5 |
* it under the terms of the GNU Lesser General Public License |
|---|
| 6 |
* as published by the Free Software Foundation; either version 3 |
|---|
| 7 |
* of the License, or (at your option) any later version, with |
|---|
| 8 |
* some exceptions, please read the COPYING file. |
|---|
| 9 |
* |
|---|
| 10 |
* gtkD is distributed in the hope that it will be useful, |
|---|
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 |
* GNU Lesser General Public License for more details. |
|---|
| 14 |
* |
|---|
| 15 |
* You should have received a copy of the GNU Lesser General Public License |
|---|
| 16 |
* along with gtkD; if not, write to the Free Software |
|---|
| 17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA |
|---|
| 18 |
*/ |
|---|
| 19 |
|
|---|
| 20 |
// generated automatically - do not change |
|---|
| 21 |
// find conversion definition on APILookup.txt |
|---|
| 22 |
// implement new conversion functionalities on the wrap.utils pakage |
|---|
| 23 |
|
|---|
| 24 |
/* |
|---|
| 25 |
* Conversion parameters: |
|---|
| 26 |
* inFile = GSettings.html |
|---|
| 27 |
* outPack = gio |
|---|
| 28 |
* outFile = Settings |
|---|
| 29 |
* strct = GSettings |
|---|
| 30 |
* realStrct= |
|---|
| 31 |
* ctorStrct= |
|---|
| 32 |
* clss = Settings |
|---|
| 33 |
* interf = |
|---|
| 34 |
* class Code: No |
|---|
| 35 |
* interface Code: No |
|---|
| 36 |
* template for: |
|---|
| 37 |
* extend = |
|---|
| 38 |
* implements: |
|---|
| 39 |
* prefixes: |
|---|
| 40 |
* - g_settings_ |
|---|
| 41 |
* omit structs: |
|---|
| 42 |
* omit prefixes: |
|---|
| 43 |
* omit code: |
|---|
| 44 |
* omit signals: |
|---|
| 45 |
* imports: |
|---|
| 46 |
* - glib.Str |
|---|
| 47 |
* - glib.Variant |
|---|
| 48 |
* - glib.VariantType |
|---|
| 49 |
* - gobject.Value |
|---|
| 50 |
* - gio.SettingsBackend |
|---|
| 51 |
* structWrap: |
|---|
| 52 |
* - GSettings* -> Settings |
|---|
| 53 |
* - GSettingsBackend* -> SettingsBackend |
|---|
| 54 |
* - GValue* -> Value |
|---|
| 55 |
* - GVariant* -> Variant |
|---|
| 56 |
* - GVariantType* -> VariantType |
|---|
| 57 |
* module aliases: |
|---|
| 58 |
* local aliases: |
|---|
| 59 |
* overrides: |
|---|
| 60 |
*/ |
|---|
| 61 |
|
|---|
| 62 |
module gio.Settings; |
|---|
| 63 |
|
|---|
| 64 |
public import gtkc.giotypes; |
|---|
| 65 |
|
|---|
| 66 |
private import gtkc.gio; |
|---|
| 67 |
private import glib.ConstructionException; |
|---|
| 68 |
|
|---|
| 69 |
private import gobject.Signals; |
|---|
| 70 |
public import gtkc.gdktypes; |
|---|
| 71 |
|
|---|
| 72 |
private import glib.Str; |
|---|
| 73 |
private import glib.Variant; |
|---|
| 74 |
private import glib.VariantType; |
|---|
| 75 |
private import gobject.Value; |
|---|
| 76 |
private import gio.SettingsBackend; |
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
private import gobject.ObjectG; |
|---|
| 81 |
|
|---|
| 82 |
/** |
|---|
| 83 |
* Description |
|---|
| 84 |
* The GSettings class provides a convenient API for storing and retrieving |
|---|
| 85 |
* application settings. |
|---|
| 86 |
* Reads and writes can be considered to be non-blocking. Reading |
|---|
| 87 |
* settings with GSettings is typically extremely fast: on |
|---|
| 88 |
* approximately the same order of magnitude (but slower than) a |
|---|
| 89 |
* GHashTable lookup. Writing settings is also extremely fast in terms |
|---|
| 90 |
* of time to return to your application, but can be extremely expensive |
|---|
| 91 |
* for other threads and other processes. Many settings backends |
|---|
| 92 |
* (including dconf) have lazy initialisation which means in the common |
|---|
| 93 |
* case of the user using their computer without modifying any settings |
|---|
| 94 |
* a lot of work can be avoided. For dconf, the D-Bus service doesn't |
|---|
| 95 |
* even need to be started in this case. For this reason, you should |
|---|
| 96 |
* only ever modify GSettings keys in response to explicit user action. |
|---|
| 97 |
* Particular care should be paid to ensure that modifications are not |
|---|
| 98 |
* made during startup -- for example, when settings the initial value |
|---|
| 99 |
* of preferences widgets. The built-in g_settings_bind() functionality |
|---|
| 100 |
* is careful not to write settings in response to notify signals as a |
|---|
| 101 |
* result of modifications that it makes to widgets. |
|---|
| 102 |
* When creating a GSettings instance, you have to specify a schema |
|---|
| 103 |
* that describes the keys in your settings and their types and default |
|---|
| 104 |
* values, as well as some other information. |
|---|
| 105 |
* Normally, a schema has as fixed path that determines where the settings |
|---|
| 106 |
* are stored in the conceptual global tree of settings. However, schemas |
|---|
| 107 |
* can also be 'relocatable', i.e. not equipped with a fixed path. This is |
|---|
| 108 |
* useful e.g. when the schema describes an 'account', and you want to be |
|---|
| 109 |
* able to store a arbitrary number of accounts. |
|---|
| 110 |
* Unlike other configuration systems (like GConf), GSettings does not |
|---|
| 111 |
* restrict keys to basic types like strings and numbers. GSettings stores |
|---|
| 112 |
* values as GVariant, and allows any GVariantType for keys. Key names |
|---|
| 113 |
* are restricted to lowercase characters, numbers and '-'. Furthermore, |
|---|
| 114 |
* the names must begin with a lowercase character, must not end |
|---|
| 115 |
* with a '-', and must not contain consecutive dashes. Key names can |
|---|
| 116 |
* be up to 32 characters long. |
|---|
| 117 |
* Similar to GConf, the default values in GSettings schemas can be |
|---|
| 118 |
* localized, but the localized values are stored in gettext catalogs |
|---|
| 119 |
* and looked up with the domain that is specified in the |
|---|
| 120 |
* gettext-domain attribute of the |
|---|
| 121 |
* <schemalist> or <schema> |
|---|
| 122 |
* elements and the category that is specified in the l10n attribute of the |
|---|
| 123 |
* <key> element. |
|---|
| 124 |
* GSettings uses schemas in a compact binary form that is created |
|---|
| 125 |
* by the glib-compile-schemas |
|---|
| 126 |
* utility. The input is a schema description in an XML format that can be |
|---|
| 127 |
* described by the following DTD: |
|---|
| 128 |
* $(DDOC_COMMENT example) |
|---|
| 129 |
* glib-compile-schemas expects schema files to have the extension .gschema.xml |
|---|
| 130 |
* At runtime, schemas are identified by their id (as specified |
|---|
| 131 |
* in the id attribute of the |
|---|
| 132 |
* <schema> element). The |
|---|
| 133 |
* convention for schema ids is to use a dotted name, similar in |
|---|
| 134 |
* style to a D-Bus bus name, e.g. "org.gnome.SessionManager". In particular, |
|---|
| 135 |
* if the settings are for a specific service that owns a D-Bus bus name, |
|---|
| 136 |
* the D-Bus bus name and schema id should match. For schemas which deal |
|---|
| 137 |
* with settings not associated with one named application, the id should |
|---|
| 138 |
* not use StudlyCaps, e.g. "org.gnome.font-rendering". |
|---|
| 139 |
* In addition to GVariant types, keys can have types that have enumerated |
|---|
| 140 |
* types. These can be described by a <choice>, |
|---|
| 141 |
* <enum> or <flags> element, see |
|---|
| 142 |
* Example 12, âRanges, choices and enumerated typesâ. The underlying type of |
|---|
| 143 |
* such a key is string, but you can use g_settings_get_enum(), |
|---|
| 144 |
* g_settings_set_enum(), g_settings_get_flags(), g_settings_set_flags() |
|---|
| 145 |
* access the numeric values corresponding to the string value of enum |
|---|
| 146 |
* and flags keys. |
|---|
| 147 |
* $(DDOC_COMMENT example) |
|---|
| 148 |
* $(DDOC_COMMENT example) |
|---|
| 149 |
* Vendor overrides |
|---|
| 150 |
* Default values are defined in the schemas that get installed by |
|---|
| 151 |
* an application. Sometimes, it is necessary for a vendor or distributor |
|---|
| 152 |
* to adjust these defaults. Since patching the XML source for the schema |
|---|
| 153 |
* is inconvenient and error-prone, |
|---|
| 154 |
* glib-compile-schemas reads |
|---|
| 155 |
* so-called 'vendor override' files. These are keyfiles in the same |
|---|
| 156 |
* directory as the XML schema sources which can override default values. |
|---|
| 157 |
* The schema id serves as the group name in the key file, and the values |
|---|
| 158 |
* are expected in serialized GVariant form, as in the following example: |
|---|
| 159 |
* $(DDOC_COMMENT example) |
|---|
| 160 |
* glib-compile-schemas expects schema files to have the extension |
|---|
| 161 |
* .gschema.override |
|---|
| 162 |
* Binding |
|---|
| 163 |
* A very convenient feature of GSettings lets you bind GObject properties |
|---|
| 164 |
* directly to settings, using g_settings_bind(). Once a GObject property |
|---|
| 165 |
* has been bound to a setting, changes on either side are automatically |
|---|
| 166 |
* propagated to the other side. GSettings handles details like |
|---|
| 167 |
* mapping between GObject and GVariant types, and preventing infinite |
|---|
| 168 |
* cycles. |
|---|
| 169 |
* This makes it very easy to hook up a preferences dialog to the |
|---|
| 170 |
* underlying settings. To make this even more convenient, GSettings |
|---|
| 171 |
* looks for a boolean property with the name "sensitivity" and |
|---|
| 172 |
* automatically binds it to the writability of the bound setting. |
|---|
| 173 |
* If this 'magic' gets in the way, it can be suppressed with the |
|---|
| 174 |
* G_SETTINGS_BIND_NO_SENSITIVITY flag. |
|---|
| 175 |
*/ |
|---|
| 176 |
public class Settings : ObjectG |
|---|
| 177 |
{ |
|---|
| 178 |
|
|---|
| 179 |
/** the main Gtk struct */ |
|---|
| 180 |
protected GSettings* gSettings; |
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 |
public GSettings* getSettingsStruct() |
|---|
| 184 |
{ |
|---|
| 185 |
return gSettings; |
|---|
| 186 |
} |
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 |
/** the main Gtk struct as a void* */ |
|---|
| 190 |
protected override void* getStruct() |
|---|
| 191 |
{ |
|---|
| 192 |
return cast(void*)gSettings; |
|---|
| 193 |
} |
|---|
| 194 |
|
|---|
| 195 |
/** |
|---|
| 196 |
* Sets our main struct and passes it to the parent class |
|---|
| 197 |
*/ |
|---|
| 198 |
public this (GSettings* gSettings) |
|---|
| 199 |
{ |
|---|
| 200 |
if(gSettings is null) |
|---|
| 201 |
{ |
|---|
| 202 |
this = null; |
|---|
| 203 |
return; |
|---|
| 204 |
} |
|---|
| 205 |
//Check if there already is a D object for this gtk struct |
|---|
| 206 |
void* ptr = getDObject(cast(GObject*)gSettings); |
|---|
| 207 |
if( ptr !is null ) |
|---|
| 208 |
{ |
|---|
| 209 |
this = cast(Settings)ptr; |
|---|
| 210 |
return; |
|---|
| 211 |
} |
|---|
| 212 |
super(cast(GObject*)gSettings); |
|---|
| 213 |
this.gSettings = gSettings; |
|---|
| 214 |
} |
|---|
| 215 |
|
|---|
| 216 |
protected override void setStruct(GObject* obj) |
|---|
| 217 |
{ |
|---|
| 218 |
super.setStruct(obj); |
|---|
| 219 |
gSettings = cast(GSettings*)obj; |
|---|
| 220 |
} |
|---|
| 221 |
|
|---|
| 222 |
/** |
|---|
| 223 |
*/ |
|---|
| 224 |
int[string] connectedSignals; |
|---|
| 225 |
|
|---|
| 226 |
bool delegate(gpointer, gint, Settings)[] onChangeListeners; |
|---|
| 227 |
/** |
|---|
| 228 |
* The "change-event" signal is emitted once per change event that |
|---|
| 229 |
* affects this settings object. You should connect to this signal |
|---|
| 230 |
* only if you are interested in viewing groups of changes before they |
|---|
| 231 |
* are split out into multiple emissions of the "changed" signal. |
|---|
| 232 |
* For most use cases it is more appropriate to use the "changed" signal. |
|---|
| 233 |
* In the event that the change event applies to one or more specified |
|---|
| 234 |
* keys, keys will be an array of GQuark of length n_keys. In the |
|---|
| 235 |
* event that the change event applies to the GSettings object as a |
|---|
| 236 |
* whole (ie: potentially every key has been changed) then keys will |
|---|
| 237 |
* be NULL and n_keys will be 0. |
|---|
| 238 |
* The default handler for this signal invokes the "changed" signal |
|---|
| 239 |
* for each affected key. If any other connected handler returns |
|---|
| 240 |
* TRUE then this default functionality will be supressed. |
|---|
| 241 |
* TRUE to stop other handlers from being invoked for the |
|---|
| 242 |
* event. FALSE to propagate the event further. |
|---|
| 243 |
*/ |
|---|
| 244 |
void addOnChange(bool delegate(gpointer, gint, Settings) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) |
|---|
| 245 |
{ |
|---|
| 246 |
if ( !("change-event" in connectedSignals) ) |
|---|
| 247 |
{ |
|---|
| 248 |
Signals.connectData( |
|---|
| 249 |
getStruct(), |
|---|
| 250 |
"change-event", |
|---|
| 251 |
cast(GCallback)&callBackChange, |
|---|
| 252 |
cast(void*)this, |
|---|
| 253 |
null, |
|---|
| 254 |
connectFlags); |
|---|
| 255 |
connectedSignals["change-event"] = 1; |
|---|
| 256 |
} |
|---|
| 257 |
onChangeListeners ~= dlg; |
|---|
| 258 |
} |
|---|
| 259 |
extern(C) static gboolean callBackChange(GSettings* settingsStruct, gpointer keys, gint nKeys, Settings settings) |
|---|
| 260 |
{ |
|---|
| 261 |
foreach ( bool delegate(gpointer, gint, Settings) dlg ; settings.onChangeListeners ) |
|---|
| 262 |
{ |
|---|
| 263 |
if ( dlg(keys, nKeys, settings) ) |
|---|
| 264 |
{ |
|---|
| 265 |
return 1; |
|---|
| 266 |
} |
|---|
| 267 |
} |
|---|
| 268 |
|
|---|
| 269 |
return 0; |
|---|
| 270 |
} |
|---|
| 271 |
|
|---|
| 272 |
void delegate(string, Settings)[] onChangedListeners; |
|---|
| 273 |
/** |
|---|
| 274 |
* The "changed" signal is emitted when a key has potentially changed. |
|---|
| 275 |
* You should call one of the g_settings_get() calls to check the new |
|---|
| 276 |
* value. |
|---|
| 277 |
* This signal supports detailed connections. You can connect to the |
|---|
| 278 |
* detailed signal "changed::x" in order to only receive callbacks |
|---|
| 279 |
* when key "x" changes. |
|---|
| 280 |
*/ |
|---|
| 281 |
void addOnChanged(void delegate(string, Settings) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) |
|---|
| 282 |
{ |
|---|
| 283 |
if ( !("changed" in connectedSignals) ) |
|---|
| 284 |
{ |
|---|
| 285 |
Signals.connectData( |
|---|
| 286 |
getStruct(), |
|---|
| 287 |
"changed", |
|---|
| 288 |
cast(GCallback)&callBackChanged, |
|---|
| 289 |
cast(void*)this, |
|---|
| 290 |
null, |
|---|
| 291 |
connectFlags); |
|---|
| 292 |
connectedSignals["changed"] = 1; |
|---|
| 293 |
} |
|---|
| 294 |
onChangedListeners ~= dlg; |
|---|
| 295 |
} |
|---|
| 296 |
extern(C) static void callBackChanged(GSettings* settingsStruct, gchar* key, Settings settings) |
|---|
| 297 |
{ |
|---|
| 298 |
foreach ( void delegate(string, Settings) dlg ; settings.onChangedListeners ) |
|---|
| 299 |
{ |
|---|
| 300 |
dlg(Str.toString(key), settings); |
|---|
| 301 |
} |
|---|
| 302 |
} |
|---|
| 303 |
|
|---|
| 304 |
bool delegate(guint, Settings)[] onWritableChangeListeners; |
|---|
| 305 |
/** |
|---|
| 306 |
* The "writable-change-event" signal is emitted once per writability |
|---|
| 307 |
* change event that affects this settings object. You should connect |
|---|
| 308 |
* to this signal if you are interested in viewing groups of changes |
|---|
| 309 |
* before they are split out into multiple emissions of the |
|---|
| 310 |
* "writable-changed" signal. For most use cases it is more |
|---|
| 311 |
* appropriate to use the "writable-changed" signal. |
|---|
| 312 |
* In the event that the writability change applies only to a single |
|---|
| 313 |
* key, key will be set to the GQuark for that key. In the event |
|---|
| 314 |
* that the writability change affects the entire settings object, |
|---|
| 315 |
* key will be 0. |
|---|
| 316 |
* The default handler for this signal invokes the "writable-changed" |
|---|
| 317 |
* and "changed" signals for each affected key. This is done because |
|---|
| 318 |
* changes in writability might also imply changes in value (if for |
|---|
| 319 |
* example, a new mandatory setting is introduced). If any other |
|---|
| 320 |
* connected handler returns TRUE then this default functionality |
|---|
| 321 |
* will be supressed. |
|---|
| 322 |
* TRUE to stop other handlers from being invoked for the |
|---|
| 323 |
* event. FALSE to propagate the event further. |
|---|
| 324 |
*/ |
|---|
| 325 |
void addOnWritableChange(bool delegate(guint, Settings) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) |
|---|
| 326 |
{ |
|---|
| 327 |
if ( !("writable-change-event" in connectedSignals) ) |
|---|
| 328 |
{ |
|---|
| 329 |
Signals.connectData( |
|---|
| 330 |
getStruct(), |
|---|
| 331 |
"writable-change-event", |
|---|
| 332 |
cast(GCallback)&callBackWritableChange, |
|---|
| 333 |
cast(void*)this, |
|---|
| 334 |
null, |
|---|
| 335 |
connectFlags); |
|---|
| 336 |
connectedSignals["writable-change-event"] = 1; |
|---|
| 337 |
} |
|---|
| 338 |
onWritableChangeListeners ~= dlg; |
|---|
| 339 |
} |
|---|
| 340 |
extern(C) static gboolean callBackWritableChange(GSettings* settingsStruct, guint key, Settings settings) |
|---|
| 341 |
{ |
|---|
| 342 |
foreach ( bool delegate(guint, Settings) dlg ; settings.onWritableChangeListeners ) |
|---|
| 343 |
{ |
|---|
| 344 |
if ( dlg(key, settings) ) |
|---|
| 345 |
{ |
|---|
| 346 |
return 1; |
|---|
| 347 |
} |
|---|
| 348 |
} |
|---|
| 349 |
|
|---|
| 350 |
return 0; |
|---|
| 351 |
} |
|---|
| 352 |
|
|---|
| 353 |
void delegate(string, Settings)[] onWritableChangedListeners; |
|---|
| 354 |
/** |
|---|
| 355 |
* The "writable-changed" signal is emitted when the writability of a |
|---|
| 356 |
* key has potentially changed. You should call |
|---|
| 357 |
* g_settings_is_writable() in order to determine the new status. |
|---|
| 358 |
* This signal supports detailed connections. You can connect to the |
|---|
| 359 |
* detailed signal "writable-changed::x" in order to only receive |
|---|
| 360 |
* callbacks when the writability of "x" changes. |
|---|
| 361 |
*/ |
|---|
| 362 |
void addOnWritableChanged(void delegate(string, Settings) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) |
|---|
| 363 |
{ |
|---|
| 364 |
if ( !("writable-changed" in connectedSignals) ) |
|---|
| 365 |
{ |
|---|
| 366 |
Signals.connectData( |
|---|
| 367 |
getStruct(), |
|---|
| 368 |
"writable-changed", |
|---|
| 369 |
cast(GCallback)&callBackWritableChanged, |
|---|
| 370 |
cast(void*)this, |
|---|
| 371 |
null, |
|---|
| 372 |
connectFlags); |
|---|
| 373 |
connectedSignals["writable-changed"] = 1; |
|---|
| 374 |
} |
|---|
| 375 |
onWritableChangedListeners ~= dlg; |
|---|
| 376 |
} |
|---|
| 377 |
extern(C) static void callBackWritableChanged(GSettings* settingsStruct, gchar* key, Settings settings) |
|---|
| 378 |
{ |
|---|
| 379 |
foreach ( void delegate(string, Settings) dlg ; settings.onWritableChangedListeners ) |
|---|
| 380 |
{ |
|---|
| 381 |
dlg(Str.toString(key), settings); |
|---|
| 382 |
} |
|---|
| 383 |
} |
|---|
| 384 |
|
|---|
| 385 |
|
|---|
| 386 |
/** |
|---|
| 387 |
* Creates a new GSettings object with a given schema. |
|---|
| 388 |
* Signals on the newly created GSettings object will be dispatched |
|---|
| 389 |
* via the thread-default GMainContext in effect at the time of the |
|---|
| 390 |
* call to g_settings_new(). The new GSettings will hold a reference |
|---|
| 391 |
* on the context. See g_main_context_push_thread_default(). |
|---|
| 392 |
* Since 2.26 |
|---|
| 393 |
* Params: |
|---|
| 394 |
* schema = the name of the schema |
|---|
| 395 |
* Throws: ConstructionException GTK+ fails to create the object. |
|---|
| 396 |
*/ |
|---|
| 397 |
public this (string schema) |
|---|
| 398 |
{ |
|---|
| 399 |
// GSettings * g_settings_new (const gchar *schema); |
|---|
| 400 |
auto p = g_settings_new(Str.toStringz(schema)); |
|---|
| 401 |
if(p is null) |
|---|
| 402 |
{ |
|---|
| 403 |
throw new ConstructionException("null returned by g_settings_new(Str.toStringz(schema))"); |
|---|
| 404 |
} |
|---|
| 405 |
this(cast(GSettings*) p); |
|---|
| 406 |
} |
|---|
| 407 |
|
|---|
| 408 |
/** |
|---|
| 409 |
* Creates a new GSettings object with a given schema and path. |
|---|
| 410 |
* You only need to do this if you want to directly create a settings |
|---|
| 411 |
* object with a schema that doesn't have a specified path of its own. |
|---|
| 412 |
* That's quite rare. |
|---|
| 413 |
* It is a programmer error to call this function for a schema that |
|---|
| 414 |
* has an explicitly specified path. |
|---|
| 415 |
* Since 2.26 |
|---|
| 416 |
* Params: |
|---|
| 417 |
* schema = the name of the schema |
|---|
| 418 |
* path = the path to use |
|---|
| 419 |
* Throws: ConstructionException GTK+ fails to create the object. |
|---|
| 420 |
*/ |
|---|
| 421 |
public this (string schema, string path) |
|---|
| 422 |
{ |
|---|
| 423 |
// GSettings * g_settings_new_with_path (const gchar *schema, const gchar *path); |
|---|
| 424 |
auto p = g_settings_new_with_path(Str.toStringz(schema), Str.toStringz(path)); |
|---|
| 425 |
if(p is null) |
|---|
| 426 |
{ |
|---|
| 427 |
throw new ConstructionException("null returned by g_settings_new_with_path(Str.toStringz(schema), Str.toStringz(path))"); |
|---|
| 428 |
} |
|---|
| 429 |
this(cast(GSettings*) p); |
|---|
| 430 |
} |
|---|
| 431 |
|
|---|
| 432 |
/** |
|---|
| 433 |
* Creates a new GSettings object with a given schema and backend. |
|---|
| 434 |
* Creating settings objects with an different backend allows accessing settings |
|---|
| 435 |
* from a database other than the usual one. For example, it may make |
|---|
| 436 |
* sense to pass a backend corresponding to the "defaults" settings database on |
|---|
| 437 |
* the system to get a settings object that modifies the system default |
|---|
| 438 |
* settings instead of the settings for this user. |
|---|
| 439 |
* Since 2.26 |
|---|
| 440 |
* Params: |
|---|
| 441 |
* schema = the name of the schema |
|---|
| 442 |
* backend = the GSettingsBackend to use |
|---|
| 443 |
* Throws: ConstructionException GTK+ fails to create the object. |
|---|
| 444 |
*/ |
|---|
| 445 |
public this (string schema, SettingsBackend backend) |
|---|
| 446 |
{ |
|---|
| 447 |
// GSettings * g_settings_new_with_backend (const gchar *schema, GSettingsBackend *backend); |
|---|
| 448 |
auto p = g_settings_new_with_backend(Str.toStringz(schema), (backend is null) ? null : backend.getSettingsBackendStruct()); |
|---|
| 449 |
if(p is null) |
|---|
| 450 |
{ |
|---|
| 451 |
throw new ConstructionException("null returned by g_settings_new_with_backend(Str.toStringz(schema), (backend is null) ? null : backend.getSettingsBackendStruct())"); |
|---|
| 452 |
} |
|---|
| 453 |
this(cast(GSettings*) p); |
|---|
| 454 |
} |
|---|
| 455 |
|
|---|
| 456 |
/** |
|---|
| 457 |
* Creates a new GSettings object with a given schema, backend and |
|---|
| 458 |
* path. |
|---|
| 459 |
* This is a mix of g_settings_new_with_backend() and |
|---|
| 460 |
* g_settings_new_with_path(). |
|---|
| 461 |
* Since 2.26 |
|---|
| 462 |
* Params: |
|---|
| 463 |
* schema = the name of the schema |
|---|
| 464 |
* backend = the GSettingsBackend to use |
|---|
| 465 |
* path = the path to use |
|---|
| 466 |
* Throws: ConstructionException GTK+ fails to create the object. |
|---|
| 467 |
*/ |
|---|
| 468 |
public this (string schema, SettingsBackend backend, string path) |
|---|
| 469 |
{ |
|---|
| 470 |
// GSettings * g_settings_new_with_backend_and_path (const gchar *schema, GSettingsBackend *backend, const gchar *path); |
|---|
| 471 |
auto p = g_settings_new_with_backend_and_path(Str.toStringz(schema), (backend is null) ? null : backend.getSettingsBackendStruct(), Str.toStringz(path)); |
|---|
| 472 |
if(p is null) |
|---|
| 473 |
{ |
|---|
| 474 |
throw new ConstructionException("null returned by g_settings_new_with_backend_and_path(Str.toStringz(schema), (backend is null) ? null : backend.getSettingsBackendStruct(), Str.toStringz(path))"); |
|---|
| 475 |
} |
|---|
| 476 |
this(cast(GSettings*) p); |
|---|
| 477 |
} |
|---|
| 478 |
|
|---|
| 479 |
/** |
|---|
| 480 |
* Ensures that all pending operations for the given are complete for |
|---|
| 481 |
* the default backend. |
|---|
| 482 |
* Writes made to a GSettings are handled asynchronously. For this |
|---|
| 483 |
* reason, it is very unlikely that the changes have it to disk by the |
|---|
| 484 |
* time g_settings_set() returns. |
|---|
| 485 |
* This call will block until all of the writes have made it to the |
|---|
| 486 |
* backend. Since the mainloop is not running, no change notifications |
|---|
| 487 |
* will be dispatched during this call (but some may be queued by the |
|---|
| 488 |
* time the call is done). |
|---|
| 489 |
*/ |
|---|
| 490 |
public static void sync() |
|---|
| 491 |
{ |
|---|
| 492 |
// void g_settings_sync (void); |
|---|
| 493 |
g_settings_sync(); |
|---|
| 494 |
} |
|---|
| 495 |
|
|---|
| 496 |
/** |
|---|
| 497 |
* Gets the value that is stored in settings for key. |
|---|
| 498 |
* It is a programmer error to give a key that isn't contained in the |
|---|
| 499 |
* schema for settings. |
|---|
| 500 |
* Since 2.26 |
|---|
| 501 |
* Params: |
|---|
| 502 |
* key = the key to get the value for |
|---|
| 503 |
* Returns: a new GVariant |
|---|
| 504 |
*/ |
|---|
| 505 |
public Variant getValue(string key) |
|---|
| 506 |
{ |
|---|
| 507 |
// GVariant * g_settings_get_value (GSettings *settings, const gchar *key); |
|---|
| 508 |
auto p = g_settings_get_value(gSettings, Str.toStringz(key)); |
|---|
| 509 |
if(p is null) |
|---|
| 510 |
{ |
|---|
| 511 |
return null; |
|---|
| 512 |
} |
|---|
| 513 |
return new Variant(cast(GVariant*) p); |
|---|
| 514 |
} |
|---|
| 515 |
|
|---|
| 516 |
/** |
|---|
| 517 |
* Sets key in settings to value. |
|---|
| 518 |
* It is a programmer error to give a key that isn't contained in the |
|---|
| 519 |
* schema for settings or for value to have the incorrect type, per |
|---|
| 520 |
* the schema. |
|---|
| 521 |
* If value is floating then this function consumes the reference. |
|---|
| 522 |
* Since 2.26 |
|---|
| 523 |
* Params: |
|---|
| 524 |
* key = the name of the key to set |
|---|
| 525 |
* value = a GVariant of the correct type |
|---|
| 526 |
* Returns: TRUE if setting the key succeeded, FALSE if the key was not writable |
|---|
| 527 |
*/ |
|---|
| 528 |
public int setValue(string key, Variant value) |
|---|
| 529 |
{ |
|---|
| 530 |
// gboolean g_settings_set_value (GSettings *settings, const gchar *key, GVariant *value); |
|---|
| 531 |
return g_settings_set_value(gSettings, Str.toStringz(key), (value is null) ? null : value.getVariantStruct()); |
|---|
| 532 |
} |
|---|
| 533 |
|
|---|
| 534 |
/** |
|---|
| 535 |
* Finds out if a key can be written or not |
|---|
| 536 |
* Since 2.26 |
|---|
| 537 |
* Params: |
|---|
| 538 |
* name = the name of a key |
|---|
| 539 |
* Returns: TRUE if the key name is writable |
|---|
| 540 |
*/ |
|---|
| 541 |
public int isWritable(string name) |
|---|
| 542 |
{ |
|---|
| 543 |
// gboolean g_settings_is_writable (GSettings *settings, const gchar *name); |
|---|
| 544 |
return g_settings_is_writable(gSettings, Str.toStringz(name)); |
|---|
| 545 |
} |
|---|
| 546 |
|
|---|
| 547 |
/** |
|---|
| 548 |
* Changes the GSettings object into 'delay-apply' mode. In this |
|---|
| 549 |
* mode, changes to settings are not immediately propagated to the |
|---|
| 550 |
* backend, but kept locally until g_settings_apply() is called. |
|---|
| 551 |
* Since 2.26 |
|---|
| 552 |
*/ |
|---|
| 553 |
public void delay() |
|---|
| 554 |
{ |
|---|
| 555 |
// void g_settings_delay (GSettings *settings); |
|---|
| 556 |
g_settings_delay(gSettings); |
|---|
| 557 |
} |
|---|
| 558 |
|
|---|
| 559 |
/** |
|---|
| 560 |
* Applies any changes that have been made to the settings. This |
|---|
| 561 |
* function does nothing unless settings is in 'delay-apply' mode; |
|---|
| 562 |
* see g_settings_delay(). In the normal case settings are always |
|---|
| 563 |
* applied immediately. |
|---|
| 564 |
*/ |
|---|
| 565 |
public void apply() |
|---|
| 566 |
{ |
|---|
| 567 |
// void g_settings_apply (GSettings *settings); |
|---|
| 568 |
g_settings_apply(gSettings); |
|---|
| 569 |
} |
|---|
| 570 |
|
|---|
| 571 |
/** |
|---|
| 572 |
* Reverts all non-applied changes to the settings. This function |
|---|
| 573 |
* does nothing unless settings is in 'delay-apply' mode; see |
|---|
| 574 |
* g_settings_delay(). In the normal case settings are always applied |
|---|
| 575 |
* immediately. |
|---|
| 576 |
* Change notifications will be emitted for affected keys. |
|---|
| 577 |
*/ |
|---|
| 578 |
public void revert() |
|---|
| 579 |
{ |
|---|
| 580 |
// void g_settings_revert (GSettings *settings); |
|---|
| 581 |
g_settings_revert(gSettings); |
|---|
| 582 |
} |
|---|
| 583 |
|
|---|
| 584 |
/** |
|---|
| 585 |
* Returns whether the GSettings object has any unapplied |
|---|
| 586 |
* changes. This can only be the case if it is in 'delayed-apply' mode. |
|---|
| 587 |
* Since 2.26 |
|---|
| 588 |
* Returns: TRUE if settings has unapplied changes |
|---|
| 589 |
*/ |
|---|
| 590 |
public int getHasUnapplied() |
|---|
| 591 |
{ |
|---|
| 592 |
// gboolean g_settings_get_has_unapplied (GSettings *settings); |
|---|
| 593 |
return g_settings_get_has_unapplied(gSettings); |
|---|
| 594 |
} |
|---|
| 595 |
|
|---|
| 596 |
/** |
|---|
| 597 |
* Creates a 'child' settings object which has a base path of |
|---|
| 598 |
* base-path/name, where |
|---|
| 599 |
* base-path is the base path of settings. |
|---|
| 600 |
* The schema for the child settings object must have been declared |
|---|
| 601 |
* in the schema of settings using a <child> element. |
|---|
| 602 |
* Since 2.26 |
|---|
| 603 |
* Params: |
|---|
| 604 |
* name = the name of the 'child' schema |
|---|
| 605 |
* Returns: a 'child' settings object. [transfer full] |
|---|
| 606 |
*/ |
|---|
| 607 |
public Settings getChild(string name) |
|---|
| 608 |
{ |
|---|
| 609 |
// GSettings * g_settings_get_child (GSettings *settings, const gchar *name); |
|---|
| 610 |
auto p = g_settings_get_child(gSettings, Str.toStringz(name)); |
|---|
| 611 |
if(p is null) |
|---|
| 612 |
{ |
|---|
| 613 |
return null; |
|---|
| 614 |
} |
|---|
| 615 |
return new Settings(cast(GSettings*) p); |
|---|
| 616 |
} |
|---|
| 617 |
|
|---|
| 618 |
/** |
|---|
| 619 |
* Resets key to its default value. |
|---|
| 620 |
* This call resets the key, as much as possible, to its default value. |
|---|
| 621 |
* That might the value specified in the schema or the one set by the |
|---|
| 622 |
* administrator. |
|---|
| 623 |
* Params: |
|---|
| 624 |
* key = the name of a key |
|---|
| 625 |
*/ |
|---|
| 626 |
public void reset(string key) |
|---|
| 627 |
{ |
|---|
| 628 |
// void g_settings_reset (GSettings *settings, const gchar *key); |
|---|
| 629 |
g_settings_reset(gSettings, Str.toStringz(key)); |
|---|
| 630 |
} |
|---|
| 631 |
|
|---|
| 632 |
/** |
|---|
| 633 |
* Gets a list of the GSettings schemas installed on the system. The |
|---|
| 634 |
* returned list is exactly the list of schemas for which you may call |
|---|
| 635 |
* g_settings_new() without adverse effects. |
|---|
| 636 |
* This function does not list the schemas that do not provide their own |
|---|
| 637 |
* paths (ie: schemas for which you must use |
|---|
| 638 |
* g_settings_new_with_path()). See |
|---|
| 639 |
* g_settings_list_relocatable_schemas() for that. |
|---|
| 640 |
* Since 2.26 |
|---|
| 641 |
* Returns: a list of GSettings schemas that are available. The list must not be modified or freed. [element-type utf8][transfer none] |
|---|
| 642 |
*/ |
|---|
| 643 |
public static string[] listSchemas() |
|---|
| 644 |
{ |
|---|
| 645 |
// const gchar * const * g_settings_list_schemas (void); |
|---|
| 646 |
return Str.toStringArray(g_settings_list_schemas()); |
|---|
| 647 |
} |
|---|
| 648 |
|
|---|
| 649 |
/** |
|---|
| 650 |
* Gets a list of the relocatable GSettings schemas installed on the |
|---|
| 651 |
* system. These are schemas that do not provide their own path. It is |
|---|
| 652 |
* usual to instantiate these schemas directly, but if you want to you |
|---|
| 653 |
* can use g_settings_new_with_path() to specify the path. |
|---|
| 654 |
* The output of this function, tTaken together with the output of |
|---|
| 655 |
* g_settings_list_schemas() represents the complete list of all |
|---|
| 656 |
* installed schemas. |
|---|
| 657 |
* Since 2.28 |
|---|
| 658 |
* Returns: a list of relocatable GSettings schemas that are available. The list must not be modified or freed. [element-type utf8][transfer none] |
|---|
| 659 |
*/ |
|---|
| 660 |
public static string[] listRelocatableSchemas() |
|---|
| 661 |
{ |
|---|
| 662 |
// const gchar * const * g_settings_list_relocatable_schemas (void); |
|---|
| 663 |
return Str.toStringArray(g_settings_list_relocatable_schemas()); |
|---|
| 664 |
} |
|---|
| 665 |
|
|---|
| 666 |
/** |
|---|
| 667 |
* Introspects the list of keys on settings. |
|---|
| 668 |
* You should probably not be calling this function from "normal" code |
|---|
| 669 |
* (since you should already know what keys are in your schema). This |
|---|
| 670 |
* function is intended for introspection reasons. |
|---|
| 671 |
* You should free the return value with g_strfreev() when you are done |
|---|
| 672 |
* with it. |
|---|
| 673 |
* Returns: a list of the keys on settings. [transfer full][element-type utf8] |
|---|
| 674 |
*/ |
|---|
| 675 |
public string[] listKeys() |
|---|
| 676 |
{ |
|---|
| 677 |
// gchar ** g_settings_list_keys (GSettings *settings); |
|---|
| 678 |
return Str.toStringArray(g_settings_list_keys(gSettings)); |
|---|
| 679 |
} |
|---|
| 680 |
|
|---|
| 681 |
/** |
|---|
| 682 |
* Gets the list of children on settings. |
|---|
| 683 |
* The list is exactly the list of strings for which it is not an error |
|---|
| 684 |
* to call g_settings_get_child(). |
|---|
| 685 |
* For GSettings objects that are lists, this value can change at any |
|---|
| 686 |
* time and you should connect to the "children-changed" signal to watch |
|---|
| 687 |
* for those changes. Note that there is a race condition here: you may |
|---|
| 688 |
* request a child after listing it only for it to have been destroyed |
|---|
| 689 |
* in the meantime. For this reason, g_settings_get_child() may return |
|---|
| 690 |
* NULL even for a child that was listed by this function. |
|---|
| 691 |
* For GSettings objects that are not lists, you should probably not be |
|---|
| 692 |
* calling this function from "normal" code (since you should already |
|---|
| 693 |
* know what children are in your schema). This function may still be |
|---|
| 694 |
* useful there for introspection reasons, however. |
|---|
| 695 |
* You should free the return value with g_strfreev() when you are done |
|---|
| 696 |
* with it. |
|---|
| 697 |
* Returns: a list of the children on settings. [transfer full][element-type utf8] |
|---|
| 698 |
*/ |
|---|
| 699 |
public string[] listChildren() |
|---|
| 700 |
{ |
|---|
| 701 |
// gchar ** g_settings_list_children (GSettings *settings); |
|---|
| 702 |
return Str.toStringArray(g_settings_list_children(gSettings)); |
|---|
| 703 |
} |
|---|
| 704 |
|
|---|
| 705 |
/** |
|---|
| 706 |
* Queries the range of a key. |
|---|
| 707 |
* This function will return a GVariant that fully describes the range |
|---|
| 708 |
* of values that are valid for key. |
|---|
| 709 |
* The type of GVariant returned is (sv). The |
|---|
| 710 |
* string describes the type of range restriction in effect. The type |
|---|
| 711 |
* and meaning of the value contained in the variant depends on the |
|---|
| 712 |
* string. |
|---|
| 713 |
* If the string is 'type' then the variant contains |
|---|
| 714 |
* an empty array. The element type of that empty array is the expected |
|---|
| 715 |
* type of value and all values of that type are valid. |
|---|
| 716 |
* If the string is 'enum' then the variant contains |
|---|
| 717 |
* an array enumerating the possible values. Each item in the array is |
|---|
| 718 |
* a possible valid value and no other values are valid. |
|---|
| 719 |
* If the string is 'flags' then the variant contains |
|---|
| 720 |
* an array. Each item in the array is a value that may appear zero or |
|---|
| 721 |
* one times in an array to be used as the value for this key. For |
|---|
| 722 |
* example, if the variant contained the array ['x', |
|---|
| 723 |
* 'y'] then the valid values for the key would be |
|---|
| 724 |
* [], ['x'], |
|---|
| 725 |
* ['y'], ['x', 'y'] and |
|---|
| 726 |
* ['y', 'x']. |
|---|
| 727 |
* Finally, if the string is 'range' then the variant |
|---|
| 728 |
* contains a pair of like-typed values -- the minimum and maximum |
|---|
| 729 |
* permissible values for this key. |
|---|
| 730 |
* This information should not be used by normal programs. It is |
|---|
| 731 |
* considered to be a hint for introspection purposes. Normal programs |
|---|
| 732 |
* should already know what is permitted by their own schema. The |
|---|
| 733 |
* format may change in any way in the future -- but particularly, new |
|---|
| 734 |
* forms may be added to the possibilities described above. |
|---|
| 735 |
* It is a programmer error to give a key that isn't contained in the |
|---|
| 736 |
* schema for settings. |
|---|
| 737 |
* You should free the returned value with g_variant_unref() when it is |
|---|
| 738 |
* no longer needed. |
|---|
| 739 |
* Since 2.28 |
|---|
| 740 |
* Params: |
|---|
| 741 |
* key = the key to query the range of |
|---|
| 742 |
* Returns: a GVariant describing the range |
|---|
| 743 |
*/ |
|---|
| 744 |
public Variant getRange(string key) |
|---|
| 745 |
{ |
|---|
| 746 |
// GVariant * g_settings_get_range (GSettings *settings, const gchar *key); |
|---|
| 747 |
auto p = g_settings_get_range(gSettings, Str.toStringz(key)); |
|---|
| 748 |
if(p is null) |
|---|
| 749 |
{ |
|---|
| 750 |
return null; |
|---|
| 751 |
} |
|---|
| 752 |
return new Variant(cast(GVariant*) p); |
|---|
| 753 |
} |
|---|
| 754 |
|
|---|
| 755 |
/** |
|---|
| 756 |
* Checks if the given value is of the correct type and within the |
|---|
| 757 |
* permitted range for key. |
|---|
| 758 |
* This API is not intended to be used by normal programs -- they should |
|---|
| 759 |
* already know what is permitted by their own schemas. This API is |
|---|
| 760 |
* meant to be used by programs such as editors or commandline tools. |
|---|
| 761 |
* It is a programmer error to give a key that isn't contained in the |
|---|
| 762 |
* schema for settings. |
|---|
| 763 |
* Since 2.28 |
|---|
| 764 |
* Params: |
|---|
| 765 |
* key = the key to check |
|---|
| 766 |
* value = the value to check |
|---|
| 767 |
* Returns: TRUE if value is valid for key |
|---|
| 768 |
*/ |
|---|
| 769 |
public int rangeCheck(string key, Variant value) |
|---|
| 770 |
{ |
|---|
| 771 |
// gboolean g_settings_range_check (GSettings *settings, const gchar *key, GVariant *value); |
|---|
| 772 |
return g_settings_range_check(gSettings, Str.toStringz(key), (value is null) ? null : value.getVariantStruct()); |
|---|
| 773 |
} |
|---|
| 774 |
|
|---|
| 775 |
/** |
|---|
| 776 |
* Gets the value that is stored at key in settings. |
|---|
| 777 |
* A convenience variant of g_settings_get() for booleans. |
|---|
| 778 |
* It is a programmer error to give a key that isn't specified as |
|---|
| 779 |
* having a boolean type in the schema for settings. |
|---|
| 780 |
* Since 2.26 |
|---|
| 781 |
* Params: |
|---|
| 782 |
* key = the key to get the value for |
|---|
| 783 |
* Returns: a boolean |
|---|
| 784 |
*/ |
|---|
| 785 |
public int getBoolean(string key) |
|---|
| 786 |
{ |
|---|
| 787 |
// gboolean g_settings_get_boolean (GSettings *settings, const gchar *key); |
|---|
| 788 |
return g_settings_get_boolean(gSettings, Str.toStringz(key)); |
|---|
| 789 |
} |
|---|
| 790 |
|
|---|
| 791 |
/** |
|---|
| 792 |
* Sets key in settings to value. |
|---|
| 793 |
* A convenience variant of g_settings_set() for booleans. |
|---|
| 794 |
* It is a programmer error to give a key that isn't specified as |
|---|
| 795 |
* having a boolean type in the schema for settings. |
|---|
| 796 |
* Since 2.26 |
|---|
| 797 |
* Params: |
|---|
| 798 |
* key = the name of the key to set |
|---|
| 799 |
* value = the value to set it to |
|---|
| 800 |
* Returns: TRUE if setting the key succeeded, FALSE if the key was not writable |
|---|
| 801 |
*/ |
|---|
| 802 |
public int setBoolean(string key, int value) |
|---|
| 803 |
{ |
|---|
| 804 |
// gboolean g_settings_set_boolean (GSettings *settings, const gchar *key, gboolean value); |
|---|
| 805 |
return g_settings_set_boolean(gSettings, Str.toStringz(key), value); |
|---|
| 806 |
} |
|---|
| 807 |
|
|---|
| 808 |
/** |
|---|
| 809 |
* Gets the value that is stored at key in settings. |
|---|
| 810 |
* A convenience variant of g_settings_get() for 32-bit integers. |
|---|
| 811 |
* It is a programmer error to give a key that isn't specified as |
|---|
| 812 |
* having a int32 type in the schema for settings. |
|---|
| 813 |
* Since 2.26 |
|---|
| 814 |
* Params: |
|---|
| 815 |
* key = the key to get the value for |
|---|
| 816 |
* Returns: an integer |
|---|
| 817 |
*/ |
|---|
| 818 |
public int getInt(string key) |
|---|
| 819 |
{ |
|---|
| 820 |
// gint g_settings_get_int (GSettings *settings, const gchar *key); |
|---|
| 821 |
return g_settings_get_int(gSettings, Str.toStringz(key)); |
|---|
| 822 |
} |
|---|
| 823 |
|
|---|
| 824 |
/** |
|---|
| 825 |
* Sets key in settings to value. |
|---|
| 826 |
* A convenience variant of g_settings_set() for 32-bit integers. |
|---|
| 827 |
* It is a programmer error to give a key that isn't specified as |
|---|
| 828 |
* having a int32 type in the schema for settings. |
|---|
| 829 |
* Since 2.26 |
|---|
| 830 |
* Params: |
|---|
| 831 |
* key = the name of the key to set |
|---|
| 832 |
* value = the value to set it to |
|---|
| 833 |
* Returns: TRUE if setting the key succeeded, FALSE if the key was not writable |
|---|
| 834 |
*/ |
|---|
| 835 |
public int setInt(string key, int value) |
|---|
| 836 |
{ |
|---|
| 837 |
// gboolean g_settings_set_int (GSettings *settings, const gchar *key, gint value); |
|---|
| 838 |
return g_settings_set_int(gSettings, Str.toStringz(key), value); |
|---|
| 839 |
} |
|---|
| 840 |
|
|---|
| 841 |
/** |
|---|
| 842 |
* Gets the value that is stored at key in settings. |
|---|
| 843 |
* A convenience variant of g_settings_get() for doubles. |
|---|
| 844 |
* It is a programmer error to give a key that isn't specified as |
|---|
| 845 |
* having a 'double' type in the schema for settings. |
|---|
| 846 |
* Since 2.26 |
|---|
| 847 |
* Params: |
|---|
| 848 |
* key = the key to get the value for |
|---|
| 849 |
* Returns: a double |
|---|
| 850 |
*/ |
|---|
| 851 |
public double getDouble(string key) |
|---|
| 852 |
{ |
|---|
| 853 |
// gdouble g_settings_get_double (GSettings *settings, const gchar *key); |
|---|
| 854 |
return g_settings_get_double(gSettings, Str.toStringz(key)); |
|---|
| 855 |
} |
|---|
| 856 |
|
|---|
| 857 |
/** |
|---|
| 858 |
* Sets key in settings to value. |
|---|
| 859 |
* A convenience variant of g_settings_set() for doubles. |
|---|
| 860 |
* It is a programmer error to give a key that isn't specified as |
|---|
| 861 |
* having a 'double' type in the schema for settings. |
|---|
| 862 |
* Since 2.26 |
|---|
| 863 |
* Params: |
|---|
| 864 |
* key = the name of the key to set |
|---|
| 865 |
* value = the value to set it to |
|---|
| 866 |
* Returns: TRUE if setting the key succeeded, FALSE if the key was not writable |
|---|
| 867 |
*/ |
|---|
| 868 |
public int setDouble(string key, double value) |
|---|
| 869 |
{ |
|---|
| 870 |
// gboolean g_settings_set_double (GSettings *settings, const gchar *key, gdouble value); |
|---|
| 871 |
return g_settings_set_double(gSettings, Str.toStringz(key), value); |
|---|
| 872 |
} |
|---|
| 873 |
|
|---|
| 874 |
/** |
|---|
| 875 |
* Gets the value that is stored at key in settings. |
|---|
| 876 |
* A convenience variant of g_settings_get() for strings. |
|---|
| 877 |
* It is a programmer error to give a key that isn't specified as |
|---|
| 878 |
* having a string type in the schema for settings. |
|---|
| 879 |
* Since 2.26 |
|---|
| 880 |
* Params: |
|---|
| 881 |
* key = the key to get the value for |
|---|
| 882 |
* Returns: a newly-allocated string |
|---|
| 883 |
*/ |
|---|
| 884 |
public string getString(string key) |
|---|
| 885 |
{ |
|---|
| 886 |
// gchar * g_settings_get_string (GSettings *settings, const gchar *key); |
|---|
| 887 |
return Str.toString(g_settings_get_string(gSettings, Str.toStringz(key))); |
|---|
| 888 |
} |
|---|
| 889 |
|
|---|
| 890 |
/** |
|---|
| 891 |
* Sets key in settings to value. |
|---|
| 892 |
* A convenience variant of g_settings_set() for strings. |
|---|
| 893 |
* It is a programmer error to give a key that isn't specified as |
|---|
| 894 |
* having a string type in the schema for settings. |
|---|
| 895 |
* Since 2.26 |
|---|
| 896 |
* Params: |
|---|
| 897 |
* key = the name of the key to set |
|---|
| 898 |
* value = the value to set it to |
|---|
| 899 |
* Returns: TRUE if setting the key succeeded, FALSE if the key was not writable |
|---|
| 900 |
*/ |
|---|
| 901 |
public int setString(string key, string value) |
|---|
| 902 |
{ |
|---|
| 903 |
// gboolean g_settings_set_string (GSettings *settings, const gchar *key, const gchar *value); |
|---|
| 904 |
return g_settings_set_string(gSettings, Str.toStringz(key), Str.toStringz(value)); |
|---|
| 905 |
} |
|---|
| 906 |
|
|---|
| 907 |
/** |
|---|
| 908 |
* A convenience variant of g_settings_get() for string arrays. |
|---|
| 909 |
* It is a programmer error to give a key that isn't specified as |
|---|
| 910 |
* having an array of strings type in the schema for settings. |
|---|
| 911 |
* Since 2.26 |
|---|
| 912 |
* Params: |
|---|
| 913 |
* key = the key to get the value for |
|---|
| 914 |
* Returns: a newly-allocated, NULL-terminated array of strings, the value that is stored at key in settings. [array zero-terminated=1][transfer full] |
|---|
| 915 |
*/ |
|---|
| 916 |
public string[] getStrv(string key) |
|---|
| 917 |
{ |
|---|
| 918 |
// gchar ** g_settings_get_strv (GSettings *settings, const gchar *key); |
|---|
| 919 |
return Str.toStringArray(g_settings_get_strv(gSettings, Str.toStringz(key))); |
|---|
| 920 |
} |
|---|
| 921 |
|
|---|
| 922 |
/** |
|---|
| 923 |
* Sets key in settings to value. |
|---|
| 924 |
* A convenience variant of g_settings_set() for string arrays. If |
|---|
| 925 |
* value is NULL, then key is set to be the empty array. |
|---|
| 926 |
* It is a programmer error to give a key that isn't specified as |
|---|
| 927 |
* having an array of strings type in the schema for settings. |
|---|
| 928 |
* Since 2.26 |
|---|
| 929 |
* Params: |
|---|
| 930 |
* key = the name of the key to set |
|---|
| 931 |
* value = the value to set it to, or NULL. [allow-none][array zero-terminated=1] |
|---|
| 932 |
* Returns: TRUE if setting the key succeeded, FALSE if the key was not writable |
|---|
| 933 |
*/ |
|---|
| 934 |
public int setStrv(string key, string[] value) |
|---|
| 935 |
{ |
|---|
| 936 |
// gboolean g_settings_set_strv (GSettings *settings, const gchar *key, const gchar *const *value); |
|---|
| 937 |
return g_settings_set_strv(gSettings, Str.toStringz(key), Str.toStringzArray(value)); |
|---|
| 938 |
} |
|---|
| 939 |
|
|---|
| 940 |
/** |
|---|
| 941 |
* Gets the value that is stored in settings for key and converts it |
|---|
| 942 |
* to the enum value that it represents. |
|---|
| 943 |
* In order to use this function the type of the value must be a string |
|---|
| 944 |
* and it must be marked in the schema file as an enumerated type. |
|---|
| 945 |
* It is a programmer error to give a key that isn't contained in the |
|---|
| 946 |
* schema for settings or is not marked as an enumerated type. |
|---|
| 947 |
* If the value stored in the configuration database is not a valid |
|---|
| 948 |
* value for the enumerated type then this function will return the |
|---|
| 949 |
* default value. |
|---|
| 950 |
* Since 2.26 |
|---|
| 951 |
* Params: |
|---|
| 952 |
* key = the key to get the value for |
|---|
| 953 |
* Returns: the enum value |
|---|
| 954 |
*/ |
|---|
| 955 |
public int getEnum(string key) |
|---|
| 956 |
{ |
|---|
| 957 |
// gint g_settings_get_enum (GSettings *settings, const gchar *key); |
|---|
| 958 |
return g_settings_get_enum(gSettings, Str.toStringz(key)); |
|---|
| 959 |
} |
|---|
| 960 |
|
|---|
| 961 |
/** |
|---|
| 962 |
* Looks up the enumerated type nick for value and writes it to key, |
|---|
| 963 |
* within settings. |
|---|
| 964 |
* It is a programmer error to give a key that isn't contained in the |
|---|
| 965 |
* schema for settings or is not marked as an enumerated type, or for |
|---|
| 966 |
* value not to be a valid value for the named type. |
|---|
| 967 |
* After performing the write, accessing key directly with |
|---|
| 968 |
* g_settings_get_string() will return the 'nick' associated with |
|---|
| 969 |
* value. |
|---|
| 970 |
* Params: |
|---|
| 971 |
* key = a key, within settings |
|---|
| 972 |
* value = an enumerated value |
|---|
| 973 |
* Returns: TRUE, if the set succeeds |
|---|
| 974 |
*/ |
|---|
| 975 |
public int setEnum(string key, int value) |
|---|
| 976 |
{ |
|---|
| 977 |
// gboolean g_settings_set_enum (GSettings *settings, const gchar *key, gint value); |
|---|
| 978 |
return g_settings_set_enum(gSettings, Str.toStringz(key), value); |
|---|
| 979 |
} |
|---|
| 980 |
|
|---|
| 981 |
/** |
|---|
| 982 |
* Gets the value that is stored in settings for key and converts it |
|---|
| 983 |
* to the flags value that it represents. |
|---|
| 984 |
* In order to use this function the type of the value must be an array |
|---|
| 985 |
* of strings and it must be marked in the schema file as an flags type. |
|---|
| 986 |
* It is a programmer error to give a key that isn't contained in the |
|---|
| 987 |
* schema for settings or is not marked as a flags type. |
|---|
| 988 |
* If the value stored in the configuration database is not a valid |
|---|
| 989 |
* value for the flags type then this function will return the default |
|---|
| 990 |
* value. |
|---|
| 991 |
* Since 2.26 |
|---|
| 992 |
* Params: |
|---|
| 993 |
* key = the key to get the value for |
|---|
| 994 |
* Returns: the flags value |
|---|
| 995 |
*/ |
|---|
| 996 |
public uint getFlags(string key) |
|---|
| 997 |
{ |
|---|
| 998 |
// guint g_settings_get_flags (GSettings *settings, const gchar *key); |
|---|
| 999 |
return g_settings_get_flags(gSettings, Str.toStringz(key)); |
|---|
| 1000 |
} |
|---|
| 1001 |
|
|---|
| 1002 |
/** |
|---|
| 1003 |
* Looks up the flags type nicks for the bits specified by value, puts |
|---|
| 1004 |
* them in an array of strings and writes the array to key, withing |
|---|
| 1005 |
* settings. |
|---|
| 1006 |
* It is a programmer error to give a key that isn't contained in the |
|---|
| 1007 |
* schema for settings or is not marked as a flags type, or for value |
|---|
| 1008 |
* to contain any bits that are not value for the named type. |
|---|
| 1009 |
* After performing the write, accessing key directly with |
|---|
| 1010 |
* g_settings_get_strv() will return an array of 'nicks'; one for each |
|---|
| 1011 |
* bit in value. |
|---|
| 1012 |
* Params: |
|---|
| 1013 |
* key = a key, within settings |
|---|
| 1014 |
* value = a flags value |
|---|
| 1015 |
* Returns: TRUE, if the set succeeds |
|---|
| 1016 |
*/ |
|---|
| 1017 |
public int setFlags(string key, uint value) |
|---|
| 1018 |
{ |
|---|
| 1019 |
// gboolean g_settings_set_flags (GSettings *settings, const gchar *key, guint value); |
|---|
| 1020 |
return g_settings_set_flags(gSettings, Str.toStringz(key), value); |
|---|
| 1021 |
} |
|---|
| 1022 |
|
|---|
| 1023 |
/** |
|---|
| 1024 |
* Gets the value that is stored at key in settings, subject to |
|---|
| 1025 |
* application-level validation/mapping. |
|---|
| 1026 |
* You should use this function when the application needs to perform |
|---|
| 1027 |
* some processing on the value of the key (for example, parsing). The |
|---|
| 1028 |
* mapping function performs that processing. If the function |
|---|
| 1029 |
* indicates that the processing was unsuccessful (due to a parse error, |
|---|
| 1030 |
* for example) then the mapping is tried again with another value. |
|---|
| 1031 |
* This allows a robust 'fall back to defaults' behaviour to be |
|---|
| 1032 |
* implemented somewhat automatically. |
|---|
| 1033 |
* The first value that is tried is the user's setting for the key. If |
|---|
| 1034 |
* the mapping function fails to map this value, other values may be |
|---|
| 1035 |
* tried in an unspecified order (system or site defaults, translated |
|---|
| 1036 |
* schema default values, untranslated schema default values, etc). |
|---|
| 1037 |
* If the mapping function fails for all possible values, one additional |
|---|
| 1038 |
* attempt is made: the mapping function is called with a NULL value. |
|---|
| 1039 |
* If the mapping function still indicates failure at this point then |
|---|
| 1040 |
* the application will be aborted. |
|---|
| 1041 |
* The result parameter for the mapping function is pointed to a |
|---|
| 1042 |
* gpointer which is initially set to NULL. The same pointer is given |
|---|
| 1043 |
* to each invocation of mapping. The final value of that gpointer is |
|---|
| 1044 |
* what is returned by this function. NULL is valid; it is returned |
|---|
| 1045 |
* just as any other value would be. |
|---|
| 1046 |
* Params: |
|---|
| 1047 |
* key = the key to get the value for |
|---|
| 1048 |
* mapping = the function to map the value in the |
|---|
| 1049 |
* settings database to the value used by the application. [scope call] |
|---|
| 1050 |
* userData = user data for mapping |
|---|
| 1051 |
* Returns: the result, which may be NULL. [transfer full] |
|---|
| 1052 |
*/ |
|---|
| 1053 |
public void* getMapped(string key, GSettingsGetMapping mapping, void* userData) |
|---|
| 1054 |
{ |
|---|
| 1055 |
// gpointer g_settings_get_mapped (GSettings *settings, const gchar *key, GSettingsGetMapping mapping, gpointer user_data); |
|---|
| 1056 |
return g_settings_get_mapped(gSettings, Str.toStringz(key), mapping, userData); |
|---|
| 1057 |
} |
|---|
| 1058 |
|
|---|
| 1059 |
/** |
|---|
| 1060 |
* Create a binding between the key in the settings object |
|---|
| 1061 |
* and the property property of object. |
|---|
| 1062 |
* The binding uses the default GIO mapping functions to map |
|---|
| 1063 |
* between the settings and property values. These functions |
|---|
| 1064 |
* handle booleans, numeric types and string types in a |
|---|
| 1065 |
* straightforward way. Use g_settings_bind_with_mapping() if |
|---|
| 1066 |
* you need a custom mapping, or map between types that are not |
|---|
| 1067 |
* supported by the default mapping functions. |
|---|
| 1068 |
* Unless the flags include G_SETTINGS_BIND_NO_SENSITIVITY, this |
|---|
| 1069 |
* function also establishes a binding between the writability of |
|---|
| 1070 |
* key and the "sensitive" property of object (if object has |
|---|
| 1071 |
* a boolean property by that name). See g_settings_bind_writable() |
|---|
| 1072 |
* for more details about writable bindings. |
|---|
| 1073 |
* Note that the lifecycle of the binding is tied to the object, |
|---|
| 1074 |
* and that you can have only one binding per object property. |
|---|
| 1075 |
* If you bind the same property twice on the same object, the second |
|---|
| 1076 |
* binding overrides the first one. |
|---|
| 1077 |
* Since 2.26 |
|---|
| 1078 |
* Params: |
|---|
| 1079 |
* key = the key to bind |
|---|
| 1080 |
* object = a GObject. [type GObject.Object] |
|---|
| 1081 |
* property = the name of the property to bind |
|---|
| 1082 |
* flags = flags for the binding |
|---|
| 1083 |
*/ |
|---|
| 1084 |
public void bind(string key, void* object, string property, GSettingsBindFlags flags) |
|---|
| 1085 |
{ |
|---|
| 1086 |
// void g_settings_bind (GSettings *settings, const gchar *key, gpointer object, const gchar *property, GSettingsBindFlags flags); |
|---|
| 1087 |
g_settings_bind(gSettings, Str.toStringz(key), object, Str.toStringz(property), flags); |
|---|
| 1088 |
} |
|---|
| 1089 |
|
|---|
| 1090 |
/** |
|---|
| 1091 |
* Create a binding between the key in the settings object |
|---|
| 1092 |
* and the property property of object. |
|---|
| 1093 |
* The binding uses the provided mapping functions to map between |
|---|
| 1094 |
* settings and property values. |
|---|
| 1095 |
* Note that the lifecycle of the binding is tied to the object, |
|---|
| 1096 |
* and that you can have only one binding per object property. |
|---|
| 1097 |
* If you bind the same property twice on the same object, the second |
|---|
| 1098 |
* binding overrides the first one. |
|---|
| 1099 |
* Since 2.26 |
|---|
| 1100 |
* Params: |
|---|
| 1101 |
* key = the key to bind |
|---|
| 1102 |
* object = a GObject. [type GObject.Object] |
|---|
| 1103 |
* property = the name of the property to bind |
|---|
| 1104 |
* flags = flags for the binding |
|---|
| 1105 |
* getMapping = a function that gets called to convert values |
|---|
| 1106 |
* from settings to object, or NULL to use the default GIO mapping |
|---|
| 1107 |
* setMapping = a function that gets called to convert values |
|---|
| 1108 |
* from object to settings, or NULL to use the default GIO mapping |
|---|
| 1109 |
* userData = data that gets passed to get_mapping and set_mapping |
|---|
| 1110 |
* destroy = GDestroyNotify function for user_data |
|---|
| 1111 |
*/ |
|---|
| 1112 |
public void bindWithMapping(string key, void* object, string property, GSettingsBindFlags flags, GSettingsBindGetMapping getMapping, GSettingsBindSetMapping setMapping, void* userData, GDestroyNotify destroy) |
|---|
| 1113 |
{ |
|---|
| 1114 |
// void g_settings_bind_with_mapping (GSettings *settings, const gchar *key, gpointer object, const gchar *property, GSettingsBindFlags flags, GSettingsBindGetMapping get_mapping, GSettingsBindSetMapping set_mapping, gpointer user_data, GDestroyNotify destroy); |
|---|
| 1115 |
g_settings_bind_with_mapping(gSettings, Str.toStringz(key), object, Str.toStringz(property), flags, getMapping, setMapping, userData, destroy); |
|---|
| 1116 |
} |
|---|
| 1117 |
|
|---|
| 1118 |
/** |
|---|
| 1119 |
* Create a binding between the writability of key in the |
|---|
| 1120 |
* settings object and the property property of object. |
|---|
| 1121 |
* The property must be boolean; "sensitive" or "visible" |
|---|
| 1122 |
* properties of widgets are the most likely candidates. |
|---|
| 1123 |
* Writable bindings are always uni-directional; changes of the |
|---|
| 1124 |
* writability of the setting will be propagated to the object |
|---|
| 1125 |
* property, not the other way. |
|---|
| 1126 |
* When the inverted argument is TRUE, the binding inverts the |
|---|
| 1127 |
* value as it passes from the setting to the object, i.e. property |
|---|
| 1128 |
* will be set to TRUE if the key is not |
|---|
| 1129 |
* writable. |
|---|
| 1130 |
* Note that the lifecycle of the binding is tied to the object, |
|---|
| 1131 |
* and that you can have only one binding per object property. |
|---|
| 1132 |
* If you bind the same property twice on the same object, the second |
|---|
| 1133 |
* binding overrides the first one. |
|---|
| 1134 |
* Since 2.26 |
|---|
| 1135 |
* Params: |
|---|
| 1136 |
* key = the key to bind |
|---|
| 1137 |
* object = a GObject. [type GObject.Object] |
|---|
| 1138 |
* property = the name of a boolean property to bind |
|---|
| 1139 |
* inverted = whether to 'invert' the value |
|---|
| 1140 |
*/ |
|---|
| 1141 |
public void bindWritable(string key, void* object, string property, int inverted) |
|---|
| 1142 |
{ |
|---|
| 1143 |
// void g_settings_bind_writable (GSettings *settings, const gchar *key, gpointer object, const gchar *property, gboolean inverted); |
|---|
| 1144 |
g_settings_bind_writable(gSettings, Str.toStringz(key), object, Str.toStringz(property), inverted); |
|---|
| 1145 |
} |
|---|
| 1146 |
|
|---|
| 1147 |
/** |
|---|
| 1148 |
* Removes an existing binding for property on object. |
|---|
| 1149 |
* Note that bindings are automatically removed when the |
|---|
| 1150 |
* object is finalized, so it is rarely necessary to call this |
|---|
| 1151 |
* function. |
|---|
| 1152 |
* Since 2.26 |
|---|
| 1153 |
* Params: |
|---|
| 1154 |
* object = the object |
|---|
| 1155 |
* property = the property whose binding is removed |
|---|
| 1156 |
*/ |
|---|
| 1157 |
public static void unbind(void* object, string property) |
|---|
| 1158 |
{ |
|---|
| 1159 |
// void g_settings_unbind (gpointer object, const gchar *property); |
|---|
| 1160 |
g_settings_unbind(object, Str.toStringz(property)); |
|---|
| 1161 |
} |
|---|
| 1162 |
} |
|---|