# HG changeset patch # User Ray Kohler # Date 1252462664 14400 # Node ID 036c96ee90f5f0cd804b8a3ad854aece5ea018bb # Parent bfd6b9370ce3b013db5993c8a49fd47836b12286 [mq]: write_bookmarks diff --git a/config.def.h b/config.def.h --- a/config.def.h +++ b/config.def.h @@ -8,6 +8,7 @@ /* these are relative to surf_dir */ static const char *download_dir = "dl"; static const char *cookie_file = "cookies"; +static const char *bookmark_file = "bookmarks"; #define MODKEY GDK_CONTROL_MASK static Key keys[] = { @@ -27,6 +28,7 @@ { MODKEY, GDK_l, navigate, { .i = +1 }, BROWSER }, { MODKEY, GDK_h, navigate, { .i = -1 }, BROWSER }, { 0, GDK_Escape, stop, { 0 }, BROWSER }, + { MODKEY, GDK_B, savebookmark, {0}, BROWSER }, { MODKEY, GDK_n, searchtext, { .b = TRUE }, BROWSER|SEARCHBAR }, { MODKEY, GDK_N, searchtext, { .b = FALSE }, BROWSER|SEARCHBAR }, { 0, GDK_Return, searchtext, { .b = TRUE }, SEARCHBAR }, diff --git a/surf.c b/surf.c --- a/surf.c +++ b/surf.c @@ -99,6 +99,7 @@ static void request(SoupSession *s, SoupMessage *m, Client *c); static void reload(Client *c, const Arg *arg); static void rereadcookies(); +static void savebookmark(Client *c, const Arg *arg); static void setcookie(char *name, char *val, char *dom, char *path, long exp); static void setup(); static void titlechange(WebKitWebView* view, WebKitWebFrame* frame, @@ -528,6 +529,21 @@ } void +savebookmark(Client *c, const Arg *arg) { + const gchar *uri, *home, *bookmarkpath; + FILE *bookmarkfile; + + uri = geturi(c); + + home = g_get_home_dir(); + bookmarkpath = g_build_filename(home, surf_dir, bookmark_file, NULL); + + bookmarkfile = g_fopen(bookmarkpath, "a"); + fprintf(bookmarkfile, "%s\n", uri); + fclose(bookmarkfile); +} + +void setcookie(char *name, char *val, char *dom, char *path, long exp) { }