diff options
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r-- | src/ui/documentwidget.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 23f34577..76ceebcd 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -554,6 +554,20 @@ static void updateTheme_DocumentWidget_(iDocumentWidget *d) { | |||
554 | } | 554 | } |
555 | } | 555 | } |
556 | 556 | ||
557 | static void updateFetchProgress_DocumentWidget_(iDocumentWidget *d) { | ||
558 | iLabelWidget *prog = findWidget_App("document.progress"); | ||
559 | const size_t dlSize = d->request ? size_Block(body_GmRequest(d->request)) : 0; | ||
560 | setFlags_Widget(as_Widget(prog), hidden_WidgetFlag, dlSize < 250000); | ||
561 | if (isVisible_Widget(prog)) { | ||
562 | updateText_LabelWidget(prog, | ||
563 | collectNewFormat_String("%s%.3f MB", | ||
564 | isFinished_GmRequest(d->request) | ||
565 | ? uiHeading_ColorEscape | ||
566 | : uiTextCaution_ColorEscape, | ||
567 | dlSize / 1.0e6f)); | ||
568 | } | ||
569 | } | ||
570 | |||
557 | static void updateDocument_DocumentWidget_(iDocumentWidget *d, const iGmResponse *response) { | 571 | static void updateDocument_DocumentWidget_(iDocumentWidget *d, const iGmResponse *response) { |
558 | if (d->state == ready_RequestState) { | 572 | if (d->state == ready_RequestState) { |
559 | return; | 573 | return; |
@@ -566,7 +580,7 @@ static void updateDocument_DocumentWidget_(iDocumentWidget *d, const iGmResponse | |||
566 | invalidate_DocumentWidget_(d); | 580 | invalidate_DocumentWidget_(d); |
567 | updateTheme_DocumentWidget_(d); | 581 | updateTheme_DocumentWidget_(d); |
568 | clear_String(&d->sourceMime); | 582 | clear_String(&d->sourceMime); |
569 | set_Block(&d->sourceContent, &response->body); | 583 | // set_Block(&d->sourceContent, &response->body); |
570 | initBlock_String(&str, &response->body); | 584 | initBlock_String(&str, &response->body); |
571 | if (category_GmStatusCode(statusCode) == categorySuccess_GmStatusCode) { | 585 | if (category_GmStatusCode(statusCode) == categorySuccess_GmStatusCode) { |
572 | /* Check the MIME type. */ | 586 | /* Check the MIME type. */ |
@@ -867,7 +881,6 @@ static void checkResponse_DocumentWidget_(iDocumentWidget *d) { | |||
867 | case categorySuccess_GmStatusCode: | 881 | case categorySuccess_GmStatusCode: |
868 | d->scrollY = 0; | 882 | d->scrollY = 0; |
869 | resetSmoothScroll_DocumentWidget_(d); | 883 | resetSmoothScroll_DocumentWidget_(d); |
870 | clear_Block(&d->sourceContent); | ||
871 | reset_GmDocument(d->doc); /* new content incoming */ | 884 | reset_GmDocument(d->doc); /* new content incoming */ |
872 | updateDocument_DocumentWidget_(d, response_GmRequest(d->request)); | 885 | updateDocument_DocumentWidget_(d, response_GmRequest(d->request)); |
873 | break; | 886 | break; |
@@ -1062,6 +1075,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
1062 | } | 1075 | } |
1063 | else if (equal_Command(cmd, "tabs.changed")) { | 1076 | else if (equal_Command(cmd, "tabs.changed")) { |
1064 | d->showLinkNumbers = iFalse; | 1077 | d->showLinkNumbers = iFalse; |
1078 | updateFetchProgress_DocumentWidget_(d); | ||
1065 | if (cmp_String(id_Widget(w), suffixPtr_Command(cmd, "id")) == 0) { | 1079 | if (cmp_String(id_Widget(w), suffixPtr_Command(cmd, "id")) == 0) { |
1066 | /* Set palette for our document. */ | 1080 | /* Set palette for our document. */ |
1067 | updateTheme_DocumentWidget_(d); | 1081 | updateTheme_DocumentWidget_(d); |
@@ -1148,11 +1162,16 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
1148 | } | 1162 | } |
1149 | else if (equalWidget_Command(cmd, w, "document.request.updated") && | 1163 | else if (equalWidget_Command(cmd, w, "document.request.updated") && |
1150 | pointerLabel_Command(cmd, "request") == d->request) { | 1164 | pointerLabel_Command(cmd, "request") == d->request) { |
1165 | set_Block(&d->sourceContent, body_GmRequest(d->request)); | ||
1166 | updateFetchProgress_DocumentWidget_(d); | ||
1151 | checkResponse_DocumentWidget_(d); | 1167 | checkResponse_DocumentWidget_(d); |
1168 | set_Atomic(&d->isRequestUpdated, iFalse); /* ready to be notified again */ | ||
1152 | return iFalse; | 1169 | return iFalse; |
1153 | } | 1170 | } |
1154 | else if (equalWidget_Command(cmd, w, "document.request.finished") && | 1171 | else if (equalWidget_Command(cmd, w, "document.request.finished") && |
1155 | pointerLabel_Command(cmd, "request") == d->request) { | 1172 | pointerLabel_Command(cmd, "request") == d->request) { |
1173 | set_Block(&d->sourceContent, body_GmRequest(d->request)); | ||
1174 | updateFetchProgress_DocumentWidget_(d); | ||
1156 | checkResponse_DocumentWidget_(d); | 1175 | checkResponse_DocumentWidget_(d); |
1157 | resetSmoothScroll_DocumentWidget_(d); | 1176 | resetSmoothScroll_DocumentWidget_(d); |
1158 | d->scrollY = d->initNormScrollY * size_GmDocument(d->doc).y; | 1177 | d->scrollY = d->initNormScrollY * size_GmDocument(d->doc).y; |
@@ -1185,6 +1204,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
1185 | postCommandf_App("document.request.cancelled doc:%p url:%s", d, cstr_String(d->mod.url)); | 1204 | postCommandf_App("document.request.cancelled doc:%p url:%s", d, cstr_String(d->mod.url)); |
1186 | iReleasePtr(&d->request); | 1205 | iReleasePtr(&d->request); |
1187 | d->state = ready_RequestState; | 1206 | d->state = ready_RequestState; |
1207 | updateFetchProgress_DocumentWidget_(d); | ||
1188 | return iTrue; | 1208 | return iTrue; |
1189 | } | 1209 | } |
1190 | } | 1210 | } |