X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=surf.c;h=6dc32ea0e729f40e46f21e3e736dfb9584bdb478;hb=62f54a3745f193223def1c14a19a8581af1c00ed;hp=1a1aae45aa7ef8feefc6fde8d3f4841ff075f64d;hpb=7ce2856194a55a31314c19c81a05008c24076dc8;p=surf.git diff --git a/surf.c b/surf.c index 1a1aae4..6dc32ea 100644 --- a/surf.c +++ b/surf.c @@ -23,7 +23,7 @@ #define LENGTH(x) (sizeof x / sizeof x[0]) #define CLEANMASK(mask) (mask & ~(GDK_MOD2_MASK)) -enum { AtomFind, AtomGo, AtomUri, AtomHiLight, AtomLast }; +enum { AtomFind, AtomGo, AtomUri, AtomLast }; typedef union Arg Arg; union Arg { @@ -81,6 +81,7 @@ static const char *getatom(Client *c, int a); static const char *getcookies(SoupURI *uri); static char *geturi(Client *c); void gotheaders(SoupMessage *msg, gpointer user_data); +static gboolean initdownload(WebKitWebView *v, WebKitDownload *o, Client *c); static gboolean keypress(GtkWidget *w, GdkEventKey *ev, Client *c); static void linkhover(WebKitWebView *v, const char* t, const char* l, Client *c); static void loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c); @@ -187,10 +188,7 @@ createwindow(WebKitWebView *v, WebKitWebFrame *f, Client *c) { gboolean decidedownload(WebKitWebView *v, WebKitWebFrame *f, WebKitNetworkRequest *r, gchar *m, WebKitWebPolicyDecision *p, Client *c) { if(!webkit_web_view_can_show_mime_type(v, m)) { - webkit_web_policy_decision_ignore(p); - webkit_web_view_load_html_string(c->view, - "Can't display content.", - webkit_network_request_get_uri(r)); + webkit_web_policy_decision_download(p); return TRUE; } return FALSE; @@ -213,6 +211,7 @@ void destroyclient(Client *c) { Client *p; + webkit_web_view_stop_loading(c->view); gtk_widget_destroy(c->indicator); gtk_widget_destroy(GTK_WIDGET(c->view)); gtk_widget_destroy(c->scroll); @@ -328,6 +327,16 @@ gotheaders(SoupMessage *msg, gpointer v) { soup_cookies_free(l); } +gboolean +initdownload(WebKitWebView *view, WebKitDownload *o, Client *c) { + Arg arg; + + updatewinid(c); + arg = (Arg)DOWNLOAD((char *)webkit_download_get_uri(o)); + spawn(c, &arg); + return FALSE; +} + gboolean keypress(GtkWidget* w, GdkEventKey *ev, Client *c) { guint i; @@ -454,6 +463,7 @@ newclient(void) { g_signal_connect(G_OBJECT(c->view), "window-object-cleared", G_CALLBACK(windowobjectcleared), c); g_signal_connect(G_OBJECT(c->view), "notify::load-status", G_CALLBACK(loadstatuschange), c); g_signal_connect(G_OBJECT(c->view), "notify::progress", G_CALLBACK(progresschange), c); + g_signal_connect(G_OBJECT(c->view), "download-requested", G_CALLBACK(initdownload), c); /* Indicator */ c->indicator = gtk_drawing_area_new(); @@ -491,11 +501,13 @@ newclient(void) { g_object_set(G_OBJECT(settings), "auto-load-images", loadimage, NULL); g_object_set(G_OBJECT(settings), "enable-plugins", plugin, NULL); g_object_set(G_OBJECT(settings), "enable-scripts", script, NULL); + g_object_set(G_OBJECT(settings), "enable-spatial-navigation", true, NULL); + g_free(uri); setatom(c, AtomFind, ""); setatom(c, AtomUri, "about:blank"); - if(NOBACKGROUND) + if(HIDE_BACKGROUND) webkit_web_view_set_transparent(c->view, TRUE); c->title = NULL; @@ -675,7 +687,6 @@ setup(void) { atoms[AtomFind] = XInternAtom(dpy, "_SURF_FIND", False); atoms[AtomGo] = XInternAtom(dpy, "_SURF_GO", False); atoms[AtomUri] = XInternAtom(dpy, "_SURF_URI", False); - atoms[AtomHiLight] = XInternAtom(dpy, "_SURF_HILIGHT", False); /* dirs and files */ cookiefile = buildpath(cookiefile);