.TH SURF 1 surf\-VERSION
.SH NAME
-surf \- simple webkit based browser
+surf \- simple webkit-based browser
.SH SYNOPSIS
.B surf
.RB [ \-ehvx ]
-.RB [ \-f " FILE"]
-.RB [ \-u " URI"]
+.RB "URI"
.SH DESCRIPTION
-surf is a simple webbrowser which is based on webkit/gtk+. It is able
-to display websites and follow links. It supports the Xembedded protocol
-which makes it possible to embed it into another application. Furthermore
-one can point surf to another URI by setting it's XProperties.
+surf is a simple Web browser based on WebKit/GTK+. It is able
+to display websites and follow links. It supports the XEmbed protocol
+which makes it possible to embed it in another application. Furthermore,
+one can point surf to another URI by setting its XProperties.
.SH OPTIONS
.TP
.B \-e
-prints xid to standard output and waits until some application reparent the
+Prints xid to standard output and waits until an application reparents the
window.
.TP
-.B \-f FILE
-Sets the browsers URI to FILE. Also it's possible to read from stdin.
-.TP
.B \-h
-prints usage information to standard output, then exits.
-.TP
-.B \-u URI
-Sets the browsers URI.
+Prints usage information to standard output, then exits.
.TP
.B \-v
-prints version information to standard output, then exits.
+Prints version information to standard output, then exits.
.TP
.B \-x
-prints xid to standard output. This can be used to script the browser by using
-xprop
+Prints xid to standard output. This can be used to script the browser by using
+.BR xprop(1).
.SH USAGE
.TP
-.B Ctrl\-Left
+.B Ctrl\-h
Walks back the history.
.TP
-.B Ctrl\-Right
+.B Ctrl\-l
Walks forward the history.
.TP
.B Ctrl\-/
.B Ctrl\-g
Opens the URL-bar.
.TP
+.B Ctrl\-p
+Loads URI from primary selection.
+.TP
.B Ctrl\-r
Reloads the website.
.TP
.B Ctrl\-Shift\-r
Reloads the website without using cache.
+.TP
+.B Ctrl\-y
+Copies current URI to primary selection.
.SH SEE ALSO
-.BR dmenu (1)
-.BR xprop (1)
+.BR dmenu(1)
+.BR xprop(1)
.SH BUGS
Please report them!
struct Client *next;
} Client;
+typedef struct Cookie {
+ char *name;
+ char *value;
+ char *domain;
+ char *path;
+ struct Cookie *next;
+} Cookie;
+
typedef struct {
guint mod;
guint keyval;
} KeySet;
SoupCookieJar *cookiejar;
+SoupSession *session;
Client *clients = NULL;
+Cookie *cookies = NULL;
gboolean embed = FALSE;
gboolean showxid = FALSE;
gboolean ignore_once = FALSE;
extern int optind;
static void cleanup(void);
+static void proccookies(SoupMessage *m, Client *c);
static void clipboard(Client *c, const Arg *arg);
static void destroyclient(Client *c);
static void destroywin(GtkWidget* w, Client *c);
static void pasteurl(GtkClipboard *clipboard, const gchar *text, gpointer d);
static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event, gpointer d);
static void progresschange(WebKitWebView *view, gint p, Client *c);
+static void request(SoupSession *s, SoupMessage *m, Client *c);
+static void setcookie(char *name, char *val, char *dom, char *path, long exp);
static void reload(Client *c, const Arg *arg);
static void setup(void);
+static void titlechange(WebKitWebView* view, WebKitWebFrame* frame,
+ const gchar* title, Client *c);
static void searchtext(Client *c, const Arg *arg);
static void showsearch(Client *c, const Arg *arg);
static void showurl(Client *c, const Arg *arg);
destroyclient(clients);
}
+void
+proccookies(SoupMessage *m, Client *c) {
+ GSList *l;
+ SoupCookie *co;
+ long t;
+
+ for (l = soup_cookies_from_response(m); l; l = l->next){
+ co = (SoupCookie *)l->data;
+ t = co->expires ? soup_date_to_time_t(co->expires) : 0;
+ setcookie(co->name, co->value, co->domain, co->value, t);
+ }
+ g_slist_free(l);
+}
+
void
clipboard(Client *c, const Arg *arg) {
gboolean paste = *(gboolean *)arg;
fprintf(stderr, "keypress(): Unknown Keypressmode\n");
break;
}
-
if(n < LENGTH(keysets)) {
matchkeys:
for(m = 0; m < keysets[n].numkeys; m++) {
const gchar *uri = (gchar *)arg->v;
if(!uri)
uri = gtk_entry_get_text(GTK_ENTRY(c->urlbar));
- u = g_strrstr(uri, ":") ? g_strdup(uri)
+ u = g_strrstr(uri, "://") ? g_strdup(uri)
: g_strdup_printf("http://%s", uri);
webkit_web_view_load_uri(c->view, u);
c->progress = 0;
g_signal_connect(G_OBJECT(c->view), "hovering-over-link", G_CALLBACK(linkhover), c);
g_signal_connect(G_OBJECT(c->view), "create-web-view", G_CALLBACK(newwindow), c);
g_signal_connect(G_OBJECT(c->view), "download-requested", G_CALLBACK(initdownload), c);
+ g_signal_connect_after(session, "request-started", G_CALLBACK(request), c);
/* urlbar */
c->urlbar = gtk_entry_new();
unsigned long ldummy;
unsigned char *buf = NULL;
Arg arg;
+
if(((XEvent *)e)->type == PropertyNotify) {
ev = &((XEvent *)e)->xproperty;
if(ev->atom == urlprop && ev->state == PropertyNewValue) {
updatetitle(c, NULL);
}
+void
+request(SoupSession *s, SoupMessage *m, Client *c) {
+ soup_message_add_header_handler(m, "got-headers", "Set-Cookie",
+ G_CALLBACK(proccookies), c);
+}
+
void
reload(Client *c, const Arg *arg) {
gboolean nocache = *(gboolean *)arg;
webkit_web_view_reload(c->view);
}
-void setup(void) {
+void
+setcookie(char *name, char *val, char *dom, char *path, long exp) {
+ printf("%s %s %s %s %li\n", name, val, dom, path, exp);
+}
+
+void
+setup() {
dpy = GDK_DISPLAY();
+ session = webkit_get_default_session();
urlprop = XInternAtom(dpy, "_SURF_URL", False);
}
void
usage() {
fputs("surf - simple browser\n", stderr);
- die("usage: surf [-e] [-x] [-u uri] [-f file]\n");
+ die("usage: surf [-e] [-x] [uri]\n");
}
void
showxid = TRUE;
embed = TRUE;
break;
- case 'u':
- c = newclient();
- arg.v = optarg;
- loaduri(c, &arg);
- break;
- case 'f':
- c = newclient();
- loadfile(c, optarg);
- break;
case 'v':
die("surf-"VERSION", © 2009 surf engineers, see LICENSE for details\n");
break;
default:
usage();
}
- if(optind != argc)
+ if(optind + 1 == argc) {
+ c = newclient();
+ arg.v = argv[optind];
+ if(strchr("./", argv[optind][0]) || strcmp("-", argv[optind]) == 0)
+ loadfile(c, argv[optind]);
+ else
+ loaduri(c, &arg);
+
+ }
+ else if(optind != argc)
usage();
if(!clients)
newclient();