diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-20 14:31:09 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-20 14:31:09 +0300 |
commit | 202e2a95e8f93d520377a03d0bc2c0c44cce95ab (patch) | |
tree | b5ca001a9b36380f301a21191a70290ec69ba49b /src | |
parent | 4b50a09a4c835c23ff0ff389e976f2539d41f61b (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')
-rw-r--r-- | src/app.c | 74 | ||||
-rw-r--r-- | src/ui/util.c | 54 |
2 files changed, 110 insertions, 18 deletions
@@ -1653,12 +1653,36 @@ iDocumentWidget *newTab_App(const iDocumentWidget *duplicateOf, iBool switchToNe | |||
1653 | 1653 | ||
1654 | static iBool handleIdentityCreationCommands_(iWidget *dlg, const char *cmd) { | 1654 | static 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 | } |
diff --git a/src/ui/util.c b/src/ui/util.c index 86478300..0c71cb1f 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -1551,8 +1551,8 @@ void updatePreferencesLayout_Widget(iWidget *prefs) { | |||
1551 | } | 1551 | } |
1552 | } | 1552 | } |
1553 | 1553 | ||
1554 | static void addDialogInputWithHeading_(iWidget *headings, iWidget *values, const char *labelText, | 1554 | static void addDialogInputWithHeadingAndFlags_(iWidget *headings, iWidget *values, const char *labelText, |
1555 | const char *inputId, iInputWidget *input) { | 1555 | const char *inputId, iInputWidget *input, int64_t flags) { |
1556 | iLabelWidget *head = addChild_Widget(headings, iClob(makeHeading_Widget(labelText))); | 1556 | iLabelWidget *head = addChild_Widget(headings, iClob(makeHeading_Widget(labelText))); |
1557 | #if defined (iPlatformMobile) | 1557 | #if defined (iPlatformMobile) |
1558 | /* On mobile, inputs have 2 gaps of extra padding. */ | 1558 | /* On mobile, inputs have 2 gaps of extra padding. */ |
@@ -1564,6 +1564,13 @@ static void addDialogInputWithHeading_(iWidget *headings, iWidget *values, const | |||
1564 | /* Ensure that the label has the same height as the input widget. */ | 1564 | /* Ensure that the label has the same height as the input widget. */ |
1565 | as_Widget(head)->sizeRef = as_Widget(input); | 1565 | as_Widget(head)->sizeRef = as_Widget(input); |
1566 | } | 1566 | } |
1567 | setFlags_Widget(as_Widget(head), flags, iTrue); | ||
1568 | setFlags_Widget(as_Widget(input), flags, iTrue); | ||
1569 | } | ||
1570 | |||
1571 | static void addDialogInputWithHeading_(iWidget *headings, iWidget *values, const char *labelText, | ||
1572 | const char *inputId, iInputWidget *input) { | ||
1573 | addDialogInputWithHeadingAndFlags_(headings, values, labelText, inputId, input, 0); | ||
1567 | } | 1574 | } |
1568 | 1575 | ||
1569 | iInputWidget *addTwoColumnDialogInputField_Widget(iWidget *headings, iWidget *values, | 1576 | iInputWidget *addTwoColumnDialogInputField_Widget(iWidget *headings, iWidget *values, |
@@ -2049,7 +2056,21 @@ iWidget *makeIdentityCreation_Widget(void) { | |||
2049 | page, iClob(new_Widget()), arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag); | 2056 | page, iClob(new_Widget()), arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag); |
2050 | iWidget *values = addChildFlags_Widget( | 2057 | iWidget *values = addChildFlags_Widget( |
2051 | page, iClob(new_Widget()), arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag); | 2058 | page, iClob(new_Widget()), arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag); |
2059 | setId_Widget(headings, "headings"); | ||
2060 | setId_Widget(values, "values"); | ||
2052 | iInputWidget *inputs[6]; | 2061 | iInputWidget *inputs[6]; |
2062 | /* Where will the new identity be active on? */ { | ||
2063 | addChild_Widget(headings, iClob(makeHeading_Widget("${dlg.newident.scope}"))); | ||
2064 | const iMenuItem items[] = { | ||
2065 | { "Current Domain", 0, 0, "ident.scope arg:0" }, | ||
2066 | { "Current Page", 0, 0, "ident.scope arg:1" }, | ||
2067 | { "Not Used", 0, 0, "ident.scope arg:2" }, | ||
2068 | }; | ||
2069 | setId_Widget(addChild_Widget(values, | ||
2070 | iClob(makeMenuButton_LabelWidget( | ||
2071 | items[0].label, items, iElemCount(items)))), | ||
2072 | "ident.scope"); | ||
2073 | } | ||
2053 | addDialogInputWithHeading_(headings, | 2074 | addDialogInputWithHeading_(headings, |
2054 | values, | 2075 | values, |
2055 | "${dlg.newident.until}", | 2076 | "${dlg.newident.until}", |
@@ -2066,32 +2087,35 @@ iWidget *makeIdentityCreation_Widget(void) { | |||
2066 | setFlags_Widget(tmpGroup, arrangeSize_WidgetFlag | arrangeHorizontal_WidgetFlag, iTrue); | 2087 | setFlags_Widget(tmpGroup, arrangeSize_WidgetFlag | arrangeHorizontal_WidgetFlag, iTrue); |
2067 | addChild_Widget(tmpGroup, iClob(makeToggle_Widget("ident.temp"))); | 2088 | addChild_Widget(tmpGroup, iClob(makeToggle_Widget("ident.temp"))); |
2068 | setId_Widget( | 2089 | setId_Widget( |
2069 | addChildFlags_Widget( | 2090 | addChildFlags_Widget(tmpGroup, |
2070 | tmpGroup, | 2091 | iClob(new_LabelWidget(uiTextCaution_ColorEscape warning_Icon |
2071 | iClob(new_LabelWidget(uiTextCaution_ColorEscape "\u26a0 ${dlg.newident.notsaved}", NULL)), | 2092 | " ${dlg.newident.notsaved}", |
2072 | hidden_WidgetFlag | frameless_WidgetFlag), | 2093 | NULL)), |
2094 | hidden_WidgetFlag | frameless_WidgetFlag), | ||
2073 | "ident.temp.note"); | 2095 | "ident.temp.note"); |
2074 | addChild_Widget(values, iClob(tmpGroup)); | 2096 | addChild_Widget(values, iClob(tmpGroup)); |
2075 | } | 2097 | } |
2076 | addChild_Widget(headings, iClob(makePadding_Widget(gap_UI))); | 2098 | addChildFlags_Widget(headings, iClob(makePadding_Widget(gap_UI)), collapse_WidgetFlag | hidden_WidgetFlag); |
2077 | addChild_Widget(values, iClob(makePadding_Widget(gap_UI))); | 2099 | addChildFlags_Widget(values, iClob(makePadding_Widget(gap_UI)), collapse_WidgetFlag | hidden_WidgetFlag); |
2078 | addDialogInputWithHeading_(headings, values, "${dlg.newident.email}", "ident.email", iClob(inputs[1] = newHint_InputWidget(0, "${hint.newident.optional}"))); | 2100 | addDialogInputWithHeadingAndFlags_(headings, values, "${dlg.newident.email}", "ident.email", iClob(inputs[1] = newHint_InputWidget(0, "${hint.newident.optional}")), collapse_WidgetFlag | hidden_WidgetFlag); |
2079 | addDialogInputWithHeading_(headings, values, "${dlg.newident.userid}", "ident.userid", iClob(inputs[2] = newHint_InputWidget(0, "${hint.newident.optional}"))); | 2101 | addDialogInputWithHeadingAndFlags_(headings, values, "${dlg.newident.userid}", "ident.userid", iClob(inputs[2] = newHint_InputWidget(0, "${hint.newident.optional}")), collapse_WidgetFlag | hidden_WidgetFlag); |
2080 | addDialogInputWithHeading_(headings, values, "${dlg.newident.domain}", "ident.domain", iClob(inputs[3] = newHint_InputWidget(0, "${hint.newident.optional}"))); | 2102 | addDialogInputWithHeadingAndFlags_(headings, values, "${dlg.newident.domain}", "ident.domain", iClob(inputs[3] = newHint_InputWidget(0, "${hint.newident.optional}")), collapse_WidgetFlag | hidden_WidgetFlag); |
2081 | addDialogInputWithHeading_(headings, values, "${dlg.newident.org}", "ident.org", iClob(inputs[4] = newHint_InputWidget(0, "${hint.newident.optional}"))); | 2103 | addDialogInputWithHeadingAndFlags_(headings, values, "${dlg.newident.org}", "ident.org", iClob(inputs[4] = newHint_InputWidget(0, "${hint.newident.optional}")), collapse_WidgetFlag | hidden_WidgetFlag); |
2082 | addDialogInputWithHeading_(headings, values, "${dlg.newident.country}", "ident.country", iClob(inputs[5] = newHint_InputWidget(0, "${hint.newident.optional}"))); | 2104 | addDialogInputWithHeadingAndFlags_(headings, values, "${dlg.newident.country}", "ident.country", iClob(inputs[5] = newHint_InputWidget(0, "${hint.newident.optional}")), collapse_WidgetFlag | hidden_WidgetFlag); |
2083 | arrange_Widget(dlg); | 2105 | arrange_Widget(dlg); |
2084 | for (size_t i = 0; i < iElemCount(inputs); ++i) { | 2106 | for (size_t i = 0; i < iElemCount(inputs); ++i) { |
2085 | as_Widget(inputs[i])->rect.size.x = 100 * gap_UI - headings->rect.size.x; | 2107 | as_Widget(inputs[i])->rect.size.x = 100 * gap_UI - headings->rect.size.x; |
2086 | } | 2108 | } |
2087 | addChild_Widget(dlg, | 2109 | addChild_Widget(dlg, |
2088 | iClob(makeDialogButtons_Widget( | 2110 | iClob(makeDialogButtons_Widget( |
2089 | (iMenuItem[]){ { "${cancel}", 0, 0, NULL }, | 2111 | (iMenuItem[]){ { "${dlg.newident.more}", 0, 0, "ident.showmore" }, |
2112 | { "---", 0, 0, NULL }, | ||
2113 | { "${cancel}", SDLK_ESCAPE, 0, "ident.cancel" }, | ||
2090 | { uiTextAction_ColorEscape "${dlg.newident.create}", | 2114 | { uiTextAction_ColorEscape "${dlg.newident.create}", |
2091 | SDLK_RETURN, | 2115 | SDLK_RETURN, |
2092 | KMOD_PRIMARY, | 2116 | KMOD_PRIMARY, |
2093 | "ident.accept" } }, | 2117 | "ident.accept" } }, |
2094 | 2))); | 2118 | 4))); |
2095 | addChild_Widget(get_Root()->widget, iClob(dlg)); | 2119 | addChild_Widget(get_Root()->widget, iClob(dlg)); |
2096 | finalizeSheet_Mobile(dlg); | 2120 | finalizeSheet_Mobile(dlg); |
2097 | return dlg; | 2121 | return dlg; |