# HG changeset patch # User Ray Kohler # Date 1252462667 14400 # Node ID 9819d5a95fb7baf1cc063b0815fc0163efd550c7 # Parent 036c96ee90f5f0cd804b8a3ad854aece5ea018bb [mq]: write_history diff --git a/config.def.h b/config.def.h --- a/config.def.h +++ b/config.def.h @@ -2,6 +2,9 @@ static gchar *progress = "#FF0000"; static gchar *progress_trust = "#00FF00"; +/* whether to write a history file */ +static const bool write_history = true; + /* persistent files and directories */ /* this one is relative to home directory */ static const char *surf_dir = ".surf"; @@ -9,6 +12,7 @@ static const char *download_dir = "dl"; static const char *cookie_file = "cookies"; static const char *bookmark_file = "bookmarks"; +static const char *history_file = "history"; #define MODKEY GDK_CONTROL_MASK static Key keys[] = { diff --git a/surf.c b/surf.c --- a/surf.c +++ b/surf.c @@ -299,12 +299,23 @@ void loadcommit(WebKitWebView *view, WebKitWebFrame *f, Client *c) { gchar *uri; + const gchar *home, *historypath; + FILE *historyfile; ignore_once = TRUE; uri = geturi(c); XChangeProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window), urlprop, XA_STRING, 8, PropModeReplace, (unsigned char *)uri, strlen(uri) + 1); + + if(write_history) { + home = g_get_home_dir(); + historypath = g_build_filename(home, surf_dir, history_file, NULL); + + historyfile = g_fopen(historypath, "a"); + fprintf(historyfile, "%s\n", uri); + fclose(historyfile); + } } void