From db076b9c8e01e3e92340712a29d269c464bcf9f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Tue, 24 Aug 2021 17:40:22 +0200 Subject: HeaderLayout: save name in configuration Use a name in the user configuration file instead of the compile time enum value, so that future reorderings or insertions do not change the user selected layout. --- Settings.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Settings.c') diff --git a/Settings.c b/Settings.c index 756e256c..1f95abab 100644 --- a/Settings.c +++ b/Settings.c @@ -7,6 +7,7 @@ in the source distribution for its full text. #include "Settings.h" +#include #include #include #include @@ -266,7 +267,7 @@ static bool Settings_read(Settings* this, const char* fileName, unsigned int ini this->enableMouse = atoi(option[1]); #endif } else if (String_eq(option[0], "header_layout")) { - this->hLayout = atoi(option[1]); + this->hLayout = isdigit((unsigned char)option[1][0]) ? ((HeaderLayout) atoi(option[1])) : HeaderLayout_fromName(option[1]); if (this->hLayout < 0 || this->hLayout >= LAST_HEADER_LAYOUT) this->hLayout = HF_TWO_50_50; free(this->hColumns); @@ -394,7 +395,7 @@ int Settings_write(const Settings* this, bool onCrash) { fprintf(fd, "enable_mouse=%d\n", (int) this->enableMouse); #endif fprintf(fd, "delay=%d\n", (int) this->delay); - fprintf(fd, "header_layout=%d\n", (int) this->hLayout); + fprintf(fd, "header_layout=%s\n", HeaderLayout_getName(this->hLayout)); for (unsigned int i = 0; i < HeaderLayout_getColumns(this->hLayout); i++) { fprintf(fd, "column_meters_%u=", i); writeMeters(this, fd, i); -- cgit v1.2.3