diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-10-17 11:15:14 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-10-17 11:15:14 +0300 |
commit | 2e2b823bfb5d34d42c6b6c1b289193c854459b45 (patch) | |
tree | 345f37aa1b84d8dedb98ff260265b41495e10878 /src/ui/documentwidget.c | |
parent | 2f3987f5e54d95658f95c6991b0644bc15eedabf (diff) |
Media and FontPacks (work in progress)
Saving this as the last point of progress. This direction is too complicated: Media needs to be a lot more sophisticated to allow dynamic and interactive media at the level of FontPacks. (A bit like Player handles audio playback.)
This will be reverted. FontPack management will happen using an another method.
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r-- | src/ui/documentwidget.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 924dc0c4..1aca895c 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -2916,6 +2916,27 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
2916 | updateMedia_DocumentWidget_(d); | 2916 | updateMedia_DocumentWidget_(d); |
2917 | return iFalse; | 2917 | return iFalse; |
2918 | } | 2918 | } |
2919 | else if (equal_Command(cmd, "media.fontpack.updated")) { | ||
2920 | iMedia *media = pointerLabel_Command(cmd, "media"); | ||
2921 | if (media == media_GmDocument(d->doc)) { | ||
2922 | /*iGmMediaInfo info; | ||
2923 | if (info_Media(media, | ||
2924 | (iMediaId){ fontpack_MediaType, argU32Label_Command(cmd, "id")}, | ||
2925 | &info)) { | ||
2926 | |||
2927 | }*/ | ||
2928 | |||
2929 | // findCachedContent_App(<#const iString *url#>, <#iString *mime_out#>, <#iBlock *data_out#>) | ||
2930 | // setData_Media(media, | ||
2931 | } | ||
2932 | return iFalse; | ||
2933 | } | ||
2934 | else if (equal_Command(cmd, "media.fontpack.install")) { | ||
2935 | if (pointerLabel_Command(cmd, "media") == media_GmDocument(d->doc)) { | ||
2936 | /* TODO: This is ours, we may have a MediaRequest with the data in memory. */ | ||
2937 | } | ||
2938 | return iFalse; | ||
2939 | } | ||
2919 | else if (equal_Command(cmd, "document.stop") && document_App() == d) { | 2940 | else if (equal_Command(cmd, "document.stop") && document_App() == d) { |
2920 | if (cancelRequest_DocumentWidget_(d, iTrue /* navigate back */)) { | 2941 | if (cancelRequest_DocumentWidget_(d, iTrue /* navigate back */)) { |
2921 | return iTrue; | 2942 | return iTrue; |
@@ -5169,6 +5190,28 @@ void updateSize_DocumentWidget(iDocumentWidget *d) { | |||
5169 | invalidate_DocumentWidget_(d); | 5190 | invalidate_DocumentWidget_(d); |
5170 | } | 5191 | } |
5171 | 5192 | ||
5193 | iBool findCachedContent_DocumentWidget(const iDocumentWidget *d, const iString *url, | ||
5194 | iString *mime_out, iBlock *data_out) { | ||
5195 | if (equal_String(d->mod.url, url) && !isRequestOngoing_DocumentWidget(d)) { | ||
5196 | /* It's the currently open page. */ | ||
5197 | set_String(mime_out, &d->sourceMime); | ||
5198 | set_Block(data_out, &d->sourceContent); | ||
5199 | return iTrue; | ||
5200 | } | ||
5201 | /* Finished media requests are kept in memory while the page is open. */ | ||
5202 | iConstForEach(ObjectList, i, d->media) { | ||
5203 | const iMediaRequest *mr = i.object; | ||
5204 | if (mr->req && | ||
5205 | isFinished_GmRequest(mr->req) && | ||
5206 | equal_String(linkUrl_GmDocument(d->doc, mr->linkId), url)) { | ||
5207 | set_String(mime_out, meta_GmRequest(mr->req)); | ||
5208 | set_Block(data_out, body_GmRequest(mr->req)); | ||
5209 | return iTrue; | ||
5210 | } | ||
5211 | } | ||
5212 | return iFalse; | ||
5213 | } | ||
5214 | |||
5172 | iBeginDefineSubclass(DocumentWidget, Widget) | 5215 | iBeginDefineSubclass(DocumentWidget, Widget) |
5173 | .processEvent = (iAny *) processEvent_DocumentWidget_, | 5216 | .processEvent = (iAny *) processEvent_DocumentWidget_, |
5174 | .draw = (iAny *) draw_DocumentWidget_, | 5217 | .draw = (iAny *) draw_DocumentWidget_, |