summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2024-08-19 09:11:09 +0200
committerFelix Morgner <felix.morgner@gmail.com>2024-08-19 09:11:09 +0200
commite2dad5f30ca4d8502558e0560d2059a51aae4c4c (patch)
tree4be91eaa56c58403d77c6a5b694a9ddc49a4b481 /core/src
parenta4e62c525fdc6b9662cdd48aaef2de7e9376f062 (diff)
downloadturns-e2dad5f30ca4d8502558e0560d2059a51aae4c4c.tar.xz
turns-e2dad5f30ca4d8502558e0560d2059a51aae4c4c.zip
core: add settings accessor
Diffstat (limited to 'core/src')
-rw-r--r--core/src/settings.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/core/src/settings.cpp b/core/src/settings.cpp
new file mode 100644
index 0000000..c98e5eb
--- /dev/null
+++ b/core/src/settings.cpp
@@ -0,0 +1,28 @@
+#include "turns/core/settings.hpp"
+
+#include <glibmm/refptr.h>
+#include <glibmm/wrap.h>
+
+#include <giomm/settings.h>
+#include <giomm/settingsschemasource.h>
+
+#include <gio/gsettings.h>
+
+namespace turns::core
+{
+
+ auto get_settings() -> Glib::RefPtr<Gio::Settings>
+ {
+ auto constexpr schema_id = "ch.arknet.Turns";
+
+#ifdef TURNS_SETTINGS_SCHEMA_DIR
+ auto source = Gio::SettingsSchemaSource::create(TURNS_SETTINGS_SCHEMA_DIR "/glib-2.0/schemas", true);
+ auto schema = source->lookup(schema_id, true);
+ auto settings = g_settings_new_full(Glib::unwrap(schema), nullptr, nullptr);
+ return Glib::wrap(settings);
+#else
+ return Gio::Settings::create(schema);
+#endif
+ }
+
+} // namespace turns::core