summaryrefslogtreecommitdiff
path: root/src/ui/documentwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-09-18 10:35:32 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-09-18 10:35:32 +0300
commit24769923618c19e7c4634f6dbdcc7ed087918a9c (patch)
tree938c8598058c76e90cd9884419dd8fa63f8567c9 /src/ui/documentwidget.c
parentd45b2fd2da5183610aef250becd1d32dab46dcae (diff)
Improved download indicator and stop/reload button
Follow which tab is open and actually stop ongoing requests instead of restarting them.
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r--src/ui/documentwidget.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 26fd81cf..33b419c8 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -146,7 +146,7 @@ struct Impl_DocumentWidget {
146 iObjectList * media; 146 iObjectList * media;
147 iString sourceMime; 147 iString sourceMime;
148 iBlock sourceContent; /* original content as received, for saving */ 148 iBlock sourceContent; /* original content as received, for saving */
149 iGmDocument * doc; 149 iGmDocument * doc;
150 int certFlags; 150 int certFlags;
151 iDate certExpiry; 151 iDate certExpiry;
152 iString * certSubject; 152 iString * certSubject;
@@ -782,7 +782,9 @@ void setRedirectCount_DocumentWidget(iDocumentWidget *d, int count) {
782} 782}
783 783
784iBool isRequestOngoing_DocumentWidget(const iDocumentWidget *d) { 784iBool isRequestOngoing_DocumentWidget(const iDocumentWidget *d) {
785 return d->state == fetching_RequestState || d->state == receivedPartialResponse_RequestState; 785 /*return d->state == fetching_RequestState ||
786 d->state == receivedPartialResponse_RequestState;*/
787 return d->request != NULL;
786} 788}
787 789
788static void scroll_DocumentWidget_(iDocumentWidget *d, int offset) { 790static void scroll_DocumentWidget_(iDocumentWidget *d, int offset) {
@@ -1072,12 +1074,12 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
1072 } 1074 }
1073 else if (equal_Command(cmd, "tabs.changed")) { 1075 else if (equal_Command(cmd, "tabs.changed")) {
1074 d->showLinkNumbers = iFalse; 1076 d->showLinkNumbers = iFalse;
1075 updateFetchProgress_DocumentWidget_(d);
1076 if (cmp_String(id_Widget(w), suffixPtr_Command(cmd, "id")) == 0) { 1077 if (cmp_String(id_Widget(w), suffixPtr_Command(cmd, "id")) == 0) {
1077 /* Set palette for our document. */ 1078 /* Set palette for our document. */
1078 updateTheme_DocumentWidget_(d); 1079 updateTheme_DocumentWidget_(d);
1079 updateTrust_DocumentWidget_(d, NULL); 1080 updateTrust_DocumentWidget_(d, NULL);
1080 updateSize_DocumentWidget(d); 1081 updateSize_DocumentWidget(d);
1082 updateFetchProgress_DocumentWidget_(d);
1081 } 1083 }
1082 updateWindowTitle_DocumentWidget_(d); 1084 updateWindowTitle_DocumentWidget_(d);
1083 allocVisBuffer_DocumentWidget_(d); 1085 allocVisBuffer_DocumentWidget_(d);
@@ -1160,7 +1162,9 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
1160 else if (equalWidget_Command(cmd, w, "document.request.updated") && 1162 else if (equalWidget_Command(cmd, w, "document.request.updated") &&
1161 pointerLabel_Command(cmd, "request") == d->request) { 1163 pointerLabel_Command(cmd, "request") == d->request) {
1162 set_Block(&d->sourceContent, body_GmRequest(d->request)); 1164 set_Block(&d->sourceContent, body_GmRequest(d->request));
1163 updateFetchProgress_DocumentWidget_(d); 1165 if (document_App() == d) {
1166 updateFetchProgress_DocumentWidget_(d);
1167 }
1164 checkResponse_DocumentWidget_(d); 1168 checkResponse_DocumentWidget_(d);
1165 set_Atomic(&d->isRequestUpdated, iFalse); /* ready to be notified again */ 1169 set_Atomic(&d->isRequestUpdated, iFalse); /* ready to be notified again */
1166 return iFalse; 1170 return iFalse;
@@ -1189,18 +1193,24 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
1189 cancel_GmRequest(d->request); 1193 cancel_GmRequest(d->request);
1190 return iFalse; 1194 return iFalse;
1191 } 1195 }
1196 /*
1192 else if (equal_Command(cmd, "document.request.cancelled") && document_Command(cmd) == d) { 1197 else if (equal_Command(cmd, "document.request.cancelled") && document_Command(cmd) == d) {
1193 postCommand_App("navigate.back"); 1198 postCommand_App("navigate.back");
1194 return iFalse; 1199 return iFalse;
1195 } 1200 }
1201 */
1196 else if (equal_Command(cmd, "media.updated") || equal_Command(cmd, "media.finished")) { 1202 else if (equal_Command(cmd, "media.updated") || equal_Command(cmd, "media.finished")) {
1197 return handleMediaCommand_DocumentWidget_(d, cmd); 1203 return handleMediaCommand_DocumentWidget_(d, cmd);
1198 } 1204 }
1199 else if (equal_Command(cmd, "document.stop") && document_App() == d) { 1205 else if (equal_Command(cmd, "document.stop") && document_App() == d) {
1200 if (d->request) { 1206 if (d->request) {
1201 postCommandf_App("document.request.cancelled doc:%p url:%s", d, cstr_String(d->mod.url)); 1207 postCommandf_App(
1208 "document.request.cancelled doc:%p url:%s", d, cstr_String(d->mod.url));
1202 iReleasePtr(&d->request); 1209 iReleasePtr(&d->request);
1203 d->state = ready_RequestState; 1210 if (d->state != ready_RequestState) {
1211 d->state = ready_RequestState;
1212 postCommand_App("navigate.back");
1213 }
1204 updateFetchProgress_DocumentWidget_(d); 1214 updateFetchProgress_DocumentWidget_(d);
1205 return iTrue; 1215 return iTrue;
1206 } 1216 }
@@ -1554,8 +1564,10 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
1554 'c', 1564 'c',
1555 KMOD_PRIMARY, 1565 KMOD_PRIMARY,
1556 "copy" }, 1566 "copy" },
1567 { "---", 0, 0, NULL },
1568 { "Save to Downloads", SDLK_s, KMOD_PRIMARY, "document.save" },
1557 }, 1569 },
1558 6); 1570 8);
1559 d->menu = makeMenu_Widget(w, data_Array(&items), size_Array(&items)); 1571 d->menu = makeMenu_Widget(w, data_Array(&items), size_Array(&items));
1560 deinit_Array(&items); 1572 deinit_Array(&items);
1561 } 1573 }