For the moment I've done a little patch (against tip) that fixes the
recently removed "wget download" feature, and also allows to download
files using the "Download linked file" entry in the popup menu. It
would be easy change the DOWNLOAD(p) macro to use another download
manager.

Kind regards,
-- nibble

On Tue, 25 May 2010 15:41:24 +0200
pancake <panc...@youterm.com> wrote:

> On 05/25/10 15:24, Josh Rickmar wrote:
> > On Tue, May 25, 2010 at 11:36:28AM +0200, Claudio M. Alessi wrote:
> >    
> >> On Mon, May 24, 2010 at 04:06:00PM -0400, Josh Rickmar wrote:
> >>      
> >>> Also, is there a better way of doing cookies then wget?  As an
> >>> (Open)BSD user, I'd like to use something in base (I did install
> >>> wget though to test to make sure that wasn't the download problem
> >>> above). 
> >> IIRC you can use ftp(1) for HTTP requests.
> >>      
> > Thanks, I knew about (and use) ftp(1), but didn't think it would
> > work with cookies.  However, after checking the manpage, I see that
> > it does support them with the -c flag.
> >
> >    
> Why dont distribute a shellscript that gets URL+cookie as arguments,
> and let the users implement their own methods like using wget, ftp,
> curl, firefox* or whatever
> 
> * = yeah, using surf for browsing and firefox for download is the most
> retarded idea i can think of xD.. but surely..opening xterm or having
> a way to display all wgets in a single xterm would be good (dvtm?)
> 
> Having a suckless download manager can be good. just few locs in sh.
> 
> --pancake
> 

diff -r 4fe78ffcd81e config.def.h
--- a/config.def.h	Tue May 25 10:38:23 2010 +0200
+++ b/config.def.h	Tue May 25 15:48:41 2010 +0200
@@ -12,9 +12,15 @@
 	"prop=\"`xprop -id $2 $0 | cut -d '\"' -f 2 | dmenu`\" &&" \
 	"xprop -id $2 -f $1 8s -set $1 \"$prop\"", \
 	p, q, winid, NULL } }
+#define DOWNLOAD(p)       { \
+	.v = (char *[]){ "/bin/sh", "-c", \
+	"prop=\"`xprop -id $1 $0 | cut -d '\"' -f 2`\";" \
+	"xterm -e \"wget --load-cookies ~/.surf/cookies.txt $prop;\"", \
+	p, winid, NULL } }
 #define MODKEY GDK_CONTROL_MASK
 static Key keys[] = {
     /* modifier	            keyval      function    arg             Focus */
+    { MODKEY,               GDK_s,      spawn,      DOWNLOAD("_SURF_HILIGHT") },
     { MODKEY|GDK_SHIFT_MASK,GDK_r,      reload,     { .b = TRUE } },
     { MODKEY,               GDK_r,      reload,     { .b = FALSE } },
     { MODKEY|GDK_SHIFT_MASK,GDK_p,      print,      { 0 } },
diff -r 4fe78ffcd81e surf.c
--- a/surf.c	Tue May 25 10:38:23 2010 +0200
+++ b/surf.c	Tue May 25 15:48:41 2010 +0200
@@ -81,6 +81,7 @@
 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);
@@ -329,6 +330,16 @@
 }
 
 gboolean
+initdownload(WebKitWebView *view, WebKitDownload *o, Client *c) {
+	Arg cmd;
+
+	updatewinid(c);
+	cmd = (Arg)DOWNLOAD("_SURF_HILIGHT");
+	spawn(c, &cmd);
+	return FALSE;
+}
+
+gboolean
 keypress(GtkWidget* w, GdkEventKey *ev, Client *c) {
 	guint i;
 	gboolean processed = FALSE;
@@ -454,6 +465,7 @@
 	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();
@@ -495,6 +507,7 @@
 
 	setatom(c, AtomFind, "");
 	setatom(c, AtomUri, "about:blank");
+	setatom(c, AtomHiLight, "about:blank");
 	if(NOBACKGROUND)
 		webkit_web_view_set_transparent(c->view, TRUE);
 
@@ -750,6 +763,7 @@
 		t = g_strdup(c->linkhover);
 	else
 		t = g_strdup(c->title);
+	setatom(c, AtomHiLight, c->linkhover ? c->linkhover : geturi(c));
 	drawindicator(c);
 	gtk_window_set_title(GTK_WINDOW(c->win), t);
 	g_free(t);

Reply via email to