diff options
author | James Booth <boothj5@gmail.com> | 2012-05-10 10:02:03 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-05-10 10:02:03 +0100 |
commit | f621787e51d27d3541345cdaba4d2a0f920400f9 (patch) | |
tree | 1b484fb3b5e4351a75e52b9f1a81e8db439e5aec | |
parent | aa26278a4611157e3eb8e55239bd6cd4f2a6b687 (diff) | |
download | profani-tty-f621787e51d27d3541345cdaba4d2a0f920400f9.tar.gz |
Write properties on change
-rw-r--r-- | preferences.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/preferences.c b/preferences.c index 7b33b390..32790225 100644 --- a/preferences.c +++ b/preferences.c @@ -23,11 +23,14 @@ #include <stdlib.h> #include <glib.h> +static GString *prefs_loc; static GKeyFile *prefs; +void _save_prefs(void); + void prefs_load(void) { - GString *prefs_loc = g_string_new(getenv("HOME")); + prefs_loc = g_string_new(getenv("HOME")); g_string_append(prefs_loc, "/.profanity"); prefs = g_key_file_new(); @@ -47,6 +50,7 @@ gboolean prefs_get_beep(void) void prefs_set_beep(gboolean value) { g_key_file_set_boolean(prefs, "ui", "beep", value); + _save_prefs(); } gboolean prefs_get_flash(void) @@ -57,4 +61,12 @@ gboolean prefs_get_flash(void) void prefs_set_flash(gboolean value) { g_key_file_set_boolean(prefs, "ui", "flash", value); + _save_prefs(); +} + +void _save_prefs(void) +{ + gsize g_data_size; + char *g_prefs_data = g_key_file_to_data(prefs, &g_data_size, NULL); + g_file_set_contents(prefs_loc->str, g_prefs_data, g_data_size, NULL); } |