X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=surf.c;h=360e0dc281d55e648ea41753feae1ae1456da690;hb=7330d0e26190e40fd857546b4cbc46855c75aeaa;hp=5e6d777493b5c34d5dbc4598ca534c0743d7e4ef;hpb=5878067225ac2f2a66522f3a1d4458c31390fad4;p=surf.git diff --git a/surf.c b/surf.c index 5e6d777..360e0dc 100644 --- a/surf.c +++ b/surf.c @@ -81,11 +81,11 @@ 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); static void loaduri(Client *c, const Arg *arg); -static void mousemove(GtkWidget *w, GdkEventMotion *e, Client *c); static void navigate(Client *c, const Arg *arg); static Client *newclient(void); static void newwindow(Client *c, const Arg *arg); @@ -329,6 +329,16 @@ gotheaders(SoupMessage *msg, gpointer v) { soup_cookies_free(l); } +gboolean +initdownload(WebKitWebView *view, WebKitDownload *o, Client *c) { + Arg arg; + + updatewinid(c); + cmd = (Arg)DOWNLOAD("_SURF_HILIGHT"); + spawn(c, &cmg); + return FALSE; +} + gboolean keypress(GtkWidget* w, GdkEventKey *ev, Client *c) { guint i; @@ -396,21 +406,6 @@ loaduri(Client *c, const Arg *arg) { } } -void -mousemove(GtkWidget *w, GdkEventMotion *e, Client *c) { - int result; - GdkEventButton coord; - WebKitHitTestResult *hit; - - coord.x = e->x; - coord.y = e->y; - hit = webkit_web_view_get_hit_test_result(c->view, &coord); - g_object_get(hit, "context", &result, NULL); - if(result & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE && !c->linkhover) { - puts("Picture"); - } -} - void navigate(Client *c, const Arg *arg) { int steps = *(int *)arg; @@ -470,7 +465,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), "motion-notify-event", G_CALLBACK(mousemove), c); + g_signal_connect(G_OBJECT(c->view), "download-requested", G_CALLBACK(initdownload), c); /* Indicator */ c->indicator = gtk_drawing_area_new(); @@ -762,9 +757,8 @@ void update(Client *c) { char *t; - if(c->progress != 100) { + if(c->progress != 100) t = g_strdup_printf("[%i%%] %s", c->progress, c->title); - } else if(c->linkhover) t = g_strdup(c->linkhover); else