aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--AUTHORS5
-rw-r--r--Makefile4
-rw-r--r--examples/configs/sampleconfig3
-rw-r--r--examples/configs/sampleconfig-dev3
-rwxr-xr-xexamples/scripts/cookies.sh38
-rwxr-xr-xexamples/scripts/download.sh5
-rw-r--r--examples/scripts/linkfollow.js10
-rwxr-xr-xexamples/scripts/session.sh42
-rw-r--r--uzbl.c23
-rw-r--r--uzbl.h2
10 files changed, 89 insertions, 46 deletions
diff --git a/AUTHORS b/AUTHORS
index 8a55a32..e5e3806 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -20,6 +20,11 @@ Contributors:
Mark Nevill - misc patches
Uli Schlachter (psychon) - basic mime_policy_cb & Makefile patch
(uranther) - zoom level
+ (bobpaul) - session script patches
+ Tom Adams (holizz) - few patches
+ neutralinsomniac - load_progress = 0 fix
+ Maximilian Gaß (mxey) - small patches
+ Abel Camarillo (00z) - make it compile on OpenBSD
Originaly based on http://trac.webkit.org/browser/trunk/WebKitTools/GtkLauncher/main.c
Which is copyrighted:
diff --git a/Makefile b/Makefile
index 34d5a1a..c22370b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
-CPPFLAGS:=$(shell pkg-config --cflags gtk+-2.0 webkit-1.0) -ggdb -Wall -W -DARCH="\"$(shell uname -m)\"" -DG_ERRORCHECK_MUTEXES -DCOMMIT="\"$(shell git log | head -n1 | sed "s/.* //")\"" $(CPPFLAGS)
-LDFLAGS:=$(shell pkg-config --libs gtk+-2.0 webkit-1.0) $(LDFLAGS)
+CFLAGS:=-std=c99 $(shell pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4) -ggdb -Wall -W -DARCH="\"$(shell uname -m)\"" -DG_ERRORCHECK_MUTEXES -DCOMMIT="\"$(shell git log | head -n1 | sed "s/.* //")\"" $(CPPFLAGS)
+LDFLAGS:=$(shell pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4) -pthread $(LDFLAGS)
all: uzbl uzblctrl
PREFIX?=$(DESTDIR)/usr
diff --git a/examples/configs/sampleconfig b/examples/configs/sampleconfig
index 1321803..e853836 100644
--- a/examples/configs/sampleconfig
+++ b/examples/configs/sampleconfig
@@ -69,7 +69,8 @@ bind r = reload
bind R = reload_ign_cache
bind + = zoom_in
bind - = zoom_out
-bind = = reset_zoom
+bind 1 = sh "echo set zoom_level = 1.0 > $4"
+bind 2 = sh "echo set zoom_level = 2.0 > $4"
bind t = toggle_status
# Hilight matches. Notice the * after the slash - it makes the command incremental, i.e. gets called
# on every character you type. You can do `bind /_ = search %s' if you want it less interactive.
diff --git a/examples/configs/sampleconfig-dev b/examples/configs/sampleconfig-dev
index c8eddd0..ad6de24 100644
--- a/examples/configs/sampleconfig-dev
+++ b/examples/configs/sampleconfig-dev
@@ -104,7 +104,8 @@ bind r = reload
bind R = reload_ign_cache
bind + = zoom_in
bind - = zoom_out
-bind 0 = sh "echo set zoom_level = 1.0 > $4"
+bind 1 = sh "echo set zoom_level = 1.0 > $4"
+bind 2 = sh "echo set zoom_level = 2.0 > $4"
bind t = toggle_status
# Hilight matches. Notice the * after the slash - it makes the command incremental, i.e. gets called
# on every character you type. You can do `bind /_ = search %s' if you want it less interactive.
diff --git a/examples/scripts/cookies.sh b/examples/scripts/cookies.sh
index efac322..c0c37db 100755
--- a/examples/scripts/cookies.sh
+++ b/examples/scripts/cookies.sh
@@ -24,22 +24,24 @@
# http://kb.mozillazine.org/Cookies.txt
# don't always append cookies, sometimes we need to overwrite
-[ -f /usr/share/uzbl/examples/configs/cookies ] && file=/usr/share/uzbl/examples/configs/cookies
-[ -f $XDG_CONFIG_HOME/uzbl/cookies ] && file=$XDG_CONFIG_HOME/uzbl/cookies
-[ -f ./examples/configs/cookies ] && file=./examples/configs/cookies #useful when developing
-[ -z "$file" ] && exit 1
+[ -f /usr/share/uzbl/examples/configs/cookies ] && cookie_config=/usr/share/uzbl/examples/configs/cookies
+[ -f $XDG_CONFIG_HOME/uzbl/cookies ] && cookie_config=$XDG_CONFIG_HOME/uzbl/cookies
+[ -f ./examples/configs/cookies ] && cookie_config=./examples/configs/cookies #useful when developing
+[ -z "$cookie_config" ] && exit 1
+
+[ -d /usr/share/uzbl/examples/data ] && cookie_data=/usr/share/uzbl/examples/data/cookies.txt
+[ -d $XDG_DATA_HOME/uzbl/ ] && cookie_data=$XDG_DATA_HOME/uzbl/cookies.txt
+[ -d ./examples/data/ ] && cookie_data=./examples/data/cookies.txt #useful when developing
+[ -z "$cookie_data" ] && exit 1
-[ -d /usr/share/uzbl/examples/data ] && cookie_file=/usr/share/uzbl/examples/data/cookies.txt
-[ -d $XDG_DATA_HOME/uzbl/ ] && cookie_file=$XDG_DATA_HOME/uzbl/cookies.txt
-[ -d ./examples/data/ ] && cookie_file=./examples/data/cookies.txt #useful when developing
-[ -z "$cookie_file" ] && exit 1
-# if this variable is set, we will use it to inform you when and which cookies we store, and when/which we send.
#notifier=
#notifier=notify-send
notify_wrapper () {
echo "$@" >> $HOME/cookielog
}
+
+# if this variable is set, we will use it to inform you when and which cookies we store, and when/which we send.
notifier=notify_wrapper
which zenity &>/dev/null || exit 2
@@ -90,17 +92,17 @@ function parse_cookie () {
unset IFS
}
-# match cookies in cookies.txt againsh hostname and path
+# match cookies in cookies.txt against hostname and path
function get_cookie () {
path_esc=${path//\//\\/}
search="^[^\t]*$host\t[^\t]*\t$path_esc"
- cookie=`awk "/$search/" $cookie_file 2>/dev/null | tail -n 1`
+ cookie=`awk "/$search/" $cookie_data 2>/dev/null | tail -n 1`
if [ -z "$cookie" ]
then
- notify "Get_cookie: search: $search in $cookie_file -> no result"
+ notify "Get_cookie: search: $search in $cookie_data -> no result"
false
else
- notify "Get_cookie: search: $search in $cookie_file -> result: $cookie"
+ notify "Get_cookie: search: $search in $cookie_data -> result: $cookie"
read domain alow_read_other_subdomains path http_required expiration name value <<< "$cookie"
cookie="$name=$value"
true
@@ -111,8 +113,8 @@ function save_cookie () {
if parse_cookie
then
data="$field_domain\tFALSE\t$field_path\tFALSE\t$field_exp\t$field_name\t$field_value"
- notify "save_cookie: adding $data to $cookie_file"
- echo -e "$data" >> $cookie_file
+ notify "save_cookie: adding $data to $cookie_data"
+ echo -e "$data" >> $cookie_data
else
notify "not saving a cookie. since we don't have policies yet, parse_cookie must have returned false. this is a bug"
fi
@@ -128,15 +130,15 @@ exit
# $1 = section (TRUSTED or DENY)
# $2 =url
function match () {
- sed -n "/$1/,/^\$/p" $file 2>/dev/null | grep -q "^$host"
+ sed -n "/$1/,/^\$/p" $cookie_config 2>/dev/null | grep -q "^$host"
}
function fetch_cookie () {
- cookie=`cat $cookie_file/$host.cookie`
+ cookie=`cat $cookie_data`
}
function store_cookie () {
- echo $cookie > $cookie_file/$host.cookie
+ echo $cookie > $cookie_data
}
if match TRUSTED $host
diff --git a/examples/scripts/download.sh b/examples/scripts/download.sh
index 0d38d3c..d87335f 100755
--- a/examples/scripts/download.sh
+++ b/examples/scripts/download.sh
@@ -7,10 +7,9 @@ WGET="wget --user-agent=Firefox"
if [[ $8 =~ .*(.torrent) ]]
then
- pushd $HOME
+ cd $HOME
$WGET $8
else
- pushd $HOME
+ cd $HOME
$WGET $8
fi
-popd
diff --git a/examples/scripts/linkfollow.js b/examples/scripts/linkfollow.js
index b90b82d..a348af9 100644
--- a/examples/scripts/linkfollow.js
+++ b/examples/scripts/linkfollow.js
@@ -94,9 +94,17 @@ function Hints(){
this.test = test;
this.toString = toString;
this.numbers = numbers;
+ function matchAgainst(element){
+ if(element.node.nodeName == "INPUT"){
+ return element.node.value;
+ } else {
+ return element.node.textContent;
+ }
+ }
function test(element) {
// test all the regexp
- return words.every(function (regex) { return element.node.textContent.match(regex)});
+ var item = matchAgainst(element);
+ return words.every(function (regex) { return item.match(regex)});
}
}
diff --git a/examples/scripts/session.sh b/examples/scripts/session.sh
index b8e2bd6..e2642c7 100755
--- a/examples/scripts/session.sh
+++ b/examples/scripts/session.sh
@@ -1,42 +1,62 @@
#!/bin/bash
# Very simple session manager for uzbl. When called with "endsession" as the
-# argument, it'lla empty the sessionfile, look for fifos in $fifodir and
+# argument, it'll backup $sessionfile, look for fifos in $fifodir and
# instruct each of them to store their current url in $sessionfile and
# terminate themselves. Run with "launch" as the argument and an instance of
# uzbl will be launched for each stored url. "endinstance" is used internally
# and doesn't need to be called manually at any point.
+# Add a line like 'bind quit = /path/to/session.sh endsession' to your config
-
-scriptfile=$XDG_CONFIG_HOME/uzbl/session.sh # this script
+scriptfile=$0 # this script
sessionfile=$XDG_DATA_HOME/uzbl/session # the file in which the "session" (i.e. urls) are stored
-UZBL="uzbl" # add custom flags and whatever here.
+configfile=$XDG_DATA_HOME/uzbl/config # uzbl configuration file
+UZBL="uzbl -c $configfile" # add custom flags and whatever here.
fifodir=/tmp # remember to change this if you instructed uzbl to put its fifos elsewhere
thisfifo="$4"
act="$8"
url="$6"
+if [ "$act." = "." ]; then
+ act="$1"
+fi
+
+
case $act in
"launch" )
- for url in $(cat $sessionfile); do
- $UZBL --uri "$url" &
- done
- exit 0;;
+ urls=$(cat $sessionfile)
+ if [ "$urls." = "." ]; then
+ $UZBL
+ else
+ for url in $urls; do
+ $UZBL --uri "$url" &
+ done
+ fi
+ exit 0
+ ;;
+
"endinstance" )
if [ "$url" != "(null)" ]; then
echo "$url" >> $sessionfile;
fi
echo "exit" > "$thisfifo"
;;
+
"endsession" )
- echo -n "" > "$sessionfile"
+ mv "$sessionfile" "$sessionfile~"
for fifo in $fifodir/uzbl_fifo_*; do
if [ "$fifo" != "$thisfifo" ]; then
echo "spawn $scriptfile endinstance" > "$fifo"
fi
done
- echo "spawn $scriptfile endinstance" > "$thisfifo";;
- * ) echo "session manager: bad action";;
+ echo "spawn $scriptfile endinstance" > "$thisfifo"
+ ;;
+
+ * ) echo "session manager: bad action"
+ echo "Usage: $scriptfile [COMMAND] where commands are:"
+ echo " launch - Restore a saved session or start a new one"
+ echo " endsession - Quit the running session. Must be called from uzbl"
+ ;;
esac
diff --git a/uzbl.c b/uzbl.c
index 411b765..b219ce3 100644
--- a/uzbl.c
+++ b/uzbl.c
@@ -32,6 +32,7 @@
#define LENGTH(x) (sizeof x / sizeof x[0])
#define MAX_BINDINGS 256
+#define _POSIX_SOURCE
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
@@ -545,6 +546,7 @@ load_start_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data) {
(void) page;
(void) frame;
(void) data;
+ uzbl.gui.sbar.load_progress = 0;
g_string_truncate(uzbl.state.keycmd, 0); // don't need old commands to remain on new page?
if (uzbl.behave.load_start_handler)
run_handler(uzbl.behave.load_start_handler, "");
@@ -732,7 +734,11 @@ static void
load_uri (WebKitWebView *web_view, GArray *argv) {
if (argv_idx(argv, 0)) {
GString* newuri = g_string_new (argv_idx(argv, 0));
- if (g_strrstr (argv_idx(argv, 0), "://") == NULL)
+ if (g_strstr_len (argv_idx(argv, 0), 11, "javascript:") != NULL) {
+ run_js(web_view, argv);
+ return;
+ }
+ if (g_strrstr (argv_idx(argv, 0), "://") == NULL && g_strstr_len (argv_idx(argv, 0), 5, "data:") == NULL)
g_string_prepend (newuri, "http://");
/* if we do handle cookies, ask our handler for them */
webkit_web_view_load_uri (web_view, newuri->str);
@@ -1117,7 +1123,7 @@ sharg_append(GArray *a, const gchar *str) {
// make sure that the args string you pass can properly be interpreted (eg properly escaped against whitespace, quotes etc)
static gboolean
run_command (const gchar *command, const guint npre, const gchar **args,
- const gboolean sync, char **stdout) {
+ const gboolean sync, char **output_stdout) {
//command <uzbl conf> <uzbl pid> <uzbl win id> <uzbl fifo file> <uzbl socket file> [args]
GError *err = NULL;
@@ -1141,10 +1147,10 @@ run_command (const gchar *command, const guint npre, const gchar **args,
gboolean result;
if (sync) {
- if (*stdout) *stdout = strfree(*stdout);
+ if (*output_stdout) *output_stdout = strfree(*output_stdout);
result = g_spawn_sync(NULL, (gchar **)a->data, NULL, G_SPAWN_SEARCH_PATH,
- NULL, NULL, stdout, NULL, NULL, &err);
+ NULL, NULL, output_stdout, NULL, NULL, &err);
} else result = g_spawn_async(NULL, (gchar **)a->data, NULL, G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL, &err);
@@ -1158,8 +1164,8 @@ run_command (const gchar *command, const guint npre, const gchar **args,
g_string_append_printf(s, " -- result: %s", (result ? "true" : "false"));
printf("%s\n", s->str);
g_string_free(s, TRUE);
- if(stdout) {
- printf("Stdout: %s\n", *stdout);
+ if(output_stdout) {
+ printf("Stdout: %s\n", *output_stdout);
}
}
if (err) {
@@ -1555,7 +1561,7 @@ set_var_value(gchar *name, gchar *val) {
} else if (c->type == TYPE_FLOAT) {
float *fp = (float *)c->ptr;
buf = expand_vars(val);
- *fp = strtof(buf, &endp);
+ *fp = strtod(buf, &endp);
g_free(buf);
}
@@ -2033,6 +2039,7 @@ create_mainbar () {
gtk_misc_set_alignment (GTK_MISC(g->mainbar_label), 0, 0);
gtk_misc_set_padding (GTK_MISC(g->mainbar_label), 2, 2);
gtk_box_pack_start (GTK_BOX (g->mainbar), g->mainbar_label, TRUE, TRUE, 0);
+ g_signal_connect (G_OBJECT (g->mainbar), "key-press-event", G_CALLBACK (key_press_cb), NULL);
return g->mainbar;
}
@@ -2252,7 +2259,7 @@ settings_init () {
printf ("No configuration file loaded.\n");
}
- g_signal_connect(n->soup_session, "request-queued", G_CALLBACK(handle_cookies), NULL);
+ g_signal_connect_after(n->soup_session, "request-started", G_CALLBACK(handle_cookies), NULL);
}
static void handle_cookies (SoupSession *session, SoupMessage *msg, gpointer user_data){
diff --git a/uzbl.h b/uzbl.h
index 6297a64..8a66506 100644
--- a/uzbl.h
+++ b/uzbl.h
@@ -322,7 +322,7 @@ close_uzbl (WebKitWebView *page, GArray *argv);
static gboolean
run_command(const gchar *command, const guint npre,
- const gchar **args, const gboolean sync, char **stdout);
+ const gchar **args, const gboolean sync, char **output_stdout);
static void
spawn(WebKitWebView *web_view, GArray *argv);