File: WPESettings.cpp

package info (click to toggle)
wpewebkit 2.48.3-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 421,720 kB
  • sloc: cpp: 3,670,389; javascript: 194,411; ansic: 165,592; python: 46,476; asm: 19,276; ruby: 18,528; perl: 16,602; xml: 4,650; yacc: 2,360; java: 1,993; sh: 1,948; lex: 1,327; pascal: 366; makefile: 85
file content (566 lines) | stat: -rw-r--r-- 21,219 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
/*
 * Copyright (C) 2024 Igalia S.L.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "config.h"
#include "WPESettings.h"

#include <glib.h>
#include <wpe/WPEDisplay.h>
#include <wtf/HashMap.h>
#include <wtf/glib/GRefPtr.h>
#include <wtf/glib/GUniquePtr.h>
#include <wtf/glib/WTFGType.h>
#include <wtf/text/CString.h>


struct SettingEntry {
    SettingEntry() = default;

    SettingEntry(GRefPtr<GVariant>&& defaultValue, GUniquePtr<GVariantType>&& type)
        : defaultValue(WTFMove(defaultValue))
        , type(WTFMove(type))
    {
    }

    GRefPtr<GVariant> value() const
    {
        return setValue ? setValue : defaultValue;
    }

    GRefPtr<GVariant> setValue;
    GRefPtr<GVariant> defaultValue;
    GUniquePtr<GVariantType> type;
    bool setByApplication { false };
};

/**
 * wpe_settings_error_quark:
 *
 * Gets the WPESettings Error Quark.
 *
 * Returns: a #GQuark.
 **/
G_DEFINE_QUARK(wpe-settings-error-quark, wpe_settings_error)

/**
 * WPESettings:
 *
 * This class stores settings for the WPE platform.
 *
 * It is a map of keys to arbitrary values. These keys are registered with [method@WPESettings.register].
 *
 * They can be stored and loaded with [method@WPESettings.save_to_keyfile] and [method@WPESettings.load_from_keyfile].
 *
 * The [signal@WPESettings::changed] signal is emitted when a setting is changed. You can connect to the detailed signal
 * to watch a specific key, e.g. `changed::/wpe-platform/fonts/font-hinting`.
 */
struct _WPESettingsPrivate {
    HashMap<CString, SettingEntry> settings;

    _WPESettingsPrivate()
    {
        struct Setting {
            const char* key;
            const GVariantType* type;
            GVariant* defaultValue;
        };

        // We convert all floating refs to normal as multiple instances share the same static objects.
        static const std::vector<Setting> defaultSettings = {
            { WPE_SETTING_FONT_NAME, G_VARIANT_TYPE_STRING, g_variant_ref_sink(g_variant_new_string("Sans 10")) },
            { WPE_SETTING_DARK_MODE, G_VARIANT_TYPE_BOOLEAN, g_variant_ref_sink(g_variant_new_boolean(false)) },
            { WPE_SETTING_DISABLE_ANIMATIONS, G_VARIANT_TYPE_BOOLEAN, g_variant_ref_sink(g_variant_new_boolean(false)) },
            { WPE_SETTING_FONT_ANTIALIAS, G_VARIANT_TYPE_BOOLEAN, g_variant_ref_sink(g_variant_new_boolean(true)) },
            { WPE_SETTING_FONT_HINTING_STYLE, G_VARIANT_TYPE_BYTE, g_variant_ref_sink(g_variant_new_byte(WPE_SETTINGS_HINTING_STYLE_SLIGHT)) },
            { WPE_SETTING_FONT_SUBPIXEL_LAYOUT, G_VARIANT_TYPE_BYTE, g_variant_ref_sink(g_variant_new_byte(WPE_SETTINGS_SUBPIXEL_LAYOUT_RGB)) },
            { WPE_SETTING_FONT_DPI, G_VARIANT_TYPE_DOUBLE, g_variant_ref_sink(g_variant_new_double(96.0)) },
            { WPE_SETTING_KEY_REPEAT_DELAY, G_VARIANT_TYPE_UINT32, g_variant_ref_sink(g_variant_new_uint32(400)) },
            { WPE_SETTING_KEY_REPEAT_INTERVAL, G_VARIANT_TYPE_UINT32, g_variant_ref_sink(g_variant_new_uint32(80)) },
            { WPE_SETTING_CURSOR_BLINK_TIME, G_VARIANT_TYPE_UINT32, g_variant_ref_sink(g_variant_new_uint32(1200)) },
            { WPE_SETTING_TOPLEVEL_DEFAULT_SIZE, G_VARIANT_TYPE("(uu)"), g_variant_ref_sink(g_variant_new("(uu)", 1024, 768)) },
            { WPE_SETTING_DOUBLE_CLICK_DISTANCE, G_VARIANT_TYPE_UINT32, g_variant_ref_sink(g_variant_new_uint32(5)) },
            { WPE_SETTING_DOUBLE_CLICK_TIME, G_VARIANT_TYPE_UINT32, g_variant_ref_sink(g_variant_new_uint32(400)) },
            { WPE_SETTING_DRAG_THRESHOLD, G_VARIANT_TYPE_UINT32, g_variant_ref_sink(g_variant_new_uint32(8)) },
        };

        for (auto& setting : defaultSettings)
            settings.add(setting.key, SettingEntry(setting.defaultValue, GUniquePtr<GVariantType>(g_variant_type_copy(setting.type))));
    }
};

