summaryrefslogtreecommitdiff
path: root/src/app.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-05-20 14:31:09 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-05-20 14:31:09 +0300
commit202e2a95e8f93d520377a03d0bc2c0c44cce95ab (patch)
treeb5ca001a9b36380f301a21191a70290ec69ba49b /src/app.c
parent4b50a09a4c835c23ff0ff389e976f2539d41f61b (diff)
Identity creation user experience
Revised the New Identity dialog to hide the additional fields by default. Added a new option to select where the new identity will be active (current domain/page/nowhere). When the new identity is automatically activated, reload the URL used for activation.
Diffstat (limited to 'src/app.c')
-rw-r--r--src/app.c74
1 files changed, 71 insertions, 3 deletions
diff --git a/src/app.c b/src/app.c
index 3f0ec2c4..4c4d08e9 100644
--- a/src/app.c
+++ b/src/app.c
@@ -1653,12 +1653,36 @@ iDocumentWidget *newTab_App(const iDocumentWidget *duplicateOf, iBool switchToNe
1653 1653
1654static iBool handleIdentityCreationCommands_(iWidget *dlg, const char *cmd) { 1654static iBool handleIdentityCreationCommands_(iWidget *dlg, const char *cmd) {
1655 iApp *d = &app_; 1655 iApp *d = &app_;
1656 if (equal_Command(cmd, "ident.showmore")) {
1657 iForEach(ObjectList, i, children_Widget(findChild_Widget(dlg, "headings"))) {
1658 if (flags_Widget(i.object) & collapse_WidgetFlag) {
1659 setFlags_Widget(i.object, hidden_WidgetFlag, iFalse);
1660 }
1661 }
1662 iForEach(ObjectList, j, children_Widget(findChild_Widget(dlg, "values"))) {
1663 if (flags_Widget(j.object) & collapse_WidgetFlag) {
1664 setFlags_Widget(j.object, hidden_WidgetFlag, iFalse);
1665 }
1666 }
1667 setFlags_Widget(child_Widget(findChild_Widget(dlg, "dialogbuttons"), 0), disabled_WidgetFlag,
1668 iTrue);
1669 arrange_Widget(dlg);
1670 refresh_Widget(dlg);
1671 return iTrue;
1672 }
1673 if (equal_Command(cmd, "ident.scope")) {
1674 iLabelWidget *scope = findChild_Widget(dlg, "ident.scope");
1675 setText_LabelWidget(scope,
1676 text_LabelWidget(child_Widget(
1677 findChild_Widget(as_Widget(scope), "menu"), arg_Command(cmd))));
1678 return iTrue;
1679 }
1656 if (equal_Command(cmd, "ident.temp.changed")) { 1680 if (equal_Command(cmd, "ident.temp.changed")) {
1657 setFlags_Widget( 1681 setFlags_Widget(
1658 findChild_Widget(dlg, "ident.temp.note"), hidden_WidgetFlag, !arg_Command(cmd)); 1682 findChild_Widget(dlg, "ident.temp.note"), hidden_WidgetFlag, !arg_Command(cmd));
1659 return iFalse; 1683 return iFalse;
1660 } 1684 }
1661 if (equal_Command(cmd, "ident.accept") || equal_Command(cmd, "cancel")) { 1685 if (equal_Command(cmd, "ident.accept") || equal_Command(cmd, "ident.cancel")) {
1662 if (equal_Command(cmd, "ident.accept")) { 1686 if (equal_Command(cmd, "ident.accept")) {
1663 const iString *commonName = text_InputWidget (findChild_Widget(dlg, "ident.common")); 1687 const iString *commonName = text_InputWidget (findChild_Widget(dlg, "ident.common"));
1664 const iString *email = text_InputWidget (findChild_Widget(dlg, "ident.email")); 1688 const iString *email = text_InputWidget (findChild_Widget(dlg, "ident.email"));
@@ -1706,11 +1730,55 @@ static iBool handleIdentityCreationCommands_(iWidget *dlg, const char *cmd) {
1706 } 1730 }
1707 } 1731 }
1708 /* The input seems fine. */ 1732 /* The input seems fine. */
1709 newIdentity_GmCerts(d->certs, isTemp ? temporary_GmIdentityFlag : 0, 1733 iGmIdentity *ident = newIdentity_GmCerts(d->certs,
1710 until, commonName, email, userId, domain, organization, country); 1734 isTemp ? temporary_GmIdentityFlag : 0,
1735 until,
1736 commonName,
1737 email,
1738 userId,
1739 domain,
1740 organization,
1741 country);
1742 /* Use in the chosen scope. */ {
1743 const iLabelWidget *scope = findChild_Widget(dlg, "ident.scope");
1744 const iString * selLabel = text_LabelWidget(scope);
1745 int selScope = 0;
1746// printf("SelLabel: %s\n", cstr_String(selLabel));
1747 iConstForEach(ObjectList,
1748 i,
1749 children_Widget(findChild_Widget(constAs_Widget(scope), "menu"))) {
1750 if (isInstance_Object(i.object, &Class_LabelWidget)) {
1751 const iLabelWidget *item = i.object;
1752// printf("itemLabel: %s\n", cstr_String(text_LabelWidget(item)));
1753 if (equal_String(text_LabelWidget(item), selLabel)) {
1754 break;
1755 }
1756 selScope++;
1757 }
1758 }
1759// printf("selScope:%d\n", selScope);
1760 const iString *docUrl = url_DocumentWidget(document_Root(dlg->root));
1761 switch (selScope) {
1762 case 0: /* current domain */
1763 signIn_GmCerts(d->certs,
1764 ident,
1765 collectNewFormat_String(
1766 "gemini://%s", cstr_Rangecc(urlHost_String(docUrl))));
1767 break;
1768 case 1: /* current page */
1769 signIn_GmCerts(d->certs, ident, docUrl);
1770 break;
1771 default: /* not used */
1772 break;
1773 }
1774 if (selScope == 0 || selScope == 1) {
1775 postCommand_App("navigate.reload");
1776 }
1777 }
1711 postCommandf_App("sidebar.mode arg:%d show:1", identities_SidebarMode); 1778 postCommandf_App("sidebar.mode arg:%d show:1", identities_SidebarMode);
1712 postCommand_App("idents.changed"); 1779 postCommand_App("idents.changed");
1713 } 1780 }
1781 setupSheetTransition_Mobile(dlg, iFalse);
1714 destroy_Widget(dlg); 1782 destroy_Widget(dlg);
1715 return iTrue; 1783 return iTrue;
1716 } 1784 }