diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-09-24 22:52:13 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-09-24 22:52:13 +0300 |
commit | de976d7d8bcfcb7bcc1436e215a8713aefbf091f (patch) | |
tree | 3ae409c022b5120e5e40d883316156d46908f471 /src/bookmarks.c | |
parent | 030b535d831a8abf4a73d4e36f3f63adb07fff03 (diff) |
Bookmarks: Deleting a tree of bookmarks
Sidebar asks for confirmation when deleting a folder hierarchy of bookmarks.
Diffstat (limited to 'src/bookmarks.c')
-rw-r--r-- | src/bookmarks.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/bookmarks.c b/src/bookmarks.c index 35e16d9a..fe2ca47a 100644 --- a/src/bookmarks.c +++ b/src/bookmarks.c | |||
@@ -83,6 +83,10 @@ int cmpTitleAscending_Bookmark(const iBookmark **a, const iBookmark **b) { | |||
83 | return cmpStringCase_String(&(*a)->title, &(*b)->title); | 83 | return cmpStringCase_String(&(*a)->title, &(*b)->title); |
84 | } | 84 | } |
85 | 85 | ||
86 | iBool filterInsideFolder_Bookmark(void *context, const iBookmark *bm) { | ||
87 | return hasParent_Bookmark(bm, id_Bookmark(context)); | ||
88 | } | ||
89 | |||
86 | /*----------------------------------------------------------------------------------------------*/ | 90 | /*----------------------------------------------------------------------------------------------*/ |
87 | 91 | ||
88 | static const char *oldFileName_Bookmarks_ = "bookmarks.txt"; | 92 | static const char *oldFileName_Bookmarks_ = "bookmarks.txt"; |
@@ -345,16 +349,9 @@ iBool remove_Bookmarks(iBookmarks *d, uint32_t id) { | |||
345 | lock_Mutex(d->mtx); | 349 | lock_Mutex(d->mtx); |
346 | iBookmark *bm = (iBookmark *) remove_Hash(&d->bookmarks, id); | 350 | iBookmark *bm = (iBookmark *) remove_Hash(&d->bookmarks, id); |
347 | if (bm) { | 351 | if (bm) { |
348 | /* If this is a remote source, make sure all the remote bookmarks are | 352 | /* Remove all the contained bookmarks as well. */ |
349 | removed as well. */ | 353 | iConstForEach(PtrArray, i, list_Bookmarks(d, NULL, filterInsideFolder_Bookmark, bm)) { |
350 | if (hasTag_Bookmark(bm, remoteSource_BookmarkTag)) { | 354 | delete_Bookmark((iBookmark *) remove_Hash(&d->bookmarks, id_Bookmark(i.ptr))); |
351 | iForEach(Hash, i, &d->bookmarks) { | ||
352 | iBookmark *j = (iBookmark *) i.value; | ||
353 | if (j->parentId == id_Bookmark(bm)) { | ||
354 | remove_HashIterator(&i); | ||
355 | delete_Bookmark(j); | ||
356 | } | ||
357 | } | ||
358 | } | 355 | } |
359 | delete_Bookmark(bm); | 356 | delete_Bookmark(bm); |
360 | } | 357 | } |