enum {
    CHANGED,

    LAST_SIGNAL
};

static std::array<unsigned, LAST_SIGNAL> signals;

WEBKIT_DEFINE_FINAL_TYPE(WPESettings, wpe_settings, G_TYPE_OBJECT, GObject)

static void wpe_settings_class_init(WPESettingsClass* settingsClass)
{
    /**
     * WPESettings::changed:
     * @settings: a #WPESettings
     * @key: the key that changed
     * @value: the new value
     *
     * Emitted when a settings is changed.
     * It will contain a detail of the specific key that changed.
     */
    signals[CHANGED] = g_signal_new(
        "changed",
        G_TYPE_FROM_CLASS(G_OBJECT_CLASS(settingsClass)),
        static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED),
        0, nullptr, nullptr,
        g_cclosure_marshal_generic,
        G_TYPE_NONE, 2,
        G_TYPE_STRING,
        G_TYPE_VARIANT);
}

static CString makeKeyPath(const char* group, const char* key)
{
    std::span<char> buffer;
    size_t length = strlen(group) + strlen(key) + 3;

    CString path = CString::newUninitialized(length - 1, buffer);
    g_snprintf(buffer.data(), length, "/%s/%s", group, key);

    return path;
}

/**
 * wpe_settings_register:
 * @settings: a #WPESettings
 * @key: the key to register
 * @type: the type of the setting
 * @default_value: (transfer floating): the default value for the setting
 * @error: return location for a #GError, or %NULL
 *
 * Registers a key to be used for settings. This is only intended to be used by platforms and not applications.
 *
 * The key must begin with `/wpe-platform/` and not end with `/`. e.g. `/wpe-platform/fonts/hinting`.
 *
 * Any floating reference of @default_value will be consumed.
 *
 * It is an error to call this function with a key that has already been registered.
 */
gboolean wpe_settings_register(WPESettings* settingsObject, const char* key, const GVariantType* type, GVariant* defaultValue, GError** error)
{
    g_return_val_if_fail(WPE_IS_SETTINGS(settingsObject), FALSE);
    g_return_val_if_fail(key && g_str_has_prefix(key, "/wpe-platform/") && !g_str_has_suffix(key, "/"), FALSE);
    g_return_val_if_fail(defaultValue, FALSE);
    g_return_val_if_fail(type, FALSE);
    g_return_val_if_fail(g_variant_type_equal(type, g_variant_get_type(defaultValue)), FALSE);

    if (settingsObject->priv->settings.contains(key)) {
        g_set_error(error, WPE_SETTINGS_ERROR, WPE_SETTINGS_ERROR_ALREADY_REGISTERED, "%s has already been reigstered", key);
        return FALSE;
    }

    settingsObject->priv->settings.add(key, SettingEntry(defaultValue, GUniquePtr<GVariantType>(g_variant_type_copy(type))));

    return TRUE;
}

/**
 * wpe_settings_load_from_keyfile:
 * @settings: a #WPESettings
 * @keyfile: the keyfile to load settings from
 * @error: return location for a #GError, or %NULL
 *
 * Loads settings from a keyfile.
 *
 * Only groups named `wpe-platform` or with the prefix `wpe-platform/` will be considered.
 * All keys under these groups must be registered with [method@WPESettings.register].
 *
 * If a value is already set it will be overwritten.
 *
 * All keys loaded are expected to be formatted as a GVariant.
 *
 * [signal@WPESettings::changed] will be emitted for each key that is loaded with a *new* value.
 *
 * Returns: %TRUE if the settings were loaded successfully, %FALSE otherwise.
 */
