diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-04 14:26:15 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-04 22:24:43 +0200 |
commit | b1b4b6458548e42656045cad9d0552e30b45678d (patch) | |
tree | 0fe8d88862f2212f685447d2f2f8d3f0049e9bc9 | |
parent | 92dd2e36482beb8f9d651f8f3956950f173ff8a7 (diff) |
Fixed buttons in Import Identity dialog
-rw-r--r-- | src/ui/certimportwidget.c | 32 | ||||
-rw-r--r-- | src/ui/util.c | 14 | ||||
-rw-r--r-- | src/ui/util.h | 1 |
3 files changed, 28 insertions, 19 deletions
diff --git a/src/ui/certimportwidget.c b/src/ui/certimportwidget.c index c0f041b9..0c1cf674 100644 --- a/src/ui/certimportwidget.c +++ b/src/ui/certimportwidget.c | |||
@@ -151,17 +151,18 @@ void init_CertImportWidget(iCertImportWidget *d) { | |||
151 | setSize_Widget(as_Widget(d->crtLabel), init_I2(width_Widget(w) - 6.5 * gap_UI, gap_UI * 12)); | 151 | setSize_Widget(as_Widget(d->crtLabel), init_I2(width_Widget(w) - 6.5 * gap_UI, gap_UI * 12)); |
152 | setSize_Widget(as_Widget(d->keyLabel), init_I2(width_Widget(w) - 6.5 * gap_UI, gap_UI * 12)); | 152 | setSize_Widget(as_Widget(d->keyLabel), init_I2(width_Widget(w) - 6.5 * gap_UI, gap_UI * 12)); |
153 | /* Buttons. */ | 153 | /* Buttons. */ |
154 | iWidget *div = new_Widget(); { | 154 | addChild_Widget(w, iClob(makePadding_Widget(gap_UI))); |
155 | setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); | 155 | iWidget *buttons = makeDialogButtons_Widget( |
156 | addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); | 156 | (iMenuItem[]){ |
157 | iLabelWidget *accept = addChild_Widget( | 157 | { "Cancel", 0, 0, NULL }, |
158 | div, | 158 | { uiTextAction_ColorEscape "Import", SDLK_RETURN, KMOD_PRIMARY, "certimport.accept" } }, |
159 | iClob(newKeyMods_LabelWidget( | 159 | 2); |
160 | uiTextAction_ColorEscape "Import", SDLK_RETURN, KMOD_PRIMARY, "certimport.accept"))); | 160 | addChild_Widget(w, iClob(buttons)); |
161 | setFont_LabelWidget(accept, uiLabelBold_FontId); | ||
162 | } | ||
163 | addChild_Widget(w, iClob(div)); | ||
164 | arrange_Widget(w); | 161 | arrange_Widget(w); |
162 | if (deviceType_App() != desktop_AppDeviceType) { | ||
163 | /* Try auto-pasting. */ | ||
164 | postCommand_App("certimport.paste"); | ||
165 | } | ||
165 | } | 166 | } |
166 | 167 | ||
167 | void deinit_CertImportWidget(iCertImportWidget *d) { | 168 | void deinit_CertImportWidget(iCertImportWidget *d) { |
@@ -186,14 +187,17 @@ void setPageContent_CertImportWidget(iCertImportWidget *d, const iBlock *content | |||
186 | arrange_Widget(as_Widget(d)); | 187 | arrange_Widget(as_Widget(d)); |
187 | } | 188 | } |
188 | 189 | ||
190 | static iBool tryImportFromClipboard_CertImportWidget_(iCertImportWidget *d) { | ||
191 | return tryImport_CertImportWidget_(d, collect_Block(newCStr_Block(SDL_GetClipboardText()))); | ||
192 | } | ||
193 | |||
189 | static iBool processEvent_CertImportWidget_(iCertImportWidget *d, const SDL_Event *ev) { | 194 | static iBool processEvent_CertImportWidget_(iCertImportWidget *d, const SDL_Event *ev) { |
190 | iWidget *w = as_Widget(d); | 195 | iWidget *w = as_Widget(d); |
191 | if (ev->type == SDL_KEYDOWN) { | 196 | if (ev->type == SDL_KEYDOWN) { |
192 | const int key = ev->key.keysym.sym; | 197 | const int key = ev->key.keysym.sym; |
193 | const int mods = keyMods_Sym(ev->key.keysym.mod); | 198 | const int mods = keyMods_Sym(ev->key.keysym.mod); |
194 | if (key == SDLK_v && mods == KMOD_PRIMARY) { | 199 | if (key == SDLK_v && mods == KMOD_PRIMARY) { |
195 | if (!tryImport_CertImportWidget_( | 200 | if (!tryImportFromClipboard_CertImportWidget_(d)) { |
196 | d, collect_Block(newCStr_Block(SDL_GetClipboardText())))) { | ||
197 | makeMessage_Widget(uiTextCaution_ColorEscape "PASTED FROM CLIPBOARD", | 201 | makeMessage_Widget(uiTextCaution_ColorEscape "PASTED FROM CLIPBOARD", |
198 | "No certificate or private key was found."); | 202 | "No certificate or private key was found."); |
199 | } | 203 | } |
@@ -201,6 +205,10 @@ static iBool processEvent_CertImportWidget_(iCertImportWidget *d, const SDL_Even | |||
201 | return iTrue; | 205 | return iTrue; |
202 | } | 206 | } |
203 | } | 207 | } |
208 | if (isCommand_UserEvent(ev, "certimport.paste")) { | ||
209 | tryImportFromClipboard_CertImportWidget_(d); | ||
210 | return iTrue; | ||
211 | } | ||
204 | if (isCommand_Widget(w, ev, "cancel")) { | 212 | if (isCommand_Widget(w, ev, "cancel")) { |
205 | destroy_Widget(w); | 213 | destroy_Widget(w); |
206 | return iTrue; | 214 | return iTrue; |
diff --git a/src/ui/util.c b/src/ui/util.c index 934a6d9b..055191c7 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -939,7 +939,7 @@ iBool valueInputHandler_(iWidget *dlg, const char *cmd) { | |||
939 | return iFalse; | 939 | return iFalse; |
940 | } | 940 | } |
941 | 941 | ||
942 | static iWidget *makeDialogButtons_(const iMenuItem *actions, size_t numActions) { | 942 | iWidget *makeDialogButtons_Widget(const iMenuItem *actions, size_t numActions) { |
943 | iWidget *div = new_Widget(); | 943 | iWidget *div = new_Widget(); |
944 | setFlags_Widget(div, | 944 | setFlags_Widget(div, |
945 | arrangeHorizontal_WidgetFlag | arrangeHeight_WidgetFlag | | 945 | arrangeHorizontal_WidgetFlag | arrangeHeight_WidgetFlag | |
@@ -1016,7 +1016,7 @@ iWidget *makeValueInput_Widget(iWidget *parent, const iString *initialValue, con | |||
1016 | addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI))); | 1016 | addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI))); |
1017 | addChild_Widget( | 1017 | addChild_Widget( |
1018 | dlg, | 1018 | dlg, |
1019 | iClob(makeDialogButtons_( | 1019 | iClob(makeDialogButtons_Widget( |
1020 | (iMenuItem[]){ { "Cancel", 0, 0, NULL }, { acceptLabel, 0, 0, "valueinput.accept" } }, | 1020 | (iMenuItem[]){ { "Cancel", 0, 0, NULL }, { acceptLabel, 0, 0, "valueinput.accept" } }, |
1021 | 2))); | 1021 | 2))); |
1022 | centerSheet_Widget(dlg); | 1022 | centerSheet_Widget(dlg); |
@@ -1062,7 +1062,7 @@ iWidget *makeQuestion_Widget(const char *title, const char *msg, | |||
1062 | addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, NULL)), frameless_WidgetFlag); | 1062 | addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, NULL)), frameless_WidgetFlag); |
1063 | addChildFlags_Widget(dlg, iClob(new_LabelWidget(msg, NULL)), frameless_WidgetFlag); | 1063 | addChildFlags_Widget(dlg, iClob(new_LabelWidget(msg, NULL)), frameless_WidgetFlag); |
1064 | addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI))); | 1064 | addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI))); |
1065 | addChild_Widget(dlg, iClob(makeDialogButtons_(items, numItems))); | 1065 | addChild_Widget(dlg, iClob(makeDialogButtons_Widget(items, numItems))); |
1066 | addChild_Widget(get_Window()->root, iClob(dlg)); | 1066 | addChild_Widget(get_Window()->root, iClob(dlg)); |
1067 | arrange_Widget(dlg); /* BUG: This extra arrange shouldn't be needed but the dialog won't | 1067 | arrange_Widget(dlg); /* BUG: This extra arrange shouldn't be needed but the dialog won't |
1068 | be arranged correctly unless it's here. */ | 1068 | be arranged correctly unless it's here. */ |
@@ -1347,7 +1347,7 @@ iWidget *makePreferences_Widget(void) { | |||
1347 | expandInputFieldWidth_(findChild_Widget(tabs, "prefs.proxy.http")); | 1347 | expandInputFieldWidth_(findChild_Widget(tabs, "prefs.proxy.http")); |
1348 | } | 1348 | } |
1349 | addChild_Widget(dlg, | 1349 | addChild_Widget(dlg, |
1350 | iClob(makeDialogButtons_( | 1350 | iClob(makeDialogButtons_Widget( |
1351 | (iMenuItem[]){ { "Dismiss", SDLK_ESCAPE, 0, "prefs.dismiss" } }, 1))); | 1351 | (iMenuItem[]){ { "Dismiss", SDLK_ESCAPE, 0, "prefs.dismiss" } }, 1))); |
1352 | addChild_Widget(get_Window()->root, iClob(dlg)); | 1352 | addChild_Widget(get_Window()->root, iClob(dlg)); |
1353 | centerSheet_Widget(dlg); | 1353 | centerSheet_Widget(dlg); |
@@ -1384,7 +1384,7 @@ iWidget *makeBookmarkEditor_Widget(void) { | |||
1384 | } | 1384 | } |
1385 | addChild_Widget( | 1385 | addChild_Widget( |
1386 | dlg, | 1386 | dlg, |
1387 | iClob(makeDialogButtons_((iMenuItem[]){ { "Cancel", 0, 0, NULL }, | 1387 | iClob(makeDialogButtons_Widget((iMenuItem[]){ { "Cancel", 0, 0, NULL }, |
1388 | { uiTextCaution_ColorEscape "Save Bookmark", | 1388 | { uiTextCaution_ColorEscape "Save Bookmark", |
1389 | SDLK_RETURN, | 1389 | SDLK_RETURN, |
1390 | KMOD_PRIMARY, | 1390 | KMOD_PRIMARY, |
@@ -1518,7 +1518,7 @@ iWidget *makeFeedSettings_Widget(uint32_t bookmarkId) { | |||
1518 | addChildFlags_Widget(values, iClob(types), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); | 1518 | addChildFlags_Widget(values, iClob(types), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); |
1519 | iWidget *buttons = | 1519 | iWidget *buttons = |
1520 | addChild_Widget(dlg, | 1520 | addChild_Widget(dlg, |
1521 | iClob(makeDialogButtons_( | 1521 | iClob(makeDialogButtons_Widget( |
1522 | (iMenuItem[]){ { "Cancel", 0, 0, NULL }, | 1522 | (iMenuItem[]){ { "Cancel", 0, 0, NULL }, |
1523 | { bookmarkId ? uiTextCaution_ColorEscape "Save Settings" | 1523 | { bookmarkId ? uiTextCaution_ColorEscape "Save Settings" |
1524 | : uiTextCaution_ColorEscape "Subscribe", | 1524 | : uiTextCaution_ColorEscape "Subscribe", |
@@ -1600,7 +1600,7 @@ iWidget *makeIdentityCreation_Widget(void) { | |||
1600 | } | 1600 | } |
1601 | addChild_Widget( | 1601 | addChild_Widget( |
1602 | dlg, | 1602 | dlg, |
1603 | iClob(makeDialogButtons_((iMenuItem[]){ { "Cancel", 0, 0, NULL }, | 1603 | iClob(makeDialogButtons_Widget((iMenuItem[]){ { "Cancel", 0, 0, NULL }, |
1604 | { uiTextAction_ColorEscape "Create Identity", | 1604 | { uiTextAction_ColorEscape "Create Identity", |
1605 | SDLK_RETURN, | 1605 | SDLK_RETURN, |
1606 | KMOD_PRIMARY, | 1606 | KMOD_PRIMARY, |
diff --git a/src/ui/util.h b/src/ui/util.h index 9e45f369..40fd0c69 100644 --- a/src/ui/util.h +++ b/src/ui/util.h | |||
@@ -194,6 +194,7 @@ size_t tabCount_Widget (const iWidget *tabs); | |||
194 | 194 | ||
195 | iWidget * makeSheet_Widget (const char *id); | 195 | iWidget * makeSheet_Widget (const char *id); |
196 | void centerSheet_Widget (iWidget *sheet); | 196 | void centerSheet_Widget (iWidget *sheet); |
197 | iWidget * makeDialogButtons_Widget(const iMenuItem *actions, size_t numActions); | ||
197 | 198 | ||
198 | void makeFilePath_Widget (iWidget *parent, const iString *initialPath, const char *title, | 199 | void makeFilePath_Widget (iWidget *parent, const iString *initialPath, const char *title, |
199 | const char *acceptLabel, const char *command); | 200 | const char *acceptLabel, const char *command); |