From 90717c77b29c4a8ca0c3f49e9b4670b6fcbbe9d9 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Sat, 24 Apr 2021 15:36:05 +0300 Subject: Added "Show Downloads" and "Open Downloaded File" Contents of the Downloads folder can now be viewed as a directory index page. --- po/en.po | 3 +++ res/lang/de.bin | Bin 18677 -> 18707 bytes res/lang/en.bin | Bin 17165 -> 17195 bytes res/lang/es.bin | Bin 19256 -> 19286 bytes res/lang/fi.bin | Bin 18959 -> 18989 bytes res/lang/fr.bin | Bin 18282 -> 18312 bytes res/lang/ie.bin | Bin 18380 -> 18410 bytes res/lang/ru.bin | Bin 28868 -> 28898 bytes res/lang/sr.bin | Bin 27363 -> 27393 bytes res/lang/zh_Hans.bin | Bin 16555 -> 16585 bytes res/lang/zh_Hant.bin | Bin 16629 -> 16659 bytes src/app.c | 29 +++++++++++++++++------------ src/ui/certimportwidget.c | 8 ++++---- src/ui/documentwidget.c | 22 ++++++++++++++-------- src/ui/sidebarwidget.c | 4 ++-- src/ui/util.c | 13 ++++++++++--- src/ui/util.h | 4 +++- src/ui/window.c | 7 ++++++- 18 files changed, 59 insertions(+), 31 deletions(-) diff --git a/po/en.po b/po/en.po index 4cd9b155..4508e8cd 100644 --- a/po/en.po +++ b/po/en.po @@ -155,6 +155,9 @@ msgstr "Duplicate Tab" msgid "menu.openlocation" msgstr "Open Location…" +msgid "menu.downloads" +msgstr "Show Downloads" + msgid "menu.find" msgstr "Find on Page" diff --git a/res/lang/de.bin b/res/lang/de.bin index ac331478..672999b3 100644 Binary files a/res/lang/de.bin and b/res/lang/de.bin differ diff --git a/res/lang/en.bin b/res/lang/en.bin index 612b9a14..6a60d536 100644 Binary files a/res/lang/en.bin and b/res/lang/en.bin differ diff --git a/res/lang/es.bin b/res/lang/es.bin index 970a2972..f1cb61f5 100644 Binary files a/res/lang/es.bin and b/res/lang/es.bin differ diff --git a/res/lang/fi.bin b/res/lang/fi.bin index 70424111..c13fa332 100644 Binary files a/res/lang/fi.bin and b/res/lang/fi.bin differ diff --git a/res/lang/fr.bin b/res/lang/fr.bin index c25f6b17..c8871928 100644 Binary files a/res/lang/fr.bin and b/res/lang/fr.bin differ diff --git a/res/lang/ie.bin b/res/lang/ie.bin index e933c41b..8b4c52d9 100644 Binary files a/res/lang/ie.bin and b/res/lang/ie.bin differ diff --git a/res/lang/ru.bin b/res/lang/ru.bin index dc3592aa..a2e4b3bd 100644 Binary files a/res/lang/ru.bin and b/res/lang/ru.bin differ diff --git a/res/lang/sr.bin b/res/lang/sr.bin index 85be8b45..2766d595 100644 Binary files a/res/lang/sr.bin and b/res/lang/sr.bin differ diff --git a/res/lang/zh_Hans.bin b/res/lang/zh_Hans.bin index e6ffbdc4..311bf19d 100644 Binary files a/res/lang/zh_Hans.bin and b/res/lang/zh_Hans.bin differ diff --git a/res/lang/zh_Hant.bin b/res/lang/zh_Hant.bin index 7b705e15..083d3f08 100644 Binary files a/res/lang/zh_Hant.bin and b/res/lang/zh_Hant.bin differ diff --git a/src/app.c b/src/app.c index 4abb63c6..ce3f94f9 100644 --- a/src/app.c +++ b/src/app.c @@ -1491,8 +1491,8 @@ static iBool handleIdentityCreationCommands_(iWidget *dlg, const char *cmd) { const iString *country = text_InputWidget (findChild_Widget(dlg, "ident.country")); const iBool isTemp = isSelected_Widget(findChild_Widget(dlg, "ident.temp")); if (isEmpty_String(commonName)) { - makeMessage_Widget(orange_ColorEscape "MISSING INFO", - "A \"Common name\" must be specified."); + makeSimpleMessage_Widget(orange_ColorEscape "MISSING INFO", + "A \"Common name\" must be specified."); return iTrue; } iDate until; @@ -1506,11 +1506,11 @@ static iBool handleIdentityCreationCommands_(iWidget *dlg, const char *cmd) { "%04u-%u-%u %u:%u:%u", &val[0], &val[1], &val[2], &val[3], &val[4], &val[5]); if (n <= 0) { - makeMessage_Widget(orange_ColorEscape "INVALID DATE", - "Please check the \"Valid until\" date. Examples:\n" - "\u2022 2030\n" - "\u2022 2025-06-30\n" - "\u2022 2021-12-31 23:59:59"); + makeSimpleMessage_Widget(orange_ColorEscape "INVALID DATE", + "Please check the \"Valid until\" date. Examples:\n" + "\u2022 2030\n" + "\u2022 2025-06-30\n" + "\u2022 2021-12-31 23:59:59"); return iTrue; } until.year = val[0]; @@ -1525,8 +1525,8 @@ static iBool handleIdentityCreationCommands_(iWidget *dlg, const char *cmd) { initCurrent_Time(&now); init_Time(&t, &until); if (cmp_Time(&t, &now) <= 0) { - makeMessage_Widget(orange_ColorEscape "INVALID DATE", - "Expiration date must be in the future."); + makeSimpleMessage_Widget(orange_ColorEscape "INVALID DATE", + "Expiration date must be in the future."); return iTrue; } } @@ -1559,9 +1559,10 @@ const iString *searchQueryUrl_App(const iString *queryStringUnescaped) { iBool handleCommand_App(const char *cmd) { iApp *d = &app_; if (equal_Command(cmd, "config.error")) { - makeMessage_Widget(uiTextCaution_ColorEscape "CONFIG ERROR", - format_CStr("Error in config file: %s\nSee \"about:debug\" for details.", - suffixPtr_Command(cmd, "where"))); + makeSimpleMessage_Widget(uiTextCaution_ColorEscape "CONFIG ERROR", + format_CStr("Error in config file: %s\n" + "See \"about:debug\" for details.", + suffixPtr_Command(cmd, "where"))); return iTrue; } else if (equal_Command(cmd, "prefs.changed")) { @@ -1810,6 +1811,10 @@ iBool handleCommand_App(const char *cmd) { setCStr_String(&d->prefs.downloadDir, suffixPtr_Command(cmd, "path")); return iTrue; } + else if (equal_Command(cmd, "downloads.open")) { + postCommandf_App("open url:%s", cstrCollect_String(makeFileUrl_String(downloadDir_App()))); + return iTrue; + } else if (equal_Command(cmd, "ca.file")) { setCStr_String(&d->prefs.caFile, suffixPtr_Command(cmd, "path")); if (!argLabel_Command(cmd, "noset")) { diff --git a/src/ui/certimportwidget.c b/src/ui/certimportwidget.c index 3a037135..fdc189db 100644 --- a/src/ui/certimportwidget.c +++ b/src/ui/certimportwidget.c @@ -207,8 +207,8 @@ static iBool processEvent_CertImportWidget_(iCertImportWidget *d, const SDL_Even const int mods = keyMods_Sym(ev->key.keysym.mod); if (key == SDLK_v && mods == KMOD_PRIMARY) { if (!tryImportFromClipboard_CertImportWidget_(d)) { - makeMessage_Widget(uiTextCaution_ColorEscape "${heading.certimport.pasted}", - "${dlg.certimport.notfound}"); + makeSimpleMessage_Widget(uiTextCaution_ColorEscape "${heading.certimport.pasted}", + "${dlg.certimport.notfound}"); } postRefresh_App(); return iTrue; @@ -241,8 +241,8 @@ static iBool processEvent_CertImportWidget_(iCertImportWidget *d, const SDL_Even } } else { - makeMessage_Widget(uiTextCaution_ColorEscape "${heading.certimport.dropped}", - "${dlg.certimport.notfound}"); + makeSimpleMessage_Widget(uiTextCaution_ColorEscape "${heading.certimport.dropped}", + "${dlg.certimport.notfound}"); } } iRelease(f); diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 1960d9b7..9b414b63 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c @@ -1615,7 +1615,7 @@ static iBool handleMediaCommand_DocumentWidget_(iDocumentWidget *d, const char * } else { const iGmError *err = get_GmError(code); - makeMessage_Widget(format_CStr(uiTextCaution_ColorEscape "%s", err->title), err->info); + makeSimpleMessage_Widget(format_CStr(uiTextCaution_ColorEscape "%s", err->title), err->info); removeMediaRequest_DocumentWidget_(d, req->linkId); } return iTrue; @@ -1665,15 +1665,21 @@ static void saveToDownloads_(const iString *url, const iString *mime, const iBlo #if defined (iPlatformAppleMobile) exportDownloadedFile_iOS(savePath); #else + const iMenuItem items[2] = { + { "Open Downloaded File", 0, 0, + format_CStr("!open url:%s", cstrCollect_String(makeFileUrl_String(savePath))) }, + { "${dlg.message.ok}", 0, 0, "message.ok" }, + }; makeMessage_Widget(uiHeading_ColorEscape "${heading.save}", format_CStr("%s\n${dlg.save.size} %.3f %s", cstr_String(path_File(f)), isMega ? size / 1.0e6f : (size / 1.0e3f), - isMega ? "${mb}" : "${kb}")); + isMega ? "${mb}" : "${kb}"), + items, iElemCount(items)); #endif } else { - makeMessage_Widget(uiTextCaution_ColorEscape "${heading.save.error}", - strerror(errno)); + makeSimpleMessage_Widget(uiTextCaution_ColorEscape "${heading.save.error}", + strerror(errno)); } iRelease(f); } @@ -2141,8 +2147,8 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) } else if (equal_Command(cmd, "document.save") && document_App() == d) { if (d->request) { - makeMessage_Widget(uiTextCaution_ColorEscape "${heading.save.incomplete}", - "${dlg.save.incomplete}"); + makeSimpleMessage_Widget(uiTextCaution_ColorEscape "${heading.save.incomplete}", + "${dlg.save.incomplete}"); } else if (!isEmpty_Block(&d->sourceContent)) { saveToDownloads_(d->mod.url, &d->sourceMime, &d->sourceContent); @@ -2375,8 +2381,8 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) } } else { - makeMessage_Widget(uiHeading_ColorEscape "${heading.import.bookmarks}", - "${dlg.import.notnew}"); + makeSimpleMessage_Widget(uiHeading_ColorEscape "${heading.import.bookmarks}", + "${dlg.import.notnew}"); } return iTrue; } diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index e7dcadde..5aa17140 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c @@ -1161,8 +1161,8 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) else if (isCommand_Widget(w, ev, "ident.showuse")) { const iGmIdentity *ident = menuIdentity_SidebarWidget_(d); if (ident) { - makeMessage_Widget(uiHeading_ColorEscape "${heading.ident.use}", - cstrCollect_String(joinCStr_StringSet(ident->useUrls, "\n"))); + makeSimpleMessage_Widget(uiHeading_ColorEscape "${heading.ident.use}", + cstrCollect_String(joinCStr_StringSet(ident->useUrls, "\n"))); } return iTrue; } diff --git a/src/ui/util.c b/src/ui/util.c index 586a08be..e3a3689b 100644 --- a/src/ui/util.c +++ b/src/ui/util.c @@ -1927,9 +1927,16 @@ static iBool messageHandler_(iWidget *msg, const char *cmd) { return iFalse; } -iWidget *makeMessage_Widget(const char *title, const char *msg) { - iWidget *dlg = - makeQuestion_Widget(title, msg, (iMenuItem[]){ { "${dlg.message.ok}", 0, 0, "message.ok" } }, 1); +iWidget *makeSimpleMessage_Widget(const char *title, const char *msg) { + return makeMessage_Widget(title, + msg, + (iMenuItem[]){ { "${dlg.message.ok}", 0, 0, "message.ok" } }, + 1); +} + +iWidget *makeMessage_Widget(const char *title, const char *msg, const iMenuItem *items, + size_t numItems) { + iWidget *dlg = makeQuestion_Widget(title, msg, items, numItems); addAction_Widget(dlg, SDLK_ESCAPE, 0, "message.ok"); addAction_Widget(dlg, SDLK_SPACE, 0, "message.ok"); return dlg; diff --git a/src/ui/util.h b/src/ui/util.h index 223982a8..aaffb1b8 100644 --- a/src/ui/util.h +++ b/src/ui/util.h @@ -259,7 +259,9 @@ void makeFilePath_Widget (iWidget *parent, const iString *initialPath iWidget * makeValueInput_Widget (iWidget *parent, const iString *initialValue, const char *title, const char *prompt, const char *acceptLabel, const char *command); void updateValueInput_Widget (iWidget *, const char *title, const char *prompt); -iWidget * makeMessage_Widget (const char *title, const char *msg); +iWidget * makeSimpleMessage_Widget(const char *title, const char *msg); +iWidget * makeMessage_Widget (const char *title, const char *msg, + const iMenuItem *items, size_t numItems); iWidget * makeQuestion_Widget (const char *title, const char *msg, const iMenuItem *items, size_t numItems); diff --git a/src/ui/window.c b/src/ui/window.c index b400dced..086ab86e 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -195,6 +195,7 @@ static const iMenuItem navMenuItems_[] = { { "${menu.openlocation}", SDLK_l, KMOD_PRIMARY, "navigate.focus" }, { "---", 0, 0, NULL }, { download_Icon " " saveToDownloads_Label, SDLK_s, KMOD_PRIMARY, "document.save" }, + { "${menu.downloads}", 0, 0, "downloads.open" }, { "${menu.page.copysource}", SDLK_c, KMOD_PRIMARY, "copy" }, { "---", 0, 0, NULL }, { leftHalf_Icon " ${menu.sidebar.left}", SDLK_l, KMOD_PRIMARY | KMOD_SHIFT, "sidebar.toggle" }, @@ -227,7 +228,8 @@ static const iMenuItem tabletNavMenuItems_[] = { { "---", 0, 0, NULL }, { book_Icon " ${menu.bookmarks.list}", 0, 0, "!open url:about:bookmarks" }, { "${menu.bookmarks.bytag}", 0, 0, "!open url:about:bookmarks?tags" }, - { "${menu.bookmarks.bytime}", 0, 0, "!open url:about:feeds" }, + { "${menu.feeds.entrylist}", 0, 0, "!open url:about:feeds" }, + { "${menu.downloads}", 0, 0, "downloads.open" }, { "---", 0, 0, NULL }, { gear_Icon " ${menu.preferences}", SDLK_COMMA, KMOD_PRIMARY, "preferences" }, { "${menu.help}", SDLK_F1, 0, "!open url:about:help" }, @@ -244,6 +246,7 @@ static const iMenuItem phoneNavMenuItems_[] = { { "---", 0, 0, NULL }, { book_Icon " ${menu.bookmarks.list}", 0, 0, "!open url:about:bookmarks" }, { "${menu.feeds.entrylist}", 0, 0, "!open url:about:feeds" }, + { "${menu.downloads}", 0, 0, "downloads.open" }, { "---", 0, 0, NULL }, { gear_Icon " Settings...", SDLK_COMMA, KMOD_PRIMARY, "preferences" }, }; @@ -257,6 +260,8 @@ static const iMenuItem fileMenuItems_[] = { { "${menu.openlocation}", SDLK_l, KMOD_PRIMARY, "navigate.focus" }, { "---", 0, 0, NULL }, { saveToDownloads_Label, SDLK_s, KMOD_PRIMARY, "document.save" }, + { "---", 0, 0, NULL }, + { "${menu.downloads}", 0, 0, "downloads.open" }, }; static const iMenuItem editMenuItems_[] = { -- cgit v1.2.3