diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2022-02-20 12:53:12 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2022-02-20 12:53:12 +0200 |
commit | 6d7b6122e68c8d53b6e7533a6e5d5f55e33831e1 (patch) | |
tree | 80bc2867510e3c9b7bc43578fc416165dae3876c /src/sitespec.c | |
parent | 2d52f13afb15232cc9c834f0aa14284bf9072a31 (diff) | |
parent | 41f378c4b46cb5dd3599d44c81fa51d3183eefee (diff) |
Merge branch 'work/v1.11' into dev
# Conflicts:
# res/lang/es.bin
# res/lang/ie.bin
# res/lang/ru.bin
# res/lang/sr.bin
# res/lang/uk.bin
Diffstat (limited to 'src/sitespec.c')
-rw-r--r-- | src/sitespec.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/sitespec.c b/src/sitespec.c index fe80ad13..5133abe5 100644 --- a/src/sitespec.c +++ b/src/sitespec.c | |||
@@ -37,7 +37,8 @@ struct Impl_SiteParams { | |||
37 | iString titanIdentity; /* fingerprint */ | 37 | iString titanIdentity; /* fingerprint */ |
38 | int dismissWarnings; | 38 | int dismissWarnings; |
39 | iStringArray usedIdentities; /* fingerprints; latest ones at the end */ | 39 | iStringArray usedIdentities; /* fingerprints; latest ones at the end */ |
40 | /* TODO: theme seed, style settings */ | 40 | iString paletteSeed; |
41 | /* TODO: style settings */ | ||
41 | }; | 42 | }; |
42 | 43 | ||
43 | void init_SiteParams(iSiteParams *d) { | 44 | void init_SiteParams(iSiteParams *d) { |
@@ -45,9 +46,11 @@ void init_SiteParams(iSiteParams *d) { | |||
45 | init_String(&d->titanIdentity); | 46 | init_String(&d->titanIdentity); |
46 | d->dismissWarnings = 0; | 47 | d->dismissWarnings = 0; |
47 | init_StringArray(&d->usedIdentities); | 48 | init_StringArray(&d->usedIdentities); |
49 | init_String(&d->paletteSeed); | ||
48 | } | 50 | } |
49 | 51 | ||
50 | void deinit_SiteParams(iSiteParams *d) { | 52 | void deinit_SiteParams(iSiteParams *d) { |
53 | deinit_String(&d->paletteSeed); | ||
51 | deinit_StringArray(&d->usedIdentities); | 54 | deinit_StringArray(&d->usedIdentities); |
52 | deinit_String(&d->titanIdentity); | 55 | deinit_String(&d->titanIdentity); |
53 | } | 56 | } |
@@ -149,6 +152,9 @@ static void handleIniKeyValue_SiteSpec_(void *context, const iString *table, con | |||
149 | pushBack_StringArray(&d->loadParams->usedIdentities, collectNewRange_String(seg)); | 152 | pushBack_StringArray(&d->loadParams->usedIdentities, collectNewRange_String(seg)); |
150 | } | 153 | } |
151 | } | 154 | } |
155 | else if (!cmp_String(key, "paletteSeed") && value->type == string_TomlType) { | ||
156 | set_String(&d->loadParams->paletteSeed, value->value.string); | ||
157 | } | ||
152 | } | 158 | } |
153 | 159 | ||
154 | static iBool load_SiteSpec_(iSiteSpec *d) { | 160 | static iBool load_SiteSpec_(iSiteSpec *d) { |
@@ -173,7 +179,7 @@ static void save_SiteSpec_(iSiteSpec *d) { | |||
173 | iBeginCollect(); | 179 | iBeginCollect(); |
174 | const iBlock * key = &i.value->keyBlock; | 180 | const iBlock * key = &i.value->keyBlock; |
175 | const iSiteParams *params = i.value->object; | 181 | const iSiteParams *params = i.value->object; |
176 | format_String(buf, "[%s]\n", cstr_Block(key)); | 182 | clear_String(buf); |
177 | if (params->titanPort) { | 183 | if (params->titanPort) { |
178 | appendFormat_String(buf, "titanPort = %u\n", params->titanPort); | 184 | appendFormat_String(buf, "titanPort = %u\n", params->titanPort); |
179 | } | 185 | } |
@@ -190,8 +196,18 @@ static void save_SiteSpec_(iSiteSpec *d) { | |||
190 | "usedIdentities = \"%s\"\n", | 196 | "usedIdentities = \"%s\"\n", |
191 | cstrCollect_String(joinCStr_StringArray(¶ms->usedIdentities, " "))); | 197 | cstrCollect_String(joinCStr_StringArray(¶ms->usedIdentities, " "))); |
192 | } | 198 | } |
193 | appendCStr_String(buf, "\n"); | 199 | if (!isEmpty_String(¶ms->paletteSeed)) { |
194 | write_File(f, utf8_String(buf)); | 200 | appendCStr_String(buf, "paletteSeed = \""); |
201 | append_String(buf, collect_String(quote_String(¶ms->paletteSeed, iFalse))); | ||
202 | appendCStr_String(buf, "\"\n"); | ||
203 | } | ||
204 | if (!isEmpty_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 | } | ||
195 | iEndCollect(); | 211 | iEndCollect(); |
196 | } | 212 | } |
197 | delete_String(buf); | 213 | delete_String(buf); |
@@ -257,6 +273,12 @@ void setValueString_SiteSpec(const iString *site, enum iSiteSpecKey key, const i | |||
257 | set_String(¶ms->titanIdentity, value); | 273 | set_String(¶ms->titanIdentity, value); |
258 | } | 274 | } |
259 | break; | 275 | break; |
276 | case paletteSeed_SiteSpecKey: | ||
277 | if (!equal_String(¶ms->paletteSeed, value)) { | ||
278 | needSave = iTrue; | ||
279 | set_String(¶ms->paletteSeed, value); | ||
280 | } | ||
281 | break; | ||
260 | default: | 282 | default: |
261 | break; | 283 | break; |
262 | } | 284 | } |
@@ -328,6 +350,8 @@ const iString *valueString_SiteSpec(const iString *site, enum iSiteSpecKey key) | |||
328 | switch (key) { | 350 | switch (key) { |
329 | case titanIdentity_SiteSpecKey: | 351 | case titanIdentity_SiteSpecKey: |
330 | return ¶ms->titanIdentity; | 352 | return ¶ms->titanIdentity; |
353 | case paletteSeed_SiteSpecKey: | ||
354 | return ¶ms->paletteSeed; | ||
331 | default: | 355 | default: |
332 | return collectNew_String(); | 356 | return collectNew_String(); |
333 | } | 357 | } |