diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-11-26 13:50:07 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-11-26 13:50:07 +0200 |
commit | c69280c86ad2602171daa4b4bf820c7b59bc9324 (patch) | |
tree | faffa5447a64204893e24c7deeaf82a7304b96f5 /src/ui | |
parent | 0635b3d7d37ea111379df65df35432845a0ea133 (diff) |
Feeds: Working on menu items
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/sidebarwidget.c | 39 | ||||
-rw-r--r-- | src/ui/window.c | 45 |
2 files changed, 46 insertions, 38 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index 9946ac5a..a3ff8a3e 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c | |||
@@ -83,18 +83,18 @@ iDefineObjectConstruction(SidebarItem) | |||
83 | /*----------------------------------------------------------------------------------------------*/ | 83 | /*----------------------------------------------------------------------------------------------*/ |
84 | 84 | ||
85 | struct Impl_SidebarWidget { | 85 | struct Impl_SidebarWidget { |
86 | iWidget widget; | 86 | iWidget widget; |
87 | enum iSidebarMode mode; | 87 | enum iSidebarMode mode; |
88 | iWidget *blank; | 88 | iWidget * blank; |
89 | iListWidget *list; | 89 | iListWidget * list; |
90 | int modeScroll[max_SidebarMode]; | 90 | int modeScroll[max_SidebarMode]; |
91 | int width; | 91 | iLabelWidget * modeButtons[max_SidebarMode]; |
92 | iLabelWidget *modeButtons[max_SidebarMode]; | 92 | int maxButtonLabelWidth; |
93 | int maxButtonLabelWidth; | 93 | int width; |
94 | iWidget *resizer; | 94 | iWidget * resizer; |
95 | SDL_Cursor *resizeCursor; | 95 | SDL_Cursor * resizeCursor; |
96 | iWidget *menu; | 96 | iWidget * menu; |
97 | iSidebarItem *menuItem; /* list item accessed in the context menu */ | 97 | iSidebarItem * menuItem; /* list item accessed in the context menu */ |
98 | }; | 98 | }; |
99 | 99 | ||
100 | iDefineObjectConstruction(SidebarWidget) | 100 | iDefineObjectConstruction(SidebarWidget) |
@@ -149,10 +149,6 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) { | |||
149 | const iBookmark *bm = get_Bookmarks(bookmarks_App(), entry->bookmarkId); | 149 | const iBookmark *bm = get_Bookmarks(bookmarks_App(), entry->bookmarkId); |
150 | if (bm) { | 150 | if (bm) { |
151 | item->icon = bm->icon; | 151 | item->icon = bm->icon; |
152 | // appendCStr_String(&item->meta, uiTextCaution_ColorEscape); | ||
153 | // appendChar_String(&item->meta, bm->icon); | ||
154 | // appendChar_String(&item->meta, ' '); | ||
155 | // appendCStr_String(&item->meta, uiText_ColorEscape); | ||
156 | append_String(&item->meta, &bm->title); | 152 | append_String(&item->meta, &bm->title); |
157 | } | 153 | } |
158 | addItem_ListWidget(d->list, item); | 154 | addItem_ListWidget(d->list, item); |
@@ -167,8 +163,10 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) { | |||
167 | { "Add Bookmark...", 0, 0, "feed.entry.bookmark" }, | 163 | { "Add Bookmark...", 0, 0, "feed.entry.bookmark" }, |
168 | { "Edit Feed...", 0, 0, "feed.entry.edit" }, | 164 | { "Edit Feed...", 0, 0, "feed.entry.edit" }, |
169 | { "---", 0, 0, NULL }, | 165 | { "---", 0, 0, NULL }, |
170 | { uiTextCaution_ColorEscape "Unsubscribe", 0, 0, "feed.entry.unsubscribe" } }, | 166 | { uiTextCaution_ColorEscape "Unsubscribe...", 0, 0, "feed.entry.unsubscribe" }, |
171 | 8); | 167 | { "---", 0, 0, NULL }, |
168 | { "Refresh Feeds", SDLK_r, KMOD_PRIMARY | KMOD_SHIFT, "feeds.refresh" } }, | ||
169 | 10); | ||
172 | break; | 170 | break; |
173 | } | 171 | } |
174 | case documentOutline_SidebarMode: { | 172 | case documentOutline_SidebarMode: { |
@@ -942,6 +940,7 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect, | |||
942 | } | 940 | } |
943 | iInt2 pos = itemRect.pos; | 941 | iInt2 pos = itemRect.pos; |
944 | /* Selection indicator. */ | 942 | /* Selection indicator. */ |
943 | /* TODO: Make a better-looking one. */ | ||
945 | if (d->listItem.isSelected && (sidebar->mode == feeds_SidebarMode || | 944 | if (d->listItem.isSelected && (sidebar->mode == feeds_SidebarMode || |
946 | sidebar->mode == identities_SidebarMode)) { | 945 | sidebar->mode == identities_SidebarMode)) { |
947 | drawRectThickness_Paint(p, | 946 | drawRectThickness_Paint(p, |
@@ -962,7 +961,7 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect, | |||
962 | const int fg = isHover ? (isPressing ? uiTextPressed_ColorId : uiTextFramelessHover_ColorId) | 961 | const int fg = isHover ? (isPressing ? uiTextPressed_ColorId : uiTextFramelessHover_ColorId) |
963 | : uiText_ColorId; | 962 | : uiText_ColorId; |
964 | if (d->listItem.isSeparator) { | 963 | if (d->listItem.isSeparator) { |
965 | if (itemRect.pos.y > 0) { | 964 | if (d != constItem_ListWidget(list, 0)) { |
966 | drawHLine_Paint(p, | 965 | drawHLine_Paint(p, |
967 | addY_I2(pos, 2 * gap_UI), | 966 | addY_I2(pos, 2 * gap_UI), |
968 | width_Rect(itemRect) - scrollBarWidth, | 967 | width_Rect(itemRect) - scrollBarWidth, |
@@ -995,7 +994,9 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect, | |||
995 | drawCentered_Text(uiContent_FontId, | 994 | drawCentered_Text(uiContent_FontId, |
996 | adjusted_Rect(iconArea, init_I2(gap_UI, 0), zero_I2()), | 995 | adjusted_Rect(iconArea, init_I2(gap_UI, 0), zero_I2()), |
997 | iTrue, | 996 | iTrue, |
998 | isHover && isPressing ? iconColor : uiTextCaution_ColorId, | 997 | isHover && isPressing |
998 | ? iconColor | ||
999 | : (isUnread ? uiTextCaution_ColorId : iconColor), | ||
999 | "%s", | 1000 | "%s", |
1000 | cstr_String(&str)); | 1001 | cstr_String(&str)); |
1001 | deinit_String(&str); | 1002 | deinit_String(&str); |
diff --git a/src/ui/window.c b/src/ui/window.c index b31707fe..6e046bdc 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -97,7 +97,7 @@ static iBool handleRootCommands_(iWidget *root, const char *cmd) { | |||
97 | 97 | ||
98 | #if !defined (iHaveNativeMenus) | 98 | #if !defined (iHaveNativeMenus) |
99 | /* TODO: Submenus wouldn't hurt here. */ | 99 | /* TODO: Submenus wouldn't hurt here. */ |
100 | static const iMenuItem navMenuItems[] = { | 100 | static const iMenuItem navMenuItems_[] = { |
101 | { "New Tab", 't', KMOD_PRIMARY, "tabs.new" }, | 101 | { "New Tab", 't', KMOD_PRIMARY, "tabs.new" }, |
102 | { "Open Location...", SDLK_l, KMOD_PRIMARY, "navigate.focus" }, | 102 | { "Open Location...", SDLK_l, KMOD_PRIMARY, "navigate.focus" }, |
103 | { "---", 0, 0, NULL }, | 103 | { "---", 0, 0, NULL }, |
@@ -121,27 +121,21 @@ static const iMenuItem navMenuItems[] = { | |||
121 | 121 | ||
122 | #if defined (iHaveNativeMenus) | 122 | #if defined (iHaveNativeMenus) |
123 | /* Using native menus. */ | 123 | /* Using native menus. */ |
124 | static const iMenuItem fileMenuItems[] = { | 124 | static const iMenuItem fileMenuItems_[] = { |
125 | { "New Tab", SDLK_t, KMOD_PRIMARY, "tabs.new" }, | 125 | { "New Tab", SDLK_t, KMOD_PRIMARY, "tabs.new" }, |
126 | { "Open Location...", SDLK_l, KMOD_PRIMARY, "navigate.focus" }, | 126 | { "Open Location...", SDLK_l, KMOD_PRIMARY, "navigate.focus" }, |
127 | { "---", 0, 0, NULL }, | 127 | { "---", 0, 0, NULL }, |
128 | { "Save to Downloads", SDLK_s, KMOD_PRIMARY, "document.save" }, | 128 | { "Save to Downloads", SDLK_s, KMOD_PRIMARY, "document.save" }, |
129 | }; | 129 | }; |
130 | 130 | ||
131 | static const iMenuItem editMenuItems[] = { | 131 | static const iMenuItem editMenuItems_[] = { |
132 | { "Copy", SDLK_c, KMOD_PRIMARY, "copy" }, | 132 | { "Copy", SDLK_c, KMOD_PRIMARY, "copy" }, |
133 | { "Copy Link to Page", SDLK_c, KMOD_PRIMARY | KMOD_SHIFT, "document.copylink" }, | 133 | { "Copy Link to Page", SDLK_c, KMOD_PRIMARY | KMOD_SHIFT, "document.copylink" }, |
134 | { "---", 0, 0, NULL }, | 134 | { "---", 0, 0, NULL }, |
135 | { "Find", SDLK_f, KMOD_PRIMARY, "focus.set id:find.input" }, | 135 | { "Find", SDLK_f, KMOD_PRIMARY, "focus.set id:find.input" }, |
136 | { "---", 0, 0, NULL }, | ||
137 | { "Bookmark This Page...", SDLK_d, KMOD_PRIMARY, "bookmark.add" }, | ||
138 | }; | 136 | }; |
139 | 137 | ||
140 | static const iMenuItem identityMenuItems[] = { | 138 | static const iMenuItem viewMenuItems_[] = { |
141 | { "New Identity...", SDLK_n, KMOD_PRIMARY | KMOD_SHIFT, "ident.new" }, | ||
142 | }; | ||
143 | |||
144 | static const iMenuItem viewMenuItems[] = { | ||
145 | { "Show Bookmarks", '1', KMOD_PRIMARY, "sidebar.mode arg:0 toggle:1" }, | 139 | { "Show Bookmarks", '1', KMOD_PRIMARY, "sidebar.mode arg:0 toggle:1" }, |
146 | { "Show Feeds", '2', KMOD_PRIMARY, "sidebar.mode arg:1 toggle:1" }, | 140 | { "Show Feeds", '2', KMOD_PRIMARY, "sidebar.mode arg:1 toggle:1" }, |
147 | { "Show History", '3', KMOD_PRIMARY, "sidebar.mode arg:2 toggle:1" }, | 141 | { "Show History", '3', KMOD_PRIMARY, "sidebar.mode arg:2 toggle:1" }, |
@@ -162,13 +156,25 @@ static const iMenuItem viewMenuItems[] = { | |||
162 | { "Wrap Preformatted", 0, 0, "forcewrap.toggle" } | 156 | { "Wrap Preformatted", 0, 0, "forcewrap.toggle" } |
163 | }; | 157 | }; |
164 | 158 | ||
165 | static const iMenuItem helpMenuItems[] = { | 159 | static iMenuItem bookmarksMenuItems_[] = { |
160 | { "Bookmark This Page...", SDLK_d, KMOD_PRIMARY, "bookmark.add" }, | ||
161 | { "---", 0, 0, NULL }, | ||
162 | { "Subscribe as Feed", 0, 0, "bookmark.addtag tag:subscribed" }, | ||
163 | { "---", 0, 0, NULL }, | ||
164 | { "Refresh Feeds", SDLK_r, KMOD_PRIMARY | KMOD_SHIFT, "feeds.refresh" }, | ||
165 | }; | ||
166 | |||
167 | static const iMenuItem identityMenuItems_[] = { | ||
168 | { "New Identity...", SDLK_n, KMOD_PRIMARY | KMOD_SHIFT, "ident.new" }, | ||
169 | }; | ||
170 | |||
171 | static const iMenuItem helpMenuItems_[] = { | ||
166 | { "Help", 0, 0, "!open url:about:help" }, | 172 | { "Help", 0, 0, "!open url:about:help" }, |
167 | { "Release Notes", 0, 0, "!open url:about:version" }, | 173 | { "Release Notes", 0, 0, "!open url:about:version" }, |
168 | }; | 174 | }; |
169 | #endif | 175 | #endif |
170 | 176 | ||
171 | static const iMenuItem identityButtonMenuItems[] = { | 177 | static const iMenuItem identityButtonMenuItems_[] = { |
172 | { "No Active Identity", 0, 0, "ident.showactive" }, | 178 | { "No Active Identity", 0, 0, "ident.showactive" }, |
173 | { "---", 0, 0, NULL }, | 179 | { "---", 0, 0, NULL }, |
174 | #if !defined (iHaveNativeMenus) | 180 | #if !defined (iHaveNativeMenus) |
@@ -377,7 +383,7 @@ static void setupUserInterface_Window(iWindow *d) { | |||
377 | addChild_Widget(navBar, iClob(newIcon_LabelWidget("\U0001f870", 0, 0, "navigate.back"))); | 383 | addChild_Widget(navBar, iClob(newIcon_LabelWidget("\U0001f870", 0, 0, "navigate.back"))); |
378 | addChild_Widget(navBar, iClob(newIcon_LabelWidget("\U0001f872", 0, 0, "navigate.forward"))); | 384 | addChild_Widget(navBar, iClob(newIcon_LabelWidget("\U0001f872", 0, 0, "navigate.forward"))); |
379 | iLabelWidget *idMenu = makeMenuButton_LabelWidget( | 385 | iLabelWidget *idMenu = makeMenuButton_LabelWidget( |
380 | "\U0001f464", identityButtonMenuItems, iElemCount(identityButtonMenuItems)); | 386 | "\U0001f464", identityButtonMenuItems_, iElemCount(identityButtonMenuItems_)); |
381 | setAlignVisually_LabelWidget(idMenu, iTrue); | 387 | setAlignVisually_LabelWidget(idMenu, iTrue); |
382 | addChild_Widget(navBar, iClob(idMenu)); | 388 | addChild_Widget(navBar, iClob(idMenu)); |
383 | setId_Widget(as_Widget(idMenu), "navbar.ident"); | 389 | setId_Widget(as_Widget(idMenu), "navbar.ident"); |
@@ -414,15 +420,16 @@ static void setupUserInterface_Window(iWindow *d) { | |||
414 | "\U0001f3e0", SDLK_h, KMOD_PRIMARY | KMOD_SHIFT, "navigate.home"))); | 420 | "\U0001f3e0", SDLK_h, KMOD_PRIMARY | KMOD_SHIFT, "navigate.home"))); |
415 | #if !defined (iHaveNativeMenus) | 421 | #if !defined (iHaveNativeMenus) |
416 | iLabelWidget *navMenu = | 422 | iLabelWidget *navMenu = |
417 | makeMenuButton_LabelWidget("\U0001d362", navMenuItems, iElemCount(navMenuItems)); | 423 | makeMenuButton_LabelWidget("\U0001d362", navMenuItems_, iElemCount(navMenuItems_)); |
418 | setAlignVisually_LabelWidget(navMenu, iTrue); | 424 | setAlignVisually_LabelWidget(navMenu, iTrue); |
419 | addChild_Widget(navBar, iClob(navMenu)); | 425 | addChild_Widget(navBar, iClob(navMenu)); |
420 | #else | 426 | #else |
421 | insertMenuItems_MacOS("File", 1, fileMenuItems, iElemCount(fileMenuItems)); | 427 | insertMenuItems_MacOS("File", 1, fileMenuItems_, iElemCount(fileMenuItems_)); |
422 | insertMenuItems_MacOS("Edit", 2, editMenuItems, iElemCount(editMenuItems)); | 428 | insertMenuItems_MacOS("Edit", 2, editMenuItems_, iElemCount(editMenuItems_)); |
423 | insertMenuItems_MacOS("View", 3, viewMenuItems, iElemCount(viewMenuItems)); | 429 | insertMenuItems_MacOS("View", 3, viewMenuItems_, iElemCount(viewMenuItems_)); |
424 | insertMenuItems_MacOS("Identity", 4, identityMenuItems, iElemCount(identityMenuItems)); | 430 | insertMenuItems_MacOS("Bookmarks", 4, bookmarksMenuItems_, iElemCount(bookmarksMenuItems_)); |
425 | insertMenuItems_MacOS("Help", 6, helpMenuItems, iElemCount(helpMenuItems)); | 431 | insertMenuItems_MacOS("Identity", 5, identityMenuItems_, iElemCount(identityMenuItems_)); |
432 | insertMenuItems_MacOS("Help", 7, helpMenuItems_, iElemCount(helpMenuItems_)); | ||
426 | #endif | 433 | #endif |
427 | } | 434 | } |
428 | /* Tab bar. */ { | 435 | /* Tab bar. */ { |