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/app.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/app.c')
-rw-r--r-- | src/app.c | 61 |
1 files changed, 43 insertions, 18 deletions
@@ -231,6 +231,9 @@ static iString *serializePrefs_App_(const iApp *d) { | |||
231 | appendFormat_String(str, "linewidth.set arg:%d\n", d->prefs.lineWidth); | 231 | appendFormat_String(str, "linewidth.set arg:%d\n", d->prefs.lineWidth); |
232 | appendFormat_String(str, "linespacing.set arg:%f\n", d->prefs.lineSpacing); | 232 | appendFormat_String(str, "linespacing.set arg:%f\n", d->prefs.lineSpacing); |
233 | appendFormat_String(str, "returnkey.set arg:%d\n", d->prefs.returnKey); | 233 | appendFormat_String(str, "returnkey.set arg:%d\n", d->prefs.returnKey); |
234 | iConstForEach(StringSet, fp, d->prefs.disabledFontPacks) { | ||
235 | appendFormat_String(str, "fontpack.disable id:%s\n", cstr_String(fp.value)); | ||
236 | } | ||
234 | /* TODO: This array belongs in Prefs. It can then be used for command handling as well. */ | 237 | /* TODO: This array belongs in Prefs. It can then be used for command handling as well. */ |
235 | const struct { | 238 | const struct { |
236 | const char * id; | 239 | const char * id; |
@@ -256,21 +259,6 @@ static iString *serializePrefs_App_(const iApp *d) { | |||
256 | iForIndices(i, boolPrefs) { | 259 | iForIndices(i, boolPrefs) { |
257 | appendFormat_String(str, "%s.changed arg:%d\n", boolPrefs[i].id, *boolPrefs[i].value); | 260 | appendFormat_String(str, "%s.changed arg:%d\n", boolPrefs[i].id, *boolPrefs[i].value); |
258 | } | 261 | } |
259 | // appendFormat_String(str, "prefs.animate.changed arg:%d\n", d->prefs.uiAnimations); | ||
260 | // appendFormat_String(str, "prefs.font.smooth.changed arg:%d\n", d->prefs.fontSmoothing); | ||
261 | // appendFormat_String(str, "prefs.gemtext.ansi.changed arg:%d\n", d->prefs.gemtextAnsiEscapes); | ||
262 | // appendFormat_String(str, "prefs.mono.gemini.changed arg:%d\n", d->prefs.monospaceGemini); | ||
263 | // appendFormat_String(str, "prefs.mono.gopher.changed arg:%d\n", d->prefs.monospaceGopher); | ||
264 | // appendFormat_String(str, "prefs.boldlink.dark.changed arg:%d\n", d->prefs.boldLinkDark); | ||
265 | // appendFormat_String(str, "prefs.boldlink.light.changed arg:%d\n", d->prefs.boldLinkLight); | ||
266 | // appendFormat_String(str, "prefs.biglede.changed arg:%d\n", d->prefs.bigFirstParagraph); | ||
267 | // appendFormat_String(str, "prefs.plaintext.wrap.changed arg:%d\n", d->prefs.plainTextWrap); | ||
268 | // appendFormat_String(str, "prefs.sideicon.changed arg:%d\n", d->prefs.sideIcon); | ||
269 | // appendFormat_String(str, "prefs.centershort.changed arg:%d\n", d->prefs.centerShortDocs); | ||
270 | // appendFormat_String(str, "prefs.collapsepreonload.changed arg:%d\n", d->prefs.collapsePreOnLoad); | ||
271 | // appendFormat_String(str, "prefs.hoverlink.changed arg:%d\n", d->prefs.hoverLink); | ||
272 | // appendFormat_String(str, "prefs.bookmarks.addbottom arg:%d\n", d->prefs.addBookmarksToBottom); | ||
273 | // appendFormat_String(str, "prefs.archive.openindex.changed arg:%d\n", d->prefs.openArchiveIndexPages); | ||
274 | appendFormat_String(str, "quoteicon.set arg:%d\n", d->prefs.quoteIcon ? 1 : 0); | 262 | appendFormat_String(str, "quoteicon.set arg:%d\n", d->prefs.quoteIcon ? 1 : 0); |
275 | appendFormat_String(str, "theme.set arg:%d auto:1\n", d->prefs.theme); | 263 | appendFormat_String(str, "theme.set arg:%d auto:1\n", d->prefs.theme); |
276 | appendFormat_String(str, "accent.set arg:%d\n", d->prefs.accent); | 264 | appendFormat_String(str, "accent.set arg:%d\n", d->prefs.accent); |
@@ -381,6 +369,10 @@ static void loadPrefs_App_(iApp *d) { | |||
381 | d->initialWindowRect = init_Rect( | 369 | d->initialWindowRect = init_Rect( |
382 | pos.x, pos.y, argLabel_Command(cmd, "width"), argLabel_Command(cmd, "height")); | 370 | pos.x, pos.y, argLabel_Command(cmd, "width"), argLabel_Command(cmd, "height")); |
383 | } | 371 | } |
372 | else if (equal_Command(cmd, "fontpack.disable")) { | ||
373 | insert_StringSet(d->prefs.disabledFontPacks, | ||
374 | collect_String(suffix_Command(cmd, "id"))); | ||
375 | } | ||
384 | #if !defined (LAGRANGE_ENABLE_DOWNLOAD_EDIT) | 376 | #if !defined (LAGRANGE_ENABLE_DOWNLOAD_EDIT) |
385 | else if (equal_Command(cmd, "downloads")) { | 377 | else if (equal_Command(cmd, "downloads")) { |
386 | continue; /* can't change downloads directory */ | 378 | continue; /* can't change downloads directory */ |
@@ -1119,6 +1111,18 @@ void trimMemory_App(void) { | |||
1119 | iRelease(docs); | 1111 | iRelease(docs); |
1120 | } | 1112 | } |
1121 | 1113 | ||
1114 | iBool findCachedContent_App(const iString *url, iString *mime_out, iBlock *data_out) { | ||
1115 | /* Cached content can be found in MediaRequests of DocumentWidgets (loaded on the currently | ||
1116 | open page) and the DocumentWidget itself. `Media` doesn't store source data, only | ||
1117 | presentation data. */ | ||
1118 | iConstForEach(ObjectList, i, iClob(listDocuments_App(NULL))) { | ||
1119 | if (findCachedContent_DocumentWidget(i.object, url, mime_out, data_out)) { | ||
1120 | return iTrue; | ||
1121 | } | ||
1122 | } | ||
1123 | return iFalse; | ||
1124 | } | ||
1125 | |||
1122 | iLocalDef iBool isWaitingAllowed_App_(iApp *d) { | 1126 | iLocalDef iBool isWaitingAllowed_App_(iApp *d) { |
1123 | if (!isEmpty_Periodic(&d->periodic)) { | 1127 | if (!isEmpty_Periodic(&d->periodic)) { |
1124 | return iFalse; | 1128 | return iFalse; |
@@ -2086,7 +2090,8 @@ const iString *searchQueryUrl_App(const iString *queryStringUnescaped) { | |||
2086 | "%s?%s", cstr_String(&d->prefs.strings[searchUrl_PrefsString]), cstr_String(escaped)); | 2090 | "%s?%s", cstr_String(&d->prefs.strings[searchUrl_PrefsString]), cstr_String(escaped)); |
2087 | } | 2091 | } |
2088 | 2092 | ||
2089 | static void resetFonts_App_(iApp *d) { | 2093 | void resetFonts_App(void) { |
2094 | iApp *d = &app_; | ||
2090 | iConstForEach(PtrArray, win, listWindows_App_(d)) { | 2095 | iConstForEach(PtrArray, win, listWindows_App_(d)) { |
2091 | resetFonts_Text(text_Window(win.ptr)); | 2096 | resetFonts_Text(text_Window(win.ptr)); |
2092 | } | 2097 | } |
@@ -2163,7 +2168,11 @@ iBool handleCommand_App(const char *cmd) { | |||
2163 | return iTrue; | 2168 | return iTrue; |
2164 | } | 2169 | } |
2165 | else if (equal_Command(cmd, "font.reset")) { | 2170 | else if (equal_Command(cmd, "font.reset")) { |
2166 | resetFonts_App_(d); | 2171 | resetFonts_App(); |
2172 | return iTrue; | ||
2173 | } | ||
2174 | else if (equal_Command(cmd, "font.reload")) { | ||
2175 | reload_Fonts(); /* also does font cache reset, window invalidation */ | ||
2167 | return iTrue; | 2176 | return iTrue; |
2168 | } | 2177 | } |
2169 | #if 0 | 2178 | #if 0 |
@@ -2175,7 +2184,7 @@ iBool handleCommand_App(const char *cmd) { | |||
2175 | } | 2184 | } |
2176 | setCStr_String(&d->prefs.symbolFontPath, path); | 2185 | setCStr_String(&d->prefs.symbolFontPath, path); |
2177 | loadUserFonts_Text(); | 2186 | loadUserFonts_Text(); |
2178 | resetFonts_App_(d); | 2187 | resetFonts_App(d); |
2179 | if (!isFrozen) { | 2188 | if (!isFrozen) { |
2180 | postCommand_App("font.changed"); | 2189 | postCommand_App("font.changed"); |
2181 | postCommand_App("window.unfreeze"); | 2190 | postCommand_App("window.unfreeze"); |
@@ -3034,6 +3043,22 @@ iBool handleCommand_App(const char *cmd) { | |||
3034 | } | 3043 | } |
3035 | return iFalse; | 3044 | return iFalse; |
3036 | } | 3045 | } |
3046 | else if (equal_Command(cmd, "media.fontpack.enable")) { | ||
3047 | const iString *packId = collect_String(suffix_Command(cmd, "packid")); | ||
3048 | if (arg_Command(cmd)) { | ||
3049 | remove_StringSet(d->prefs.disabledFontPacks, packId); | ||
3050 | } | ||
3051 | else { | ||
3052 | insert_StringSet(d->prefs.disabledFontPacks, packId); | ||
3053 | } | ||
3054 | resetFonts_App(); | ||
3055 | const iMedia *media = pointerLabel_Command(cmd, "media"); | ||
3056 | if (media) { | ||
3057 | postCommandf_App("media.fontpack.updated id:%u media:%p", | ||
3058 | argU32Label_Command(cmd, "mediaid"), media); | ||
3059 | } | ||
3060 | return iTrue; | ||
3061 | } | ||
3037 | #if defined (LAGRANGE_ENABLE_IPC) | 3062 | #if defined (LAGRANGE_ENABLE_IPC) |
3038 | else if (equal_Command(cmd, "ipc.list.urls")) { | 3063 | else if (equal_Command(cmd, "ipc.list.urls")) { |
3039 | iProcessId pid = argLabel_Command(cmd, "pid"); | 3064 | iProcessId pid = argLabel_Command(cmd, "pid"); |