From 09c1f3d7c06b1852ab973e16e2c169a6e541082e Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Sun, 20 Feb 2022 11:42:36 +0200 Subject: Context menu items for opening items --- src/ui/documentwidget.c | 12 ++++++------ src/ui/sidebarwidget.c | 32 +++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 99039ff5..7492d9bd 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c @@ -5107,22 +5107,22 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e format_CStr("!open newtab:2 origin:%s url:%s", cstr_String(id_Widget(w)), cstr_String(linkUrl)) }, - { "${link.side}", + { openWindow_Icon " ${link.newwindow}", 0, 0, - format_CStr("!open newtab:4 origin:%s url:%s", + format_CStr("!open newwindow:1 origin:%s url:%s", cstr_String(id_Widget(w)), cstr_String(linkUrl)) }, - { "${link.side.newtab}", + { "${link.side}", 0, 0, - format_CStr("!open newtab:5 origin:%s url:%s", + format_CStr("!open newtab:4 origin:%s url:%s", cstr_String(id_Widget(w)), cstr_String(linkUrl)) }, - { openWindow_Icon " ${link.newwindow}", + { "${link.side.newtab}", 0, 0, - format_CStr("!open newwindow:1 origin:%s url:%s", + format_CStr("!open newtab:5 origin:%s url:%s", cstr_String(id_Widget(w)), cstr_String(linkUrl)) }, }, diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index 0322b2a9..8f9e44c8 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c @@ -420,7 +420,7 @@ static void updateItemsWithFlags_SidebarWidget_(iSidebarWidget *d, iBool keepAct { "---", 0, 0, NULL }, { circle_Icon " ${feeds.entry.markread}", 0, 0, "feed.entry.toggleread" }, { bookmark_Icon " ${feeds.entry.bookmark}", 0, 0, "feed.entry.bookmark" }, - { "${menu.copyurl}", 0, 0, "feed.entry.copyurl" }, + { "${menu.copyurl}", 0, 0, "feed.entry.copy" }, { "---", 0, 0, NULL }, { page_Icon " ${feeds.entry.openfeed}", 0, 0, "feed.entry.openfeed" }, { edit_Icon " ${feeds.edit}", 0, 0, "feed.entry.edit" }, @@ -580,8 +580,8 @@ static void updateItemsWithFlags_SidebarWidget_(iSidebarWidget *d, iBool keepAct { openTabBg_Icon " ${menu.opentab.background}", 0, 0, "history.open newtab:2" }, { openWindow_Icon " ${menu.openwindow}", 0, 0, "history.open newwindow:1" }, { "---" }, - { "${menu.copyurl}", 0, 0, "history.copy" }, { bookmark_Icon " ${sidebar.entry.bookmark}", 0, 0, "history.addbookmark" }, + { "${menu.copyurl}", 0, 0, "history.copy" }, { "---", 0, 0, NULL }, { close_Icon " ${menu.forgeturl}", 0, 0, "history.delete" }, { "---", 0, 0, NULL }, @@ -1652,12 +1652,18 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) if (item) { if (isCommand_Widget(w, ev, "feed.entry.open")) { const char *cmd = command_UserEvent(ev); - postCommandString_Root(get_Root(), feedEntryOpenCommand_String(&item->url, - argLabel_Command(cmd, "newtab"), - argLabel_Command(cmd, "newwindow"))); + postCommandString_Root( + get_Root(), + feedEntryOpenCommand_String(&item->url, + argLabel_Command(cmd, "newtab"), + argLabel_Command(cmd, "newwindow"))); return iTrue; } - if (isCommand_Widget(w, ev, "feed.entry.toggleread")) { + else if (isCommand_Widget(w, ev, "feed.entry.copy")) { + SDL_SetClipboardText(cstr_String(&item->url)); + return iTrue; + } + else if (isCommand_Widget(w, ev, "feed.entry.toggleread")) { iVisited *vis = visited_App(); const iString *url = urlFragmentStripped_String(&item->url); if (containsUrl_Visited(vis, url)) { @@ -1669,7 +1675,7 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) postCommand_App("visited.changed"); return iTrue; } - if (isCommand_Widget(w, ev, "feed.entry.bookmark")) { + else if (isCommand_Widget(w, ev, "feed.entry.bookmark")) { makeBookmarkCreation_Widget(&item->url, &item->label, item->icon); if (deviceType_App() == desktop_AppDeviceType) { postCommand_App("focus.set id:bmed.title"); @@ -1718,6 +1724,18 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) } return iTrue; } + else if (isCommand_Widget(w, ev, "history.open")) { + const iSidebarItem *item = d->contextItem; + if (item && !isEmpty_String(&item->url)) { + const char *cmd = command_UserEvent(ev); + postCommand_Widget(d, + "!open newtab:%d newwindow:%d url:%s", + argLabel_Command(cmd, "newtab"), + argLabel_Command(cmd, "newwindow"), + cstr_String(&item->url)); + } + return iTrue; + } else if (isCommand_Widget(w, ev, "history.copy")) { const iSidebarItem *item = d->contextItem; if (item && !isEmpty_String(&item->url)) { -- cgit v1.2.3