diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-12-19 14:11:54 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-12-19 14:11:54 +0200 |
commit | c3ae8bac2bb7d7ed0450ac6c0f5916fd0ba32354 (patch) | |
tree | 35fae92c18d5b2509325e9d9a5a1b294ddcc4b42 /src/ui/sidebarwidget.c | |
parent | 443eb6e7e82ea7c42e430f16007b454c761be52d (diff) |
Duplicating a bookmark; cloud icon color
Diffstat (limited to 'src/ui/sidebarwidget.c')
-rw-r--r-- | src/ui/sidebarwidget.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index 4c7435c5..ad23da3e 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c | |||
@@ -230,7 +230,8 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) { | |||
230 | (iMenuItem[]){ { "Open in New Tab", 0, 0, "bookmark.open newtab:1" }, | 230 | (iMenuItem[]){ { "Open in New Tab", 0, 0, "bookmark.open newtab:1" }, |
231 | { "Open in Background Tab", 0, 0, "bookmark.open newtab:2" }, | 231 | { "Open in Background Tab", 0, 0, "bookmark.open newtab:2" }, |
232 | { "---", 0, 0, NULL }, | 232 | { "---", 0, 0, NULL }, |
233 | { "Edit Bookmark...", 0, 0, "bookmark.edit" }, | 233 | { "Edit...", 0, 0, "bookmark.edit" }, |
234 | { "Duplicate...", 0, 0, "bookmark.dup" }, | ||
234 | { "Copy URL", 0, 0, "bookmark.copy" }, | 235 | { "Copy URL", 0, 0, "bookmark.copy" }, |
235 | { "---", 0, 0, NULL }, | 236 | { "---", 0, 0, NULL }, |
236 | { "?", 0, 0, "bookmark.tag tag:subscribed" }, | 237 | { "?", 0, 0, "bookmark.tag tag:subscribed" }, |
@@ -239,8 +240,8 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) { | |||
239 | { "---", 0, 0, NULL }, | 240 | { "---", 0, 0, NULL }, |
240 | { uiTextCaution_ColorEscape "Delete Bookmark", 0, 0, "bookmark.delete" }, | 241 | { uiTextCaution_ColorEscape "Delete Bookmark", 0, 0, "bookmark.delete" }, |
241 | { "---", 0, 0, NULL }, | 242 | { "---", 0, 0, NULL }, |
242 | { "Refresh Remote Bookmarks", 0, 0, "bookmarks.reload.remote" } }, | 243 | { "Refresh Remote Sources", 0, 0, "bookmarks.reload.remote" } }, |
243 | 13); | 244 | 14); |
244 | break; | 245 | break; |
245 | } | 246 | } |
246 | case history_SidebarMode: { | 247 | case history_SidebarMode: { |
@@ -751,6 +752,22 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) | |||
751 | } | 752 | } |
752 | return iTrue; | 753 | return iTrue; |
753 | } | 754 | } |
755 | else if (isCommand_Widget(w, ev, "bookmark.dup")) { | ||
756 | const iSidebarItem *item = d->contextItem; | ||
757 | if (d->mode == bookmarks_SidebarMode && item) { | ||
758 | setFlags_Widget(w, disabled_WidgetFlag, iTrue); | ||
759 | iBookmark *bm = get_Bookmarks(bookmarks_App(), item->id); | ||
760 | const iBool isRemote = hasTag_Bookmark(bm, "remote"); | ||
761 | iChar icon = isRemote ? 0x1f588 : bm->icon; | ||
762 | iWidget *dlg = makeBookmarkCreation_Widget(&bm->url, &bm->title, icon); | ||
763 | setId_Widget(dlg, format_CStr("bmed.%s", cstr_String(id_Widget(w)))); | ||
764 | if (!isRemote) { | ||
765 | setText_InputWidget(findChild_Widget(dlg, "bmed.tags"), &bm->tags); | ||
766 | } | ||
767 | setFocus_Widget(findChild_Widget(dlg, "bmed.title")); | ||
768 | } | ||
769 | return iTrue; | ||
770 | } | ||
754 | else if (isCommand_Widget(w, ev, "bookmark.tag")) { | 771 | else if (isCommand_Widget(w, ev, "bookmark.tag")) { |
755 | const iSidebarItem *item = d->contextItem; | 772 | const iSidebarItem *item = d->contextItem; |
756 | if (d->mode == bookmarks_SidebarMode && item) { | 773 | if (d->mode == bookmarks_SidebarMode && item) { |
@@ -1220,7 +1237,14 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect, | |||
1220 | init_String(&str); | 1237 | init_String(&str); |
1221 | appendChar_String(&str, d->icon ? d->icon : 0x1f588); | 1238 | appendChar_String(&str, d->icon ? d->icon : 0x1f588); |
1222 | const iRect iconArea = { addX_I2(pos, gap_UI), init_I2(7 * gap_UI, itemHeight) }; | 1239 | const iRect iconArea = { addX_I2(pos, gap_UI), init_I2(7 * gap_UI, itemHeight) }; |
1223 | drawCentered_Text(font, iconArea, iTrue, iconColor, "%s", cstr_String(&str)); | 1240 | drawCentered_Text(font, |
1241 | iconArea, | ||
1242 | iTrue, | ||
1243 | isPressing ? iconColor | ||
1244 | : d->icon == 0x2601 /* remote */ ? uiTextCaution_ColorId | ||
1245 | : iconColor, | ||
1246 | "%s", | ||
1247 | cstr_String(&str)); | ||
1224 | deinit_String(&str); | 1248 | deinit_String(&str); |
1225 | const iInt2 textPos = addY_I2(topRight_Rect(iconArea), (itemHeight - lineHeight_Text(font)) / 2); | 1249 | const iInt2 textPos = addY_I2(topRight_Rect(iconArea), (itemHeight - lineHeight_Text(font)) / 2); |
1226 | drawRange_Text(font, textPos, fg, range_String(&d->label)); | 1250 | drawRange_Text(font, textPos, fg, range_String(&d->label)); |