[hackers] [surf] Applying Nibbles download patch. Thanks! || Enno Boland (tox)

From: <hg_AT_suckless.org>
Date: Wed, 26 May 2010 13:32:05 +0000 (UTC)

changeset: 214:18584af1bcd4
tag: tip
user: Enno Boland (tox) <tox_AT_s01.de>
date: Wed May 26 15:33:01 2010 +0200
files: config.def.h surf.c
description:
Applying Nibbles download patch. Thanks!

diff -r 4fe78ffcd81e -r 18584af1bcd4 config.def.h
--- a/config.def.h Tue May 25 10:38:23 2010 +0200
+++ b/config.def.h Wed May 26 15:33:01 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 -r 18584af1bcd4 surf.c
--- a/surf.c Tue May 25 10:38:23 2010 +0200
+++ b/surf.c Wed May 26 15:33:01 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 arg;
+
+ updatewinid(c);
+ cmd = (Arg)DOWNLOAD("_SURF_HILIGHT");
+ spawn(c, &cmg);
+ 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);
Received on Wed May 26 2010 - 13:32:05 UTC

This archive was generated by hypermail 2.2.0 : Wed May 26 2010 - 13:36:05 UTC