diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2024-12-19 08:51:52 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2024-12-19 14:38:19 +0100 |
commit | 531f18d827dd515befa8a91f5ac80c6b3872498d (patch) | |
tree | 5cbfc9e79b0335d19141511b57df285f580ed51a /src/utils.c | |
parent | 862cde36aeaf9b6fbaadc9ab32b95eaa3a8ba7f4 (diff) | |
download | tdv-531f18d827dd515befa8a91f5ac80c6b3872498d.tar.gz tdv-531f18d827dd515befa8a91f5ac80c6b3872498d.tar.xz tdv-531f18d827dd515befa8a91f5ac80c6b3872498d.zip |
GUI: add basic configuration
It is simply not feasible to write the text file by hand on Windows.
Diffstat (limited to 'src/utils.c')
-rw-r--r-- | src/utils.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/utils.c b/src/utils.c index 0926848..ab5f2e7 100644 --- a/src/utils.c +++ b/src/utils.c @@ -222,7 +222,7 @@ load_project_config_file (GError **error) // which is completely undocumented g_key_file_load_from_dirs (key_file, PROJECT_NAME G_DIR_SEPARATOR_S PROJECT_NAME ".conf", - paths, NULL, 0, &e); + paths, NULL, G_KEY_FILE_KEEP_COMMENTS, &e); g_free (paths); if (!e) return key_file; @@ -236,6 +236,25 @@ load_project_config_file (GError **error) return NULL; } +gboolean +save_project_config_file (GKeyFile *key_file, GError **error) +{ + gchar *dirname = + g_build_filename (g_get_user_config_dir (), PROJECT_NAME, NULL); + (void) g_mkdir_with_parents (dirname, 0755); + gchar *path = g_build_filename (dirname, PROJECT_NAME ".conf", NULL); + g_free (dirname); + + gsize length = 0; + gchar *data = g_key_file_to_data (key_file, &length, error); + if (!data) + return FALSE; + + gboolean result = g_file_set_contents (path, data, length, error); + g_free (data); + return result; +} + // --- Loading ----------------------------------------------------------------- void |