gboolean wpe_settings_load_from_keyfile(WPESettings* settingsObject, GKeyFile* keyFile, GError** error)
{
    g_return_val_if_fail(WPE_IS_SETTINGS(settingsObject), FALSE);
    g_return_val_if_fail(!error || !*error, FALSE);
    g_return_val_if_fail(keyFile, FALSE);

    GUniquePtr<char*> groups(g_key_file_get_groups(keyFile, nullptr));
    for (unsigned i = 0; groups.get()[i]; i++) {
        const char* group = groups.get()[i];

        if (!g_str_has_prefix(group, "wpe-platform/") && strcmp(group, "wpe-platform"))
            continue;

        GUniquePtr<char*> keys(g_key_file_get_keys(keyFile, group, nullptr, nullptr));

        for (unsigned k = 0; keys.get()[k]; k++) {
            const char* key = keys.get()[k];
            GUniquePtr<char> value(g_key_file_get_value(keyFile, group, key, nullptr));
            if (!value)
                continue;

            auto path = makeKeyPath(group, key);
            auto iter = settingsObject->priv->settings.find(path);
            if (iter == settingsObject->priv->settings.end()) {
                g_set_error(error, WPE_SETTINGS_ERROR, WPE_SETTINGS_ERROR_NOT_REGISTERED, "Key %s not registered", path.data());
                return FALSE;
            }

            GUniqueOutPtr<GError> innerError;
            GRefPtr<GVariant> parsedValue = adoptGRef(g_variant_parse(iter->value.type.get(), value.get(), nullptr, nullptr, &innerError.outPtr()));
            if (!parsedValue) {
                g_set_error(error, WPE_SETTINGS_ERROR, WPE_SETTINGS_ERROR_INVALID_VALUE, "Failed to parse value for key %s: %s", path.data(), innerError->message);
                return FALSE;
            }

            if (iter->value.setValue && !g_variant_compare(iter->value.setValue.get(), parsedValue.get()))
                continue;

            iter->value.setValue = WTFMove(parsedValue);
            g_signal_emit(settingsObject, signals[CHANGED], g_quark_from_string(path.data()), path.data(), iter->value.setValue.get());
        }
    }

    return TRUE;
}

/**
 * wpe_settings_save_to_keyfile:
 * @settings: a #WPESettings
 * @keyfile: the keyfile to save settings to
 *
 * Adds settings to a keyfile. Keys are transformed into group names, for example:
 * `/wpe-platform/fonts/hinting` will be saved as `hinting` in the group `wpe-platform/fonts`.
 *
 * Any existing values in the keyfile will be overwritten.
 */
void wpe_settings_save_to_keyfile(WPESettings* settingsObject, GKeyFile* keyFile)
{
    g_return_if_fail(WPE_IS_SETTINGS(settingsObject));
    g_return_if_fail(keyFile);

    for (auto& [key, entry] : settingsObject->priv->settings) {
        if (!entry.setValue)
            continue;

        // Transform "/foo/bar/baz" into "foo/bar" and "baz".
        GUniquePtr<char> keyString(g_strdup(key.data()));
        auto* keyStart = strrchr(keyString.get(), '/');
        ASSERT(keyStart && keyStart != keyString.get());
        *keyStart = '\0';
        keyStart++;

        const char* group = keyString.get() + 1;
        // FIXME: Handle empty?

        GUniquePtr<char> variantString(g_variant_print(entry.setValue.get(), FALSE));
        g_key_file_set_value(keyFile, group, keyStart, variantString.get());
    }
}

/**
 * wpe_settings_set_value:
 * @settings: a #WPESettings
 * @key: the key to set
 * @value: (transfer floating) (nullable): the value to set or %NULL
 * @source: the source of the settings change
 * @error: return location for a #GError, or %NULL
 *
 * If @source is %WPE_SETTINGS_SOURCE_APPLICATION, then the value will not be overwritten by the platform.
 * This value should always be %WPE_SETTINGS_SOURCE_PLATFORM for platforms themselves. This can cause this
 * method to return %TRUE even though no setting changes.
 *
 * To set a value @key must have been registered and @value must be of the correct type.
 *
 * Any floating reference of @value will be consumed.
 *
 * Setting @value to %NULL will reset it to the default.
 *
 * On a value being changed it will emit [signal@WPESettings::changed].
 *
 * Returns: %FALSE if @error was set, %TRUE otherwise
 */
