summaryrefslogtreecommitdiff
path: root/src/gmdocument.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gmdocument.c')
-rw-r--r--src/gmdocument.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c
index a3e233f3..bc0cc073 100644
--- a/src/gmdocument.c
+++ b/src/gmdocument.c
@@ -1292,7 +1292,7 @@ static void updateIconBasedOnUrl_GmDocument_(iGmDocument *d) {
1292 } 1292 }
1293} 1293}
1294 1294
1295void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { 1295void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *paletteSeed, const iBlock *iconSeed) {
1296 const iPrefs * prefs = prefs_App(); 1296 const iPrefs * prefs = prefs_App();
1297 enum iGmDocumentTheme theme = currentTheme_(); 1297 enum iGmDocumentTheme theme = currentTheme_();
1298 static const iChar siteIcons[] = { 1298 static const iChar siteIcons[] = {
@@ -1303,6 +1303,16 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) {
1303 0x1f306, 0x1f308, 0x1f30a, 0x1f319, 0x1f31f, 0x1f320, 0x1f340, 0x1f4cd, 0x1f4e1, 0x1f531, 1303 0x1f306, 0x1f308, 0x1f30a, 0x1f319, 0x1f31f, 0x1f320, 0x1f340, 0x1f4cd, 0x1f4e1, 0x1f531,
1304 0x1f533, 0x1f657, 0x1f659, 0x1f665, 0x1f668, 0x1f66b, 0x1f78b, 0x1f796, 0x1f79c, 1304 0x1f533, 0x1f657, 0x1f659, 0x1f665, 0x1f668, 0x1f66b, 0x1f78b, 0x1f796, 0x1f79c,
1305 }; 1305 };
1306 if (!iconSeed) {
1307 iconSeed = paletteSeed;
1308 }
1309 if (iconSeed && !isEmpty_Block(iconSeed)) {
1310 const uint32_t seedHash = themeHash_(iconSeed);
1311 d->siteIcon = siteIcons[(seedHash >> 7) % iElemCount(siteIcons)];
1312 }
1313 else {
1314 d->siteIcon = 0;
1315 }
1306 /* Default colors. These are used on "about:" pages and local files, for example. */ { 1316 /* Default colors. These are used on "about:" pages and local files, for example. */ {
1307 /* Link colors are generally the same in all themes. */ 1317 /* Link colors are generally the same in all themes. */
1308 set_Color(tmBadLink_ColorId, get_Color(red_ColorId)); 1318 set_Color(tmBadLink_ColorId, get_Color(red_ColorId));
@@ -1504,13 +1514,11 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) {
1504 } 1514 }
1505 } 1515 }
1506 } 1516 }
1507 if (seed && !isEmpty_Block(seed)) { 1517 if (paletteSeed && !isEmpty_Block(paletteSeed)) {
1508 d->themeSeed = themeHash_(seed); 1518 d->themeSeed = themeHash_(paletteSeed);
1509 d->siteIcon = siteIcons[(d->themeSeed >> 7) % iElemCount(siteIcons)];
1510 } 1519 }
1511 else { 1520 else {
1512 d->themeSeed = 0; 1521 d->themeSeed = 0;
1513 d->siteIcon = 0;
1514 } 1522 }
1515 /* Set up colors. */ 1523 /* Set up colors. */
1516 if (d->themeSeed) { 1524 if (d->themeSeed) {
@@ -1739,8 +1747,8 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) {
1739 /* Derived colors. */ 1747 /* Derived colors. */
1740 setDerivedThemeColors_(theme); 1748 setDerivedThemeColors_(theme);
1741 /* Special exceptions. */ 1749 /* Special exceptions. */
1742 if (seed) { 1750 if (iconSeed) {
1743 if (equal_CStr(cstr_Block(seed), "gemini.circumlunar.space")) { 1751 if (equal_CStr(cstr_Block(iconSeed), "gemini.circumlunar.space")) {
1744 d->siteIcon = 0x264a; /* gemini symbol */ 1752 d->siteIcon = 0x264a; /* gemini symbol */
1745 } 1753 }
1746 updateIconBasedOnUrl_GmDocument_(d); 1754 updateIconBasedOnUrl_GmDocument_(d);
@@ -1761,7 +1769,8 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) {
1761void makePaletteGlobal_GmDocument(const iGmDocument *d) { 1769void makePaletteGlobal_GmDocument(const iGmDocument *d) {
1762 if (!d->isPaletteValid) { 1770 if (!d->isPaletteValid) {
1763 /* Recompute the palette since it's needed now. */ 1771 /* Recompute the palette since it's needed now. */
1764 setThemeSeed_GmDocument((iGmDocument *) d, urlThemeSeed_String(&d->url)); 1772 setThemeSeed_GmDocument(
1773 (iGmDocument *) d, urlPaletteSeed_String(&d->url), urlThemeSeed_String(&d->url));
1765 } 1774 }
1766 iAssert(d->isPaletteValid); 1775 iAssert(d->isPaletteValid);
1767 memcpy(get_Root()->tmPalette, d->palette, sizeof(d->palette)); 1776 memcpy(get_Root()->tmPalette, d->palette, sizeof(d->palette));
@@ -1938,7 +1947,7 @@ static void normalize_GmDocument(iGmDocument *d) {
1938void setUrl_GmDocument(iGmDocument *d, const iString *url) { 1947void setUrl_GmDocument(iGmDocument *d, const iString *url) {
1939 url = canonicalUrl_String(url); 1948 url = canonicalUrl_String(url);
1940 set_String(&d->url, url); 1949 set_String(&d->url, url);
1941 setThemeSeed_GmDocument(d, urlThemeSeed_String(url)); 1950 setThemeSeed_GmDocument(d, urlPaletteSeed_String(url), urlThemeSeed_String(url));
1942 iUrl parts; 1951 iUrl parts;
1943 init_Url(&parts, url); 1952 init_Url(&parts, url);
1944 setRange_String(&d->localHost, parts.host); 1953 setRange_String(&d->localHost, parts.host);