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.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 3d663afd..2219eba9 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -264,10 +264,12 @@ static iBool isBookmarkFolded_SidebarWidget_(const iSidebarWidget *d, const iBoo
264 return iFalse; 264 return iFalse;
265} 265}
266 266
267static void updateItems_SidebarWidget_(iSidebarWidget *d) { 267static void updateItemsWithFlags_SidebarWidget_(iSidebarWidget *d, iBool keepActions) {
268 clear_ListWidget(d->list); 268 clear_ListWidget(d->list);
269 releaseChildren_Widget(d->blank); 269 releaseChildren_Widget(d->blank);
270 if (!keepActions) {
270 releaseChildren_Widget(d->actions); 271 releaseChildren_Widget(d->actions);
272 }
271 d->actions->rect.size.y = 0; 273 d->actions->rect.size.y = 0;
272 destroy_Widget(d->menu); 274 destroy_Widget(d->menu);
273 destroy_Widget(d->modeMenu); 275 destroy_Widget(d->modeMenu);
@@ -348,7 +350,8 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) {
348 break; 350 break;
349 } 351 }
350 } 352 }
351 /* Actions. */ { 353 /* Actions. */
354 if (!keepActions) {
352 addActionButton_SidebarWidget_( 355 addActionButton_SidebarWidget_(
353 d, check_Icon " ${sidebar.action.feeds.markallread}", "feeds.markallread", expand_WidgetFlag | 356 d, check_Icon " ${sidebar.action.feeds.markallread}", "feeds.markallread", expand_WidgetFlag |
354 tight_WidgetFlag); 357 tight_WidgetFlag);
@@ -362,6 +365,8 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) {
362 iWidget *dropButton = addChild_Widget( 365 iWidget *dropButton = addChild_Widget(
363 d->actions, 366 d->actions,
364 iClob(makeMenuButton_LabelWidget(items[d->feedsMode].label, items, 2))); 367 iClob(makeMenuButton_LabelWidget(items[d->feedsMode].label, items, 2)));
368 setId_Widget(dropButton, "feeds.modebutton");
369 checkIcon_LabelWidget((iLabelWidget *) dropButton);
365 setFixedSize_Widget( 370 setFixedSize_Widget(
366 dropButton, 371 dropButton,
367 init_I2(iMaxi(20 * gap_UI, measure_Text( 372 init_I2(iMaxi(20 * gap_UI, measure_Text(
@@ -371,6 +376,10 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) {
371 6 * gap_UI), 376 6 * gap_UI),
372 -1)); 377 -1));
373 } 378 }
379 else {
380 updateDropdownSelection_LabelWidget(findChild_Widget(d->actions, "feeds.modebutton"),
381 format_CStr(" arg:%d", d->feedsMode));
382 }
374 d->menu = makeMenu_Widget( 383 d->menu = makeMenu_Widget(
375 as_Widget(d), 384 as_Widget(d),
376 (iMenuItem[]){ { openTab_Icon " ${feeds.entry.newtab}", 0, 0, "feed.entry.opentab" }, 385 (iMenuItem[]){ { openTab_Icon " ${feeds.entry.newtab}", 0, 0, "feed.entry.opentab" },
@@ -653,6 +662,10 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) {
653 updateMouseHover_ListWidget(d->list); 662 updateMouseHover_ListWidget(d->list);
654} 663}
655 664
665static void updateItems_SidebarWidget_(iSidebarWidget *d) {
666 updateItemsWithFlags_SidebarWidget_(d, iFalse);
667}
668
656static size_t findItem_SidebarWidget_(const iSidebarWidget *d, int id) { 669static size_t findItem_SidebarWidget_(const iSidebarWidget *d, int id) {
657 /* Note that this is O(n), so only meant for infrequent use. */ 670 /* Note that this is O(n), so only meant for infrequent use. */
658 for (size_t i = 0; i < numItems_ListWidget(d->list); i++) { 671 for (size_t i = 0; i < numItems_ListWidget(d->list); i++) {
@@ -1315,9 +1328,9 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
1315 } 1328 }
1316 return iTrue; 1329 return iTrue;
1317 } 1330 }
1318 else if (isCommand_Widget(w, ev, "menu.closed")) { 1331// else if (isCommand_Widget(w, ev, "menu.closed")) {
1319 // invalidateItem_ListWidget(d->list, d->contextIndex); 1332 // invalidateItem_ListWidget(d->list, d->contextIndex);
1320 } 1333// }
1321 else if (isCommand_Widget(w, ev, "bookmark.open")) { 1334 else if (isCommand_Widget(w, ev, "bookmark.open")) {
1322 const iSidebarItem *item = d->contextItem; 1335 const iSidebarItem *item = d->contextItem;
1323 if (d->mode == bookmarks_SidebarMode && item) { 1336 if (d->mode == bookmarks_SidebarMode && item) {
@@ -1474,7 +1487,7 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
1474 } 1487 }
1475 else if (equalWidget_Command(cmd, w, "feeds.mode")) { 1488 else if (equalWidget_Command(cmd, w, "feeds.mode")) {
1476 d->feedsMode = arg_Command(cmd); 1489 d->feedsMode = arg_Command(cmd);
1477 updateItems_SidebarWidget_(d); 1490 updateItemsWithFlags_SidebarWidget_(d, iTrue);
1478 return iTrue; 1491 return iTrue;
1479 } 1492 }
1480 else if (equal_Command(cmd, "feeds.markallread") && d->mode == feeds_SidebarMode) { 1493 else if (equal_Command(cmd, "feeds.markallread") && d->mode == feeds_SidebarMode) {