22 Commits

Author SHA1 Message Date
Quentin Rameau 9ba143baba Bump version to 1.8
We're using the new scheme: 1.x is for webkit1, so we jump from previous
0.7 to 1.8
2017-03-28 18:15:47 +02:00
Quentin Rameau 58634c74b3 Add contributors to the LICENSE 2017-03-28 18:15:27 +02:00
Quentin Rameau ab16fa5e7c Simplify proxy toggle 2017-02-08 15:59:55 +01:00
Christoph Lohmann dcabd0239e Add a way to toggle proxy usage while running. 2017-02-06 11:30:44 +01:00
Christoph Lohmann 6c8da4c851 Style change. (Test commit for new update script in hackers@) 2016-08-11 10:41:38 +02:00
Christoph Lohmann 31ec0fb93d Fixing the last patch to the surf style. 2016-06-03 15:14:53 +02:00
Dmitry Bogatov 1308872b8b Check $HOME and home dir of $USER before getpwuid()->pw_dir
getpwnam(3) recommends to use $HOME instead of getpwuid()->pw_dir,
as it allows users to point programs to a different path.

Using getpwuid() also breaks namespaces-related use cases,
like `unshare -r`.

Patch was submitted by Dmitry Bogatov on the Debian bug tracker:
https://bugs.debian.org/825397

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2016-06-03 15:09:08 +02:00
Christoph Lohmann f5e8baad06 Disable globbing in curl. 2016-03-07 14:28:23 +01:00
Christoph Lohmann 842103322c Import the arg.h from st which fixed the oob bug. 2016-02-22 06:47:46 +01:00
Christoph Lohmann 7895fb9c5d Add Code of Conduct. 2016-01-27 16:01:23 +01:00
Christoph Lohmann fd6e80a279 Check for about: too.
Thanks to Claudio Alessi <smoppy@gmail.com>!
2016-01-27 06:44:31 +01:00
Markus Teich 743fa9f3d1 style fixes (mainly whitespace)
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2016-01-18 22:45:04 +01:00
Charles Lehner 0ac6bf5a97 Reload on SIGHUP
This patch makes surf reload its pages when it receives a SIGHUP signal. This makes it easier for shell scripts to trigger surf to reload.

I'm aware of using xdotool to trigger ctrl+r keypresses for reloading [1] but I wasn't able to get that to work in a general way.

I'm sending this here in case surf maintainers and users would like to include this in core - if not I will submit it to the wiki.

Regards,
Charles

[1] http://surf.suckless.org/files/autorefresh

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2016-01-09 21:14:30 +01:00
Christoph Lohmann 3d81a0f0b7 Bump year. 2016-01-01 14:18:19 +01:00
Felix Janda 018a67986d Include fcntl.h for open()
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-12-31 15:18:07 +01:00
Christoph Lohmann 3393ded725 Bumping up to 0.7 for release. 2015-12-19 15:59:30 +01:00
Christoph Lohmann cd7f831776 Remove unncessary includes. 2015-12-17 23:38:51 +01:00
Ivan Tham 86efaf8093 proxy-uri -> proxy-resolver for no_proxy; add #inc
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-12-17 23:36:56 +01:00
Ivan Tham 9fa4ffef72 Fix title handling
1. file:/// stay the same when you navigate
    2. Fix "http://~" to "file://~" in home dir
    3. Expands "file://~" to "file://home/user"

