summaryrefslogtreecommitdiff
path: root/src/ui/documentwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-02-22 21:35:10 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-02-22 21:35:10 +0200
commit90443011c98a6dc8340d2c84f1e538c7a98327f2 (patch)
tree94e1522758d7b83be08144ae4bac54853fd3a277 /src/ui/documentwidget.c
parent1174f2e9318a58602baccdfb3e2465645d263601 (diff)
Dialog buttons on the right
Follow typical GUI conventions by placing dialog buttons on the right edge. This leaves space for additional actions on the left.
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r--src/ui/documentwidget.c46
1 files changed, 32 insertions, 14 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 7e7ac79f..69461901 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -1645,10 +1645,8 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
1645 return iFalse; 1645 return iFalse;
1646 } 1646 }
1647 else if (equal_Command(cmd, "document.info") && d == document_App()) { 1647 else if (equal_Command(cmd, "document.info") && d == document_App()) {
1648 const char *unchecked = red_ColorEscape "\u2610"; 1648 const char *unchecked = red_ColorEscape "\u2610";
1649 const char *checked = green_ColorEscape "\u2611"; 1649 const char *checked = green_ColorEscape "\u2611";
1650 const char *actionLabels[] = { uiTextCaution_ColorEscape "Trust", "Copy Fingerprint", "Dismiss" };
1651 const char *actionCmds[] = { "server.trustcert", "server.copycert", "message.ok" };
1652 const iBool haveFingerprint = (d->certFlags & haveFingerprint_GmCertFlag) != 0; 1650 const iBool haveFingerprint = (d->certFlags & haveFingerprint_GmCertFlag) != 0;
1653 const iBool canTrust = 1651 const iBool canTrust =
1654 (d->certFlags == (available_GmCertFlag | haveFingerprint_GmCertFlag | 1652 (d->certFlags == (available_GmCertFlag | haveFingerprint_GmCertFlag |
@@ -1692,11 +1690,23 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
1692 uiText_ColorEscape, 1690 uiText_ColorEscape,
1693 d->certFlags & trusted_GmCertFlag ? "Trusted" : "Not trusted"); 1691 d->certFlags & trusted_GmCertFlag ? "Trusted" : "Not trusted");
1694 setFocus_Widget(NULL); 1692 setFocus_Widget(NULL);
1693 iArray *items = new_Array(sizeof(iMenuItem));
1694 if (canTrust) {
1695 pushBack_Array(
1696 items, &(iMenuItem){ uiTextCaution_ColorEscape "Trust", 0, 0, "server.trustcert" });
1697 }
1698 if (haveFingerprint) {
1699 pushBack_Array(items, &(iMenuItem){ "Copy Fingerprint", 0, 0, "server.copycert" });
1700 }
1701 if (!isEmpty_Array(items)) {
1702 pushBack_Array(items, &(iMenuItem){ "---", 0, 0, 0 });
1703 }
1704 pushBack_Array(items, &(iMenuItem){ "Dismiss", 0, 0, "message.ok" });
1695 iWidget *dlg = makeQuestion_Widget(uiHeading_ColorEscape "PAGE INFORMATION", 1705 iWidget *dlg = makeQuestion_Widget(uiHeading_ColorEscape "PAGE INFORMATION",
1696 cstr_String(msg), 1706 cstr_String(msg),
1697 actionLabels + (canTrust ? 0 : haveFingerprint ? 1 : 2), 1707 data_Array(items),
1698 actionCmds + (canTrust ? 0 : haveFingerprint ? 1 : 2), 1708 size_Array(items));
1699 canTrust ? 3 : haveFingerprint ? 2 : 1); 1709 delete_Array(items);
1700 /* Enforce a minimum size. */ 1710 /* Enforce a minimum size. */
1701 iWidget *sizer = new_Widget(); 1711 iWidget *sizer = new_Widget();
1702 setSize_Widget(sizer, init_I2(gap_UI * 90, 1)); 1712 setSize_Widget(sizer, init_I2(gap_UI * 90, 1));
@@ -2072,11 +2082,18 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
2072 makeQuestion_Widget( 2082 makeQuestion_Widget(
2073 uiHeading_ColorEscape "IMPORT BOOKMARKS", 2083 uiHeading_ColorEscape "IMPORT BOOKMARKS",
2074 format_CStr("Found %d new link%s on the page.", size_PtrArray(links), plural), 2084 format_CStr("Found %d new link%s on the page.", size_PtrArray(links), plural),
2075 (const char *[]){ "Cancel", 2085 (iMenuItem[]){ { "Cancel", 0, 0, NULL },
2076 format_CStr(uiTextAction_ColorEscape "Add %d Bookmark%s", 2086 { format_CStr(uiTextAction_ColorEscape "Add %d Bookmark%s",
2077 size_PtrArray(links), plural) }, 2087 size_PtrArray(links),
2078 (const char *[]){ "cancel", "bookmark.links" }, 2088 plural), 0, 0, "bookmark.links" } },
2079 2); 2089 2);
2090
2091 // (const char *[]){ "Cancel",
2092 // format_CStr(uiTextAction_ColorEscape "Add %d
2093 // Bookmark%s",
2094 // size_PtrArray(links), plural) },
2095 // (const char *[]){ "cancel", "bookmark.links" },
2096 // 2);
2080 } 2097 }
2081 else { 2098 else {
2082 iConstForEach(PtrArray, j, links) { 2099 iConstForEach(PtrArray, j, links) {
@@ -2669,9 +2686,10 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
2669 "Open this link in the default browser?\n" uiTextAction_ColorEscape 2686 "Open this link in the default browser?\n" uiTextAction_ColorEscape
2670 "%s", 2687 "%s",
2671 cstr_String(url)), 2688 cstr_String(url)),
2672 (const char *[]){ "Cancel", uiTextCaution_ColorEscape "Open Link" }, 2689 (iMenuItem[]){
2673 (const char *[]){ 2690 { "Cancel", 0, 0, NULL },
2674 "cancel", format_CStr("!open default:1 url:%s", cstr_String(url)) }, 2691 { uiTextCaution_ColorEscape "Open Link",
2692 0, 0, format_CStr("!open default:1 url:%s", cstr_String(url)) } },
2675 2); 2693 2);
2676 } 2694 }
2677 } 2695 }