Hey there.
The two current diffs pertaining to history I considered incomplete
because:
omnitool -- I should not have to dispatch a multitool script just to
save the URL I've changed to
history -- If you ^g to one link, then click on another, it doesn't
save the second to the history file.
so to fix this I hacked this patch up. I don't think there should be any
obvious bugs with it, but feel free to point any out!
Uh.
Enjoy =)
- Finn
diff --git a/config.def.h b/config.def.h
index 7c2b10f..be1d010 100644
--- a/config.def.h
+++ b/config.def.h
@@ -5,6 +5,7 @@ static char *useragent = "Mozilla/5.0 (X11; U; Unix; en-US) "
static char *scriptfile = "~/.surf/script.js";
static char *styledir = "~/.surf/styles/";
static char *cachefolder = "~/.surf/cache/";
+static char *historyfile = "~/.surf/history";
static Bool kioskmode = FALSE; /* Ignore shortcuts */
static Bool showindicators = TRUE; /* Show indicators in window title */
diff --git a/surf.c b/surf.c
index 46aef68..54128b3 100644
--- a/surf.c
+++ b/surf.c
@@ -392,6 +392,7 @@ cleanup(void)
destroyclient(clients);
g_free(cookiefile);
g_free(scriptfile);
+ g_free(historyfile);
g_free(stylefile);
}
@@ -817,6 +818,15 @@ linkhover(WebKitWebView *v, const char* t, const char* l, Client *c)
updatetitle(c);
}
+void addhistory(char *uri)
+{
+ FILE *h;
+ if ((h = fopen(historyfile, "a+"))) {
+ fprintf(h, "%s\n", uri);
+ fclose(h);
+ }
+}
+
void
loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c)
{
@@ -829,6 +839,7 @@ loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c)
switch (webkit_web_view_get_load_status (c->view)) {
case WEBKIT_LOAD_COMMITTED:
uri = geturi(c);
+ addhistory(uri);
if (strstr(uri, "https://") == uri) {
frame = webkit_web_view_get_main_frame(c->view);
src = webkit_web_frame_get_data_source(frame);
@@ -1345,6 +1356,7 @@ setup(void)
/* dirs and files */
cookiefile = buildfile(cookiefile);
scriptfile = buildfile(scriptfile);
+ historyfile = buildfile(historyfile);
cachefolder = buildpath(cachefolder);
if (stylefile == NULL) {
styledir = buildpath(styledir);