From 6c668bce8861c24a4fd1e9d238798efb1dbd31e4 Mon Sep 17 00:00:00 2001 From: James Booth Date: Thu, 2 Jul 2015 16:31:09 +0100 Subject: [PATCH] Migrate old time display format settings --- src/config/preferences.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/config/preferences.c b/src/config/preferences.c index 56950e90..43ddae6b 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -103,6 +103,28 @@ prefs_load(void) g_error_free(err); } + // migrate pre 0.4.7 time settings format + if (g_key_file_has_key(prefs, PREF_GROUP_UI, "time", NULL)) { + char *time = g_key_file_get_string(prefs, PREF_GROUP_UI, "time", NULL); + if (g_strcmp0(time, "minutes") == 0) { + g_key_file_set_string(prefs, PREF_GROUP_UI, "time", "%H:%M"); + } else if (g_strcmp0(time, "seconds") == 0) { + g_key_file_set_string(prefs, PREF_GROUP_UI, "time", "%H:%M:%S"); + } else if (g_strcmp0(time, "off") == 0) { + g_key_file_set_string(prefs, PREF_GROUP_UI, "time", ""); + } + } + if (g_key_file_has_key(prefs, PREF_GROUP_UI, "time.statusbar", NULL)) { + char *time = g_key_file_get_string(prefs, PREF_GROUP_UI, "time.statusbar", NULL); + if (g_strcmp0(time, "minutes") == 0) { + g_key_file_set_string(prefs, PREF_GROUP_UI, "time.statusbar", "%H:%M"); + } else if (g_strcmp0(time, "seconds") == 0) { + g_key_file_set_string(prefs, PREF_GROUP_UI, "time.statusbar", "%H:%M:%S"); + } else if (g_strcmp0(time, "off") == 0) { + g_key_file_set_string(prefs, PREF_GROUP_UI, "time.statusbar", ""); + } + } + _save_prefs(); boolean_choice_ac = autocomplete_new();