diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-07-26 14:49:06 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-07-26 14:49:06 +0300 |
commit | 3d60806534f5fd20e321a1290f3942215dcf1121 (patch) | |
tree | 3e3b6683ea42ecdbcd380930724ebb54d1686055 /src/ui/documentwidget.c | |
parent | deba8cc58be7511ede63d0b6417c739e8e35b176 (diff) |
Asking for sensitive input
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r-- | src/ui/documentwidget.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 9fdadc4c..29f880ee 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #include "documentwidget.h" | 1 | #include "documentwidget.h" |
2 | #include "scrollwidget.h" | 2 | #include "scrollwidget.h" |
3 | #include "inputwidget.h" | ||
3 | #include "paint.h" | 4 | #include "paint.h" |
4 | #include "command.h" | 5 | #include "command.h" |
5 | #include "util.h" | 6 | #include "util.h" |
@@ -38,7 +39,6 @@ struct Impl_DocumentWidget { | |||
38 | iClick click; | 39 | iClick click; |
39 | iScrollWidget *scroll; | 40 | iScrollWidget *scroll; |
40 | iWidget *menu; | 41 | iWidget *menu; |
41 | // iWidget *userInput; | ||
42 | }; | 42 | }; |
43 | 43 | ||
44 | iDefineObjectConstruction(DocumentWidget) | 44 | iDefineObjectConstruction(DocumentWidget) |
@@ -65,7 +65,6 @@ void init_DocumentWidget(iDocumentWidget *d) { | |||
65 | { "---", 0, 0, NULL }, | 65 | { "---", 0, 0, NULL }, |
66 | { "Reload", 'r', KMOD_PRIMARY, "navigate.reload" } }, | 66 | { "Reload", 'r', KMOD_PRIMARY, "navigate.reload" } }, |
67 | 4); | 67 | 4); |
68 | // setFlags_Widget(d->userInput, hidden_WidgetFlag | disabled_WidgetFlag, iTrue); | ||
69 | } | 68 | } |
70 | 69 | ||
71 | void deinit_DocumentWidget(iDocumentWidget *d) { | 70 | void deinit_DocumentWidget(iDocumentWidget *d) { |
@@ -293,10 +292,14 @@ static void showErrorPage_DocumentWidget_(iDocumentWidget *d, enum iGmStatusCode | |||
293 | } | 292 | } |
294 | 293 | ||
295 | static void checkResponseCode_DocumentWidget_(iDocumentWidget *d) { | 294 | static void checkResponseCode_DocumentWidget_(iDocumentWidget *d) { |
295 | if (!d->request) { | ||
296 | return; | ||
297 | } | ||
296 | if (d->state == fetching_DocumentState) { | 298 | if (d->state == fetching_DocumentState) { |
297 | d->state = receivedPartialResponse_DocumentState; | 299 | d->state = receivedPartialResponse_DocumentState; |
298 | d->scrollY = 0; | 300 | d->scrollY = 0; |
299 | switch (status_GmRequest(d->request)) { | 301 | enum iGmStatusCode statusCode = status_GmRequest(d->request); |
302 | switch (statusCode) { | ||
300 | case none_GmStatusCode: | 303 | case none_GmStatusCode: |
301 | case success_GmStatusCode: | 304 | case success_GmStatusCode: |
302 | break; | 305 | break; |
@@ -304,7 +307,7 @@ static void checkResponseCode_DocumentWidget_(iDocumentWidget *d) { | |||
304 | case sensitiveInput_GmStatusCode: { | 307 | case sensitiveInput_GmStatusCode: { |
305 | iUrl parts; | 308 | iUrl parts; |
306 | init_Url(&parts, d->url); | 309 | init_Url(&parts, d->url); |
307 | makeValueInput_Widget( | 310 | iWidget *dlg = makeValueInput_Widget( |
308 | as_Widget(d), | 311 | as_Widget(d), |
309 | NULL, | 312 | NULL, |
310 | cstrFormat_String(cyan_ColorEscape "%s", | 313 | cstrFormat_String(cyan_ColorEscape "%s", |
@@ -316,6 +319,8 @@ static void checkResponseCode_DocumentWidget_(iDocumentWidget *d) { | |||
316 | : cstr_String(meta_GmRequest(d->request)), | 319 | : cstr_String(meta_GmRequest(d->request)), |
317 | orange_ColorEscape "Send \u21d2", | 320 | orange_ColorEscape "Send \u21d2", |
318 | "document.input.submit"); | 321 | "document.input.submit"); |
322 | setSensitive_InputWidget(findChild_Widget(dlg, "input"), | ||
323 | statusCode == sensitiveInput_GmStatusCode); | ||
319 | break; | 324 | break; |
320 | } | 325 | } |
321 | case redirectTemporary_GmStatusCode: | 326 | case redirectTemporary_GmStatusCode: |
@@ -324,12 +329,13 @@ static void checkResponseCode_DocumentWidget_(iDocumentWidget *d) { | |||
324 | showErrorPage_DocumentWidget_(d, invalidRedirect_GmStatusCode); | 329 | showErrorPage_DocumentWidget_(d, invalidRedirect_GmStatusCode); |
325 | } | 330 | } |
326 | else { | 331 | else { |
327 | postCommandf_App("open redirect:1 url:%s", cstr_String(meta_GmRequest(d->request))); | 332 | postCommandf_App("open redirect:1 url:%s", |
333 | cstr_String(meta_GmRequest(d->request))); | ||
328 | iReleasePtr(&d->request); | 334 | iReleasePtr(&d->request); |
329 | } | 335 | } |
330 | break; | 336 | break; |
331 | default: | 337 | default: |
332 | showErrorPage_DocumentWidget_(d, status_GmRequest(d->request)); | 338 | showErrorPage_DocumentWidget_(d, statusCode); |
333 | break; | 339 | break; |
334 | } | 340 | } |
335 | } | 341 | } |
@@ -411,17 +417,6 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e | |||
411 | updateVisible_DocumentWidget_(d); | 417 | updateVisible_DocumentWidget_(d); |
412 | refresh_Widget(w); | 418 | refresh_Widget(w); |
413 | return iTrue; | 419 | return iTrue; |
414 | #if 0 | ||
415 | case 't': | ||
416 | if (mods == KMOD_PRIMARY) { | ||
417 | makeValueInput_Widget(get_Window()->root, | ||
418 | NULL, | ||
419 | cyan_ColorEscape "Input Needed", | ||
420 | "Give it!", | ||
421 | "document.input.submit"); | ||
422 | } | ||
423 | return iTrue; | ||
424 | #endif | ||
425 | case SDLK_END: | 420 | case SDLK_END: |
426 | d->scrollY = scrollMax_DocumentWidget_(d); | 421 | d->scrollY = scrollMax_DocumentWidget_(d); |
427 | updateVisible_DocumentWidget_(d); | 422 | updateVisible_DocumentWidget_(d); |