summaryrefslogtreecommitdiff
path: root/src/app.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-07-30 10:03:24 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-07-30 10:03:24 +0300
commit9eb27c0930017dd60d27d2e7f24561c369f5ac65 (patch)
tree2e9829eb37115e872a95068c97024ced904919fd /src/app.c
parent50f176335ed82c6517e5eeca107ce06b02a2d024 (diff)
History of visited URLs; visualize time of last link visit
Diffstat (limited to 'src/app.c')
-rw-r--r--src/app.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/app.c b/src/app.c
index cff7c7d6..f7f0b044 100644
--- a/src/app.c
+++ b/src/app.c
@@ -41,7 +41,6 @@ static const char *dataDir_App_ = "~/AppData/Roaming/fi.skyjake.Lagrange";
41static const char *dataDir_App_ = "~/.config/lagrange"; 41static const char *dataDir_App_ = "~/.config/lagrange";
42#endif 42#endif
43static const char *prefsFileName_App_ = "prefs.cfg"; 43static const char *prefsFileName_App_ = "prefs.cfg";
44static const char *historyFileName_App_ = "history.txt";
45 44
46struct Impl_App { 45struct Impl_App {
47 iCommandLine args; 46 iCommandLine args;
@@ -96,10 +95,6 @@ static const iString *prefsFileName_(void) {
96 return collect_String(concatCStr_Path(&iStringLiteral(dataDir_App_), prefsFileName_App_)); 95 return collect_String(concatCStr_Path(&iStringLiteral(dataDir_App_), prefsFileName_App_));
97} 96}
98 97
99static const iString *historyFileName_(void) {
100 return collect_String(concatCStr_Path(&iStringLiteral(dataDir_App_), historyFileName_App_));
101}
102
103static void loadPrefs_App_(iApp *d) { 98static void loadPrefs_App_(iApp *d) {
104 iUnused(d); 99 iUnused(d);
105 /* Create the data dir if it doesn't exist yet. */ 100 /* Create the data dir if it doesn't exist yet. */
@@ -148,7 +143,7 @@ static void init_App_(iApp *d, int argc, char **argv) {
148 d->pendingRefresh = iFalse; 143 d->pendingRefresh = iFalse;
149 d->history = new_History(); 144 d->history = new_History();
150 loadPrefs_App_(d); 145 loadPrefs_App_(d);
151 load_History(d->history, historyFileName_()); 146 load_History(d->history, dataDir_App_);
152#if defined (iHaveLoadEmbed) 147#if defined (iHaveLoadEmbed)
153 /* Load the resources from a file. */ { 148 /* Load the resources from a file. */ {
154 if (!load_Embed( 149 if (!load_Embed(
@@ -166,7 +161,7 @@ static void init_App_(iApp *d, int argc, char **argv) {
166 161
167static void deinit_App(iApp *d) { 162static void deinit_App(iApp *d) {
168 savePrefs_App_(d); 163 savePrefs_App_(d);
169 save_History(d->history, historyFileName_()); 164 save_History(d->history, dataDir_App_);
170 delete_History(d->history); 165 delete_History(d->history);
171 deinit_SortedArray(&d->tickers); 166 deinit_SortedArray(&d->tickers);
172 delete_Window(d->window); 167 delete_Window(d->window);
@@ -310,6 +305,10 @@ void addTicker_App(void (*ticker)(iAny *), iAny *context) {
310 insert_SortedArray(&d->tickers, &(iTicker){ context, ticker }); 305 insert_SortedArray(&d->tickers, &(iTicker){ context, ticker });
311} 306}
312 307
308const iHistory *history_App(void) {
309 return app_.history;
310}
311
313static iBool handlePrefsCommands_(iWidget *d, const char *cmd) { 312static iBool handlePrefsCommands_(iWidget *d, const char *cmd) {
314 if (equal_Command(cmd, "prefs.dismiss") || equal_Command(cmd, "preferences")) { 313 if (equal_Command(cmd, "prefs.dismiss") || equal_Command(cmd, "preferences")) {
315 setUiScale_Window(get_Window(), 314 setUiScale_Window(get_Window(),
@@ -327,11 +326,7 @@ iBool handleCommand_App(const char *cmd) {
327 const iString *url = collect_String(newCStr_String(suffixPtr_Command(cmd, "url"))); 326 const iString *url = collect_String(newCStr_String(suffixPtr_Command(cmd, "url")));
328 if (!argLabel_Command(cmd, "history")) { 327 if (!argLabel_Command(cmd, "history")) {
329 if (argLabel_Command(cmd, "redirect")) { 328 if (argLabel_Command(cmd, "redirect")) {
330 /* Update in the history. */ 329 replace_History(d->history, url);
331 iHistoryItem *item = item_History(d->history);
332 if (item) {
333 set_String(&item->url, url);
334 }
335 } 330 }
336 else { 331 else {
337 addUrl_History(d->history, url); 332 addUrl_History(d->history, url);