diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2022-02-16 06:28:00 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2022-02-16 06:28:00 +0200 |
commit | dd114c2e44f5e5a4b5058db8bb9e37232d28eade (patch) | |
tree | 8b6101aa421a55e3cb02a882117ece810213d577 | |
parent | e455699fca461e7e73d920a9ebfe557c20a67f98 (diff) |
Cleanup: Omit empty sitespec.ini sections
-rw-r--r-- | src/sitespec.c | 11 | ||||
-rw-r--r-- | src/ui/util.c | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/sitespec.c b/src/sitespec.c index 21edc0a2..5133abe5 100644 --- a/src/sitespec.c +++ b/src/sitespec.c | |||
@@ -179,7 +179,7 @@ static void save_SiteSpec_(iSiteSpec *d) { | |||
179 | iBeginCollect(); | 179 | iBeginCollect(); |
180 | const iBlock * key = &i.value->keyBlock; | 180 | const iBlock * key = &i.value->keyBlock; |
181 | const iSiteParams *params = i.value->object; | 181 | const iSiteParams *params = i.value->object; |
182 | format_String(buf, "[%s]\n", cstr_Block(key)); | 182 | clear_String(buf); |
183 | if (params->titanPort) { | 183 | if (params->titanPort) { |
184 | appendFormat_String(buf, "titanPort = %u\n", params->titanPort); | 184 | appendFormat_String(buf, "titanPort = %u\n", params->titanPort); |
185 | } | 185 | } |
@@ -201,8 +201,13 @@ static void save_SiteSpec_(iSiteSpec *d) { | |||
201 | append_String(buf, collect_String(quote_String(¶ms->paletteSeed, iFalse))); | 201 | append_String(buf, collect_String(quote_String(¶ms->paletteSeed, iFalse))); |
202 | appendCStr_String(buf, "\"\n"); | 202 | appendCStr_String(buf, "\"\n"); |
203 | } | 203 | } |
204 | appendCStr_String(buf, "\n"); | 204 | if (!isEmpty_String(buf)) { |
205 | write_File(f, utf8_String(buf)); | 205 | writeData_File(f, "[", 1); |
206 | writeData_File(f, constData_Block(key), size_Block(key)); | ||
207 | writeData_File(f, "]\n", 2); | ||
208 | appendCStr_String(buf, "\n"); | ||
209 | write_File(f, utf8_String(buf)); | ||
210 | } | ||
206 | iEndCollect(); | 211 | iEndCollect(); |
207 | } | 212 | } |
208 | delete_String(buf); | 213 | delete_String(buf); |
diff --git a/src/ui/util.c b/src/ui/util.c index 5cd8a582..94e4b00c 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -3265,9 +3265,11 @@ static void closeSiteSpecific_(iWidget *dlg) { | |||
3265 | 3265 | ||
3266 | static iBool siteSpecificSettingsHandler_(iWidget *dlg, const char *cmd) { | 3266 | static iBool siteSpecificSettingsHandler_(iWidget *dlg, const char *cmd) { |
3267 | if (equal_Command(cmd, "cancel")) { | 3267 | if (equal_Command(cmd, "cancel")) { |
3268 | const iBool wasNoFade = (flags_Widget(dlg) & noFadeBackground_WidgetFlag) != 0; | ||
3268 | iInputWidget *palSeed = findChild_Widget(dlg, "sitespec.palette"); | 3269 | iInputWidget *palSeed = findChild_Widget(dlg, "sitespec.palette"); |
3269 | setText_InputWidget(palSeed, userData_Object(dlg)); | 3270 | setText_InputWidget(palSeed, userData_Object(dlg)); |
3270 | updateSiteSpecificTheme_(palSeed, dlg); | 3271 | updateSiteSpecificTheme_(palSeed, dlg); |
3272 | setFlags_Widget(dlg, noFadeBackground_WidgetFlag, wasNoFade); | ||
3271 | closeSiteSpecific_(dlg); | 3273 | closeSiteSpecific_(dlg); |
3272 | return iTrue; | 3274 | return iTrue; |
3273 | } | 3275 | } |