GTK: save boolean settings as JSON booleans.

pull/307/merge
whitequark 2018-07-17 16:05:15 +00:00
parent 26f3751ce8
commit 84bf37abed
1 changed files with 13 additions and 0 deletions

View File

@ -120,6 +120,19 @@ public:
return defaultValue; return defaultValue;
} }
void FreezeBool(const std::string &key, bool value) override {
struct json_object *jsonValue = json_object_new_boolean(value);
json_object_object_add(_json, key.c_str(), jsonValue);
}
bool ThawBool(const std::string &key, bool defaultValue) override {
struct json_object *jsonValue;
if(json_object_object_get_ex(_json, key.c_str(), &jsonValue)) {
return json_object_get_boolean(jsonValue);
}
return defaultValue;
}
void FreezeFloat(const std::string &key, double value) override { void FreezeFloat(const std::string &key, double value) override {
struct json_object *jsonValue = json_object_new_double(value); struct json_object *jsonValue = json_object_new_double(value);
json_object_object_add(_json, key.c_str(), jsonValue); json_object_object_add(_json, key.c_str(), jsonValue);