From dd114c2e44f5e5a4b5058db8bb9e37232d28eade Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Wed, 16 Feb 2022 06:28:00 +0200 Subject: Cleanup: Omit empty sitespec.ini sections --- src/sitespec.c | 11 ++++++++--- src/ui/util.c | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src') 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) { iBeginCollect(); const iBlock * key = &i.value->keyBlock; const iSiteParams *params = i.value->object; - format_String(buf, "[%s]\n", cstr_Block(key)); + clear_String(buf); if (params->titanPort) { appendFormat_String(buf, "titanPort = %u\n", params->titanPort); } @@ -201,8 +201,13 @@ static void save_SiteSpec_(iSiteSpec *d) { append_String(buf, collect_String(quote_String(¶ms->paletteSeed, iFalse))); appendCStr_String(buf, "\"\n"); } - appendCStr_String(buf, "\n"); - write_File(f, utf8_String(buf)); + if (!isEmpty_String(buf)) { + writeData_File(f, "[", 1); + writeData_File(f, constData_Block(key), size_Block(key)); + writeData_File(f, "]\n", 2); + appendCStr_String(buf, "\n"); + write_File(f, utf8_String(buf)); + } iEndCollect(); } 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) { static iBool siteSpecificSettingsHandler_(iWidget *dlg, const char *cmd) { if (equal_Command(cmd, "cancel")) { + const iBool wasNoFade = (flags_Widget(dlg) & noFadeBackground_WidgetFlag) != 0; iInputWidget *palSeed = findChild_Widget(dlg, "sitespec.palette"); setText_InputWidget(palSeed, userData_Object(dlg)); updateSiteSpecificTheme_(palSeed, dlg); + setFlags_Widget(dlg, noFadeBackground_WidgetFlag, wasNoFade); closeSiteSpecific_(dlg); return iTrue; } -- cgit v1.2.3