gboolean wpe_settings_set_value(WPESettings* settingsObject, const char* key, GVariant* value, WPESettingsSource source, GError** error)
{
    g_return_val_if_fail(WPE_IS_SETTINGS(settingsObject), FALSE);
    g_return_val_if_fail(!error || !*error, FALSE);
    g_return_val_if_fail(key && *key == '/', FALSE);

    auto iter = settingsObject->priv->settings.find(key);
    if (iter == settingsObject->priv->settings.end()) {
        g_set_error(error, WPE_SETTINGS_ERROR, WPE_SETTINGS_ERROR_NOT_REGISTERED, "Key %s not registered", key);
        return FALSE;
    }

    if (iter->value.setByApplication && source != WPE_SETTINGS_SOURCE_APPLICATION)
        return TRUE;

    if (!value) {
        auto previousValue = iter->value.setValue;
        iter->value.setValue = nullptr;
        iter->value.setByApplication = source == WPE_SETTINGS_SOURCE_APPLICATION;
        if (previousValue && g_variant_compare(previousValue.get(), iter->value.defaultValue.get()))
            g_signal_emit(settingsObject, signals[CHANGED], g_quark_from_string(key), key, iter->value.value().get());
        return TRUE;
    }

    if (!g_variant_type_equal(g_variant_get_type(value), iter->value.type.get())) {
        g_set_error(error, WPE_SETTINGS_ERROR, WPE_SETTINGS_ERROR_INCORRECT_TYPE,
            "Incorrect type (%s) for key %s", g_variant_get_type_string(value), key);
        return FALSE;
    }

    auto previousValue = iter->value.value();
    iter->value.setValue = value;
    iter->value.setByApplication = source == WPE_SETTINGS_SOURCE_APPLICATION;

    if (g_variant_compare(previousValue.get(), value))
        g_signal_emit(settingsObject, signals[CHANGED], g_quark_from_string(key), key, iter->value.value().get());

    return TRUE;
}

/**
 * wpe_settings_get_value:
 * @settings: a #WPESettings
 * @key: the key to look up
 * @error: return location for a #GError, or %NULL
 *
 * If the key is not registered it will return %NULL and set @error.
 *
 * Returns: (transfer none): the value associated with the given key.
 */
GVariant* wpe_settings_get_value(WPESettings* settingsObject, const char* key, GError** error)
{
    g_return_val_if_fail(WPE_IS_SETTINGS(settingsObject), NULL);
    g_return_val_if_fail(key && *key == '/', NULL);

    const auto iter = settingsObject->priv->settings.find(key);
    if (iter == settingsObject->priv->settings.end()) {
        g_set_error(error, WPE_SETTINGS_ERROR, WPE_SETTINGS_ERROR_NOT_REGISTERED, "Key %s not registered", key);
        return nullptr;
    }

    return iter->value.value().get();
}

