summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--surf.158
-rw-r--r--surf.c26
2 files changed, 78 insertions, 6 deletions
diff --git a/surf.1 b/surf.1
new file mode 100644
index 0000000..9c2959b
--- /dev/null
+++ b/surf.1
@@ -0,0 +1,58 @@
+.TH SURF 1 surf\-VERSION
+.SH NAME
+surf \- simple webkit based browser
+.SH SYNOPSIS
+.B surf
+.RB [ \-ehvx ]
+.RB [ \-f " FILE"]
+.RB [ \-u " 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.
+.SH OPTIONS
+.TP
+.B \-e
+prints xid to standard output and waits until some application reparent 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.
+.TP
+.B \-v
+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
+.SH USAGE
+.TP
+.B Ctrl\-Left
+Walks back the history.
+.TP
+.B Ctrl\-Right
+Walks forward the history.
+.TP
+.B Ctrl\-/
+Opens the search-bar.
+.TP
+.B Ctrl\-g
+Opens the URL-bar.
+.TP
+.B Ctrl\-r
+Reloads the website.
+.TP
+.B Ctrl\-Shift\-r
+Reloads the website without using cache.
+.SH SEE ALSO
+.BR dmenu (1)
+.BR xprop (1)
+.SH BUGS
+Please report them!
diff --git a/surf.c b/surf.c
index 318d694..e1c4080 100644
--- a/surf.c
+++ b/surf.c
@@ -14,18 +14,21 @@
#include <stdlib.h>
#include <stdio.h>
#include <webkit/webkit.h>
+#include <glib/gstdio.h>
#define LENGTH(x) (sizeof x / sizeof x[0])
Display *dpy;
Atom urlprop;
typedef struct Client {
- GtkWidget *win, *scroll, *vbox, *urlbar, *urllist, *searchbar;
+ GtkWidget *win, *scroll, *vbox, *urlbar, *searchbar;
WebKitWebView *view;
+ WebKitDownload * dl;
gchar *title;
gint progress;
struct Client *next;
} Client;
+SoupCookieJar *cookiejar;
Client *clients = NULL;
gboolean embed = FALSE;
gboolean showxid = FALSE;
@@ -80,7 +83,6 @@ destroyclient(Client *c) {
gtk_widget_destroy(GTK_WIDGET(webkit_web_view_new()));
gtk_widget_destroy(c->scroll);
gtk_widget_destroy(c->urlbar);
- gtk_widget_destroy(c->urllist);
gtk_widget_destroy(c->searchbar);
gtk_widget_destroy(c->vbox);
gtk_widget_destroy(c->win);
@@ -113,8 +115,9 @@ download(WebKitWebView *view, WebKitDownload *o, gpointer d) {
gchar *uri, *filename;
home = g_get_home_dir();
- filename = g_build_filename(home, "Desktop",
+ filename = g_build_filename(home, ".surf", "dl",
webkit_download_get_suggested_filename(o), NULL);
+ g_mkdir(g_path_get_dirname(filename), 0755);
uri = g_strconcat("file://", filename, NULL);
webkit_download_set_destination_uri(o, uri);
g_free(filename);
@@ -244,11 +247,13 @@ loadfile(const Client *c, const gchar *f) {
if(strcmp(f, "-") == 0) {
chan = g_io_channel_unix_new(STDIN_FILENO);
if (chan) {
- while(g_io_channel_read_line(chan, &line, NULL, NULL, &e) == G_IO_STATUS_NORMAL) {
+ while(g_io_channel_read_line(chan, &line, NULL, NULL,
+ &e) == G_IO_STATUS_NORMAL) {
g_string_append(code, line);
g_free(line);
}
- webkit_web_view_load_html_string(c->view, code->str, NULL);
+ webkit_web_view_load_html_string(c->view, code->str,
+ "file://.");
g_io_channel_shutdown(chan, FALSE, NULL);
}
}
@@ -340,7 +345,6 @@ newclient(void) {
WebKitWebView *
newwindow(WebKitWebView *v, WebKitWebFrame *f, gpointer d) {
- /* TODO */
Client *c = newclient();
return c->view;
}
@@ -419,8 +423,10 @@ updatetitle(Client *c) {
int main(int argc, char *argv[]) {
gchar *uri = NULL, *file = NULL;
+ SoupSession *s;
Client *c;
int o;
+ const gchar *home, *filename;
gtk_init(NULL, NULL);
if (!g_thread_supported())
@@ -462,6 +468,14 @@ int main(int argc, char *argv[]) {
goto argerr;
if(!clients)
newclient();
+
+ /* cookie persistance */
+ s = webkit_get_default_session();
+ home = g_get_home_dir();
+ filename = g_build_filename(home, ".surf-cookies", NULL);
+ cookiejar = soup_cookie_jar_text_new(filename, FALSE);
+ soup_session_add_feature(s, SOUP_SESSION_FEATURE(cookiejar));
+
gtk_main();
cleanup();
return EXIT_SUCCESS;
ss='logsubject'>fixing config.mkGravatar Enno Boland (tox) 1-1/+1 2010-05-02Adding small fix by Alex Puterbaugh. Thanks.Gravatar Enno Boland (tox) 2-7/+6 2010-04-08remove empty linesGravatar pancake 1-3/+1 2010-03-29whoops... linking OoGravatar Enno Boland (tox) 1-3/+3 2010-03-26typofix.Gravatar Enno Boland (tox) 2-5/+5 2010-03-25reimplementing cookies. Now we need some file locking.Gravatar Enno Boland (tox) 1-2/+14 2010-03-25updating manpage, reformating help output.Gravatar Enno Boland (tox) 2-9/+19 2010-03-24fixing argument parsing.Gravatar Enno Boland (tox) 1-0/+2 2010-03-24fixing downloadsGravatar Enno Boland (tox) 1-8/+6 2010-03-24gotheaders will now be called correctly.Gravatar Enno Boland (tox) 1-1/+6 6584c48c395293d4e5d2eb0af0?s=13&d=retro' width='13' height='13' alt='Gravatar' /> Christoph Lohmann 1-1/+7 2015-01-17Adding disk cache support for soup.Gravatar Christoph Lohmann 2-9/+40 This is a merge of the patch of Ben Woolley <tautolog@gmail.com> 2015-01-17Fix extra newline, and add -g where other switches are forwarded.Gravatar Ben Woolley 1-1/+3 Signed-off-by: Christoph Lohmann <20h@r-36.net> 2015-01-17Newer libc want _DEFAULT_SOURCE.Gravatar Christoph Lohmann 1-1/+1 2015-01-17Major styles update.Gravatar Christoph Lohmann 3-11/+84 In config.h there is now some styles array to apply site-specific styles. This can be toggled using the -mM flags. If a stylefile is manually specified, then this will overwrite everything. 2015-01-02Fix a typo in surf manual.Gravatar Jakukyo Friel 1-1/+1 `Ctrl-/` displays incorrectly in `man surf` on my machine. A patch is attached. (You also access it here: https://github.com/weakish/surf/commit/07e97eccedd96eabf14b2fbf77de75ec1b594d97) ---- surf.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Signed-off-by: Christoph Lohmann <20h@r-36.net> 2014-09-28Minor style change.Gravatar Christoph Lohmann 1-1/+1 2014-09-28Make »Copy image address« work.Gravatar Christoph Lohmann 1-3/+10 Thanks yui@blekksprut.net for the patch! 2014-08-07Mention xdotool in SEE ALSO too.Gravatar Christoph Lohmann 1-1/+2 2014-08-07Fix the manpage about xid.Gravatar Christoph Lohmann 1-1/+3 Something was missing from this one sentence. Now it is complete.