Thanks to quinq for fixing the issue #1 in commit 934705c in surf2.

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-12-12 11:54:28 +01:00
Michael Stevens 002e82d188 Fix spelling of otherwise in surf.1
Add more spelling to surf.

Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-12-08 18:26:30 +01:00
Alexander Huemer bae5a785b3 remove duplicate header inclusion of string.h
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-11-22 12:34:54 +01:00
Ivan Tham b7a359a84f Fix cookies wording
Signed-off-by: Christoph Lohmann <20h@r-36.net>
2015-11-18 08:58:18 +01:00
7 changed files with 287 additions and 92 deletions
+85
View File
@@ -0,0 +1,85 @@
Code of Conduct
===============
> ==Phrack Inc.==
> Volume One, Issue 7, Phile 3 of 10
>
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
> The following was written shortly after my arrest...
>
> \/\The Conscience of a Hacker/\/
>
> by
>
> +++The Mentor+++
>
> Written on January 8, 1986
>
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
> Another one got caught today, it's all over the papers. "Teenager
> Arrested in Computer Crime Scandal", "Hacker Arrested after Bank Tampering"...
> Damn kids. They're all alike.
>
> But did you, in your three-piece psychology and 1950's technobrain,
> ever take a look behind the eyes of the hacker? Did you ever wonder what
> made him tick, what forces shaped him, what may have molded him?
> I am a hacker, enter my world...
> Mine is a world that begins with school... I'm smarter than most of
> the other kids, this crap they teach us bores me...
> Damn underachiever. They're all alike.
>
> I'm in junior high or high school. I've listened to teachers explain
> for the fifteenth time how to reduce a fraction. I understand it. "No, Ms.
> Smith, I didn't show my work. I did it in my head..."
> Damn kid. Probably copied it. They're all alike.
>
> I made a discovery today. I found a computer. Wait a second, this is
> cool. It does what I want it to. If it makes a mistake, it's because I
> screwed it up. Not because it doesn't like me...
> Or feels threatened by me...
> Or thinks I'm a smart ass...
> Or doesn't like teaching and shouldn't be here...
> Damn kid. All he does is play games. They're all alike.
>
> And then it happened... a door opened to a world... rushing through
> the phone line like heroin through an addict's veins, an electronic pulse is
> sent out, a refuge from the day-to-day incompetencies is sought... a board is
> found.
> "This is it... this is where I belong..."
> I know everyone here... even if I've never met them, never talked to
> them, may never hear from them again... I know you all...
> Damn kid. Tying up the phone line again. They're all alike...
>
> You bet your ass we're all alike... we've been spoon-fed baby food at
> school when we hungered for steak... the bits of meat that you did let slip
> through were pre-chewed and tasteless. We've been dominated by sadists, or
> ignored by the apathetic. The few that had something to teach found us will-
> ing pupils, but those few are like drops of water in the desert.
>
> This is our world now... the world of the electron and the switch, the
> beauty of the baud. We make use of a service already existing without paying
> for what could be dirt-cheap if it wasn't run by profiteering gluttons, and
> you call us criminals. We explore... and you call us criminals. We seek
> after knowledge... and you call us criminals. We exist without skin color,
> without nationality, without religious bias... and you call us criminals.
> You build atomic bombs, you wage wars, you murder, cheat, and lie to us
> and try to make us believe it's for our own good, yet we're the criminals.
>
> Yes, I am a criminal. My crime is that of curiosity. My crime is
> that of judging people by what they say and think, not what they look like.
> My crime is that of outsmarting you, something that you will never forgive me
> for.
>
> I am a hacker, and this is my manifesto. You may stop this individual,
> but you can't stop us all... after all, we're all alike.
Keep to your sanity, question the world, even this manifest.
Don't follow morals, nothing is right or wrong.
Have fun.
Yours project maintainer on 2016-01-27.
+27 -3
View File
@@ -1,8 +1,32 @@
MIT/X Consortium License
© 2011-2012 Troels Henriksen <athas@sigkill.at>
© 2009-2011 Enno Boland <g s01 de>
© 2012 Christoph Lohmann <20h@r-36.net>
© 2009-2010 Enno Boland <tox@s01.de>
© 2009 Thomas Menari <spaceinvader@chaotika.org>
© 2009 Simon Rozet <simon@rozet.name>
© 2009 Andrew Antle <andrew.antle@gmail.com>
© 2010-2011 pancake <nopcode.org>
© 2011-2013 Anselm R Garbe <anselm@garbe.us>
© 2011-2012 Troels Henriksen <athas@sigkill.dk>
© 2011 Connor Lane Smith <cls@lubutu.com>
© 2012-2017 Christoph Lohmann <20h@r-36.net>
© 2013 Shayan Pooya <shayan@liveve.org>
© 2013 Jens Nyberg <jens.nyberg@gmail.com>
© 2013 Carlos J. Torres <vlaadbrain@gmail.com>
© 2013 Alexander Sedov <alex0player@gmail.com>
© 2013 Nick White <git@njw.me.uk>
© 2013 David Dufberg <david@dufberg.se>
© 2014-2017 Quentin Rameau <quinq@fifth.space>
© 2014-2016 Markus Teich <markus.teich@stusta.mhn.de>
© 2015 Jakukyo Friel <weakish@gmail.com>
© 2015 Ben Woolley <tautolog@gmail.com>
© 2015 Greg Reagle <greg.reagle@umbc.edu>
© 2015 GhostAV <ghostav@riseup.net>
© 2015 Ivan Tham <pickfire@riseup.net>
© 2015 Alexander Huemer <alexander.huemer@xx.vu>
© 2015 Michael Stevens <mstevens@etla.org>
© 2015 Felix Janda <felix.janda@posteo.de>
© 2016 Charles Lehner <cel@celehner.com>
© 2016 Dmitry Bogatov <KAction@gnu.org>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
+27 -20
View File
@@ -3,39 +3,46 @@
* by 20h
*/
#ifndef __ARG_H__
#define __ARG_H__
#ifndef ARG_H__
#define ARG_H__
extern char *argv0;
#define USED(x) ((void)(x))
/* use main(int argc, char *argv[]) */
#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\
argv[0] && argv[0][1]\
&& argv[0][0] == '-';\
argv[0] && argv[0][0] == '-'\
&& argv[0][1];\
argc--, argv++) {\
char _argc;\
char **_argv;\
char argc_;\
char **argv_;\
int brk_;\
if (argv[0][1] == '-' && argv[0][2] == '\0') {\
argv++;\
argc--;\
break;\
}\
for (argv[0]++, _argv = argv; argv[0][0];\
for (brk_ = 0, argv[0]++, argv_ = argv;\
argv[0][0] && !brk_;\
argv[0]++) {\
if (_argv != argv)\
if (argv_ != argv)\
break;\
_argc = argv[0][0];\
switch (_argc)
argc_ = argv[0][0];\
switch (argc_)
#define ARGEND }\
USED(_argc);\
}\
USED(argv);\
USED(argc);
}
#define EARGF(x) ((argv[1] == NULL)? ((x), abort(), (char *)0) :\
(argc--, argv++, argv[0]))
#define ARGC() argc_
#define EARGF(x) ((argv[0][1] == '\0' && argv[1] == NULL)?\
((x), abort(), (char *)0) :\
(brk_ = 1, (argv[0][1] != '\0')?\
(&argv[0][1]) :\
(argc--, argv++, argv[0])))
#define ARGF() ((argv[0][1] == '\0' && argv[1] == NULL)?\
(char *)0 :\
(brk_ = 1, (argv[0][1] != '\0')?\
(&argv[0][1]) :\
(argc--, argv++, argv[0])))
#endif
+4 -2
View File
@@ -17,7 +17,7 @@ static gfloat zoomlevel = 1.0; /* Default zoom level */
/* Soup default features */
static char *cookiefile = "~/.surf/cookies.txt";
static char *cookiepolicies = "Aa@"; /* A: accept all; a: accept nothing,
* @: accept no third party */
* @: accept all except third party */
static char *cafile = "/etc/ssl/certs/ca-certificates.crt";
static Bool strictssl = FALSE; /* Refuse untrusted SSL connections */
static time_t sessiontime = 3600;
@@ -48,7 +48,7 @@ static Bool allowgeolocation = TRUE;
/* DOWNLOAD(URI, referer) */
#define DOWNLOAD(d, r) { \
.v = (char *[]){ "/bin/sh", "-c", \
"st -e /bin/sh -c \"curl -L -J -O --user-agent '$1'" \
"st -e /bin/sh -c \"curl -g -L -J -O --user-agent '$1'" \
" --referer '$2' -b $3 -c $3 '$0';" \
" sleep 5;\"", \
d, useragent, r, cookiefile, NULL \
@@ -127,6 +127,7 @@ static Key keys[] = {
{ MODKEY|GDK_SHIFT_MASK,GDK_m, togglestyle, { 0 } },
{ MODKEY|GDK_SHIFT_MASK,GDK_b, togglescrollbars, { 0 } },
{ MODKEY|GDK_SHIFT_MASK,GDK_g, togglegeolocation, { 0 } },
{ MODKEY|GDK_SHIFT_MASK,GDK_y, toggleproxy, { 0 } },
};
/* button definitions */
@@ -139,3 +140,4 @@ static Button buttons[] = {
{ ClkAny, 0, 8, navigate, { .i = -1 } },
{ ClkAny, 0, 9, navigate, { .i = +1 } },
};
+1 -1
View File
@@ -1,5 +1,5 @@
# surf version
VERSION = 0.6
VERSION = 1.8
# Customize below to fit your system
+11 -1
View File
@@ -221,11 +221,14 @@ Toggle script execution. This will reload the page.
Toggle the enabling of plugins on that surf instance. This will reload the
page.
.TP
.B Ctrl\-Shift\-y
Toggle if a proxy should be used (if one is set in the environment).
.TP
.B F11
Toggle fullscreen mode.
.SH INDICATORS OF OPERATION
Surf is showing indicators of operation in front of the site title.
For all indicators, unless otherwsie specified, a lower case letter means disabled and an upper case letter means enabled.
For all indicators, unless otherwise specified, a lower case letter means disabled and an upper case letter means enabled.
.TP
.B A
all cookies accepted
@@ -283,6 +286,13 @@ string
.TP
.B http_proxy
If this variable is set and not empty upon startup, surf will use it as the http proxy
.TP
.B no_proxy
If both http_proxy is set and no_proxy contain a
.BR comma-separated
list of domain extensions and both is not empty upon startup, proxy will
.BR not
be used for each of the elements in no_proxy.
.SH PLUGINS
For using plugins in surf, first determine your running architecture. Then get
the appropriate plugin for that architecture and copy it to
+132 -65
View File
@@ -12,19 +12,20 @@
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <unistd.h>
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <webkit/webkit.h>
#include <glib/gstdio.h>
#include <JavaScriptCore/JavaScript.h>
#include <sys/file.h>
#include <libgen.h>
#include <stdarg.h>
#include <regex.h>
#include <pwd.h>
#include <string.h>
#include <glib.h>
#include <glib/gstdio.h>
#include "arg.h"
@@ -114,6 +115,8 @@ static void addaccelgroup(Client *c);
static void beforerequest(WebKitWebView *w, WebKitWebFrame *f,
WebKitWebResource *r, WebKitNetworkRequest *req,
WebKitNetworkResponse *resp, Client *c);
static const char *getuserhomedir(const char *user);
static const char *getcurrentuserhomedir(void);
static char *buildfile(const char *path);
static char *buildpath(const char *path);
static gboolean buttonrelease(WebKitWebView *web, GdkEventButton *e, Client *c);
@@ -136,10 +139,10 @@ static WebKitWebView *createwindow(WebKitWebView *v, WebKitWebFrame *f,
Client *c);
static gboolean decidedownload(WebKitWebView *v, WebKitWebFrame *f,
WebKitNetworkRequest *r, gchar *m,
WebKitWebPolicyDecision *p, Client *c);
WebKitWebPolicyDecision *p, Client *c);
static gboolean decidewindow(WebKitWebView *v, WebKitWebFrame *f,
WebKitNetworkRequest *r, WebKitWebNavigationAction
*n, WebKitWebPolicyDecision *p, Client *c);
*n, WebKitWebPolicyDecision *p, Client *c);
static gboolean deletion_interface(WebKitWebView *view,
WebKitDOMHTMLElement *arg1, Client *c);
static void destroyclient(Client *c);
@@ -181,7 +184,7 @@ static void newwindow(Client *c, const Arg *arg, gboolean noembed);
static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
static gboolean contextmenu(WebKitWebView *view, GtkWidget *menu,
WebKitHitTestResult *target, gboolean keyboard,
Client *c);
Client *c);
static void menuactivate(GtkMenuItem *item, Client *c);
static void print(Client *c, const Arg *arg);
static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event,
@@ -196,6 +199,7 @@ static void scroll(GtkAdjustment *a, const Arg *arg);
static void setatom(Client *c, int a, const char *v);
static void setup(void);
static void sigchld(int unused);
static void sighup(int unused);
static void source(Client *c, const Arg *arg);
static void spawn(Client *c, const Arg *arg);
static void stop(Client *c, const Arg *arg);
@@ -204,6 +208,7 @@ static void titlechangeleave(void *a, void *b, Client *c);
static void toggle(Client *c, const Arg *arg);
static void togglecookiepolicy(Client *c, const Arg *arg);
static void togglegeolocation(Client *c, const Arg *arg);
static void toggleproxy(Client *c, const Arg *arg);
static void togglescrollbars(Client *c, const Arg *arg);
static void togglestyle(Client *c, const Arg *arg);
static void updatetitle(Client *c);
@@ -234,7 +239,7 @@ addaccelgroup(Client *c)
void
beforerequest(WebKitWebView *w, WebKitWebFrame *f, WebKitWebResource *r,
WebKitNetworkRequest *req, WebKitNetworkResponse *resp,
Client *c)
Client *c)
{
const gchar *uri = webkit_network_request_get_uri(req);
int i, isascii = 1;
@@ -285,29 +290,60 @@ buildfile(const char *path)
return fpath;
}
static const char*
getuserhomedir(const char *user)
{
struct passwd *pw = getpwnam(user);
if (!pw)
die("Can't get user %s login information.\n", user);
return pw->pw_dir;
}
static const char*
getcurrentuserhomedir(void)
{
const char *homedir;
const char *user;
struct passwd *pw;
homedir = getenv("HOME");
if (homedir)
return homedir;
user = getenv("USER");
if (user)
return getuserhomedir(user);
pw = getpwuid(getuid());
if (!pw)
die("Can't get current user home directory\n");
return pw->pw_dir;
}
char *
buildpath(const char *path)
{
struct passwd *pw;
char *apath, *name, *p, *fpath;
const char *homedir;
if (path[0] == '~') {
if (path[1] == '/' || path[1] == '\0') {
p = (char *)&path[1];
pw = getpwuid(getuid());
homedir = getcurrentuserhomedir();
} else {
if ((p = strchr(path, '/')))
if ((p = strchr(path, '/'))) {
name = g_strndup(&path[1], --p - path);
else
} else {
name = g_strdup(&path[1]);
if (!(pw = getpwnam(name))) {
die("Can't get user %s home directory: %s.\n",
name, path);
}
homedir = getuserhomedir(name);
g_free(name);
}
apath = g_build_filename(pw->pw_dir, p, NULL);
apath = g_build_filename(homedir, p, NULL);
} else {
apath = g_strdup(path);
}
@@ -339,7 +375,7 @@ buttonrelease(WebKitWebView *web, GdkEventButton *e, Client *c)
&& CLEANMASK(e->state) == CLEANMASK(buttons[i].mask)
&& buttons[i].func) {
buttons[i].func(c, buttons[i].click == ClkLink
&& buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
&& buttons[i].arg.i == 0 ? &arg : &buttons[i].arg);
return true;
}
}
@@ -371,7 +407,7 @@ cookiejar_changed(SoupCookieJar *self, SoupCookie *old_cookie,
}
SOUP_COOKIE_JAR_CLASS(cookiejar_parent_class)->changed(self,
old_cookie,
new_cookie);
new_cookie);
flock(COOKIEJAR(self)->lock, LOCK_UN);
}
@@ -405,8 +441,8 @@ cookiejar_new(const char *filename, gboolean read_only,
{
return g_object_new(COOKIEJAR_TYPE,
SOUP_COOKIE_JAR_TEXT_FILENAME, filename,
SOUP_COOKIE_JAR_READ_ONLY, read_only,
SOUP_COOKIE_JAR_ACCEPT_POLICY, policy, NULL);
SOUP_COOKIE_JAR_READ_ONLY, read_only,
SOUP_COOKIE_JAR_ACCEPT_POLICY, policy, NULL);
}
void
@@ -527,7 +563,7 @@ decidedownload(WebKitWebView *v, WebKitWebFrame *f, WebKitNetworkRequest *r,
gboolean
decidewindow(WebKitWebView *view, WebKitWebFrame *f, WebKitNetworkRequest *r,
WebKitWebNavigationAction *n, WebKitWebPolicyDecision *p,
Client *c)
Client *c)
{
Arg arg;
@@ -800,9 +836,10 @@ loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c)
request = webkit_web_data_source_get_request(src);
msg = webkit_network_request_get_message(request);
c->sslfailed = !(soup_message_get_flags(msg)
& SOUP_MESSAGE_CERTIFICATE_TRUSTED);
& SOUP_MESSAGE_CERTIFICATE_TRUSTED);
}
setatom(c, AtomUri, uri);
c->title = copystr(&c->title, uri);
if (enablestyle)
setstyle(c, getstyle(uri));
@@ -837,7 +874,7 @@ loaduri(Client *c, const Arg *arg)
u = g_strdup_printf("file://%s", rp);
free(rp);
} else {
u = g_strrstr(uri, "://") ? g_strdup(uri)
u = g_strrstr(uri, "://") || g_str_has_prefix(uri, "about:") ? g_strdup(uri)
: g_strdup_printf("http://%s", uri);
}
@@ -902,10 +939,10 @@ newclient(void)
gtk_window_set_default_size(GTK_WINDOW(c->win), 800, 600);
g_signal_connect(G_OBJECT(c->win),
"destroy",
G_CALLBACK(destroywin), c);
G_CALLBACK(destroywin), c);
g_signal_connect(G_OBJECT(c->win),
"leave_notify_event",
G_CALLBACK(titlechangeleave), c);
G_CALLBACK(titlechangeleave), c);
if (!kioskmode)
addaccelgroup(c);
@@ -922,46 +959,46 @@ newclient(void)
g_signal_connect(G_OBJECT(c->view),
"notify::title",
G_CALLBACK(titlechange), c);
G_CALLBACK(titlechange), c);
g_signal_connect(G_OBJECT(c->view),
"hovering-over-link",
G_CALLBACK(linkhover), c);
G_CALLBACK(linkhover), c);
g_signal_connect(G_OBJECT(c->view),
"geolocation-policy-decision-requested",
G_CALLBACK(geopolicyrequested), c);
G_CALLBACK(geopolicyrequested), c);
g_signal_connect(G_OBJECT(c->view),
"create-web-view",
G_CALLBACK(createwindow), c);
G_CALLBACK(createwindow), c);
g_signal_connect(G_OBJECT(c->view),
"new-window-policy-decision-requested",
G_CALLBACK(decidewindow), c);
G_CALLBACK(decidewindow), c);
g_signal_connect(G_OBJECT(c->view),
"mime-type-policy-decision-requested",
G_CALLBACK(decidedownload), c);
G_CALLBACK(decidedownload), c);
g_signal_connect(G_OBJECT(c->view),
"window-object-cleared",
G_CALLBACK(windowobjectcleared), c);
G_CALLBACK(windowobjectcleared), c);
g_signal_connect(G_OBJECT(c->view),
"notify::load-status",
G_CALLBACK(loadstatuschange), c);
G_CALLBACK(loadstatuschange), c);
g_signal_connect(G_OBJECT(c->view),
"notify::progress",
G_CALLBACK(progresschange), c);
G_CALLBACK(progresschange), c);
g_signal_connect(G_OBJECT(c->view),
"download-requested",
G_CALLBACK(initdownload), c);
G_CALLBACK(initdownload), c);
g_signal_connect(G_OBJECT(c->view),
"button-release-event",
G_CALLBACK(buttonrelease), c);
G_CALLBACK(buttonrelease), c);
g_signal_connect(G_OBJECT(c->view),
"context-menu",
G_CALLBACK(contextmenu), c);
G_CALLBACK(contextmenu), c);
g_signal_connect(G_OBJECT(c->view),
"resource-request-starting",
G_CALLBACK(beforerequest), c);
G_CALLBACK(beforerequest), c);
g_signal_connect(G_OBJECT(c->view),
"should-show-delete-interface-for-element",
G_CALLBACK(deletion_interface), c);
G_CALLBACK(deletion_interface), c);
/* Scrolled Window */
c->scroll = gtk_scrolled_window_new(NULL, NULL);
@@ -973,11 +1010,11 @@ newclient(void)
if (!enablescrollbars) {
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll),
GTK_POLICY_NEVER,
GTK_POLICY_NEVER);
GTK_POLICY_NEVER);
} else {
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
GTK_POLICY_AUTOMATIC);
}
/* Arranging */
@@ -1013,7 +1050,7 @@ newclient(void)
g_object_set(G_OBJECT(settings),
"enable-scripts", enablescripts, NULL);
g_object_set(G_OBJECT(settings),
"enable-spatial-navigation", enablespatialbrowsing, NULL);
"enable-spatial-navigation", enablespatialbrowsing, NULL);
g_object_set(G_OBJECT(settings),
"enable-developer-extras", enableinspector, NULL);
g_object_set(G_OBJECT(settings),
@@ -1072,9 +1109,8 @@ newclient(void)
printf("%u\n",
(guint)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window));
fflush(NULL);
if (fclose(stdout) != 0) {
if (fclose(stdout) != 0)
die("Error closing stdout");
}
}
return c;
@@ -1198,12 +1234,10 @@ processx(GdkXEvent *e, GdkEvent *event, gpointer d)
if (ev->atom == atoms[AtomFind]) {
arg.b = TRUE;
find(c, &arg);
return GDK_FILTER_REMOVE;
} else if (ev->atom == atoms[AtomGo]) {
arg.v = getatom(c, AtomGo);
loaduri(c, &arg);
return GDK_FILTER_REMOVE;
}
}
@@ -1290,14 +1324,14 @@ void
setup(void)
{
int i;
char *proxy, *new_proxy;
char *styledirfile, *stylepath;
SoupURI *puri;
SoupSession *s;
GError *error = NULL;
/* clean up any zombies immediately */
sigchld(0);
if (signal(SIGHUP, sighup) == SIG_ERR)
die("Can't install SIGHUP handler");
gtk_init(NULL, NULL);
dpy = GDK_DISPLAY();
@@ -1364,20 +1398,7 @@ setup(void)
g_object_set(G_OBJECT(s), "tls-database", tlsdb, NULL);
g_object_set(G_OBJECT(s), "ssl-strict", strictssl, NULL);
/* proxy */
if ((proxy = getenv("http_proxy")) && strcmp(proxy, "")) {
new_proxy = g_strrstr(proxy, "http://")
|| g_strrstr(proxy, "socks://")
|| g_strrstr(proxy, "socks4://")
|| g_strrstr(proxy, "socks5://")
? g_strdup(proxy)
: g_strdup_printf("http://%s", proxy);
puri = soup_uri_new(new_proxy);
g_object_set(G_OBJECT(s), "proxy-uri", puri, NULL);
soup_uri_free(puri);
g_free(new_proxy);
usingproxy = 1;
}
toggleproxy(NULL, NULL);
}
void
@@ -1388,6 +1409,16 @@ sigchld(int unused)
while (0 < waitpid(-1, NULL, WNOHANG));
}
void
sighup(int unused)
{
Arg a = { .b = FALSE };
Client *c;
for (c = clients; c; c = c->next)
reload(c, &a);
}
void
source(Client *c, const Arg *arg)
{
@@ -1431,6 +1462,7 @@ void
titlechange(WebKitWebView *view, GParamSpec *pspec, Client *c)
{
const gchar *t = webkit_web_view_get_title(view);
if (t) {
c->title = copystr(&c->title, t);
updatetitle(c);
@@ -1508,6 +1540,42 @@ twitch(Client *c, const Arg *arg)
gtk_adjustment_set_value(a, v);
}
void
toggleproxy(Client *c, const Arg *arg)
{
char *proxy, *new_proxy, *no_proxy, **new_no_proxy;
GProxyResolver *pr;
SoupSession *s;
/* request handler */
s = webkit_get_default_session();
if (usingproxy) {
g_object_set(G_OBJECT(s), "proxy-resolver", NULL, NULL);
usingproxy = 0;
} else if ((proxy = getenv("http_proxy")) && strcmp(proxy, "")) {
new_proxy = g_strrstr(proxy, "http://")
|| g_strrstr(proxy, "https://")
|| g_strrstr(proxy, "socks://")
|| g_strrstr(proxy, "socks4://")
|| g_strrstr(proxy, "socks4a://")
|| g_strrstr(proxy, "socks5://")
? g_strdup(proxy)
: g_strdup_printf("http://%s", proxy);
new_no_proxy = ((no_proxy = getenv("no_proxy")) && strcmp(no_proxy, ""))
? g_strsplit(no_proxy, ",", -1) : NULL;
pr = g_simple_proxy_resolver_new(new_proxy, new_no_proxy);
g_object_set(G_OBJECT(s), "proxy-resolver", pr, NULL);
g_free(new_proxy);
g_strfreev(new_no_proxy);
usingproxy = 1;
}
if (c)
updatetitle(c);
/* Do not reload. */
}
void
togglescrollbars(Client *c, const Arg *arg)
{
@@ -1520,11 +1588,11 @@ togglescrollbars(Client *c, const Arg *arg)
if (vspolicy == GTK_POLICY_AUTOMATIC) {
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll),
GTK_POLICY_NEVER,
GTK_POLICY_NEVER);
GTK_POLICY_NEVER);
} else {
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
GTK_POLICY_AUTOMATIC);
a.i = +1;
twitch(c, &a);
a.i = -1;
@@ -1537,7 +1605,6 @@ togglestyle(Client *c, const Arg *arg)
{
enablestyle = !enablestyle;
setstyle(c, enablestyle ? getstyle(geturi(c)) : "");
updatetitle(c);
}
@@ -1743,7 +1810,7 @@ main(int argc, char *argv[])
useragent = EARGF(usage());
break;
case 'v':
die("surf-"VERSION", ©2009-2015 surf engineers, "
die("surf-"VERSION", ©2009-2016 surf engineers, "
"see LICENSE for details\n");
case 'x':
showxid = TRUE;