# HG changeset patch # User Ray Kohler # Date 1252501758 14400 # Node ID 5e7b815f9127c27c1d06a86a889c080a9fabb3b3 # Parent c63f78bf2dbba972846d04bc6298e9dc05c51943 [mq]: write_bookmarks diff -r c63f78bf2dbb -r 5e7b815f9127 config.def.h --- a/config.def.h Wed Sep 09 09:08:18 2009 -0400 +++ b/config.def.h Wed Sep 09 09:09:18 2009 -0400 @@ -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[] = { @@ -28,6 +29,7 @@ { MODKEY, GDK_h, navigate, { .i = -1 }, BROWSER }, { 0, GDK_Escape, stop, { 0 }, BROWSER }, { MODKEY, GDK_o, source, { 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 -r c63f78bf2dbb -r 5e7b815f9127 surf.c --- a/surf.c Wed Sep 09 09:08:18 2009 -0400 +++ b/surf.c Wed Sep 09 09:09:18 2009 -0400 @@ -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, @@ -530,6 +531,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) { }