summaryrefslogtreecommitdiff
path: root/src/app.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-10-17 20:33:14 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-10-17 20:33:14 +0300
commitb3ae7efcb9adb1de3d02f0753e2a79888bdb71ac (patch)
tree57fb9f82f2d19a1c8e6d1aa85865f9df210e2c4b /src/app.c
parent2e2b823bfb5d34d42c6b6c1b289193c854459b45 (diff)
FontPack management via "about:fonts"
Diffstat (limited to 'src/app.c')
-rw-r--r--src/app.c50
1 files changed, 43 insertions, 7 deletions
diff --git a/src/app.c b/src/app.c
index 70b611c2..c7e803d4 100644
--- a/src/app.c
+++ b/src/app.c
@@ -2566,12 +2566,23 @@ iBool handleCommand_App(const char *cmd) {
2566 const iBool fromSidebar = argLabel_Command(cmd, "fromsidebar") != 0; 2566 const iBool fromSidebar = argLabel_Command(cmd, "fromsidebar") != 0;
2567 iUrl parts; 2567 iUrl parts;
2568 init_Url(&parts, url); 2568 init_Url(&parts, url);
2569 if (equal_Rangecc(parts.scheme, "about") && equal_Rangecc(parts.path, "command") &&
2570 !isEmpty_Range(&parts.query)) {
2571 /* NOTE: Careful here! `about:command` allows issuing UI events via links on the page.
2572 There is a special set of pages where these are allowed (e.g., "about:fonts").
2573 On every other page, `about:command` links will not be clickable. */
2574 iString *query = collectNewRange_String((iRangecc){
2575 parts.query.start + 1, parts.query.end
2576 });
2577 replace_String(query, "%20", " ");
2578 postCommandString_Root(NULL, query);
2579 return iTrue;
2580 }
2569 if (equalCase_Rangecc(parts.scheme, "titan")) { 2581 if (equalCase_Rangecc(parts.scheme, "titan")) {
2570 iUploadWidget *upload = new_UploadWidget(); 2582 iUploadWidget *upload = new_UploadWidget();
2571 setUrl_UploadWidget(upload, url); 2583 setUrl_UploadWidget(upload, url);
2572 setResponseViewer_UploadWidget(upload, document_App()); 2584 setResponseViewer_UploadWidget(upload, document_App());
2573 addChild_Widget(get_Root()->widget, iClob(upload)); 2585 addChild_Widget(get_Root()->widget, iClob(upload));
2574// finalizeSheet_Mobile(as_Widget(upload));
2575 setupSheetTransition_Mobile(as_Widget(upload), iTrue); 2586 setupSheetTransition_Mobile(as_Widget(upload), iTrue);
2576 postRefresh_App(); 2587 postRefresh_App();
2577 return iTrue; 2588 return iTrue;
@@ -3043,8 +3054,8 @@ iBool handleCommand_App(const char *cmd) {
3043 } 3054 }
3044 return iFalse; 3055 return iFalse;
3045 } 3056 }
3046 else if (equal_Command(cmd, "media.fontpack.enable")) { 3057 else if (equal_Command(cmd, "fontpack.enable")) {
3047 const iString *packId = collect_String(suffix_Command(cmd, "packid")); 3058 const iString *packId = collect_String(suffix_Command(cmd, "id"));
3048 if (arg_Command(cmd)) { 3059 if (arg_Command(cmd)) {
3049 remove_StringSet(d->prefs.disabledFontPacks, packId); 3060 remove_StringSet(d->prefs.disabledFontPacks, packId);
3050 } 3061 }
@@ -3052,10 +3063,35 @@ iBool handleCommand_App(const char *cmd) {
3052 insert_StringSet(d->prefs.disabledFontPacks, packId); 3063 insert_StringSet(d->prefs.disabledFontPacks, packId);
3053 } 3064 }
3054 resetFonts_App(); 3065 resetFonts_App();
3055 const iMedia *media = pointerLabel_Command(cmd, "media"); 3066 postCommand_App("navigate.reload");
3056 if (media) { 3067 return iTrue;
3057 postCommandf_App("media.fontpack.updated id:%u media:%p", 3068 }
3058 argU32Label_Command(cmd, "mediaid"), media); 3069 else if (equal_Command(cmd, "fontpack.delete")) {
3070 const iString *packId = collect_String(suffix_Command(cmd, "id"));
3071 if (isEmpty_String(packId)) {
3072 return iTrue;
3073 }
3074 const iFontPack *pack = pack_Fonts(cstr_String(packId));
3075 if (pack && loadPath_FontPack(pack)) {
3076 if (argLabel_Command(cmd, "confirmed")) {
3077 remove_StringSet(d->prefs.disabledFontPacks, packId);
3078 remove(cstr_String(loadPath_FontPack(pack)));
3079 reload_Fonts();
3080 postCommand_App("navigate.reload");
3081 }
3082 else {
3083 makeQuestion_Widget(
3084 uiTextCaution_ColorEscape "${heading.fontpack.delete}",
3085 format_Lang("${dlg.fontpack.delete.confirm}",
3086 cstr_String(packId)),
3087 (iMenuItem[]){ { "${cancel}" },
3088 { uiTextCaution_ColorEscape " ${dlg.fontpack.delete}",
3089 0,
3090 0,
3091 format_CStr("!fontpack.delete confirmed:1 id:%s",
3092 cstr_String(packId)) } },
3093 2);
3094 }
3059 } 3095 }
3060 return iTrue; 3096 return iTrue;
3061 } 3097 }