summaryrefslogtreecommitdiff
path: root/src/ui/documentwidget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r--src/ui/documentwidget.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 3f655db5..83f38dee 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -1168,13 +1168,25 @@ static void showErrorPage_DocumentWidget_(iDocumentWidget *d, enum iGmStatusCode
1168 iString *key = collectNew_String(); 1168 iString *key = collectNew_String();
1169 toString_Sym(SDLK_s, KMOD_PRIMARY, key); 1169 toString_Sym(SDLK_s, KMOD_PRIMARY, key);
1170 appendFormat_String(src, "\n```\n%s\n```\n", cstr_String(meta)); 1170 appendFormat_String(src, "\n```\n%s\n```\n", cstr_String(meta));
1171 makeFooterButtons_DocumentWidget_( 1171 const char *mtype = mediaTypeFromFileExtension_String(d->mod.url);
1172 d, 1172 iArray items;
1173 (iMenuItem[]){ { translateCStr_Lang(download_Icon " " saveToDownloads_Label), 1173 init_Array(&items, sizeof(iMenuItem));
1174 0, 1174 if (iCmpStr(mtype, "application/octet-stream")) {
1175 0, 1175 pushBack_Array(
1176 "document.save" } }, 1176 &items,
1177 1); 1177 &(iMenuItem){ translateCStr_Lang(format_CStr("View as \"%s\"", mtype)),
1178 SDLK_RETURN,
1179 0,
1180 format_CStr("document.setmediatype mime:%s", mtype) });
1181 }
1182 pushBack_Array(
1183 &items,
1184 &(iMenuItem){ translateCStr_Lang(download_Icon " " saveToDownloads_Label),
1185 0,
1186 0,
1187 "document.save" });
1188 makeFooterButtons_DocumentWidget_(d, data_Array(&items), size_Array(&items));
1189 deinit_Array(&items);
1178 break; 1190 break;
1179 } 1191 }
1180 default: 1192 default:
@@ -3176,6 +3188,10 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
3176 document_App() == d) { 3188 document_App() == d) {
3177 return handleSwipe_DocumentWidget_(d, cmd); 3189 return handleSwipe_DocumentWidget_(d, cmd);
3178 } 3190 }
3191 else if (equal_Command(cmd, "document.setmediatype") && document_App() == d) {
3192 setUrlAndSource_DocumentWidget(d, d->mod.url, string_Command(cmd, "mime"), &d->sourceContent);
3193 return iTrue;
3194 }
3179 return iFalse; 3195 return iFalse;
3180} 3196}
3181 3197