summaryrefslogtreecommitdiff
path: root/src/ui/sidebarwidget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/sidebarwidget.c')
-rw-r--r--src/ui/sidebarwidget.c44
1 files changed, 41 insertions, 3 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index e8aa69c1..8e38dcb8 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -1111,6 +1111,16 @@ static void bookmarkMovedOntoFolder_SidebarWidget_(iSidebarWidget *d, size_t ind
1111 postCommand_App("bookmarks.changed"); 1111 postCommand_App("bookmarks.changed");
1112} 1112}
1113 1113
1114static size_t numBookmarks_(const iPtrArray *bmList) {
1115 size_t num = 0;
1116 iConstForEach(PtrArray, i, bmList) {
1117 if (!isFolder_Bookmark(i.ptr) && !hasTag_Bookmark(i.ptr, remote_BookmarkTag)) {
1118 num++;
1119 }
1120 }
1121 return num;
1122}
1123
1114static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) { 1124static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) {
1115 iWidget *w = as_Widget(d); 1125 iWidget *w = as_Widget(d);
1116 /* Handle commands. */ 1126 /* Handle commands. */
@@ -1313,9 +1323,37 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
1313 } 1323 }
1314 else if (isCommand_Widget(w, ev, "bookmark.delete")) { 1324 else if (isCommand_Widget(w, ev, "bookmark.delete")) {
1315 const iSidebarItem *item = d->contextItem; 1325 const iSidebarItem *item = d->contextItem;
1316 if (d->mode == bookmarks_SidebarMode && item && remove_Bookmarks(bookmarks_App(), item->id)) { 1326 if (d->mode == bookmarks_SidebarMode && item) {
1317 removeEntries_Feeds(item->id); 1327 iBookmark *bm = get_Bookmarks(bookmarks_App(), item->id);
1318 postCommand_App("bookmarks.changed"); 1328 if (isFolder_Bookmark(bm)) {
1329 const iPtrArray *list = list_Bookmarks(bookmarks_App(), NULL,
1330 filterInsideFolder_Bookmark, bm);
1331 if (argLabel_Command(cmd, "confirmed") || isEmpty_PtrArray(list)) {
1332 iConstForEach(PtrArray, i, list) {
1333 removeEntries_Feeds(id_Bookmark(i.ptr));
1334 }
1335 remove_Bookmarks(bookmarks_App(), item->id);
1336 postCommand_App("bookmarks.changed");
1337 }
1338 else {
1339 const size_t numBookmarks = numBookmarks_(list);
1340 makeQuestion_Widget(uiHeading_ColorEscape "${heading.confirm.bookmarks.delete}",
1341 formatCStrs_Lang("dlg.confirm.bookmarks.delete.n", numBookmarks),
1342 (iMenuItem[]){
1343 { "${cancel}" },
1344 { format_CStr(uiTextCaution_ColorEscape "%s",
1345 formatCStrs_Lang("dlg.bookmarks.delete.n", numBookmarks)),
1346 0, 0, format_CStr("!bookmark.delete confirmed:1 ptr:%p", d) },
1347 }, 2);
1348 }
1349 }
1350 else {
1351 /* TODO: Move it to a Trash folder? */
1352 if (remove_Bookmarks(bookmarks_App(), item->id)) {
1353 removeEntries_Feeds(item->id);
1354 postCommand_App("bookmarks.changed");
1355 }
1356 }
1319 } 1357 }
1320 return iTrue; 1358 return iTrue;
1321 } 1359 }