diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-23 16:08:42 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-23 16:10:05 +0300 |
commit | 51dc5b1ef584a9aa214c518101b951f1745a6fc9 (patch) | |
tree | b904890f57bbf7e4412fd51cef8682cf37657663 | |
parent | 3b31ab31eb52578693acee07fdcf84fbeff72707 (diff) |
Added an identity creation dialog
-rw-r--r-- | src/app.c | 16 | ||||
-rw-r--r-- | src/gmcerts.c | 9 | ||||
-rw-r--r-- | src/ui/color.c | 4 | ||||
-rw-r--r-- | src/ui/color.h | 1 | ||||
-rw-r--r-- | src/ui/labelwidget.c | 6 | ||||
-rw-r--r-- | src/ui/labelwidget.h | 2 | ||||
-rw-r--r-- | src/ui/util.c | 68 | ||||
-rw-r--r-- | src/ui/util.h | 1 |
8 files changed, 101 insertions, 6 deletions
@@ -536,6 +536,17 @@ iDocumentWidget *newTab_App(const iDocumentWidget *duplicateOf) { | |||
536 | return doc; | 536 | return doc; |
537 | } | 537 | } |
538 | 538 | ||
539 | static iBool handleIdentityCreationCommands_(iWidget *dlg, const char *cmd) { | ||
540 | if (equal_Command(cmd, "ident.accept") || equal_Command(cmd, "cancel")) { | ||
541 | if (equal_Command(cmd, "ident.accept")) { | ||
542 | |||
543 | } | ||
544 | destroy_Widget(dlg); | ||
545 | return iTrue; | ||
546 | } | ||
547 | return iFalse; | ||
548 | } | ||
549 | |||
539 | iBool handleCommand_App(const char *cmd) { | 550 | iBool handleCommand_App(const char *cmd) { |
540 | iApp *d = &app_; | 551 | iApp *d = &app_; |
541 | if (equal_Command(cmd, "retainwindow")) { | 552 | if (equal_Command(cmd, "retainwindow")) { |
@@ -673,6 +684,11 @@ iBool handleCommand_App(const char *cmd) { | |||
673 | siteIcon_GmDocument(document_DocumentWidget(doc))); | 684 | siteIcon_GmDocument(document_DocumentWidget(doc))); |
674 | return iTrue; | 685 | return iTrue; |
675 | } | 686 | } |
687 | else if (equal_Command(cmd, "ident.new")) { | ||
688 | iWidget *dlg = makeIdentityCreation_Widget(); | ||
689 | setCommandHandler_Widget(dlg, handleIdentityCreationCommands_); | ||
690 | return iTrue; | ||
691 | } | ||
676 | else if (equal_Command(cmd, "theme.set")) { | 692 | else if (equal_Command(cmd, "theme.set")) { |
677 | const int isAuto = argLabel_Command(cmd, "auto"); | 693 | const int isAuto = argLabel_Command(cmd, "auto"); |
678 | d->theme = arg_Command(cmd); | 694 | d->theme = arg_Command(cmd); |
diff --git a/src/gmcerts.c b/src/gmcerts.c index cc7e9702..2600b4cf 100644 --- a/src/gmcerts.c +++ b/src/gmcerts.c | |||
@@ -384,10 +384,11 @@ iGmIdentity *newIdentity_GmCerts(iGmCerts *d, int flags, iDate validUntil, const | |||
384 | const iString *userId, const iString *org, | 384 | const iString *userId, const iString *org, |
385 | const iString *country) { | 385 | const iString *country) { |
386 | const iTlsCertificateName names[] = { | 386 | const iTlsCertificateName names[] = { |
387 | { subjectCommonName_TlsCertificateNameType, commonName }, | 387 | { issuerCommonName_TlsCertificateNameType, collectNewCStr_String("fi.skyjake.Lagrange") }, |
388 | { subjectUserId_TlsCertificateNameType, userId }, | 388 | { subjectCommonName_TlsCertificateNameType, commonName }, |
389 | { subjectOrganization_TlsCertificateNameType, org }, | 389 | { subjectUserId_TlsCertificateNameType, userId }, |
390 | { subjectCountry_TlsCertificateNameType, country }, | 390 | { subjectOrganization_TlsCertificateNameType, org }, |
391 | { subjectCountry_TlsCertificateNameType, country }, | ||
391 | { 0, NULL } | 392 | { 0, NULL } |
392 | }; | 393 | }; |
393 | iGmIdentity *id = new_GmIdentity(); | 394 | iGmIdentity *id = new_GmIdentity(); |
diff --git a/src/ui/color.c b/src/ui/color.c index 1e9571a7..221a7c2a 100644 --- a/src/ui/color.c +++ b/src/ui/color.c | |||
@@ -108,6 +108,7 @@ void setThemePalette_Color(enum iColorTheme theme) { | |||
108 | copy_(uiInputCursor_ColorId, orange_ColorId); | 108 | copy_(uiInputCursor_ColorId, orange_ColorId); |
109 | copy_(uiInputCursorText_ColorId, black_ColorId); | 109 | copy_(uiInputCursorText_ColorId, black_ColorId); |
110 | copy_(uiHeading_ColorId, cyan_ColorId); | 110 | copy_(uiHeading_ColorId, cyan_ColorId); |
111 | copy_(uiAnnotation_ColorId, teal_ColorId); | ||
111 | copy_(uiIcon_ColorId, cyan_ColorId); | 112 | copy_(uiIcon_ColorId, cyan_ColorId); |
112 | copy_(uiIconHover_ColorId, cyan_ColorId); | 113 | copy_(uiIconHover_ColorId, cyan_ColorId); |
113 | copy_(uiSeparator_ColorId, gray25_ColorId); | 114 | copy_(uiSeparator_ColorId, gray25_ColorId); |
@@ -150,6 +151,7 @@ void setThemePalette_Color(enum iColorTheme theme) { | |||
150 | copy_(uiInputCursor_ColorId, orange_ColorId); | 151 | copy_(uiInputCursor_ColorId, orange_ColorId); |
151 | copy_(uiInputCursorText_ColorId, black_ColorId); | 152 | copy_(uiInputCursorText_ColorId, black_ColorId); |
152 | copy_(uiHeading_ColorId, cyan_ColorId); | 153 | copy_(uiHeading_ColorId, cyan_ColorId); |
154 | copy_(uiAnnotation_ColorId, teal_ColorId); | ||
153 | copy_(uiIcon_ColorId, cyan_ColorId); | 155 | copy_(uiIcon_ColorId, cyan_ColorId); |
154 | copy_(uiIconHover_ColorId, cyan_ColorId); | 156 | copy_(uiIconHover_ColorId, cyan_ColorId); |
155 | copy_(uiSeparator_ColorId, black_ColorId); | 157 | copy_(uiSeparator_ColorId, black_ColorId); |
@@ -191,6 +193,7 @@ void setThemePalette_Color(enum iColorTheme theme) { | |||
191 | copy_(uiInputCursor_ColorId, teal_ColorId); | 193 | copy_(uiInputCursor_ColorId, teal_ColorId); |
192 | copy_(uiInputCursorText_ColorId, white_ColorId); | 194 | copy_(uiInputCursorText_ColorId, white_ColorId); |
193 | copy_(uiHeading_ColorId, brown_ColorId); | 195 | copy_(uiHeading_ColorId, brown_ColorId); |
196 | copy_(uiAnnotation_ColorId, gray50_ColorId); | ||
194 | copy_(uiIcon_ColorId, brown_ColorId); | 197 | copy_(uiIcon_ColorId, brown_ColorId); |
195 | copy_(uiIconHover_ColorId, brown_ColorId); | 198 | copy_(uiIconHover_ColorId, brown_ColorId); |
196 | copy_(uiSeparator_ColorId, gray25_ColorId); | 199 | copy_(uiSeparator_ColorId, gray25_ColorId); |
@@ -232,6 +235,7 @@ void setThemePalette_Color(enum iColorTheme theme) { | |||
232 | copy_(uiInputCursor_ColorId, teal_ColorId); | 235 | copy_(uiInputCursor_ColorId, teal_ColorId); |
233 | copy_(uiInputCursorText_ColorId, white_ColorId); | 236 | copy_(uiInputCursorText_ColorId, white_ColorId); |
234 | copy_(uiHeading_ColorId, brown_ColorId); | 237 | copy_(uiHeading_ColorId, brown_ColorId); |
238 | copy_(uiAnnotation_ColorId, gray50_ColorId); | ||
235 | copy_(uiIcon_ColorId, brown_ColorId); | 239 | copy_(uiIcon_ColorId, brown_ColorId); |
236 | copy_(uiIconHover_ColorId, brown_ColorId); | 240 | copy_(uiIconHover_ColorId, brown_ColorId); |
237 | copy_(uiSeparator_ColorId, gray50_ColorId); | 241 | copy_(uiSeparator_ColorId, gray50_ColorId); |
diff --git a/src/ui/color.h b/src/ui/color.h index d9f4793f..3c986d59 100644 --- a/src/ui/color.h +++ b/src/ui/color.h | |||
@@ -95,6 +95,7 @@ enum iColorId { | |||
95 | uiInputCursor_ColorId, | 95 | uiInputCursor_ColorId, |
96 | uiInputCursorText_ColorId, | 96 | uiInputCursorText_ColorId, |
97 | uiHeading_ColorId, | 97 | uiHeading_ColorId, |
98 | uiAnnotation_ColorId, | ||
98 | uiIcon_ColorId, | 99 | uiIcon_ColorId, |
99 | uiIconHover_ColorId, | 100 | uiIconHover_ColorId, |
100 | uiSeparator_ColorId, | 101 | uiSeparator_ColorId, |
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c index d9842a40..ffdacb99 100644 --- a/src/ui/labelwidget.c +++ b/src/ui/labelwidget.c | |||
@@ -341,6 +341,12 @@ const iString *command_LabelWidget(const iLabelWidget *d) { | |||
341 | return &d->command; | 341 | return &d->command; |
342 | } | 342 | } |
343 | 343 | ||
344 | iLabelWidget *newColor_LabelWidget(const char *text, int color) { | ||
345 | iLabelWidget *d = new_LabelWidget(format_CStr("%s%s", escape_Color(color), text), 0, 0, NULL); | ||
346 | setFlags_Widget(as_Widget(d), frameless_WidgetFlag, iTrue); | ||
347 | return d; | ||
348 | } | ||
349 | |||
344 | iBeginDefineSubclass(LabelWidget, Widget) | 350 | iBeginDefineSubclass(LabelWidget, Widget) |
345 | .processEvent = (iAny *) processEvent_LabelWidget_, | 351 | .processEvent = (iAny *) processEvent_LabelWidget_, |
346 | .draw = (iAny *) draw_LabelWidget_, | 352 | .draw = (iAny *) draw_LabelWidget_, |
diff --git a/src/ui/labelwidget.h b/src/ui/labelwidget.h index 64f96aed..c55ecd08 100644 --- a/src/ui/labelwidget.h +++ b/src/ui/labelwidget.h | |||
@@ -41,6 +41,8 @@ void updateTextCStr_LabelWidget (iLabelWidget *, const char *text); /* not r | |||
41 | const iString *label_LabelWidget (const iLabelWidget *); | 41 | const iString *label_LabelWidget (const iLabelWidget *); |
42 | const iString *command_LabelWidget (const iLabelWidget *); | 42 | const iString *command_LabelWidget (const iLabelWidget *); |
43 | 43 | ||
44 | iLabelWidget *newColor_LabelWidget(const char *text, int color); | ||
45 | |||
44 | iLocalDef iLabelWidget *newEmpty_LabelWidget(void) { | 46 | iLocalDef iLabelWidget *newEmpty_LabelWidget(void) { |
45 | return new_LabelWidget("", 0, 0, NULL); | 47 | return new_LabelWidget("", 0, 0, NULL); |
46 | } | 48 | } |
diff --git a/src/ui/util.c b/src/ui/util.c index 753fd140..52d5031e 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -708,8 +708,9 @@ static iBool toggleHandler_(iWidget *d, const char *cmd) { | |||
708 | } | 708 | } |
709 | 709 | ||
710 | iWidget *makeToggle_Widget(const char *id) { | 710 | iWidget *makeToggle_Widget(const char *id) { |
711 | iWidget *toggle = as_Widget(new_LabelWidget("YES", 0, 0, "toggle")); | 711 | iWidget *toggle = as_Widget(new_LabelWidget("YES", 0, 0, "toggle")); /* "YES" for sizing */ |
712 | setId_Widget(toggle, id); | 712 | setId_Widget(toggle, id); |
713 | updateTextCStr_LabelWidget((iLabelWidget *) toggle, "NO"); /* actual initial value */ | ||
713 | setCommandHandler_Widget(toggle, toggleHandler_); | 714 | setCommandHandler_Widget(toggle, toggleHandler_); |
714 | return toggle; | 715 | return toggle; |
715 | } | 716 | } |
@@ -769,7 +770,7 @@ iWidget *makeBookmarkEditor_Widget(void) { | |||
769 | page, iClob(new_Widget()), arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag); | 770 | page, iClob(new_Widget()), arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag); |
770 | iWidget *values = addChildFlags_Widget( | 771 | iWidget *values = addChildFlags_Widget( |
771 | page, iClob(new_Widget()), arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag); | 772 | page, iClob(new_Widget()), arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag); |
772 | iInputWidget *inputs[4]; | 773 | iInputWidget *inputs[3]; |
773 | addChild_Widget(headings, iClob(makeHeading_Widget("Title:"))); | 774 | addChild_Widget(headings, iClob(makeHeading_Widget("Title:"))); |
774 | setId_Widget(addChild_Widget(values, iClob(inputs[0] = new_InputWidget(0))), "bmed.title"); | 775 | setId_Widget(addChild_Widget(values, iClob(inputs[0] = new_InputWidget(0))), "bmed.title"); |
775 | addChild_Widget(headings, iClob(makeHeading_Widget("URL:"))); | 776 | addChild_Widget(headings, iClob(makeHeading_Widget("URL:"))); |
@@ -832,3 +833,66 @@ iWidget *makeBookmarkCreation_Widget(const iString *url, const iString *title, i | |||
832 | setCommandHandler_Widget(dlg, handleBookmarkCreationCommands_SidebarWidget_); | 833 | setCommandHandler_Widget(dlg, handleBookmarkCreationCommands_SidebarWidget_); |
833 | return dlg; | 834 | return dlg; |
834 | } | 835 | } |
836 | |||
837 | iWidget *makeIdentityCreation_Widget(void) { | ||
838 | iWidget *dlg = makeSheet_Widget("ident"); | ||
839 | setId_Widget(addChildFlags_Widget( | ||
840 | dlg, | ||
841 | iClob(new_LabelWidget(uiHeading_ColorEscape "NEW IDENTITY", 0, 0, NULL)), | ||
842 | frameless_WidgetFlag), | ||
843 | "ident.heading"); | ||
844 | iWidget *page = new_Widget(); | ||
845 | addChildFlags_Widget( | ||
846 | dlg, | ||
847 | iClob( | ||
848 | new_LabelWidget("Creating a 2048-bit self-signed RSA certificate.", 0, 0, NULL)), | ||
849 | frameless_WidgetFlag); | ||
850 | addChild_Widget(dlg, iClob(page)); | ||
851 | setFlags_Widget(page, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); | ||
852 | iWidget *headings = addChildFlags_Widget( | ||
853 | page, iClob(new_Widget()), arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag); | ||
854 | iWidget *values = addChildFlags_Widget( | ||
855 | page, iClob(new_Widget()), arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag); | ||
856 | iInputWidget *inputs[4]; | ||
857 | addChild_Widget(headings, iClob(makeHeading_Widget("Common name:"))); | ||
858 | setId_Widget(addChild_Widget(values, iClob(inputs[0] = new_InputWidget(0))), "ident.common"); | ||
859 | addChild_Widget(headings, iClob(makeHeading_Widget("User ID:"))); | ||
860 | setId_Widget(addChild_Widget(values, iClob(inputs[1] = new_InputWidget(0))), "ident.userid"); | ||
861 | addChild_Widget(headings, iClob(makeHeading_Widget("Organization:"))); | ||
862 | setId_Widget(addChild_Widget(values, iClob(inputs[2] = new_InputWidget(0))), "ident.org"); | ||
863 | addChild_Widget(headings, iClob(makeHeading_Widget("Country:"))); | ||
864 | setId_Widget(addChild_Widget(values, iClob(inputs[3] = new_InputWidget(0))), "ident.country"); | ||
865 | addChild_Widget(headings, iClob(makeHeading_Widget("Valid until:"))); | ||
866 | iInputWidget *until; | ||
867 | addChild_Widget(values, iClob(until = new_InputWidget(19))); | ||
868 | setTextCStr_InputWidget(until, "YYYY-MM-DD HH:MM:SS"); | ||
869 | // addChild_Widget(headings, iClob(newEmpty_LabelWidget())); | ||
870 | // addChild_Widget(values, | ||
871 | // iClob(newColor_LabelWidget("Time defaults to end of day.", | ||
872 | // uiAnnotation_ColorId))); | ||
873 | addChild_Widget(headings, iClob(makeHeading_Widget("Temporary:"))); | ||
874 | // iWidget *temp = new_Widget(); | ||
875 | // addChildFlags_Widget( | ||
876 | // values, iClob(temp), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); | ||
877 | addChild_Widget(values, iClob(makeToggle_Widget("ident.temp"))); | ||
878 | // addChild_Widget( | ||
879 | // temp, | ||
880 | // iClob(newColor_LabelWidget("Temporary identities are not saved.", | ||
881 | // uiAnnotation_ColorId))); | ||
882 | arrange_Widget(dlg); | ||
883 | for (size_t i = 0; i < iElemCount(inputs); ++i) { | ||
884 | as_Widget(inputs[i])->rect.size.x = 100 * gap_UI - headings->rect.size.x; | ||
885 | } | ||
886 | iWidget *div = new_Widget(); { | ||
887 | setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); | ||
888 | addChild_Widget(div, iClob(new_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); | ||
889 | addChild_Widget( | ||
890 | div, | ||
891 | iClob(new_LabelWidget( | ||
892 | uiTextAction_ColorEscape "Create", SDLK_RETURN, KMOD_PRIMARY, "ident.accept"))); | ||
893 | } | ||
894 | addChild_Widget(dlg, iClob(div)); | ||
895 | addChild_Widget(get_Window()->root, iClob(dlg)); | ||
896 | centerSheet_Widget(dlg); | ||
897 | return dlg; | ||
898 | } | ||
diff --git a/src/ui/util.h b/src/ui/util.h index 129053e5..a008ee0c 100644 --- a/src/ui/util.h +++ b/src/ui/util.h | |||
@@ -147,3 +147,4 @@ iWidget * makeQuestion_Widget (const char *title, const char *msg, | |||
147 | iWidget * makePreferences_Widget (void); | 147 | iWidget * makePreferences_Widget (void); |
148 | iWidget * makeBookmarkEditor_Widget (void); | 148 | iWidget * makeBookmarkEditor_Widget (void); |
149 | iWidget * makeBookmarkCreation_Widget (const iString *url, const iString *title, iChar icon); | 149 | iWidget * makeBookmarkCreation_Widget (const iString *url, const iString *title, iChar icon); |
150 | iWidget * makeIdentityCreation_Widget (void); | ||