summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-03-04 14:35:29 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-03-04 22:24:43 +0200
commit179913000184c7f7f482167192a8f968bf5e773d (patch)
tree8b11bd6e8cc665c25a4a64db647358a9464e186f
parent6b503898dfd52ea342d64a6611878aa05719fa51 (diff)
Save identity usage changes immediately
-rw-r--r--src/app.c4
-rw-r--r--src/gmcerts.c4
-rw-r--r--src/gmcerts.h1
-rw-r--r--src/ui/sidebarwidget.c6
4 files changed, 11 insertions, 4 deletions
diff --git a/src/app.c b/src/app.c
index 25b068a5..3b62cd87 100644
--- a/src/app.c
+++ b/src/app.c
@@ -1921,6 +1921,10 @@ iBool handleCommand_App(const char *cmd) {
1921 postCommand_App("idents.changed"); 1921 postCommand_App("idents.changed");
1922 return iTrue; 1922 return iTrue;
1923 } 1923 }
1924 else if (equal_Command(cmd, "idents.changed")) {
1925 saveIdentities_GmCerts(d->certs);
1926 return iFalse;
1927 }
1924 else if (equal_Command(cmd, "os.theme.changed")) { 1928 else if (equal_Command(cmd, "os.theme.changed")) {
1925 if (d->prefs.useSystemTheme) { 1929 if (d->prefs.useSystemTheme) {
1926 const int dark = argLabel_Command(cmd, "dark"); 1930 const int dark = argLabel_Command(cmd, "dark");
diff --git a/src/gmcerts.c b/src/gmcerts.c
index 3e629f8f..8c011137 100644
--- a/src/gmcerts.c
+++ b/src/gmcerts.c
@@ -200,7 +200,7 @@ static const char *magicIdentity_GmCerts_ = "iden";
200 200
201iDefineTypeConstructionArgs(GmCerts, (const char *saveDir), saveDir) 201iDefineTypeConstructionArgs(GmCerts, (const char *saveDir), saveDir)
202 202
203static void saveIdentities_GmCerts_(const iGmCerts *d) { 203void saveIdentities_GmCerts(const iGmCerts *d) {
204 iFile *f = new_File(collect_String(concatCStr_Path(&d->saveDir, identsFilename_GmCerts_))); 204 iFile *f = new_File(collect_String(concatCStr_Path(&d->saveDir, identsFilename_GmCerts_)));
205 if (open_File(f, writeOnly_FileMode)) { 205 if (open_File(f, writeOnly_FileMode)) {
206 writeData_File(f, magicIdMeta_GmCerts_, 4); 206 writeData_File(f, magicIdMeta_GmCerts_, 4);
@@ -362,7 +362,7 @@ void init_GmCerts(iGmCerts *d, const char *saveDir) {
362 362
363void deinit_GmCerts(iGmCerts *d) { 363void deinit_GmCerts(iGmCerts *d) {
364 iGuardMutex(d->mtx, { 364 iGuardMutex(d->mtx, {
365 saveIdentities_GmCerts_(d); 365 saveIdentities_GmCerts(d);
366 iForEach(PtrArray, i, &d->idents) { 366 iForEach(PtrArray, i, &d->idents) {
367 delete_GmIdentity(i.ptr); 367 delete_GmIdentity(i.ptr);
368 } 368 }
diff --git a/src/gmcerts.h b/src/gmcerts.h
index af116433..a28c050e 100644
--- a/src/gmcerts.h
+++ b/src/gmcerts.h
@@ -82,6 +82,7 @@ iGmIdentity * newIdentity_GmCerts (iGmCerts *, int flags, iDate validU
82 82
83void importIdentity_GmCerts (iGmCerts *, iTlsCertificate *cert, const iString *notes); /* takes ownership */ 83void importIdentity_GmCerts (iGmCerts *, iTlsCertificate *cert, const iString *notes); /* takes ownership */
84void deleteIdentity_GmCerts (iGmCerts *, iGmIdentity *identity); 84void deleteIdentity_GmCerts (iGmCerts *, iGmIdentity *identity);
85void saveIdentities_GmCerts (const iGmCerts *);
85 86
86const iString * certificatePath_GmCerts (const iGmCerts *, const iGmIdentity *identity); 87const iString * certificatePath_GmCerts (const iGmCerts *, const iGmIdentity *identity);
87 88
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index dd7b977e..1f5a6d01 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -1008,6 +1008,7 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
1008 else { 1008 else {
1009 signOut_GmCerts(certs_App(), tabUrl); 1009 signOut_GmCerts(certs_App(), tabUrl);
1010 } 1010 }
1011 saveIdentities_GmCerts(certs_App());
1011 updateItems_SidebarWidget_(d); 1012 updateItems_SidebarWidget_(d);
1012 } 1013 }
1013 return iTrue; 1014 return iTrue;
@@ -1459,6 +1460,7 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1459 iString icon; 1460 iString icon;
1460 initUnicodeN_String(&icon, &d->icon, 1); 1461 initUnicodeN_String(&icon, &d->icon, 1);
1461 iInt2 cPos = topLeft_Rect(itemRect); 1462 iInt2 cPos = topLeft_Rect(itemRect);
1463 const int indent = 1.4f * lineHeight_Text(font);
1462 addv_I2(&cPos, 1464 addv_I2(&cPos,
1463 init_I2(3 * gap_UI, 1465 init_I2(3 * gap_UI,
1464 (itemHeight - lineHeight_Text(default_FontId) * 2 - lineHeight_Text(font)) / 1466 (itemHeight - lineHeight_Text(default_FontId) * 2 - lineHeight_Text(font)) /
@@ -1470,11 +1472,11 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1470 font, cPos, d->listItem.isSelected ? iconColor : metaFg, range_String(&icon)); 1472 font, cPos, d->listItem.isSelected ? iconColor : metaFg, range_String(&icon));
1471 deinit_String(&icon); 1473 deinit_String(&icon);
1472 drawRange_Text(d->listItem.isSelected ? uiContentBold_FontId : font, 1474 drawRange_Text(d->listItem.isSelected ? uiContentBold_FontId : font,
1473 add_I2(cPos, init_I2(6 * gap_UI, 0)), 1475 add_I2(cPos, init_I2(indent, 0)),
1474 fg, 1476 fg,
1475 range_String(&d->label)); 1477 range_String(&d->label));
1476 drawRange_Text(default_FontId, 1478 drawRange_Text(default_FontId,
1477 add_I2(cPos, init_I2(6 * gap_UI, lineHeight_Text(font))), 1479 add_I2(cPos, init_I2(indent, lineHeight_Text(font))),
1478 metaFg, 1480 metaFg,
1479 range_String(&d->meta)); 1481 range_String(&d->meta));
1480 } 1482 }