summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
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