summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-12-07 14:01:40 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-12-07 14:01:40 +0200
commit91da66e855872972618d30e945c8b8932690388e (patch)
tree1079a223fda197ae70c4ba0a353dcd24699b7e42
parentf09b3f74dc512ee2fc09cba43c4ee7f07b895d90 (diff)
CertListWidget: Show current page's URL in menu
-rw-r--r--src/ui/certlistwidget.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/ui/certlistwidget.c b/src/ui/certlistwidget.c
index 7c140c19..31d8bac6 100644
--- a/src/ui/certlistwidget.c
+++ b/src/ui/certlistwidget.c
@@ -91,6 +91,12 @@ static iGmIdentity *menuIdentity_CertListWidget_(const iCertListWidget *d) {
91 91
92static void updateContextMenu_CertListWidget_(iCertListWidget *d) { 92static void updateContextMenu_CertListWidget_(iCertListWidget *d) {
93 iArray *items = collectNew_Array(sizeof(iMenuItem)); 93 iArray *items = collectNew_Array(sizeof(iMenuItem));
94 const iString *docUrl = url_DocumentWidget(document_App());
95 size_t firstIndex = 0;
96 if (deviceType_App() != desktop_AppDeviceType && !isEmpty_String(docUrl)) {
97 pushBack_Array(items, &(iMenuItem){ format_CStr("```%s", cstr_String(docUrl)) });
98 firstIndex = 1;
99 }
94 pushBackN_Array(items, (iMenuItem[]){ 100 pushBackN_Array(items, (iMenuItem[]){
95 { person_Icon " ${ident.use}", 0, 0, "ident.use arg:1" }, 101 { person_Icon " ${ident.use}", 0, 0, "ident.use arg:1" },
96 { close_Icon " ${ident.stopuse}", 0, 0, "ident.use arg:0" }, 102 { close_Icon " ${ident.stopuse}", 0, 0, "ident.use arg:0" },
@@ -105,11 +111,10 @@ static void updateContextMenu_CertListWidget_(iCertListWidget *d) {
105 /* Used URLs. */ 111 /* Used URLs. */
106 const iGmIdentity *ident = menuIdentity_CertListWidget_(d); 112 const iGmIdentity *ident = menuIdentity_CertListWidget_(d);
107 if (ident) { 113 if (ident) {
108 size_t insertPos = 3; 114 size_t insertPos = firstIndex + 3;
109 if (!isEmpty_StringSet(ident->useUrls)) { 115 if (!isEmpty_StringSet(ident->useUrls)) {
110 insert_Array(items, insertPos++, &(iMenuItem){ "---", 0, 0, NULL }); 116 insert_Array(items, insertPos++, &(iMenuItem){ "---", 0, 0, NULL });
111 } 117 }
112 const iString *docUrl = url_DocumentWidget(document_App());
113 iBool usedOnCurrentPage = iFalse; 118 iBool usedOnCurrentPage = iFalse;
114 iConstForEach(StringSet, i, ident->useUrls) { 119 iConstForEach(StringSet, i, ident->useUrls) {
115 const iString *url = i.value; 120 const iString *url = i.value;
@@ -126,10 +131,10 @@ static void updateContextMenu_CertListWidget_(iCertListWidget *d) {
126 format_CStr("!open url:%s", cstr_String(url)) }); 131 format_CStr("!open url:%s", cstr_String(url)) });
127 } 132 }
128 if (!usedOnCurrentPage) { 133 if (!usedOnCurrentPage) {
129 remove_Array(items, 1); 134 remove_Array(items, firstIndex + 1);
130 } 135 }
131 else { 136 else {
132 remove_Array(items, 0); 137 remove_Array(items, firstIndex);
133 } 138 }
134 } 139 }
135 destroy_Widget(d->menu); 140 destroy_Widget(d->menu);