summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gmcerts.c10
-rw-r--r--src/gmcerts.h5
-rw-r--r--src/ui/sidebarwidget.c17
3 files changed, 27 insertions, 5 deletions
diff --git a/src/gmcerts.c b/src/gmcerts.c
index f86712ac..bf0f3924 100644
--- a/src/gmcerts.c
+++ b/src/gmcerts.c
@@ -161,6 +161,16 @@ iBool isUsedOn_GmIdentity(const iGmIdentity *d, const iString *url) {
161 return iFalse; 161 return iFalse;
162} 162}
163 163
164iBool isUsedOnDomain_GmIdentity(const iGmIdentity *d, const iRangecc domain) {
165 iConstForEach(StringSet, i, d->useUrls) {
166 const iRangecc host = urlHost_String(i.value);
167 if (equalRangeCase_Rangecc(host, domain)) {
168 return iTrue;
169 }
170 }
171 return iFalse;
172}
173
164void setUse_GmIdentity(iGmIdentity *d, const iString *url, iBool use) { 174void setUse_GmIdentity(iGmIdentity *d, const iString *url, iBool use) {
165 if (use && isUsedOn_GmIdentity(d, url)) { 175 if (use && isUsedOn_GmIdentity(d, url)) {
166 return; /* Redudant. */ 176 return; /* Redudant. */
diff --git a/src/gmcerts.h b/src/gmcerts.h
index a9859845..a962d8b6 100644
--- a/src/gmcerts.h
+++ b/src/gmcerts.h
@@ -44,8 +44,9 @@ struct Impl_GmIdentity {
44 int flags; 44 int flags;
45}; 45};
46 46
47iBool isUsed_GmIdentity (const iGmIdentity *); 47iBool isUsed_GmIdentity (const iGmIdentity *);
48iBool isUsedOn_GmIdentity (const iGmIdentity *, const iString *url); 48iBool isUsedOn_GmIdentity (const iGmIdentity *, const iString *url);
49iBool isUsedOnDomain_GmIdentity (const iGmIdentity *, const iRangecc domain);
49 50
50void setUse_GmIdentity (iGmIdentity *, const iString *url, iBool use); 51void setUse_GmIdentity (iGmIdentity *, const iString *url, iBool use);
51void clearUse_GmIdentity (iGmIdentity *); 52void clearUse_GmIdentity (iGmIdentity *);
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 55c74774..aa58eb45 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -433,6 +433,7 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) {
433 } 433 }
434 case identities_SidebarMode: { 434 case identities_SidebarMode: {
435 const iString *tabUrl = url_DocumentWidget(document_App()); 435 const iString *tabUrl = url_DocumentWidget(document_App());
436 const iRangecc tabHost = urlHost_String(tabUrl);
436 isEmpty = iTrue; 437 isEmpty = iTrue;
437 iConstForEach(PtrArray, i, identities_GmCerts(certs_App())) { 438 iConstForEach(PtrArray, i, identities_GmCerts(certs_App())) {
438 const iGmIdentity *ident = i.ptr; 439 const iGmIdentity *ident = i.ptr;
@@ -467,6 +468,9 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) {
467 cstr_String(&ident->notes)); 468 cstr_String(&ident->notes));
468 } 469 }
469 item->listItem.isSelected = isActive; 470 item->listItem.isSelected = isActive;
471 if (isUsedOnDomain_GmIdentity(ident, tabHost)) {
472 item->indent = 1; /* will be highlighted */
473 }
470 addItem_ListWidget(d->list, item); 474 addItem_ListWidget(d->list, item);
471 iRelease(item); 475 iRelease(item);
472 isEmpty = iFalse; 476 isEmpty = iFalse;
@@ -1540,6 +1544,7 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1540 const int itemHeight = height_Rect(itemRect); 1544 const int itemHeight = height_Rect(itemRect);
1541 const int iconColor = isHover ? (isPressing ? uiTextPressed_ColorId : uiIconHover_ColorId) 1545 const int iconColor = isHover ? (isPressing ? uiTextPressed_ColorId : uiIconHover_ColorId)
1542 : uiIcon_ColorId; 1546 : uiIcon_ColorId;
1547 const int altIconColor = isPressing ? uiTextPressed_ColorId : uiTextCaution_ColorId;
1543 const int font = sidebar->itemFonts[d->isBold ? 1 : 0]; 1548 const int font = sidebar->itemFonts[d->isBold ? 1 : 0];
1544 int bg = uiBackgroundSidebar_ColorId; 1549 int bg = uiBackgroundSidebar_ColorId;
1545 if (isHover) { 1550 if (isHover) {
@@ -1730,6 +1735,7 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1730 else if (sidebar->mode == identities_SidebarMode) { 1735 else if (sidebar->mode == identities_SidebarMode) {
1731 const int fg = isHover ? (isPressing ? uiTextPressed_ColorId : uiTextFramelessHover_ColorId) 1736 const int fg = isHover ? (isPressing ? uiTextPressed_ColorId : uiTextFramelessHover_ColorId)
1732 : uiTextStrong_ColorId; 1737 : uiTextStrong_ColorId;
1738 const iBool isUsedOnDomain = (d->indent != 0);
1733 iString icon; 1739 iString icon;
1734 initUnicodeN_String(&icon, &d->icon, 1); 1740 initUnicodeN_String(&icon, &d->icon, 1);
1735 iInt2 cPos = topLeft_Rect(itemRect); 1741 iInt2 cPos = topLeft_Rect(itemRect);
@@ -1741,7 +1747,8 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1741 const int metaFg = isHover ? permanent_ColorId | (isPressing ? uiTextPressed_ColorId 1747 const int metaFg = isHover ? permanent_ColorId | (isPressing ? uiTextPressed_ColorId
1742 : uiTextFramelessHover_ColorId) 1748 : uiTextFramelessHover_ColorId)
1743 : uiTextDim_ColorId; 1749 : uiTextDim_ColorId;
1744 if (!d->listItem.isSelected) { 1750 if (!d->listItem.isSelected && !isUsedOnDomain) {
1751 /* Draw an outline of the icon. */
1745 for (int off = 0; off < 4; ++off) { 1752 for (int off = 0; off < 4; ++off) {
1746 drawRange_Text(font, 1753 drawRange_Text(font,
1747 add_I2(cPos, init_I2(off % 2 == 0 ? -1 : 1, off / 2 == 0 ? -1 : 1)), 1754 add_I2(cPos, init_I2(off % 2 == 0 ? -1 : 1, off / 2 == 0 ? -1 : 1)),
@@ -1749,8 +1756,12 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1749 range_String(&icon)); 1756 range_String(&icon));
1750 } 1757 }
1751 } 1758 }
1752 drawRange_Text( 1759 drawRange_Text(font,
1753 font, cPos, d->listItem.isSelected ? iconColor : uiBackgroundSidebar_ColorId /*metaFg*/, range_String(&icon)); 1760 cPos,
1761 d->listItem.isSelected ? iconColor
1762 : isUsedOnDomain ? altIconColor
1763 : uiBackgroundSidebar_ColorId,
1764 range_String(&icon));
1754 deinit_String(&icon); 1765 deinit_String(&icon);
1755 drawRange_Text(d->listItem.isSelected ? sidebar->itemFonts[1] : font, 1766 drawRange_Text(d->listItem.isSelected ? sidebar->itemFonts[1] : font,
1756 add_I2(cPos, init_I2(indent, 0)), 1767 add_I2(cPos, init_I2(indent, 0)),