summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-08-27 12:10:45 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-08-27 12:10:45 +0300
commit6f397e3e0d6623b6bf2b737825d4b3ad084eba4c (patch)
tree9bf158ea67d9ef59c4ce1f33f613d835f363f665 /src
parentee8b890f2412119add7870d7aadd07078d6b315c (diff)
SidebarWidget: Working on identity commands
Diffstat (limited to 'src')
-rw-r--r--src/ui/sidebarwidget.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 3f9f8503..7fd0d7f1 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -35,7 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
35#include "util.h" 35#include "util.h"
36#include "visited.h" 36#include "visited.h"
37 37
38#include <the_Foundation/array.h> 38#include <the_Foundation/stringarray.h>
39#include <SDL_clipboard.h> 39#include <SDL_clipboard.h>
40#include <SDL_mouse.h> 40#include <SDL_mouse.h>
41 41
@@ -232,9 +232,9 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) {
232 &item.meta, 232 &item.meta,
233 collectNewFormat_String( 233 collectNewFormat_String(
234 "%s \u2014 %s\n%s", 234 "%s \u2014 %s\n%s",
235 isEmpty_SortedArray(&ident->useUrls) 235 isUsed_GmIdentity(ident)
236 ? "Not used" 236 ? format_CStr("Used on %zu URLs", size_StringSet(ident->useUrls))
237 : format_CStr("Used on %zu URLs", size_SortedArray(&ident->useUrls)), 237 : "Not used",
238 ident->flags & temporary_GmIdentityFlag 238 ident->flags & temporary_GmIdentityFlag
239 ? "Temporary" 239 ? "Temporary"
240 : cstrCollect_String(format_Date(&until, "Expires %b %d, %Y")), 240 : cstrCollect_String(format_Date(&until, "Expires %b %d, %Y")),
@@ -600,10 +600,25 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
600 updateItems_SidebarWidget_(d); 600 updateItems_SidebarWidget_(d);
601 } 601 }
602 else if (isCommand_Widget(w, ev, "ident.use")) { 602 else if (isCommand_Widget(w, ev, "ident.use")) {
603 603 iGmIdentity *ident = hoverIdentity_SidebarWidget_(d);
604 if (ident) {
605 if (argLabel_Command(cmd, "clear")) {
606 clearUse_GmIdentity(ident);
607 }
608 else {
609 setUse_GmIdentity(
610 ident, url_DocumentWidget(document_App()), arg_Command(cmd) != 0);
611 }
612 updateItems_SidebarWidget_(d);
613 }
604 return iTrue; 614 return iTrue;
605 } 615 }
606 else if (isCommand_Widget(w, ev, "ident.showuse")) { 616 else if (isCommand_Widget(w, ev, "ident.showuse")) {
617 const iGmIdentity *ident = constHoverIdentity_SidebarWidget_(d);
618 if (ident) {
619 makeMessage_Widget(uiHeading_ColorEscape "IDENTITY USAGE",
620 cstrCollect_String(joinCStr_StringSet(ident->useUrls, "\n")));
621 }
607 return iTrue; 622 return iTrue;
608 } 623 }
609 else if (isCommand_Widget(w, ev, "ident.edit")) { 624 else if (isCommand_Widget(w, ev, "ident.edit")) {
@@ -718,11 +733,10 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
718 iLabelWidget *menuItem = i.object; 733 iLabelWidget *menuItem = i.object;
719 const char * itemCmd = cstr_String(command_LabelWidget(menuItem)); 734 const char * itemCmd = cstr_String(command_LabelWidget(menuItem));
720 if (equal_Command(itemCmd, "ident.use")) { 735 if (equal_Command(itemCmd, "ident.use")) {
721 if (!arg_Command(itemCmd)) { 736 setFlags_Widget(as_Widget(menuItem),
722 setFlags_Widget(as_Widget(menuItem), 737 disabled_WidgetFlag,
723 disabled_WidgetFlag, 738 (arg_Command(itemCmd) != 0) ^
724 !isUsed_GmIdentity(ident)); 739 (!isUsed_GmIdentity(ident)));
725 }
726 } 740 }
727 else if (equal_Command(itemCmd, "ident.showuse")) { 741 else if (equal_Command(itemCmd, "ident.showuse")) {
728 setFlags_Widget(as_Widget(menuItem), 742 setFlags_Widget(as_Widget(menuItem),