From 64b9cea544ecb2c0ae95afae5e84543ac6117f62 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Tue, 23 Feb 2021 11:46:18 +0200 Subject: Improved handling of bookmark icons The effect of a bookmark icon is restricted to URLs that begin with the bookmarked URL. TODO: Bookmark icon of an URL should affect the whole domain, but this should take into consideration user subdirectories ("~name" or "/users/name"). IssueID #140 --- src/gmdocument.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/gmdocument.c') diff --git a/src/gmdocument.c b/src/gmdocument.c index 3298fecc..ff088ef7 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c @@ -720,6 +720,13 @@ static void setDerivedThemeColors_(enum iGmDocumentTheme theme) { } } +static void updateIconBasedOnUrl_GmDocument_(iGmDocument *d) { + const iChar userIcon = siteIcon_Bookmarks(bookmarks_App(), &d->url); + if (userIcon) { + d->siteIcon = userIcon; + } +} + void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { const iPrefs * prefs = prefs_App(); enum iGmDocumentTheme theme = @@ -1092,10 +1099,7 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { if (equal_CStr(cstr_Block(seed), "gemini.circumlunar.space")) { d->siteIcon = 0x264a; /* gemini symbol */ } - const iChar userIcon = siteIcon_Bookmarks(bookmarks_App(), urlHost_String(&d->url)); - if (userIcon) { - d->siteIcon = userIcon; - } + updateIconBasedOnUrl_GmDocument_(d); } #if 0 for (int i = tmFirst_ColorId; i < max_ColorId; ++i) { @@ -1197,6 +1201,7 @@ void setUrl_GmDocument(iGmDocument *d, const iString *url) { iUrl parts; init_Url(&parts, url); setRange_String(&d->localHost, parts.host); + updateIconBasedOnUrl_GmDocument_(d); } void setSource_GmDocument(iGmDocument *d, const iString *source, int width) { -- cgit v1.2.3