diff options
-rw-r--r-- | src/ui/sidebarwidget.c | 14 | ||||
-rw-r--r-- | src/ui/sidebarwidget.h | 2 | ||||
-rw-r--r-- | src/ui/window.c | 8 |
3 files changed, 14 insertions, 10 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index 55538812..57562cab 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c | |||
@@ -250,8 +250,10 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) { | |||
250 | invalidate_ListWidget(d->list); | 250 | invalidate_ListWidget(d->list); |
251 | } | 251 | } |
252 | 252 | ||
253 | void setMode_SidebarWidget(iSidebarWidget *d, enum iSidebarMode mode) { | 253 | iBool setMode_SidebarWidget(iSidebarWidget *d, enum iSidebarMode mode) { |
254 | if (d->mode == mode) return; | 254 | if (d->mode == mode) { |
255 | return iFalse; | ||
256 | } | ||
255 | if (d->mode >= 0 && d->mode < max_SidebarMode) { | 257 | if (d->mode >= 0 && d->mode < max_SidebarMode) { |
256 | d->modeScroll[d->mode] = scrollPos_ListWidget(d->list); /* saved for later */ | 258 | d->modeScroll[d->mode] = scrollPos_ListWidget(d->list); /* saved for later */ |
257 | } | 259 | } |
@@ -266,6 +268,7 @@ void setMode_SidebarWidget(iSidebarWidget *d, enum iSidebarMode mode) { | |||
266 | setItemHeight_ListWidget(d->list, heights[mode] * lineHeight_Text(uiContent_FontId)); | 268 | setItemHeight_ListWidget(d->list, heights[mode] * lineHeight_Text(uiContent_FontId)); |
267 | /* Restore previous scroll position. */ | 269 | /* Restore previous scroll position. */ |
268 | setScrollPos_ListWidget(d->list, d->modeScroll[mode]); | 270 | setScrollPos_ListWidget(d->list, d->modeScroll[mode]); |
271 | return iTrue; | ||
269 | } | 272 | } |
270 | 273 | ||
271 | enum iSidebarMode mode_SidebarWidget(const iSidebarWidget *d) { | 274 | enum iSidebarMode mode_SidebarWidget(const iSidebarWidget *d) { |
@@ -501,10 +504,11 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) | |||
501 | return iTrue; | 504 | return iTrue; |
502 | } | 505 | } |
503 | else if (equal_Command(cmd, "sidebar.mode")) { | 506 | else if (equal_Command(cmd, "sidebar.mode")) { |
504 | setMode_SidebarWidget(d, arg_Command(cmd)); | 507 | const iBool wasChanged = setMode_SidebarWidget(d, arg_Command(cmd)); |
505 | updateItems_SidebarWidget_(d); | 508 | updateItems_SidebarWidget_(d); |
506 | if (argLabel_Command(cmd, "show") && !isVisible_Widget(w)) { | 509 | if ((argLabel_Command(cmd, "show") && !isVisible_Widget(w)) || |
507 | postCommand_App("sidebar.toggle arg:1"); | 510 | (argLabel_Command(cmd, "toggle") && !wasChanged)) { |
511 | postCommand_App("sidebar.toggle"); | ||
508 | } | 512 | } |
509 | scrollOffset_ListWidget(d->list, 0); | 513 | scrollOffset_ListWidget(d->list, 0); |
510 | return iTrue; | 514 | return iTrue; |
diff --git a/src/ui/sidebarwidget.h b/src/ui/sidebarwidget.h index 7ccc64dd..acb7d93a 100644 --- a/src/ui/sidebarwidget.h +++ b/src/ui/sidebarwidget.h | |||
@@ -35,7 +35,7 @@ enum iSidebarMode { | |||
35 | iDeclareWidgetClass(SidebarWidget) | 35 | iDeclareWidgetClass(SidebarWidget) |
36 | iDeclareObjectConstruction(SidebarWidget) | 36 | iDeclareObjectConstruction(SidebarWidget) |
37 | 37 | ||
38 | void setMode_SidebarWidget (iSidebarWidget *, enum iSidebarMode mode); | 38 | iBool setMode_SidebarWidget (iSidebarWidget *, enum iSidebarMode mode); |
39 | 39 | ||
40 | enum iSidebarMode mode_SidebarWidget (const iSidebarWidget *); | 40 | enum iSidebarMode mode_SidebarWidget (const iSidebarWidget *); |
41 | int width_SidebarWidget (const iSidebarWidget *); | 41 | int width_SidebarWidget (const iSidebarWidget *); |
diff --git a/src/ui/window.c b/src/ui/window.c index 66f1c513..dabf80de 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -128,10 +128,10 @@ static const iMenuItem identityMenuItems[] = { | |||
128 | }; | 128 | }; |
129 | 129 | ||
130 | static const iMenuItem viewMenuItems[] = { | 130 | static const iMenuItem viewMenuItems[] = { |
131 | { "Show Bookmarks", '1', KMOD_PRIMARY, "sidebar.mode arg:0 show:1" }, | 131 | { "Show Bookmarks", '1', KMOD_PRIMARY, "sidebar.mode arg:0 toggle:1" }, |
132 | { "Show History", '2', KMOD_PRIMARY, "sidebar.mode arg:1 show:1" }, | 132 | { "Show History", '2', KMOD_PRIMARY, "sidebar.mode arg:1 toggle:1" }, |
133 | { "Show Identities", '3', KMOD_PRIMARY, "sidebar.mode arg:2 show:1" }, | 133 | { "Show Identities", '3', KMOD_PRIMARY, "sidebar.mode arg:2 toggle:1" }, |
134 | { "Show Page Outline", '4', KMOD_PRIMARY, "sidebar.mode arg:3 show:1" }, | 134 | { "Show Page Outline", '4', KMOD_PRIMARY, "sidebar.mode arg:3 toggle:1" }, |
135 | { "Toggle Sidebar", SDLK_l, KMOD_PRIMARY | KMOD_SHIFT, "sidebar.toggle" }, | 135 | { "Toggle Sidebar", SDLK_l, KMOD_PRIMARY | KMOD_SHIFT, "sidebar.toggle" }, |
136 | { "---", 0, 0, NULL }, | 136 | { "---", 0, 0, NULL }, |
137 | { "Go Back", SDLK_LEFTBRACKET, KMOD_PRIMARY, "navigate.back" }, | 137 | { "Go Back", SDLK_LEFTBRACKET, KMOD_PRIMARY, "navigate.back" }, |