SameBoy/gtk3/settings.c

40 lines
942 B
C
Raw Normal View History

#include "settings.h"
void init_settings(const gchar *path) {
key_file = g_key_file_new();
GError *error = NULL;
if (path != NULL) {
settings_file_path = path;
}
else {
settings_file_path = g_build_filename(g_get_user_config_dir(), SETTINGS_FILE, NULL);
}
load_settings();
}
void load_settings(void) {
GError *error = NULL;
g_print("Trying to load settings from %s\n", settings_file_path);
if (!g_key_file_load_from_file(key_file, settings_file_path, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, &error)) {
g_warning("Error loading %s: %s", settings_file_path, error->message);
g_error_free(error);
}
}
void save_settings(void) {
GError *error = NULL;
g_print("Trying to save settings to %s\n", settings_file_path);
if (!g_key_file_save_to_file(key_file, settings_file_path, &error)) {
g_warning ("Error saving %s: %s", settings_file_path, error->message);
g_error_free(error);
return;
}
}