#define g_variant_get_string(str) g_variant_get_string(str, nullptr)
#define WPE_SETTINGS_HELPER_API(type, name, gvariant_type, retval) \
    type wpe_settings_get_##name(WPESettings* settings, const char* key, GError** error) \
    { \
        GVariant* value = wpe_settings_get_value(settings, key, error); \
        if (!value) \
            return retval; \
        if (!g_variant_type_equal(g_variant_get_type(value), gvariant_type)) { \
            g_set_error(error, WPE_SETTINGS_ERROR, WPE_SETTINGS_ERROR_INCORRECT_TYPE, \
                "Key is type %s, expected %s", g_variant_get_type_string(value), reinterpret_cast<const char*>(gvariant_type)); \
            return retval; \
        } \
        return g_variant_get_##name(value); \
    } \
    gboolean wpe_settings_set_##name(WPESettings* settings, const char* key, type value, WPESettingsSource source, GError** error) \
    { \
        return wpe_settings_set_value(settings, key, g_variant_new_##name(value), source, error); \
    }

// Unfortunately the gobject-introspection parser doesn't like comments in macros.

/**
 * wpe_settings_set_int32:
 * @settings: a #WPESettings
 * @key: the key to look up
 * @value: the value to set
 * @source: the source of the settings change
 * @error: return location for a #GError or %NULL
 *
 * This is a simple wrapper around [method@WPESettings.set_value] that also validates
 * the type.
 */
/**
 * wpe_settings_get_int32:
 * @settings: a #WPESettings
 * @key: the key to look up
 * @error: return location for a #GError or %NULL
 *
 * This is a simple wrapper around [method@WPESettings.get_value] that also validates
 * the return type.
 */
WPE_SETTINGS_HELPER_API(gint32, int32, G_VARIANT_TYPE_INT32, 0)
/**
 * wpe_settings_set_int64:
 * @settings: a #WPESettings
 * @key: the key to look up
 * @value: the value to set
 * @source: the source of the settings change
 * @error: return location for a #GError or %NULL
 *
 * This is a simple wrapper around [method@WPESettings.set_value] that also validates
 * the type.
 */
/**
 * wpe_settings_get_int64:
 * @settings: a #WPESettings
 * @key: the key to look up
 * @error: return location for a #GError or %NULL
 *
 * This is a simple wrapper around [method@WPESettings.get_value] that also validates
 * the return type.
 */
WPE_SETTINGS_HELPER_API(gint64, int64, G_VARIANT_TYPE_INT64, 0)
/**
 * wpe_settings_set_byte:
 * @settings: a #WPESettings
 * @key: the key to look up
 * @value: the value to set
 * @source: the source of the settings change
 * @error: return location for a #GError or %NULL
 *
 * This is a simple wrapper around [method@WPESettings.set_value] that also validates
 * the type.
 */
/**
 * wpe_settings_get_byte:
 * @settings: a #WPESettings
 * @key: the key to look up
 * @error: return location for a #GError or %NULL
 *
 * This is a simple wrapper around [method@WPESettings.get_value] that also validates
 * the return type.
 */
WPE_SETTINGS_HELPER_API(guint8, byte, G_VARIANT_TYPE_BYTE, 0)
/**
 * wpe_settings_set_uint32:
 * @settings: a #WPESettings
 * @key: the key to look up
 * @value: the value to set
 * @source: the source of the settings change
 * @error: return location for a #GError or %NULL
 *
 * This is a simple wrapper around [method@WPESettings.set_value] that also validates
 * the type.
 */
/**
 * wpe_settings_get_uint32:
 * @settings: a #WPESettings
 * @key: the key to look up
 * @error: return location for a #GError or %NULL
 *
 * This is a simple wrapper around [method@WPESettings.get_value] that also validates
 * the return type.
 */
WPE_SETTINGS_HELPER_API(guint32, uint32, G_VARIANT_TYPE_UINT32, 0)
/**
 * wpe_settings_set_uint64:
 * @settings: a #WPESettings
 * @key: the key to look up
 * @value: the value to set
 * @source: the source of the settings change
 * @error: return location for a #GError or %NULL
 *
 * This is a simple wrapper around [method@WPESettings.set_value] that also validates
 * the type.
 */
/**
 * wpe_settings_get_uint64:
 * @settings: a #WPESettings
 * @key: the key to look up
 * @error: return location for a #GError or %NULL
 *
 * This is a simple wrapper around [method@WPESettings.get_value] that also validates
 * the return type.
 */
WPE_SETTINGS_HELPER_API(guint64, uint64, G_VARIANT_TYPE_UINT64, 0)
/**
 * wpe_settings_set_boolean:
 * @settings: a #WPESettings
 * @key: the key to look up
 * @value: the value to set
 * @source: the source of the settings change
 * @error: return location for a #GError or %NULL
 *
 * This is a simple wrapper around [method@WPESettings.set_value] that also validates
 * the type.
 */
/**
 * wpe_settings_get_boolean:
 * @settings: a #WPESettings
 * @key: the key to look up
 * @error: return location for a #GError or %NULL
 *
 * This is a simple wrapper around [method@WPESettings.get_value] that also validates
 * the return type.
 */
WPE_SETTINGS_HELPER_API(gboolean, boolean, G_VARIANT_TYPE_BOOLEAN, FALSE)
/**
 * wpe_settings_set_string:
 * @settings: a #WPESettings
 * @key: the key to look up
 * @value: the value to set
 * @source: the source of the settings change
 * @error: return location for a #GError or %NULL
 *
 * This is a simple wrapper around [method@WPESettings.set_value] that also validates
 * the type.
 */
/**
 * wpe_settings_get_string:
 * @settings: a #WPESettings
 * @key: the key to look up
 * @error: return location for a #GError or %NULL
 *
 * This is a simple wrapper around [method@WPESettings.get_value] that also validates
 * the return type.
 */
WPE_SETTINGS_HELPER_API(const char*, string, G_VARIANT_TYPE_STRING, nullptr)
/**
 * wpe_settings_set_double:
 * @settings: a #WPESettings
 * @key: the key to look up
 * @value: the value to set
 * @source: the source of the settings change
 * @error: return location for a #GError or %NULL
 *
 * This is a simple wrapper around [method@WPESettings.set_value] that also validates
 * the type.
 */
/**
 * wpe_settings_get_double:
 * @settings: a #WPESettings
 * @key: the key to look up
 * @error: return location for a #GError or %NULL
 *
 * This is a simple wrapper around [method@WPESettings.get_value] that also validates
 * the return type.
 */
WPE_SETTINGS_HELPER_API(gdouble, double, G_VARIANT_TYPE_DOUBLE, 0.0)

#undef WPE_SETTINGS_HELPER_API
#undef g_variant_get_string