diff options
author | Timo Sirainen <cras@irssi.org> | 2000-07-23 12:29:50 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-07-23 12:29:50 +0000 |
commit | f83f64b6bec477ab87d63fae3088199eb821b969 (patch) | |
tree | f1342a72d73d227e033f962d9c922331b0a1d0d6 /src | |
parent | e322876342fc604b398f5a37e27c2b0b7477f344 (diff) | |
download | irssi-f83f64b6bec477ab87d63fae3088199eb821b969.zip |
/SET settings_autosave - If set ON, settings are automatically saved
when quitting and once per hour.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@516 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r-- | src/core/settings.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/settings.c b/src/core/settings.c index 5fa61064..96663c3b 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -33,6 +33,7 @@ CONFIG_REC *mainconfig; static GHashTable *settings; static char *last_error_msg; +static int timeout_tag; static const char *settings_get_default_str(const char *key) { @@ -334,12 +335,22 @@ int settings_save(const char *fname) return FALSE; } +static void sig_autosave(void) +{ + if (settings_get_bool("settings_autosave")) + settings_save(NULL); +} + void settings_init(void) { settings = g_hash_table_new((GHashFunc) g_str_hash, (GCompareFunc) g_str_equal); init_configfile(); + + settings_add_bool("misc", "settings_autosave", TRUE); + timeout_tag = g_timeout_add(1000*60*60, (GSourceFunc) sig_autosave, NULL); + signal_add("gui exit", (SIGNAL_FUNC) sig_autosave); } static void settings_hash_free(const char *key, SETTINGS_REC *rec) @@ -349,6 +360,9 @@ static void settings_hash_free(const char *key, SETTINGS_REC *rec) void settings_deinit(void) { + g_source_remove(timeout_tag); + signal_remove("gui exit", (SIGNAL_FUNC) sig_autosave); + g_free_not_null(last_error_msg); g_hash_table_foreach(settings, (GHFunc) settings_hash_free, NULL); g_hash_table_destroy(settings); |