gint progress;
struct Client *next;
} Client;
+SoupCookieJar *cookiejar;
Client *clients = NULL;
gboolean embed = FALSE;
gboolean showxid = FALSE;
static void destroyclient(Client *c);
static void destroywin(GtkWidget* w, gpointer d);
static void die(char *str);
-static gboolean download(WebKitWebView *view, GObject *o, gpointer d);
+static gboolean download(WebKitWebView *view, WebKitDownload *o, gpointer d);
static gchar *geturi(Client *c);
static void hidesearch(Client *c);
static void hideurl(Client *c);
}
gboolean
-download(WebKitWebView *view, GObject *o, gpointer d) {
+download(WebKitWebView *view, WebKitDownload *o, gpointer d) {
/* TODO */
- return FALSE;
+ const gchar *home;
+ gchar *uri, *filename;
+
+ home = g_get_home_dir();
+ filename = g_build_filename(home, "Desktop",
+ webkit_download_get_suggested_filename(o), NULL);
+ uri = g_strconcat("file://", filename, NULL);
+ webkit_download_set_destination_uri(o, uri);
+ g_free(filename);
+ g_free(uri);
+ webkit_download_start(o);
+ return TRUE;
}
gchar *
return FALSE;
}
}
- if(ev->state == GDK_CONTROL_MASK || ev->state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) {
+ else if(ev->state == GDK_CONTROL_MASK || ev->state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) {
switch(ev->keyval) {
case GDK_r:
case GDK_R:
return TRUE;
}
}
+ else {
+ switch(ev->keyval) {
+ case GDK_k:
+ webkit_web_view_move_cursor(c->view, GTK_MOVEMENT_DISPLAY_LINES, -1);
+ return TRUE;
+ case GDK_j:
+ webkit_web_view_move_cursor(c->view, GTK_MOVEMENT_DISPLAY_LINES, 1);
+ return TRUE;
+ }
+ }
return FALSE;
}
g_string_prepend(uri, "file://");
loaduri(c, uri->str);
}
-
+
}
void
if(((XEvent *)e)->type == PropertyNotify) {
ev = &((XEvent *)e)->xproperty;
if(ignore_once == FALSE && ev->atom == urlprop && ev->state == PropertyNewValue) {
- XGetWindowProperty(dpy, ev->window, urlprop, 0L, BUFSIZ, False, XA_STRING,
+ XGetWindowProperty(dpy, ev->window, urlprop, 0L, BUFSIZ, False, XA_STRING,
&adummy, &idummy, &ldummy, &ldummy, &buf);
loaduri(c, (gchar *)buf);
XFree(buf);
int main(int argc, char *argv[]) {
gchar *uri = NULL, *file = NULL;
+ SoupSession *s;
Client *c;
int o;
+ const gchar *home, *filename;
gtk_init(NULL, NULL);
if (!g_thread_supported())
goto argerr;
if(!clients)
newclient();
+
+ /* cookie persistance */
+ s = webkit_get_default_session();
+ home = g_get_home_dir();
+ filename = g_build_filename(home, ".surf-cookies", NULL);
+ cookiejar = soup_cookie_jar_text_new(filename, FALSE);
+ soup_session_add_feature(s, SOUP_SESSION_FEATURE(cookiejar));
+
gtk_main();
cleanup();
return EXIT_SUCCESS;