diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-12-30 08:19:03 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-12-30 08:19:03 +0200 |
commit | 136933d10165d1991cc28621ea0e941904df02a9 (patch) | |
tree | f5bf855987da4b9bc306e0483bae838f4764cc1b /src | |
parent | d382445afe8fe7b8f8b6c7a3ec6cbecd0f9946b7 (diff) |
Update bookmark icons when opening pages
If bookmarks are imported or added manually, they won't have the correct site icons. Whenever a page is loaded the bookmark icon is now updated.
Diffstat (limited to 'src')
-rw-r--r-- | src/bookmarks.c | 17 | ||||
-rw-r--r-- | src/bookmarks.h | 1 | ||||
-rw-r--r-- | src/ui/documentwidget.c | 1 | ||||
-rw-r--r-- | src/ui/window.c | 9 |
4 files changed, 28 insertions, 0 deletions
diff --git a/src/bookmarks.c b/src/bookmarks.c index e54c6239..7cf7f5a1 100644 --- a/src/bookmarks.c +++ b/src/bookmarks.c | |||
@@ -216,6 +216,23 @@ iBool remove_Bookmarks(iBookmarks *d, uint32_t id) { | |||
216 | return bm != NULL; | 216 | return bm != NULL; |
217 | } | 217 | } |
218 | 218 | ||
219 | iBool updateBookmarkIcon_Bookmarks(iBookmarks *d, const iString *url, iChar icon) { | ||
220 | iBool changed = iFalse; | ||
221 | lock_Mutex(d->mtx); | ||
222 | const uint32_t id = findUrl_Bookmarks(d, url); | ||
223 | if (id) { | ||
224 | iBookmark *bm = get_Bookmarks(d, id); | ||
225 | if (!hasTag_Bookmark(bm, "remote")) { | ||
226 | if (icon != bm->icon) { | ||
227 | bm->icon = icon; | ||
228 | changed = iTrue; | ||
229 | } | ||
230 | } | ||
231 | } | ||
232 | unlock_Mutex(d->mtx); | ||
233 | return changed; | ||
234 | } | ||
235 | |||
219 | iBookmark *get_Bookmarks(iBookmarks *d, uint32_t id) { | 236 | iBookmark *get_Bookmarks(iBookmarks *d, uint32_t id) { |
220 | return (iBookmark *) value_Hash(&d->bookmarks, id); | 237 | return (iBookmark *) value_Hash(&d->bookmarks, id); |
221 | } | 238 | } |
diff --git a/src/bookmarks.h b/src/bookmarks.h index 2975b082..26bd9a47 100644 --- a/src/bookmarks.h +++ b/src/bookmarks.h | |||
@@ -62,6 +62,7 @@ void requestFinished_Bookmarks (iBookmarks *, iGmRequest *req); | |||
62 | void add_Bookmarks (iBookmarks *, const iString *url, const iString *title, | 62 | void add_Bookmarks (iBookmarks *, const iString *url, const iString *title, |
63 | const iString *tags, iChar icon); | 63 | const iString *tags, iChar icon); |
64 | iBool remove_Bookmarks (iBookmarks *, uint32_t id); | 64 | iBool remove_Bookmarks (iBookmarks *, uint32_t id); |
65 | iBool updateBookmarkIcon_Bookmarks (iBookmarks *, const iString *url, iChar icon); | ||
65 | iBookmark * get_Bookmarks (iBookmarks *, uint32_t id); | 66 | iBookmark * get_Bookmarks (iBookmarks *, uint32_t id); |
66 | uint32_t findUrl_Bookmarks (const iBookmarks *, const iString *url); /* O(n) */ | 67 | uint32_t findUrl_Bookmarks (const iBookmarks *, const iString *url); /* O(n) */ |
67 | 68 | ||
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index bc9dbc8d..0723ed9d 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -1181,6 +1181,7 @@ static void checkResponse_DocumentWidget_(iDocumentWidget *d) { | |||
1181 | "document.input.submit"); | 1181 | "document.input.submit"); |
1182 | setSensitiveContent_InputWidget(findChild_Widget(dlg, "input"), | 1182 | setSensitiveContent_InputWidget(findChild_Widget(dlg, "input"), |
1183 | statusCode == sensitiveInput_GmStatusCode); | 1183 | statusCode == sensitiveInput_GmStatusCode); |
1184 | updateTheme_DocumentWidget_(d); | ||
1184 | break; | 1185 | break; |
1185 | } | 1186 | } |
1186 | case categorySuccess_GmStatusCode: | 1187 | case categorySuccess_GmStatusCode: |
diff --git a/src/ui/window.c b/src/ui/window.c index e1bb1c0b..2933a47d 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -27,6 +27,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
27 | #include "documentwidget.h" | 27 | #include "documentwidget.h" |
28 | #include "sidebarwidget.h" | 28 | #include "sidebarwidget.h" |
29 | #include "lookupwidget.h" | 29 | #include "lookupwidget.h" |
30 | #include "bookmarks.h" | ||
30 | #include "embedded.h" | 31 | #include "embedded.h" |
31 | #include "command.h" | 32 | #include "command.h" |
32 | #include "paint.h" | 33 | #include "paint.h" |
@@ -396,6 +397,14 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { | |||
396 | setText_InputWidget(url, urlStr); | 397 | setText_InputWidget(url, urlStr); |
397 | checkLoadAnimation_Window_(get_Window()); | 398 | checkLoadAnimation_Window_(get_Window()); |
398 | updateNavBarIdentity_(navBar); | 399 | updateNavBarIdentity_(navBar); |
400 | /* Icon updates should be limited to automatically chosen icons if the user | ||
401 | is allowed to pick their own in the future. */ | ||
402 | if (updateBookmarkIcon_Bookmarks( | ||
403 | bookmarks_App(), | ||
404 | urlStr, | ||
405 | siteIcon_GmDocument(document_DocumentWidget(document_App())))) { | ||
406 | postCommand_App("bookmarks.changed"); | ||
407 | } | ||
399 | return iFalse; | 408 | return iFalse; |
400 | } | 409 | } |
401 | else if (equal_Command(cmd, "document.request.cancelled")) { | 410 | else if (equal_Command(cmd, "document.request.cancelled")) { |