aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.gitattributes1
-rw-r--r--.gitignore1
-rw-r--r--AUTHORS10
-rw-r--r--Makefile11
-rw-r--r--Makefile-new-test2
-rw-r--r--README179
-rw-r--r--docs/CONTRIBUTING22
-rw-r--r--docs/FAQ2
-rw-r--r--docs/INSTALL4
-rw-r--r--docs/TODO5
-rw-r--r--examples/config/uzbl/config98
-rwxr-xr-xexamples/data/uzbl/scripts/clipboard.sh10
-rwxr-xr-xexamples/data/uzbl/scripts/cookies.py94
-rwxr-xr-xexamples/data/uzbl/scripts/cookies.sh51
-rwxr-xr-xexamples/data/uzbl/scripts/download.sh20
-rwxr-xr-xexamples/data/uzbl/scripts/formfiller.pl2
-rwxr-xr-xexamples/data/uzbl/scripts/history.sh3
-rwxr-xr-xexamples/data/uzbl/scripts/insert_bookmark.sh5
-rw-r--r--examples/data/uzbl/scripts/linkfollow.js14
-rwxr-xr-xexamples/data/uzbl/scripts/load_url_from_bookmarks.sh2
-rwxr-xr-xexamples/data/uzbl/scripts/load_url_from_history.sh13
-rwxr-xr-xexamples/data/uzbl/scripts/session.sh5
-rwxr-xr-xexamples/data/uzbl/scripts/uzbl_tabbed.py328
-rwxr-xr-xexamples/data/uzbl/scripts/uzblcat6
-rwxr-xr-xexamples/data/uzbl/scripts/yank.sh13
-rw-r--r--examples/data/uzbl/style.css3
-rw-r--r--tests/Makefile3
-rw-r--r--tests/test-expand.c4
-rw-r--r--uzbl.c381
-rw-r--r--uzbl.h228
-rw-r--r--uzblctrl.c12
31 files changed, 768 insertions, 764 deletions
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..7799c58
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+examples/data/uzbl/forms/bbs.archlinux.org whitespace=-trailing-space
diff --git a/.gitignore b/.gitignore
index abbd2d7..2efc5e1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
uzbl
uzblctrl
+uzbl.o
*~
tags
examples/data
diff --git a/AUTHORS b/AUTHORS
index e9b97a9..cf2635b 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -5,7 +5,7 @@ Developers:
Michael Walker (Barrucadu) <email is mike AT barrucadu.co.uk>
Přemysl Hrubý (anydot) <email is dfenze AT gmail.com>
Robert Manea (robm) <email is rob DOT manea AT gmail DOT com>
- Henri Kemppainen (DuClare) <email is akarinotengoku AT THE DOMAIN OF gmail.com>
+ Henri Kemppainen (DuClare) <email is akarinotengoku AT THE DOMAIN OF gmail.com>
Contributors:
Zane Ashby (HashBox) - Rewrote FIFO interface. Fixed various bugs.
@@ -15,23 +15,23 @@ Contributors:
Damien Leon - misc
Peter Suschlik - backwards searching
(salinasv) - move some variables to heap
- Sylvester Johansson (scj) - form filler script & different take on link follower
+ Sylvester Johansson (scj) - form filler script & different take on link follower
(mxf) - uzblcat
Mark Nevill - misc patches
Uli Schlachter (psychon) - basic mime_policy_cb & Makefile patch
- (uranther) - zoom level
+ James S Wheaton (uranther) - zoom level, test framework
(bobpaul) - session script patches
Tom Adams (holizz) - few patches, cookies.py, gtkplug/socket & proof of concept uzbl_tabbed.py
neutralinsomniac - load_progress = 0 fix
Maximilian Gaß (mxey) - several small patches
- Abel Camarillo (00z) - make it compile on OpenBSD
+ Abel Camarillo (00z) - various portability fixes, such as BSD fixes for Makefile and posix shell scripts
(israellevin) - toggle_zoom_type
(kmeaw) - fix for multibyte utf8 characters segfault
(evocallaghan) - tiny patches
Aaron Griffin (phrakture) - Makefile patches to build on OSX
Mason Larobina - os.environ.keys() & os.path.join fix in cookies.py, work on uzbl_tabbed.py
(dequis) - Uzbl.run, birectional socket, javascript commands
- Brendan Taylor (bct) - various bugfixes
+ Brendan Taylor (bct) - various bugfixes, making misc variables much better using expand(), refactoring some internal var stuff
Chris van Dijk (quigybo) - work on uzbl_tabbed.py
Moritz Lenz - small doc fix
Sergey Shepelev (temoto) - doc patch
diff --git a/Makefile b/Makefile
index b914599..0b1de70 100644
--- a/Makefile
+++ b/Makefile
@@ -1,14 +1,23 @@
+# first entries are for gnu make, 2nd for BSD make. see http://lists.uzbl.org/pipermail/uzbl-dev-uzbl.org/2009-July/000177.html
+
CFLAGS:=-std=c99 $(shell pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0) -ggdb -Wall -W -DARCH="\"$(shell uname -m)\"" -lgthread-2.0 -DG_ERRORCHECK_MUTEXES -DCOMMIT="\"$(shell git log | head -n1 | sed "s/.* //")\"" $(CPPFLAGS) -fPIC
+CFLAGS!=echo -std=c99 `pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0` -ggdb -Wall -W -DARCH='"\""'`uname -m`'"\""' -lgthread-2.0 -DG_ERRORCHECK_MUTEXES -DCOMMIT='"\""'`git log | head -n1 | sed "s/.* //"`'"\""' $(CPPFLAGS) -fPIC
+
LDFLAGS:=$(shell pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0) -pthread $(LDFLAGS)
+LDFLAGS!=echo `pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0` -pthread $(LDFLAGS)
+
all: uzbl uzblctrl
PREFIX?=$(DESTDIR)/usr
# When compiling unit tests, compile uzbl as a library first
-test: uzbl.o
+tests: uzbl.o
$(CC) -DUZBL_LIBRARY -shared -Wl uzbl.o -o ./tests/libuzbl.so
cd ./tests/; $(MAKE)
+test: uzbl
+ ./uzbl --uri http://www.uzbl.org --verbose
+
test-dev: uzbl
XDG_DATA_HOME=./examples/data XDG_CONFIG_HOME=./examples/config ./uzbl --uri http://www.uzbl.org --verbose
diff --git a/Makefile-new-test b/Makefile-new-test
index 5985c90..9f85a4e 100644
--- a/Makefile-new-test
+++ b/Makefile-new-test
@@ -27,7 +27,7 @@ test-config: uzbl
test-config-real: uzbl
./uzbl --uri http://www.uzbl.org < $(EXMPLSDIR)/configs/sampleconfig
-
+
clean:
rm -f uzbl
rm -f uzblctrl
diff --git a/README b/README
index 266a207..d73bab1 100644
--- a/README
+++ b/README
@@ -2,32 +2,31 @@
* people want a browser that does everything
* people who want a browser with things like a built-in bookmark manager, address bar, forward/back buttons, ...
* people who expect something that works by default. You'll need to read configs and write/edit scripts
-
+* people who like nothing from this list: mpd, moc, wmii, dwm, awesome, mutt, pine, vim, dmenu, screen, irssi, weechat, bitlbee
### TO NEW PEOPLE:
* please read the documentation in /usr/share/uzbl/docs
* invoke uzbl --help
* to get you started: `XDG_DATA_HOME=/usr/share/uzbl/examples/data XDG_CONFIG_HOME=/usr/share/uzbl/examples/config uzbl --uri www.archlinux.org`
-* study the sample config, have a look at all the bindings, and note how you can call the scripts to load new url from history and the bookmarks file
+* try and study the sample config, read the readme to find out how it works.
* You can change the url with commands (if you have setup the appropriate keybinds) but to be most effective it's better to do url editing/changing _outside_ of uzbl.
Eg, you can use the `load_from_*` dmenu based scripts to pick/edit a url or type a new one.
* If you have questions, you are likely to find answers in the FAQ or in the other documentation.
### INTRODUCTION
- In my opinion, any program can only be really useful if it complies to the unix philosophy.
+ Any program can only be really useful if it complies to the unix philosophy.
Web browsers are frequent violators of this principle:
-* They build in way too much things into the browser, dramatically decreasing the options to do things the way you want.
+* They build in way too much things into the browser, dramatically decreasing the options to do things the way you want.
* They store things in way too fancy formats (xml, rdf, sqlite, ... ) which are hard to store under version control, reuse in other scripts, ...
Time to change that!
- Here are the general ideas:
+ Here are the general ideas (not all of these are implemented perfectly yet):
* each instance of uzbl renders 1 page (eg it's a small wrapper around webkit), no tabbing, tab previews, or speed dial things.
- For "multiple instances management" use your window managers, scripts or wrappers.
- This way you can get something much more useful than tabbing by default
+ For "multiple instances management" use your window managers, scripts or wrappers.
* very simple, plaintext , changeable at runtime configuration
* various interfaces for (programmatic) interaction with uzbl (see below)
* customizable keyboard shortcuts in vim or emacs style (whatever user wants)
@@ -56,7 +55,7 @@ Time to change that!
The general idea is that uzbl by default is very bare bones. you can send it commands to update settings and perform actions, through various interfaces.
There is a limited default configuration. Please see config.h to see what it contains.
By default, there are *no* keybinds defined at all. (Default keybinds would work counterproductive when you try to customize)
-For examples of the possibilities what you can do, please see the sample config(s).
+For examples of the possibilities what you can do, please see the sample config(s), and uzbl wiki page.
There are several interfaces to interact with uzbl:
* uzbl --config <filename>: <filename> will be read line by line, and the commands in it will be executed. useful to configure uzbl at startup.
@@ -66,7 +65,6 @@ There are several interfaces to interact with uzbl:
By default, the behaviour is modal (vi style):
command mode: every keystroke is interpreted to run commands
insert mode: keystrokes are not interpreted so you can enter text into html forms
- Press ESC/i to toggle command/insert mode
But if you don't like modal interfaces, you can set `always_insert_mode` and configure a modkey to execute the commands. (emacs style).
There is also support for "chained" commands (multiple characters long) (with backspace/esc shortcuts), and keyworded commands.
Also you can have incremental matching on commands or match after pressing return. (see sampleconfig for more info)
@@ -161,42 +159,87 @@ The following commands are recognized:
- remember to quote the commands; one command must come as one parameter
- if you use `chain` with a handler script which must return some output (such as a cookie handler -- uzbl will wait for and use its output), use sync_spawn or sync_sh instead of spawn or sh in the command that should give the output
-### JAVASCRIPT HELPER OBJECT
-
-Javascript code run from uzbl is given a special object in the global namespace which gives special privileges to these scripts. This object is called `Uzbl`, and it is added and removed before and after the script execution so that it is hidden to web javascripts (There is no race condition, since all the javascript code runs in a single thread)
-
-Currently, the `Uzbl` object provides only one function:
-
-* `Uzbl.run( <command> )`
- - command is any uzbl command as defined above
- - return value: a string, either empty or containing the output of the command. Very few commands return their output currently, including js, script, and print.
- - Examples:
- * `Uzbl.run("spawn insert_bookmark.sh")`
- * `uri = Uzbl.run("print @uri")` (see variable expansion below)
-
-### JAVASCRIPT SECURITY
+### VARIABLES AND CONSTANTS
+Uzbl has a lot of internal variables and constants. You can get the values (using the `print` command, see above), and for variables you can also change the value at
+runtime. Some of the values can be passed at start up through commandline arguments, others need to be set by using commands (eg in config file).
+Some of them have default values (see config.h)
+Some variables have callback functions which will get called after setting the variable to perform some additional logic (see below)
+
+* Variables:
+ - uri (callback: load the uri)
+ - verbose: affects output on stdout
+ - mode:insert or command mode
+ - inject_html
+ - base_url: used when passing html through stdin
+ - html_endmarker: delimiter when passing html through stdin
+ - html_mode_timeout: consider end of html input after x seconds when no endmarker found
+ - keycmd: holds the input buffer (callback: update input buffer)
+ - status_message (callback: update title)
+ - show_status: show statusbar or not
+ - status_top: statusbar on top?
+ - status_format: marked up, to be expanded string for statusbar (callback: update statusbar)
+ - status_pbar_done: character to denote done % of pageload
+ - status_pbar_pending: character to denote pending % of pageload
+ - status_pbar_width: width of progressbar
+ - status_background: color which can be used to override Gtk theme.
+ - insert_indicator: string to denote insert mode
+ - command_indicator: string to denote command mode
+ - title_format_long: titlebar string when no statusbar shown (will be expanded
+ - title_format_short: titlebar string when statusbar shown (will be expanded)
+ - icon: path to icon for Gtk
+ - insert_mode: whether insert mode is active
+ - always_insert_mode: set this to true if you don't like modal (vim-like) interfaces
+ - reset_command_mode: automatically revert to command mode on pageload (unless always_insert_mode is set)
+ - modkey: modkey which can be pressed to activate keybind from inside insert mode
+ - load_finish_handler
+ - load_start_handler
+ - load_commit_handler
+ - history_handler
+ - download_handler
+ - cookie_handler
+ - new_window: handler to execute to invoke new uzbl window (TODO better name)
+ - fifo_dir: location to store fifo's
+ - socket_dir: location to store sockets
+ - http_debug: http debug mode (value 0-3)
+ - shell_cmd: alias which will be expanded to use shell commands (eg sh -c)
+ - proxy_url: http traffic socks proxy (eg: http://<host>:<port>)
+ - max_conns
+ - max_conns_host
+ - useragent: to be expanded strin
+ - zoom_level
+ - font_size
+ - monospace_size
+ - minimum_font_size
+ - disable_plugins (TODO rename to enable)
+ - disable_scripts (TODO rename to enable)
+ - autoload_images
+ - autoshrink_images: shrink images to window size (default 0)
+ - enable_spellcheck
+ - enable_private
+ - print_backgrounds: print background images? (default 0)
+ - stylesheet_uri: use this to override the pagelayout with a custom stylesheet
+ - resizable_text_areas
+ - default_encoding: iso-8859-1 by default
+ - enforce_96_dpi: 1 by default
+ - caret_browsing
+
+* Constants (not dumpable or writeable):
+ - WEBKIT_MAJOR: set at compile time
+ - WEBKIT_MINOR: set at compile time
+ - WEBKIT_MICRO: set at compile time
+ - ARCH_UZBL: set at compile time
+ - COMMIT: set at compile time
+ - LOAD_PROGRESS
+ - LOAD_PROGRESSBAR
+ - TITLE
+ - SELECTED_URI
+ - MODE
+ - NAME: name of the uzbl instance (Xorg window id, unless set by cmdline arg) (TODO: can't we make this a variable?)
-Since defined variables and functions are set in the global namespace (`window` object) as default, it is recommended to wrap your scripts like this:
-
- (function(Uzbl) {
- ...
- })(Uzbl);
-
-This way, everything is kept private. It also turns Uzbl into a local variable, which can be accessed from callback functions defined inside. However for some situations, isolating everything isn't an option, for example, with binds. You can define them directly in the script body, and use `var Uzbl = window.Uzbl;` to make the Uzbl variable local, as in the following example:
-
- function f() {
- var Uzbl = window.Uzbl;
- Uzbl.run(...);
- setTimeout(function() {
- Uzbl.run(...);
- }, 500);
- }
-
-Copying the Uzbl object and creating public functions should be taken with care to avoid creating security holes. Keep in mind that the "f" function above would be defined in the `window` object, and as such any javascript in the current page can call it.
### VARIABLE EXPANSION AND COMMAND/JAVA SCRIPT SUBSTITUTION
-Variable expansion works pretty much as known from shell interpreters (sh, bash, etc.). This means you can
+Variable expansion works pretty much as known from shell interpreters (sh, bash, etc.). This means you can
construct strings with uzbl variables in them and have uzbl replace the variable name with its contents.
In order to let uzbl know what to expand you'll need to prepend @ to the variable name:
@@ -282,7 +325,7 @@ status bar's markup; see the example config for examples.
### EXTERNAL SCRIPTS
You can use external scripts with uzbl the following ways:
-* let uzbl call them. these scripts are called handlers in the uzbl config. used for handling logging history, handling a new download,..
+* let uzbl call them. these scripts are called handlers in the uzbl config. used for handling logging history, handling a new download,..
* call them yourself from inside uzbl. you can bind keys for this. examples: add new bookmark, load new url,..
* You could also use xbindkeys or your WM config to trigger scripts if uzbl does not have focus
@@ -316,20 +359,55 @@ The script specific arguments are this:
* cookie handler
$8 GET/PUT
- $9 request address host (if current page url is www.foo.com/somepage, this could be something else than foo, eg advertising from another host)
- $10 request address path
- $11 cookie (only with PUT requests)
+ $9 request address scheme (e.g. http or https)
+ $10 request address host (if current page url is www.foo.com/somepage, this could be something else than foo, eg advertising from another host)
+ $11 request address path
+ $12 cookie (only with PUT requests)
Custom, userdefined scripts (`spawn foo bar`) get first the arguments as specified in the config and then the above 7 are added at the end.
+### JAVASCRIPT HELPER OBJECT
+
+Javascript code run from uzbl is given a special object in the global namespace which gives special privileges to these scripts. This object is called `Uzbl`, and it is added and removed before and after the script execution so that it is hidden to web javascripts (There is no race condition, since all the javascript code runs in a single thread)
+
+Currently, the `Uzbl` object provides only one function:
+
+* `Uzbl.run( <command> )`
+ - command is any uzbl command as defined above
+ - return value: a string, either empty or containing the output of the command. Very few commands return their output currently, including js, script, and print.
+ - Examples:
+ * `Uzbl.run("spawn insert_bookmark.sh")`
+ * `uri = Uzbl.run("print @uri")` (see variable expansion below)
+
+### JAVASCRIPT SECURITY
+
+Since defined variables and functions are set in the global namespace (`window` object) as default, it is recommended to wrap your scripts like this:
+
+ (function(Uzbl) {
+ ...
+ })(Uzbl);
+
+This way, everything is kept private. It also turns Uzbl into a local variable, which can be accessed from callback functions defined inside. However for some situations, isolating everything isn't an option, for example, with binds. You can define them directly in the script body, and use `var Uzbl = window.Uzbl;` to make the Uzbl variable local, as in the following example:
+
+ function f() {
+ var Uzbl = window.Uzbl;
+ Uzbl.run(...);
+ setTimeout(function() {
+ Uzbl.run(...);
+ }, 500);
+ }
+
+Copying the Uzbl object and creating public functions should be taken with care to avoid creating security holes. Keep in mind that the "f" function above would be defined in the `window` object, and as such any javascript in the current page can call it.
+
### COMMAND LINE ARGUMENTS
uzbl [ uri ]
- -u, --uri=URI alternative way to load uri on start. (equivalent to 'set uri = URI')
+ -u, --uri=URI Uri to load at startup (equivalent to 'uzbl <uri>' or 'set uri = URI' after uzbl has launched)
-v, --verbose Whether to print all messages or just errors.
-n, --name=NAME Name of the current instance (defaults to Xorg window id)
- -c, --config=FILE Config file (or `-` to use stdin)
+ -c, --config=FILE Path to config file or '-' for stdin
-s, --socket=SOCKET Socket ID
+ -g, --geometry=GEOMETRY Set window geometry (format: WIDTHxHEIGHT+-X+-Y)
-V, --version Print the version and exit
--display=DISPLAY X display to use
--help Help
@@ -337,12 +415,5 @@ Custom, userdefined scripts (`spawn foo bar`) get first the arguments as specifi
-
### BUGS
-known bugs:
-
-* Segfaults when using zoom commands (happens when max zoom already reached?).
-
Please report new issues @ uzbl.org/bugs
-
-
diff --git a/docs/CONTRIBUTING b/docs/CONTRIBUTING
index 14c3f0b..a45618a 100644
--- a/docs/CONTRIBUTING
+++ b/docs/CONTRIBUTING
@@ -66,9 +66,24 @@ This is a relatively easy, solid and transparent way to handle all requests in o
we know for bigger changes this is not always feasible. Just try to keep the merges about bigger "clean changesets".
* Your code should not introduce any compile warnings or errors. And also,
no regressions but that's harder to check.
+* Please try to keep the code clean - we don't like extraneous whitespace.
+ The sample pre-commit hook can check for this - so go ahead and
+ $ cp .git/hooks/pre-commit.sample .git/hooks/pre-commit
That said, you can always ask us to check on your stuff or ask for advice.
+### Bugreporting
+
+Bug reports are also welcome, especially the ones that come with a patch ;-)
+Before making a new ticket, check whether the bug is reported already.
+If you want to report a bug and you don't know where the problem in the code
+is, please supply:
+
+* version (commit hash) (see `uzbl --version`)
+* operating system
+* versions of libsoup, webkit, gtk.
+* output of uzbl --verbose (with http_debug set, if relevant)
+
### Valgrind profiling
$ add this to Makefile header: CFLAGS=-g
$ recompile
@@ -78,6 +93,13 @@ That said, you can always ask us to check on your stuff or ask for advice.
### Memory leak checking
valgrind --tool=memcheck --leak-check=full ./uzbl
+### Writing unit tests
+
+If you can, write a unit test for a bugfix or new functionality. Add relevant unit
+tests to existing .c files in tests/. Others should be made in new source files with
+corresponding changes to the tests/Makefile.
+Run all tests with `make tests`
+
### Debugging / backtraces
* compile with -ggdb (enabled by default on experimental tree)
diff --git a/docs/FAQ b/docs/FAQ
index b2a5c9c..f8e6e8a 100644
--- a/docs/FAQ
+++ b/docs/FAQ
@@ -53,7 +53,7 @@ have lots of keybinding possibilities.
We stick to "one page per uzbl instance" because that's a simple, clean and flexible method. We believe "multiple instances management" is something that must
be handled outside of uzbl by a separate/different program. Here are some solutions:
- * Many window managers can (and should) handle this by default. Xmonads tabbed layout, Wmii's stacked layout and so on.
+ * Many window managers can (and should) handle this by default. Xmonads tabbed layout, Wmii's stacked layout, fluxbox or kwin tabs and so on.
* Uzbl supports acting as a GtkPlug to plug into GtkSockets (Xembed) so you can embed uzbl instances in other Gtk applications.
This allows several implementatinos, a popular one is [uzbl_tabbed.py](http://www.uzbl.org/wiki/uzbl_tabbed)
* If you want highest customizablity, you need the 3rd option:
diff --git a/docs/INSTALL b/docs/INSTALL
index be6e85b..9213cc3 100644
--- a/docs/INSTALL
+++ b/docs/INSTALL
@@ -40,7 +40,7 @@ sample scripts:
* dmenu (with vertical patch)
* zenity
-* bash
+* bash
* python (cookies.py)
* perl (formfiller.pl)
@@ -50,7 +50,7 @@ After installing - using either method - you will find:
* /usr/bin : uzbl [and uzblctrl]
* /usr/share/uzbl/docs/ : documentation files included with uzbl. (readme, checklist, .. )
-* /usr/share/uzbl/examples: sample scripts, config files and a sample data (boomarks, .. )
+* /usr/share/uzbl/examples: sample scripts, config files and a sample data (boomarks, .. )
You will probably want to change the scripts to behave more like you want, so copy the scripts to your home dir. If you save your config as
$XDG\_CONFIG\_HOME/uzbl/config (this expands to ~/.config/uzbl/config on most systems) it will be recognized automatically. You can also pass the path to
diff --git a/docs/TODO b/docs/TODO
index 00166eb..45f4539 100644
--- a/docs/TODO
+++ b/docs/TODO
@@ -38,8 +38,9 @@ More or less in order of importance/urgency
* proxy_url is not a good var name. it's not a url.
* regex style page searching? so you can do 'or' and 'and' things. flags like case sensitive etc.
* check for real command name, not just the first letter.
+* Allow the spacebar to be binded to a command
* let users attach handlers to the most common events/signals in uzbl.
- great use case: automatically calling formfiller for certain sites
+ great use case: automatically calling formfiller for certain sites, doing stuff at uzbl startup, etc
* document:
stylesheet overridding
formfiller
@@ -53,7 +54,7 @@ More or less in order of importance/urgency
overriding variables (such as -u)
variable expansion (@var, @{var}, where do they get expanded? can users have their own vars?, should we merge this with the replacement we do for useragent/window title etc?)
how %s works for the js command
-
+
SOMEDAY:
figure out caching with webkit and in general how we can speed up everything
diff --git a/examples/config/uzbl/config b/examples/config/uzbl/config
index e75789d..ab2cf7f 100644
--- a/examples/config/uzbl/config
+++ b/examples/config/uzbl/config
@@ -1,104 +1,38 @@
# example uzbl config.
# all settings are optional. you can use uzbl without any config at all (but it won't do much)
-# keyboard behavior is vimstyle by default, but you can change this
-# set always_insert_mode to always be in insert mode and disable going out of it.
-# if you do this, make sure you've set a modkey so you can reach the commands
-# from insert mode by combining them with the modkey
+# keyboard behavior in this sample config is sort of vimstyle
-# Usually you want to spawn a script to handle things, but any command (such as sh) can be used
+# Handlers
set history_handler = spawn $XDG_DATA_HOME/uzbl/scripts/history.sh
set download_handler = spawn $XDG_DATA_HOME/uzbl/scripts/download.sh
set cookie_handler = spawn $XDG_DATA_HOME/uzbl/scripts/cookies.py
-
-# Control how new windows should open
-#set new_window = sh 'uzbl -u $8' # equivalent to the default behaviour
-#set new_window = sh 'echo uri "$8" > $4' # open in same window
-
-# You can bind whatever things (spawn <foo>, script <bar>,..) to some events TODO: make events system more generic
+#set new_window = sh 'echo uri "$8" > $4' # open in same window
+set new_window = sh 'uzbl -u $8' # equivalent to the default behaviour
set load_start_handler = set status_message = <span foreground="khaki">wait</span>
set load_commit_handler = set status_message = <span foreground="green">recv</span>
set load_finish_handler = set status_message = <span foreground="gold">done</span>
-set minimum_font_size = 6
-set font_size = 11
-## monospace_size defaults to font_size, but you can alter it independently
-#set monospace_size = 10
-
-## Display or supress images within html sites
-#set autoload_images = 0
-
-## Shrink images to window size
-#set autoshrink_images = 0
-
-## Spellchecker
-#set enable_spellcheck = 1
-
-## Private browsing
-#set enable_private = 0
-
-## The URI of a stylesheet that is applied to every page
-#set stylesheet_uri = http://www.user.com/mystylelesheet.css
-
-## enable/disable JavaScript
-#set disable_scripts = 1
-
-## Whether text areas are resizable
-#set resizeable_text_areas = 1
-
-## The default encoding used to display text
-#set default_encoding = iso-8859-1
-
-## Whether background images should be printed
-#set print_background = 0
-
-## Enforce a resolution of 96 DPI. This is meant for compatibility with
-## web pages which cope badly with different screen resolutions
-#set enforce_96_dpi = 1
-
-
-#
-# use with bind ... = sh <shell-oneliner>
-set shell_cmd = sh -c
-
-
# Behaviour and appearance
set show_status = 1
-# you can optionally use this setting to override the background color of the statusbar from your GTK theme.
set status_background = #303030
set status_format = <span font_family="monospace"><span background="khaki" foreground="black">[\@[\@MODE]\@]</span> [<span weight="bold" foreground="red">\@[\@keycmd]\@</span>] <span foreground="#606060"> \@[\@LOAD_PROGRESSBAR]\@ </span><span foreground="#99FF66">\@[\@uri]\@</span> <span foreground="khaki">\@[\@NAME]\@</span> <span foreground="orange">\@status_message</span><span foreground="#606060"> \@[\@SELECTED_URI]\@</span></span>
set status_top = 0
-# define how your titlebar should look like. (short = statusbar is also shown, long = show everything you must see if statusbar is off)
-set title_format_short = \@TITLE - Uzbl browser <\@NAME>
-set title_format_long = \@keycmd \@MODE \@TITLE - Uzbl browser <\@NAME> > \@SELECTED_URI
-# set the characters to use for, and the width of the progress bar
-set status_pbar_done = *
-set status_pbar_pending = -
-set status_pbar_width = 12
set insert_indicator = I
set command_indicator = C
-set modkey = Mod1
-# reset to command mode when new page is loaded
-set reset_command_mode = 1
-# this var has precedence over reset_command_mode
-set always_insert_mode = 0
-
-# to start a local socks server, do : ssh -fND localhost:8118 localhost
-#set proxy_url = http://127.0.0.1:8118
-#values 0-3
-#set http_debug = 0
-#set useragent = uzbl (Webkit @WEBKIT_MAJOR.@WEBKIT_MINOR.@WEBKIT_MICRO)
-# Example user agent containing everything:
-set useragent = Uzbl (Webkit @WEBKIT_MAJOR.@WEBKIT_MINOR.@WEBKIT_MICRO) (@(uname -s)@ @(uname -n)@ @(uname -r)@ @(uname -v)@ @(uname -m)@ [@ARCH_UZBL]) (Commit @COMMIT)
-#set max_conns = 0
-#set max_conns_host = 0
+set useragent = Uzbl (Webkit @WEBKIT_MAJOR.@WEBKIT_MINOR.@WEBKIT_MICRO) (@(uname -s)@ @(uname -n)@ @(uname -r)@ @(uname -v)@ @(uname -m)@ [@ARCH_UZBL]) (Commit @COMMIT)
set fifo_dir = /tmp
set socket_dir = /tmp
+set shell_cmd = sh -c
+
+# Keyboard interface
+set modkey = Mod1
+# like this you can enter any command at runtime, interactively. prefixed by ':'
+bind :_ = chain '%s'
-# Key bindings
bind j = scroll_vert 20
bind k = scroll_vert -20
bind h = scroll_horz -20
@@ -116,18 +50,12 @@ bind T = toggle_zoom_type
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.
bind /* = search %s
bind ?* = search_reverse %s
#jump to next
bind n = search
bind N = search_reverse
bind gh = uri http://www.uzbl.org
-
-# like this you can enter any command at runtime, interactively. prefixed by ':'
-bind :_ = chain '%s'
-
# shortcut to set the uri. TODO: i think we can abandon the uri command in favor of 'set uri = ..'
bind o _ = uri %s
# shortcut to set variables
@@ -188,10 +116,6 @@ bind fl* = script $XDG_DATA_HOME/uzbl/scripts/follow_Numbers.js %s
# using strings, not polished yet:
bind fL* = script $XDG_DATA_HOME/uzbl/scripts/follow_Numbers_Strings.js %s
-# you can use this to disable all plugins
-set disable_plugins = 0
-
-set icon = ./uzbl.png
# "home" page if you will
set uri = uzbl.org
diff --git a/examples/data/uzbl/scripts/clipboard.sh b/examples/data/uzbl/scripts/clipboard.sh
index c64b65c..60567d3 100755
--- a/examples/data/uzbl/scripts/clipboard.sh
+++ b/examples/data/uzbl/scripts/clipboard.sh
@@ -1,15 +1,17 @@
-#!/bin/bash
+#!/bin/sh
# with this script you can store the current url in the clipboard, or go to the url which is stored in the clipboard.
+clip=xclip
+
fifo="$5"
action="$1"
url="$7"
-selection=$(xclip -o)
+
+selection=`$clip -o`
case $action in
- "yank" ) echo -n "$url" | xclip;;
+ "yank" ) echo -n "$url" | eval "$clip";;
"goto" ) echo "uri $selection" > "$fifo";;
* ) echo "clipboard.sh: invalid action";;
esac
-
diff --git a/examples/data/uzbl/scripts/cookies.py b/examples/data/uzbl/scripts/cookies.py
index c8cf8c0..10f90fa 100755
--- a/examples/data/uzbl/scripts/cookies.py
+++ b/examples/data/uzbl/scripts/cookies.py
@@ -1,87 +1,37 @@
#!/usr/bin/env python
-import cookielib, sys, os, urllib2
-
-class FakeRequest:
- def __init__(self, argv):
- self.argv = argv
- self.cookies = None
- if len(self.argv) == 12:
- self.cookies = self.argv[11]
- def get_full_url(self):
- #TODO: this is a hack, fix in uzbl.c!
- u = self.get_host()+self.argv[10]
- if self.argv[6].startswith('https'):
- u = 'https://'+u
- else:
- u = 'http://'+u
- return u
- def get_host(self):
- return self.argv[9]
- def get_type(self):
- return self.get_full_url().split(':')[0]
- def is_unverifiable(self):
- return False
- def get_origin_req_host(self):
- return self.argv[9]
- def has_header(self, header):
- if header == 'Cookie':
- return self.cookies!=None
- def get_header(self, header_name, default=None):
- if header_name == 'Cookie' and self.cookies:
- return self.cookies
- else:
- return default
- def header_items(self):
- if self.cookies:
- return [('Cookie',self.cookies)]
- else:
- return []
- def add_unredirected_header(self, key, header):
- if key == 'Cookie':
- self.cookies = header
-
-class FakeHeaders:
- def __init__(self, argv):
- self.argv = argv
- def getallmatchingheaders(self, header):
- if header == 'Set-Cookie' and len(self.argv) == 12:
- return ['Set-Cookie: '+self.argv[11]]
- else:
- return []
- def getheaders(self, header):
- if header == 'Set-Cookie' and len(self.argv) == 12:
- return [self.argv[11]]
- else:
- return []
-class FakeResponse:
- def __init__(self, argv):
- self.argv = argv
- def info(self):
- return FakeHeaders(self.argv)
+import StringIO, cookielib, os, sys, urllib2
if __name__ == '__main__':
+ action = sys.argv[8]
+ uri = urllib2.urlparse.ParseResult(
+ scheme=sys.argv[9],
+ netloc=sys.argv[10],
+ path=sys.argv[11],
+ params='',
+ query='',
+ fragment='').geturl()
+ set_cookie = sys.argv[12] if len(sys.argv)>12 else None
+
if 'XDG_DATA_HOME' in os.environ.keys() and os.environ['XDG_DATA_HOME']:
- jar = cookielib.MozillaCookieJar(
- os.path.join(os.environ['XDG_DATA_HOME'],'uzbl/cookies.txt'))
+ f = os.path.join(os.environ['XDG_DATA_HOME'],'uzbl/cookies.txt')
else:
- jar = cookielib.MozillaCookieJar(
- os.path.join(os.environ['HOME'],'.local/share/uzbl/cookies.txt'))
+ f = os.path.join(os.environ['HOME'],'.local/share/uzbl/cookies.txt')
+ jar = cookielib.MozillaCookieJar(f)
+
try:
- jar.load()
+ jar.load(ignore_discard=True)
except:
pass
- req = FakeRequest(sys.argv)
-
- action = sys.argv[8]
+ req = urllib2.Request(uri)
if action == 'GET':
jar.add_cookie_header(req)
- if req.cookies:
- print req.cookies
+ if req.has_header('Cookie'):
+ print req.get_header('Cookie')
elif action == 'PUT':
- res = FakeResponse(sys.argv)
+ hdr = urllib2.httplib.HTTPMessage(StringIO.StringIO('Set-Cookie: %s' % set_cookie))
+ res = urllib2.addinfourl(StringIO.StringIO(), hdr, req.get_full_url())
jar.extract_cookies(res,req)
- jar.save(ignore_discard=True) # save session cookies too
- #jar.save() # save everything but session cookies
+ jar.save(ignore_discard=True)
diff --git a/examples/data/uzbl/scripts/cookies.sh b/examples/data/uzbl/scripts/cookies.sh
index 56b9c79..339c6fc 100755
--- a/examples/data/uzbl/scripts/cookies.sh
+++ b/examples/data/uzbl/scripts/cookies.sh
@@ -1,4 +1,6 @@
-#!/bin/bash
+#!/bin/sh
+
+set -n;
# THIS IS EXPERIMENTAL AND COULD BE INSECURE !!!!!!
@@ -6,7 +8,7 @@
# we use the cookies.txt format (See http://kb.mozillazine.org/Cookies.txt)
# This is one textfile with entries like this:
# kb.mozillazine.org FALSE / FALSE 1146030396 wikiUserID 16993
-# domain alow-read-other-subdomains path http-required expiration name value
+# domain alow-read-other-subdomains path http-required expiration name value
# you probably want your cookies config file in your $XDG_CONFIG_HOME ( eg $HOME/.config/uzbl/cookies)
# Note. in uzbl there is no strict definition on what a session is. it's YOUR job to clear cookies marked as end_session if you want to keep cookies only valid during a "session"
# MAYBE TODO: allow user to edit cookie before saving. this cannot be done with zenity :(
@@ -24,10 +26,10 @@
# http://kb.mozillazine.org/Cookies.txt
# don't always append cookies, sometimes we need to overwrite
-cookie_config=${XDG_CONFIG_HOME:-$HOME/.config}/uzbl/cookies
-[ -z "$cookie_config" ] && exit 1
-[ -d ${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/ ] && cookie_data=${XDG_DATA_HOME:-$home/.local/share}/uzbl/cookies.txt || exit 1
-
+cookie_config=${XDG_CONFIG_HOME:-${HOME}/.config}/uzbl/cookies
+[ "x$cookie_config" = x ] && exit 1
+[ -d "${XDG_DATA_HOME:-${HOME}/.local/share}/uzbl/" ] &&\
+cookie_data=${XDG_DATA_HOME:-${HOME}/.local/share}/uzbl/cookies.txt || exit 1
notifier=
#notifier=notify-send
@@ -48,6 +50,7 @@ which zenity &>/dev/null || exit 2
# uri=${uri/http:\/\/} # strip 'http://' part
# host=${uri/\/*/}
action=$8 # GET/PUT
+shift
host=$9
shift
path=$9
@@ -60,24 +63,24 @@ field_name=
field_value=
field_exp='end_session'
-function notify () {
+notify() {
[ -n "$notifier" ] && $notifier "$@"
}
# FOR NOW LETS KEEP IT SIMPLE AND JUST ALWAYS PUT AND ALWAYS GET
-function parse_cookie () {
+parse_cookie() {
IFS=$';'
first_pair=1
for pair in $cookie
do
- if [ "$first_pair" == 1 ]
+ if [ "x$first_pair" = x1 ]
then
field_name=${pair%%=*}
field_value=${pair#*=}
first_pair=0
else
- read -r pair <<< "$pair" #strip leading/trailing wite space
+ echo "$pair" | read -r pair #strip leading/trailing wite space
key=${pair%%=*}
val=${pair#*=}
[ "$key" == expires ] && field_exp=`date -u -d "$val" +'%s'`
@@ -89,7 +92,7 @@ function parse_cookie () {
}
# match cookies in cookies.txt against hostname and path
-function get_cookie () {
+get_cookie() {
path_esc=${path//\//\\/}
search="^[^\t]*$host\t[^\t]*\t$path_esc"
cookie=`awk "/$search/" $cookie_data 2>/dev/null | tail -n 1`
@@ -99,13 +102,15 @@ function get_cookie () {
false
else
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"
+ echo "$cookie" | \
+ read domain alow_read_other_subdomains path http_required expiration name \
+ value;
+ cookie="$name=$value"
true
fi
}
-function save_cookie () {
+save_cookie() {
if parse_cookie
then
data="$field_domain\tFALSE\t$field_path\tFALSE\t$field_exp\t$field_name\t$field_value"
@@ -116,8 +121,8 @@ function save_cookie () {
fi
}
-[ $action == PUT ] && save_cookie
-[ $action == GET ] && get_cookie && echo "$cookie"
+[ "x$action" = xPUT ] && save_cookie
+[ "x$action" = xGET ] && get_cookie && echo "$cookie"
exit
@@ -125,25 +130,25 @@ exit
# TODO: implement this later.
# $1 = section (TRUSTED or DENY)
# $2 =url
-function match () {
+match() {
sed -n "/$1/,/^\$/p" $cookie_config 2>/dev/null | grep -q "^$host"
}
-function fetch_cookie () {
+fetch_cookie() {
cookie=`cat $cookie_data`
}
-function store_cookie () {
+store_cookie() {
echo $cookie > $cookie_data
}
if match TRUSTED $host
then
- [ $action == PUT ] && store_cookie $host
- [ $action == GET ] && fetch_cookie && echo "$cookie"
+ [ "x$action" = xPUT ] && store_cookie $host
+ [ "x$action" = xGET ] && fetch_cookie && echo "$cookie"
elif ! match DENY $host
then
- [ $action == PUT ] && cookie=`zenity --entry --title 'Uzbl Cookie handler' --text "Accept this cookie from $host ?" --entry-text="$cookie"` && store_cookie $host
- [ $action == GET ] && fetch_cookie && cookie=`zenity --entry --title 'Uzbl Cookie handler' --text "Submit this cookie to $host ?" --entry-text="$cookie"` && echo $cookie
+ [ "x$action" = xPUT ] && cookie=`zenity --entry --title 'Uzbl Cookie handler' --text "Accept this cookie from $host ?" --entry-text="$cookie"` && store_cookie $host
+ [ "x$action" = xGET ] && fetch_cookie && cookie=`zenity --entry --title 'Uzbl Cookie handler' --text "Submit this cookie to $host ?" --entry-text="$cookie"` && echo $cookie
fi
exit 0
diff --git a/examples/data/uzbl/scripts/download.sh b/examples/data/uzbl/scripts/download.sh
index d87335f..aa1ca09 100755
--- a/examples/data/uzbl/scripts/download.sh
+++ b/examples/data/uzbl/scripts/download.sh
@@ -1,15 +1,19 @@
-#!/bin/bash
+#!/bin/sh
# just an example of how you could handle your downloads
# try some pattern matching on the uri to determine what we should do
-# Some sites block the default wget --user-agent...
-WGET="wget --user-agent=Firefox"
+# Some sites block the default wget --user-agent..
+GET="wget --user-agent=Firefox"
-if [[ $8 =~ .*(.torrent) ]]
+dest="$HOME"
+url="$8"
+
+test "x$url" = "x" && { echo "you must supply a url! ($url)"; exit 1; }
+
+# only changes the dir for the $get sub process
+if echo "$url" | grep -E '.*\.torrent' >/dev/null;
then
- cd $HOME
- $WGET $8
+ ( cd "$dest"; eval "$GET" "$url")
else
- cd $HOME
- $WGET $8
+ ( cd "$dest"; eval "$GET" "$url")
fi
diff --git a/examples/data/uzbl/scripts/formfiller.pl b/examples/data/uzbl/scripts/formfiller.pl
index 9ac6959..23da347 100755
--- a/examples/data/uzbl/scripts/formfiller.pl
+++ b/examples/data/uzbl/scripts/formfiller.pl
@@ -7,7 +7,7 @@
# user arg 1:
# edit: force editing of the file (fetches if file is missing)
# load: fill forms from file (fetches if file is missing)
-# new: fetch new file
+# new: fetch new file
# usage example:
# bind LL = spawn /usr/share/uzbl/examples/scripts/formfiller.pl load
diff --git a/examples/data/uzbl/scripts/history.sh b/examples/data/uzbl/scripts/history.sh
index ccc6b40..d726f9c 100755
--- a/examples/data/uzbl/scripts/history.sh
+++ b/examples/data/uzbl/scripts/history.sh
@@ -1,5 +1,6 @@
-#!/bin/bash
+#!/bin/sh
#TODO: strip 'http://' part
+
file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/history
[ -d `dirname $file` ] || exit 1
echo "$8 $6 $7" >> $file
diff --git a/examples/data/uzbl/scripts/insert_bookmark.sh b/examples/data/uzbl/scripts/insert_bookmark.sh
index 23c0d31..e04e6d4 100755
--- a/examples/data/uzbl/scripts/insert_bookmark.sh
+++ b/examples/data/uzbl/scripts/insert_bookmark.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
[ -d "${XDG_DATA_HOME:-$HOME/.local/share}/uzbl" ] || exit 1
file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/bookmarks
@@ -6,7 +6,8 @@ file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/bookmarks
which zenity &>/dev/null || exit 2
entry=`zenity --entry --text="Add bookmark. add tags after the '\t', separated by spaces" --entry-text="$6 $7\t"`
-url=`awk '{print $1}' <<< $entry`
+url=`echo $entry | awk '{print $1}'`
+
# TODO: check if already exists, if so, and tags are different: ask if you want to replace tags
echo "$entry" >/dev/null #for some reason we need this.. don't ask me why
echo -e "$entry" >> $file
diff --git a/examples/data/uzbl/scripts/linkfollow.js b/examples/data/uzbl/scripts/linkfollow.js
index a348af9..0eb629b 100644
--- a/examples/data/uzbl/scripts/linkfollow.js
+++ b/examples/data/uzbl/scripts/linkfollow.js
@@ -64,9 +64,9 @@ function Hints(){
}
function elementInViewport(p) {
- return (p.up < window.pageYOffset + window.innerHeight &&
- p.left < window.pageXOffset + window.innerWidth &&
- (p.up + p.height) > window.pageYOffset &&
+ return (p.up < window.pageYOffset + window.innerHeight &&
+ p.left < window.pageXOffset + window.innerWidth &&
+ (p.up + p.height) > window.pageYOffset &&
(p.left + p.width) > window.pageXOffset);
}
@@ -121,8 +121,8 @@ function Hints(){
this.node.className += " " + uzblclass;
}
this.isHinted = true;
-
- // create hint
+
+ // create hint
var hintNode = doc.createElement('div');
hintNode.name = uzblid;
hintNode.innerText = labelNum;
@@ -130,7 +130,7 @@ function Hints(){
hintNode.style.top = this.position.up + 'px';
hintNode.style.position = "absolute";
doc.body.firstChild.appendChild(hintNode);
-
+
}
this.removeHint = function(){
if(this.isHinted){
@@ -267,5 +267,3 @@ function Hints(){
var hints = new Hints();
// vim:set et sw=2:
-
-
diff --git a/examples/data/uzbl/scripts/load_url_from_bookmarks.sh b/examples/data/uzbl/scripts/load_url_from_bookmarks.sh
index 78ee726..f57d7b3 100755
--- a/examples/data/uzbl/scripts/load_url_from_bookmarks.sh
+++ b/examples/data/uzbl/scripts/load_url_from_bookmarks.sh
@@ -3,7 +3,7 @@
#NOTE: it's the job of the script that inserts bookmarks to make sure there are no dupes.
file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/bookmarks
-[ -r "$file" ] || exit
+[ -r "$file" ] || exit
COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030"
if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'
then
diff --git a/examples/data/uzbl/scripts/load_url_from_history.sh b/examples/data/uzbl/scripts/load_url_from_history.sh
index 57d634a..1eaf0f2 100755
--- a/examples/data/uzbl/scripts/load_url_from_history.sh
+++ b/examples/data/uzbl/scripts/load_url_from_history.sh
@@ -1,21 +1,24 @@
-#!/bin/bash
+#!/bin/sh
+
history_file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/history
[ -r "$history_file" ] || exit 1
# choose from all entries, sorted and uniqued
# goto=`awk '{print $3}' $history_file | sort -u | dmenu -i`
COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030"
-if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]'
+if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]';
then
DMENU="dmenu -i -xs -rs -l 10" # vertical patch
# choose an item in reverse order, showing also the date and page titles
# pick the last field from the first 3 fields. this way you can pick a url (prefixed with date & time) or type just a new url.
goto=`tac $history_file | $DMENU $COLORS | cut -d ' ' -f -3 | awk '{print $NF}'`
-else
+else
DMENU="dmenu -i"
# choose from all entries (no date or title), the first one being current url, and after that all others, sorted and uniqued, in ascending order
- current=`tail -n 1 $history_file | awk '{print $3}'`; goto=`(echo $current; awk '{print $3}' $history_file | grep -v "^$current\$" | sort -u) | $DMENU $COLORS`
-fi
+ current=`tail -n 1 $history_file | awk '{print $3}'`;
+ goto=`(echo $current; awk '{print $3}' $history_file | grep -v "^$current\$" \
+ | sort -u) | $DMENU $COLORS`
+fi
[ -n "$goto" ] && echo "uri $goto" > $4
#[ -n "$goto" ] && uzblctrl -s $5 -c "uri $goto"
diff --git a/examples/data/uzbl/scripts/session.sh b/examples/data/uzbl/scripts/session.sh
index 4dbae55..22d48a2 100755
--- a/examples/data/uzbl/scripts/session.sh
+++ b/examples/data/uzbl/scripts/session.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Very simple session manager for uzbl. When called with "endsession" as the
# argument, it'll backup $sessionfile, look for fifos in $fifodir and
@@ -26,7 +26,7 @@ fi
case $act in
"launch" )
- urls=$(cat $sessionfile)
+ urls=`cat $sessionfile`
if [ "$urls." = "." ]; then
$UZBL
else
@@ -60,4 +60,3 @@ case $act in
echo " endsession - Quit the running session. Must be called from uzbl"
;;
esac
-
diff --git a/examples/data/uzbl/scripts/uzbl_tabbed.py b/examples/data/uzbl/scripts/uzbl_tabbed.py
index 6ed902d..9de6fba 100755
--- a/examples/data/uzbl/scripts/uzbl_tabbed.py
+++ b/examples/data/uzbl/scripts/uzbl_tabbed.py
@@ -19,13 +19,13 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# Author(s):
+# Author(s):
# Tom Adams <tom@holizz.com>
# Wrote the original uzbl_tabbed.py as a proof of concept.
#
# Chris van Dijk (quigybo) <cn.vandijk@hotmail.com>
-# Made signifigant headway on the old uzbl_tabbing.py script on the
-# uzbl wiki <http://www.uzbl.org/wiki/uzbl_tabbed>
+# Made signifigant headway on the old uzbl_tabbing.py script on the
+# uzbl wiki <http://www.uzbl.org/wiki/uzbl_tabbed>
#
# Mason Larobina <mason.larobina@gmail.com>
# Rewrite of the uzbl_tabbing.py script to use a fifo socket interface
@@ -34,6 +34,9 @@
# Contributor(s):
# mxey <mxey@ghosthacking.net>
# uzbl_config path now honors XDG_CONFIG_HOME if it exists.
+#
+# Romain Bignon <romain@peerfuse.org>
+# Fix for session restoration code.
# Configuration:
@@ -43,12 +46,12 @@
# example values for each:
#
# General tabbing options:
-# show_tablist = 1
-# show_gtk_tabs = 0
-# tablist_top = 1
+# show_tablist = 1
+# show_gtk_tabs = 0
+# tablist_top = 1
# gtk_tab_pos = (top|left|bottom|right)
# switch_to_new_tabs = 1
-#
+#
# Tab title options:
# tab_titles = 1
# new_tab_title = Loading
@@ -58,19 +61,19 @@
# Core options:
# save_session = 1
# fifo_dir = /tmp
-# socket_dir = /tmp
+# socket_dir = /tmp
# icon_path = $HOME/.local/share/uzbl/uzbl.png
# session_file = $HOME/.local/share/uzbl/session
#
# Window options:
# status_background = #303030
# window_size = 800,800
-#
+#
# And the key bindings:
-# bind_new_tab = gn
+# bind_new_tab = gn
# bind_tab_from_clip = gY
# bind_tab_from_uri = go _
-# bind_close_tab = gC
+# bind_close_tab = gC
# bind_next_tab = gt
# bind_prev_tab = gT
# bind_goto_tab = gi_
@@ -78,9 +81,9 @@
# bind_goto_last = g>
#
# And uzbl_tabbed.py takes care of the actual binding of the commands via each
-# instances fifo socket.
+# instances fifo socket.
#
-# Custom tab styling:
+# Custom tab styling:
# tab_colours = foreground = "#888" background = "#303030"
# tab_text_colours = foreground = "#bbb"
# selected_tab = foreground = "#fff"
@@ -93,30 +96,30 @@
#
# How these styling values are used are soley defined by the syling policy
# handler below (the function in the config section). So you can for example
-# turn the tab text colour Firetruck-Red in the event "error" appears in the
+# turn the tab text colour Firetruck-Red in the event "error" appears in the
# tab title or some other arbitrary event. You may wish to make a trusted
-# hosts file and turn tab titles of tabs visiting trusted hosts purple.
+# hosts file and turn tab titles of tabs visiting trusted hosts purple.
-# Issues:
+# Issues:
# - new windows are not caught and opened in a new tab.
# - when uzbl_tabbed.py crashes it takes all the children with it.
-# - when a new tab is opened when using gtk tabs the tab button itself
-# grabs focus from its child for a few seconds.
-# - when switch_to_new_tabs is not selected the notebook page is
+# - when a new tab is opened when using gtk tabs the tab button itself
+# grabs focus from its child for a few seconds.
+# - when switch_to_new_tabs is not selected the notebook page is
# maintained but the new window grabs focus (try as I might to stop it).
-# Todo:
+# Todo:
# - add command line options to use a different session file, not use a
-# session file and or open a uri on starup.
+# session file and or open a uri on starup.
# - ellipsize individual tab titles when the tab-list becomes over-crowded
-# - add "<" & ">" arrows to tablist to indicate that only a subset of the
+# - add "<" & ">" arrows to tablist to indicate that only a subset of the
# currently open tabs are being displayed on the tablist.
# - add the small tab-list display when both gtk tabs and text vim-like
# tablist are hidden (I.e. [ 1 2 3 4 5 ])
# - check spelling.
-# - pass a uzbl socketid to uzbl_tabbed.py and have it assimilated into
+# - pass a uzbl socketid to uzbl_tabbed.py and have it assimilated into
# the collective. Resistance is futile!
# - on demand store the session to file (need binding & command for that)
@@ -146,7 +149,7 @@ def error(msg):
# ::: Default configuration section ::::::::::::::::::::::::::::::::::::::::::
# ============================================================================
-# Location of your uzbl data directory.
+# Location of your uzbl data directory.
if 'XDG_DATA_HOME' in os.environ.keys() and os.environ['XDG_DATA_HOME']:
data_dir = os.path.join(os.environ['XDG_DATA_HOME'], 'uzbl/')
else:
@@ -163,14 +166,14 @@ if not os.path.exists(uzbl_config):
error("Warning: Cannot locate your uzbl_config file %r" % uzbl_config)
# All of these settings can be inherited from your uzbl config file.
-config = {
+config = {
# Tab options
'show_tablist': True, # Show text uzbl like statusbar tab-list
'show_gtk_tabs': False, # Show gtk notebook tabs
'tablist_top': True, # Display tab-list at top of window
'gtk_tab_pos': 'top', # Gtk tab position (top|left|bottom|right)
'switch_to_new_tabs': True, # Upon opening a new tab switch to it
-
+
# Tab title options
'tab_titles': True, # Display tab titles (else only tab-nums)
'new_tab_title': 'Loading', # New tab title
@@ -180,53 +183,53 @@ config = {
# Core options
'save_session': True, # Save session in file when quit
'fifo_dir': '/tmp', # Path to look for uzbl fifo
- 'socket_dir': '/tmp', # Path to look for uzbl socket
+ 'socket_dir': '/tmp', # Path to look for uzbl socket
'icon_path': os.path.join(data_dir, 'uzbl.png'),
'session_file': os.path.join(data_dir, 'session'),
# Window options
'status_background': "#303030", # Default background for all panels
'window_size': "800,800", # width,height in pixels
-
+
# Key bindings.
- 'bind_new_tab': 'gn', # Open new tab.
+ 'bind_new_tab': 'gn', # Open new tab.
'bind_tab_from_clip': 'gY', # Open tab from clipboard.
'bind_tab_from_uri': 'go _', # Open new tab and goto entered uri.
- 'bind_close_tab': 'gC', # Close tab.
+ 'bind_close_tab': 'gC', # Close tab.
'bind_next_tab': 'gt', # Next tab.
'bind_prev_tab': 'gT', # Prev tab.
'bind_goto_tab': 'gi_', # Goto tab by tab-number (in title)
'bind_goto_first': 'g<', # Goto first tab
'bind_goto_last': 'g>', # Goto last tab
-
- # Add custom tab style definitions to be used by the tab colour policy
+
+ # Add custom tab style definitions to be used by the tab colour policy
# handler here. Because these are added to the config dictionary like
- # any other uzbl_tabbed configuration option remember that they can
- # be superseeded from your main uzbl config file.
+ # any other uzbl_tabbed configuration option remember that they can
+ # be superseeded from your main uzbl config file.
'tab_colours': 'foreground = "#888" background = "#303030"',
- 'tab_text_colours': 'foreground = "#bbb"',
+ 'tab_text_colours': 'foreground = "#bbb"',
'selected_tab': 'foreground = "#fff"',
'selected_tab_text': 'foreground = "green"',
'tab_indicate_https': True,
'https_colours': 'foreground = "#888"',
- 'https_text_colours': 'foreground = "#9c8e2d"',
+ 'https_text_colours': 'foreground = "#9c8e2d"',
'selected_https': 'foreground = "#fff"',
'selected_https_text': 'foreground = "gold"',
-
+
} # End of config dict.
-# This is the tab style policy handler. Every time the tablist is updated
+# This is the tab style policy handler. Every time the tablist is updated
# this function is called to determine how to colourise that specific tab
-# according the simple/complex rules as defined here. You may even wish to
+# according the simple/complex rules as defined here. You may even wish to
# move this function into another python script and import it using:
# from mycustomtabbingconfig import colour_selector
# Remember to rename, delete or comment out this function if you do that.
def colour_selector(tabindex, currentpage, uzbl):
- '''Tablist styling policy handler. This function must return a tuple of
+ '''Tablist styling policy handler. This function must return a tuple of
the form (tab style, text style).'''
-
- # Just as an example:
+
+ # Just as an example:
# if 'error' in uzbl.title:
# if tabindex == currentpage:
# return ('foreground="#fff"', 'foreground="red"')
@@ -239,11 +242,11 @@ def colour_selector(tabindex, currentpage, uzbl):
return (config['https_colours'], config['https_text_colours'])
# Style to indicate selected.
- if tabindex == currentpage:
+ if tabindex == currentpage:
return (config['selected_tab'], config['selected_tab_text'])
# Default tab style.
- return (config['tab_colours'], config['tab_text_colours'])
+ return (config['tab_colours'], config['tab_text_colours'])
# ============================================================================
@@ -258,38 +261,26 @@ def readconfig(uzbl_config, config):
if not os.path.exists(uzbl_config):
error("Unable to load config %r" % uzbl_config)
return None
-
+
# Define parsing regular expressions
isint = re.compile("^(\-|)[0-9]+$").match
findsets = re.compile("^set\s+([^\=]+)\s*\=\s*(.+)$",\
re.MULTILINE).findall
-
+
h = open(os.path.expandvars(uzbl_config), 'r')
rawconfig = h.read()
h.close()
-
+
for (key, value) in findsets(rawconfig):
key, value = key.strip(), value.strip()
if key not in config.keys(): continue
if isint(value): value = int(value)
config[key] = value
-
+
# Ensure that config keys that relate to paths are expanded.
expand = ['fifo_dir', 'socket_dir', 'session_file', 'icon_path']
for key in expand:
- config[key] = os.path.expandvars(config[key])
-
-
-def rmkdir(path):
- '''Recursively make directories.
- I.e. `mkdir -p /some/nonexistant/path/`'''
-
- path, sep = os.path.realpath(path), os.path.sep
- dirs = path.split(sep)
- for i in range(2,len(dirs)+1):
- dir = os.path.join(sep,sep.join(dirs[:i]))
- if not os.path.exists(dir):
- os.mkdir(dir)
+ config[key] = os.path.expandvars(config[key])
def counter():
@@ -301,6 +292,14 @@ def counter():
yield i
+def escape(s):
+ '''Replaces html markup in tab titles that screw around with pango.'''
+
+ for (split, glue) in [('&','&amp;'), ('<', '&lt;'), ('>', '&gt;')]:
+ s = s.replace(split, glue)
+ return s
+
+
def gen_endmarker():
'''Generates a random md5 for socket message-termination endmarkers.'''
@@ -310,14 +309,14 @@ def gen_endmarker():
class UzblTabbed:
'''A tabbed version of uzbl using gtk.Notebook'''
- class UzblInstance:
+ class UzblInstance:
'''Uzbl instance meta-data/meta-action object.'''
def __init__(self, parent, tab, fifo_socket, socket_file, pid,\
uri, switch):
self.parent = parent
- self.tab = tab
+ self.tab = tab
self.fifo_socket = fifo_socket
self.socket_file = socket_file
self.pid = pid
@@ -331,12 +330,12 @@ class UzblTabbed:
self._buffer = ""
# Switch to tab after loading
self._switch = switch
- # fifo/socket files exists and socket connected.
+ # fifo/socket files exists and socket connected.
self._connected = False
# The kill switch
self._kill = False
- # Message termination endmarker.
+ # Message termination endmarker.
self._marker = gen_endmarker()
# Gen probe commands string
@@ -346,16 +345,16 @@ class UzblTabbed:
probe('print title %d @<document.title>@ %s' % (self.pid,\
self._marker))
self._probecmds = '\n'.join(probes)
-
+
# Enqueue keybinding config for child uzbl instance
self.parent.config_uzbl(self)
def flush(self, timer_call=False):
'''Flush messages from the socket-out and fifo-out queues.'''
-
+
if self._kill:
- if self._socket:
+ if self._socket:
self._socket.close()
self._socket = None
@@ -369,7 +368,7 @@ class UzblTabbed:
msg = self._fifoout.pop(0)
h.write("%s\n"%msg)
h.close()
-
+
if len(self._socketout):
if not self._socket and os.path.exists(self.socket_file):
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
@@ -380,11 +379,11 @@ class UzblTabbed:
while len(self._socketout):
msg = self._socketout.pop(0)
self._socket.send("%s\n"%msg)
-
+
if not self._connected and timer_call:
if not len(self._fifoout + self._socketout):
self._connected = True
-
+
if timer_call in self.timers.keys():
gobject.source_remove(self.timers[timer_call])
del self.timers[timer_call]
@@ -394,10 +393,10 @@ class UzblTabbed:
return len(self._fifoout + self._socketout)
-
+
def grabfocus(self):
'''Steal parent focus and switch the notebook to my own tab.'''
-
+
tabs = list(self.parent.notebook)
tabid = tabs.index(self.tab)
self.parent.goto_tab(tabid)
@@ -405,7 +404,7 @@ class UzblTabbed:
def probe(self):
'''Probes the client for information about its self.'''
-
+
if self._connected:
self.send(self._probecmds)
self._lastprobe = time.time()
@@ -425,16 +424,16 @@ class UzblTabbed:
self._socketout.append(msg)
# Flush messages from queue if able.
return self.flush()
-
+
def __init__(self):
'''Create tablist, window and notebook.'''
-
+
self._fifos = {}
self._timers = {}
self._buffer = ""
-
- # Once a second is updated with the latest tabs' uris so that when the
+
+ # Once a second is updated with the latest tabs' uris so that when the
# window is killed the session is saved.
self._tabsuris = []
# And index of current page in self._tabsuris
@@ -442,13 +441,13 @@ class UzblTabbed:
# Holds metadata on the uzbl childen open.
self.tabs = {}
-
+
# Generates a unique id for uzbl socket filenames.
self.next_pid = counter().next
-
+
# Create main window
self.window = gtk.Window()
- try:
+ try:
window_size = map(int, config['window_size'].split(','))
self.window.set_default_size(*window_size)
@@ -457,7 +456,7 @@ class UzblTabbed:
self.window.set_title("Uzbl Browser")
self.window.set_border_width(0)
-
+
# Set main window icon
icon_path = config['icon_path']
if os.path.exists(icon_path):
@@ -467,11 +466,11 @@ class UzblTabbed:
icon_path = '/usr/share/uzbl/examples/data/uzbl/uzbl.png'
if os.path.exists(icon_path):
self.window.set_icon(gtk.gdk.pixbuf_new_from_file(icon_path))
-
+
# Attach main window event handlers
self.window.connect("delete-event", self.quit)
-
- # Create tab list
+
+ # Create tab list
if config['show_tablist']:
vbox = gtk.VBox()
self.window.add(vbox)
@@ -490,13 +489,13 @@ class UzblTabbed:
ebox.show()
bgcolor = gtk.gdk.color_parse(config['status_background'])
ebox.modify_bg(gtk.STATE_NORMAL, bgcolor)
-
+
# Create notebook
self.notebook = gtk.Notebook()
self.notebook.set_show_tabs(config['show_gtk_tabs'])
# Set tab position
- allposes = {'left': gtk.POS_LEFT, 'right':gtk.POS_RIGHT,
+ allposes = {'left': gtk.POS_LEFT, 'right':gtk.POS_RIGHT,
'top':gtk.POS_TOP, 'bottom':gtk.POS_BOTTOM}
if config['gtk_tab_pos'] in allposes.keys():
self.notebook.set_tab_pos(allposes[config['gtk_tab_pos']])
@@ -523,10 +522,10 @@ class UzblTabbed:
else:
self.window.add(self.notebook)
-
+
self.window.show()
self.wid = self.notebook.window.xid
-
+
# Create the uzbl_tabbed fifo
fifo_filename = 'uzbltabbed_%d' % os.getpid()
self.fifo_socket = os.path.join(config['fifo_dir'], fifo_filename)
@@ -535,7 +534,7 @@ class UzblTabbed:
def _create_fifo_socket(self, fifo_socket):
- '''Create interprocess communication fifo socket.'''
+ '''Create interprocess communication fifo socket.'''
if os.path.exists(fifo_socket):
if not os.access(fifo_socket, os.F_OK | os.R_OK | os.W_OK):
@@ -544,9 +543,10 @@ class UzblTabbed:
else:
basedir = os.path.dirname(self.fifo_socket)
if not os.path.exists(basedir):
- rmkdir(basedir)
+ os.makedirs(basedir)
+
os.mkfifo(self.fifo_socket)
-
+
print "Listening on %s" % self.fifo_socket
@@ -563,22 +563,22 @@ class UzblTabbed:
del watchers[watcherid]
del self._fifos[fifo_socket]
-
+
# Re-open fifo and add listeners.
fd = os.open(fifo_socket, os.O_RDONLY | os.O_NONBLOCK)
watchers = {}
self._fifos[fifo_socket] = (fd, watchers)
watcher = lambda key, id: watchers.__setitem__(key, id)
-
+
# Watch for incoming data.
gid = gobject.io_add_watch(fd, gobject.IO_IN, self.main_fifo_read)
watcher('main-fifo-read', gid)
-
+
# Watch for fifo hangups.
gid = gobject.io_add_watch(fd, gobject.IO_HUP, self.main_fifo_hangup)
watcher('main-fifo-hangup', gid)
-
-
+
+
def run(self):
'''UzblTabbed main function that calls the gtk loop.'''
@@ -586,7 +586,7 @@ class UzblTabbed:
#timer = "update-tablist"
#timerid = gobject.timeout_add(500, self.update_tablist,timer)
#self._timers[timer] = timerid
-
+
# Probe clients every second for window titles and location
timer = "probe-clients"
timerid = gobject.timeout_add(1000, self.probe_clients, timer)
@@ -597,7 +597,7 @@ class UzblTabbed:
def probe_clients(self, timer_call):
'''Probe all uzbl clients for up-to-date window titles and uri's.'''
-
+
sockd = {}
uriinventory = []
tabskeys = self.tabs.keys()
@@ -616,7 +616,7 @@ class UzblTabbed:
sockets = sockd.keys()
(reading, _, errors) = select.select(sockets, [], sockets, 0)
-
+
for sock in reading:
uzbl = sockd[sock]
uzbl._buffer = sock.recv(1024).replace('\n',' ')
@@ -637,7 +637,7 @@ class UzblTabbed:
def main_fifo_hangup(self, fd, cb_condition):
'''Handle main fifo socket hangups.'''
-
+
# Close fd, re-open fifo_socket and watch.
self._setup_fifo_watcher(self.fifo_socket)
@@ -661,28 +661,28 @@ class UzblTabbed:
except:
error("parse_command: invalid command %s" % ' '.join(cmd))
raise
-
+
return True
def parse_command(self, cmd):
'''Parse instructions from uzbl child processes.'''
-
- # Commands ( [] = optional, {} = required )
+
+ # Commands ( [] = optional, {} = required )
# new [uri]
- # open new tab and head to optional uri.
- # close [tab-num]
+ # open new tab and head to optional uri.
+ # close [tab-num]
# close current tab or close via tab id.
# next [n-tabs]
# open next tab or n tabs down. Supports negative indexing.
# prev [n-tabs]
# open prev tab or n tabs down. Supports negative indexing.
# goto {tab-n}
- # goto tab n.
+ # goto tab n.
# first
# goto first tab.
# last
- # goto last tab.
+ # goto last tab.
# title {pid} {document-title}
# updates tablist title.
# uri {pid} {document-location}
@@ -710,7 +710,7 @@ class UzblTabbed:
elif cmd[0] == "next":
if len(cmd) == 2:
self.next_tab(int(cmd[1]))
-
+
else:
self.next_tab()
@@ -720,7 +720,7 @@ class UzblTabbed:
else:
self.prev_tab()
-
+
elif cmd[0] == "goto":
self.goto_tab(int(cmd[1]))
@@ -744,7 +744,7 @@ class UzblTabbed:
else:
error("parse_command: unknown command %r" % ' '.join(cmd))
-
+
def get_tab_by_pid(self, pid):
'''Return uzbl instance by pid.'''
@@ -753,25 +753,25 @@ class UzblTabbed:
return self.tabs[tab]
return False
-
+
def new_tab(self, uri='', switch=None):
'''Add a new tab to the notebook and start a new instance of uzbl.
- Use the switch option to negate config['switch_to_new_tabs'] option
- when you need to load multiple tabs at a time (I.e. like when
+ Use the switch option to negate config['switch_to_new_tabs'] option
+ when you need to load multiple tabs at a time (I.e. like when
restoring a session from a file).'''
-
+
pid = self.next_pid()
tab = gtk.Socket()
tab.show()
self.notebook.append_page(tab)
sid = tab.get_id()
-
+
fifo_filename = 'uzbl_fifo_%s_%0.2d' % (self.wid, pid)
fifo_socket = os.path.join(config['fifo_dir'], fifo_filename)
socket_filename = 'uzbl_socket_%s_%0.2d' % (self.wid, pid)
socket_file = os.path.join(config['socket_dir'], socket_filename)
-
+
if switch is None:
switch = config['switch_to_new_tabs']
@@ -785,26 +785,26 @@ class UzblTabbed:
self.tabs[tab] = uzbl
cmd = 'uzbl -s %s -n %s_%0.2d %s &' % (sid, self.wid, pid, uri)
subprocess.Popen([cmd], shell=True) # TODO: do i need close_fds=True ?
-
+
# Add gobject timer to make sure the config is pushed when fifo socket
- # has been created.
+ # has been created.
timerid = gobject.timeout_add(100, uzbl.flush, "flush-initial-config")
uzbl.timers['flush-initial-config'] = timerid
-
+
self.update_tablist()
def config_uzbl(self, uzbl):
- '''Send bind commands for tab new/close/next/prev to a uzbl
+ '''Send bind commands for tab new/close/next/prev to a uzbl
instance.'''
binds = []
bind_format = 'bind %s = sh "echo \\\"%s\\\" > \\\"%s\\\""'
bind = lambda key, action: binds.append(bind_format % (key, action, \
self.fifo_socket))
-
+
# Keys are defined in the config section
- # bind ( key , command back to fifo )
+ # bind ( key , command back to fifo )
bind(config['bind_new_tab'], 'new')
bind(config['bind_tab_from_clip'], 'newfromclip')
bind(config['bind_tab_from_uri'], 'new %s')
@@ -815,38 +815,38 @@ class UzblTabbed:
bind(config['bind_goto_first'], 'goto 0')
bind(config['bind_goto_last'], 'goto -1')
- # uzbl.send via socket or uzbl.write via fifo, I'll try send.
+ # uzbl.send via socket or uzbl.write via fifo, I'll try send.
uzbl.send("\n".join(binds))
def goto_tab(self, index):
'''Goto tab n (supports negative indexing).'''
-
+
tabs = list(self.notebook)
if 0 <= index < len(tabs):
self.notebook.set_current_page(index)
self.update_tablist()
return None
- try:
+ try:
tab = tabs[index]
# Update index because index might have previously been a
- # negative index.
+ # negative index.
index = tabs.index(tab)
self.notebook.set_current_page(index)
self.update_tablist()
-
+
except IndexError:
pass
def next_tab(self, step=1):
'''Switch to next tab or n tabs right.'''
-
+
if step < 1:
error("next_tab: invalid step %r" % step)
return None
-
+
ntabs = self.notebook.get_n_pages()
tabn = (self.notebook.get_current_page() + step) % ntabs
self.notebook.set_current_page(tabn)
@@ -855,7 +855,7 @@ class UzblTabbed:
def prev_tab(self, step=1):
'''Switch to prev tab or n tabs left.'''
-
+
if step < 1:
error("prev_tab: invalid step %r" % step)
return None
@@ -869,24 +869,24 @@ class UzblTabbed:
def close_tab(self, tabn=None):
'''Closes current tab. Supports negative indexing.'''
-
- if tabn is None:
+
+ if tabn is None:
tabn = self.notebook.get_current_page()
-
+
else:
- try:
+ try:
tab = list(self.notebook)[tabn]
-
+
except IndexError:
error("close_tab: invalid index %r" % tabn)
return None
self.notebook.remove_page(tabn)
-
+
def tab_opened(self, notebook, tab, index):
'''Called upon tab creation. Called by page-added signal.'''
-
+
if config['switch_to_new_tabs']:
self.notebook.set_focus_child(tab)
@@ -897,15 +897,15 @@ class UzblTabbed:
def tab_closed(self, notebook, tab, index):
- '''Close the window if no tabs are left. Called by page-removed
+ '''Close the window if no tabs are left. Called by page-removed
signal.'''
-
+
if tab in self.tabs.keys():
uzbl = self.tabs[tab]
for timer in uzbl.timers.keys():
error("tab_closed: removing timer %r" % timer)
gobject.source_remove(uzbl.timers[timer])
-
+
if uzbl._socket:
uzbl._socket.close()
uzbl._socket = None
@@ -914,7 +914,7 @@ class UzblTabbed:
uzbl._socketout = []
uzbl._kill = True
del self.tabs[tab]
-
+
if self.notebook.get_n_pages() == 0:
self.quit()
@@ -925,7 +925,7 @@ class UzblTabbed:
def tab_changed(self, notebook, page, index):
'''Refresh tab list. Called by switch-page signal.'''
-
+
tab = self.notebook.get_nth_page(index)
self.notebook.set_focus_child(tab)
self.update_tablist(index)
@@ -934,7 +934,7 @@ class UzblTabbed:
def update_tablist(self, curpage=None):
'''Upate tablist status bar.'''
-
+
show_tablist = config['show_tablist']
show_gtk_tabs = config['show_gtk_tabs']
tab_titles = config['tab_titles']
@@ -957,17 +957,17 @@ class UzblTabbed:
tab_format = "<span %s> [ %d <span %s> %s</span> ] </span>"
else:
tab_format = "<span %s> [ <span %s>%d</span> ] </span>"
-
+
if show_gtk_tabs:
gtk_tab_format = "%d %s"
for index, tab in enumerate(self.notebook):
if tab not in tabs: continue
uzbl = self.tabs[tab]
-
+
if index == curpage:
self.window.set_title(title_format % uzbl.title)
-
+
tabtitle = uzbl.title[:max_title_len]
if show_ellipsis and len(tabtitle) != len(uzbl.title):
tabtitle = "%s\xe2\x80\xa6" % tabtitle[:-1] # Show Ellipsis
@@ -984,10 +984,11 @@ class UzblTabbed:
(tabc, textc) = style
if tab_titles:
- pango += tab_format % (tabc, index, textc, tabtitle)
+ pango += tab_format % (tabc, index, textc,\
+ escape(tabtitle))
else:
pango += tab_format % (tabc, textc, index)
-
+
if show_tablist:
self.tablist.set_markup(pango)
@@ -996,7 +997,7 @@ class UzblTabbed:
def quit(self, *args):
'''Cleanup the application and quit. Called by delete-event signal.'''
-
+
for fifo_socket in self._fifos.keys():
fd, watchers = self._fifos[fifo_socket]
os.close(fd)
@@ -1005,7 +1006,7 @@ class UzblTabbed:
del watchers[watcherid]
del self._fifos[fifo_socket]
-
+
for timerid in self._timers.keys():
gobject.source_remove(self._timers[timerid])
del self._timers[timerid]
@@ -1020,29 +1021,28 @@ class UzblTabbed:
if not os.path.isfile(session_file):
dirname = os.path.dirname(session_file)
if not os.path.isdir(dirname):
- # Recursive mkdir not rmdir.
- rmkdir(dirname)
-
+ os.makedirs(dirname)
+
sessionstr = '\n'.join(self._tabsuris)
h = open(session_file, 'w')
h.write('current = %s\n%s' % (self._curpage, sessionstr))
h.close()
-
+
else:
# Notebook has no pages so delete session file if it exists.
if os.path.isfile(session_file):
os.remove(session_file)
- gtk.main_quit()
+ gtk.main_quit()
if __name__ == "__main__":
-
- # Read from the uzbl config into the global config dictionary.
+
+ # Read from the uzbl config into the global config dictionary.
readconfig(uzbl_config, config)
-
+
uzbl = UzblTabbed()
-
+
if os.path.isfile(os.path.expandvars(config['session_file'])):
h = open(os.path.expandvars(config['session_file']),'r')
lines = [line.strip() for line in h.readlines()]
@@ -1059,16 +1059,14 @@ if __name__ == "__main__":
for (index, url) in enumerate(urls):
if current == index:
uzbl.new_tab(line, True)
-
- else:
+
+ else:
uzbl.new_tab(line, False)
if not len(urls):
- self.new_tab()
+ uzbl.new_tab()
else:
uzbl.new_tab()
uzbl.run()
-
-
diff --git a/examples/data/uzbl/scripts/uzblcat b/examples/data/uzbl/scripts/uzblcat
index 82341c7..5c3063e 100755
--- a/examples/data/uzbl/scripts/uzblcat
+++ b/examples/data/uzbl/scripts/uzblcat
@@ -2,15 +2,15 @@
# uzblcat - safely push html to uzbl
# See http://www.uzbl.org/wiki/html-mode
use strict; use warnings;
-
+
my $html;
local $/; # slurp files
# automagically choose to read from stdin/files/...
$html .= $_ for <>;
-
+
my $endmarker = rand;
$endmarker .= rand() while $html =~ /^\Q$endmarker\E$/m;
-
+
print "set base_url = $ENV{BASE_URL}\n" if $ENV{BASE_URL};
print << "EOS";
set html_endmarker = $endmarker
diff --git a/examples/data/uzbl/scripts/yank.sh b/examples/data/uzbl/scripts/yank.sh
index ee140c7..376b7e2 100755
--- a/examples/data/uzbl/scripts/yank.sh
+++ b/examples/data/uzbl/scripts/yank.sh
@@ -1,3 +1,4 @@
+#!/bin/sh
# use this script to pipe any variable to xclip, so you have it in your clipboard
# in your uzbl config, make the first argument the number of the (later) argument you want to use (see README for list of args)
# make the 2nd argument one of : primary, secondary, clipboard.
@@ -5,8 +6,12 @@
# bind yurl = spawn ./examples/scripts/yank.sh 6 primary
# bind ytitle = spawn ./examples/scripts/yank.sh 7 clipboard
-which xclip &>/dev/null || exit 1
-[ "$9" == primary -o "$9" == secondary -o "$9" == clipboard ] || exit 2
+clip=xclip
-echo echo -n "${!8}" '|' xclip -selection $9
-echo -n "${!8}" | xclip -selection $9
+which $clip &>/dev/null || exit 1
+[ "x$9" = xprimary -o "x$9" = xsecondary -o "x$9" = xclipboard ] || exit 2
+
+value=`eval "echo -n \\${$8}"` # bash: value = ${!8}
+
+echo "echo -n '${value}' | $clip -selection $9"
+echo -n "'${value}' | $clip -selection $9"
diff --git a/examples/data/uzbl/style.css b/examples/data/uzbl/style.css
index de0a38b..f9b111e 100644
--- a/examples/data/uzbl/style.css
+++ b/examples/data/uzbl/style.css
@@ -5,7 +5,7 @@
border-width: thin;
}
-#uzbl_hint > div {
+#uzbl_hint > div {
display: inline;
border: 2px solid #4a6600;
background-color: #b9ff00;
@@ -23,4 +23,3 @@
}
/* vim:set et ts=4: */
-
diff --git a/tests/Makefile b/tests/Makefile
index 7901b7d..9db398a 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,5 +1,8 @@
CFLAGS:=-std=c99 -I$(shell pwd)/../ -L$(shell pwd) -luzbl $(shell pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0) -ggdb -Wall -W -DARCH="\"$(shell uname -m)\"" -lgthread-2.0 -DG_ERRORCHECK_MUTEXES -DCOMMIT="\"$(shell git log | head -n1 | sed "s/.* //")\"" $(CPPFLAGS)
+CFLAGS!=echo -std=c99 `pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0` -ggdb -Wall -W -DARCH='"\""'`uname -m`'"\""' -lgthread-2.0 -DG_ERRORCHECK_MUTEXES -DCOMMIT='"\""'`git log | head -n1 | sed "s/.* //"`'"\""' $(CPPFLAGS)
+
LDFLAGS:=$(shell pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0) -pthread $(LDFLAGS)
+LDFLAGS!=echo `pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0` -pthread $(LDFLAGS)
GTESTER:=gtester
GTESTER_REPORT:=gtester-report
diff --git a/tests/test-expand.c b/tests/test-expand.c
index 07e3fea..2299227 100644
--- a/tests/test-expand.c
+++ b/tests/test-expand.c
@@ -111,7 +111,7 @@ test_ARCH_UZBL (void) {
void
test_COMMIT (void) {
- g_assert_cmpstr(expand("@COMMIT", 0), ==, COMMIT);
+ g_assert_cmpstr(expand("@COMMIT", 0), ==, uzbl.info.commit);
}
void
@@ -154,7 +154,7 @@ test_cmd_useragent_full (void) {
g_string_append(expected, " [");
g_string_append(expected, ARCH);
g_string_append(expected, "]) (Commit ");
- g_string_append(expected, COMMIT);
+ g_string_append(expected, uzbl.info.commit);
g_string_append(expected, ")");
set_var_value("useragent", "Uzbl (Webkit @WEBKIT_MAJOR.@WEBKIT_MINOR.@WEBKIT_MICRO) (@(uname -s)@ @(uname -n)@ @(uname -r)@ @(uname -v)@ @(uname -m)@ [@ARCH_UZBL]) (Commit @COMMIT)");
diff --git a/uzbl.c b/uzbl.c
index 8390a47..cc5f125 100644
--- a/uzbl.c
+++ b/uzbl.c
@@ -59,23 +59,21 @@
Uzbl uzbl;
-
-
/* commandline arguments (set initial values for the state variables) */
-static const
+const
GOptionEntry entries[] =
{
{ "uri", 'u', 0, G_OPTION_ARG_STRING, &uzbl.state.uri,
- "Uri to load at startup (equivalent to 'set uri = URI')", "URI" },
+ "Uri to load at startup (equivalent to 'uzbl <uri>' or 'set uri = URI' after uzbl has launched)", "URI" },
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &uzbl.state.verbose,
"Whether to print all messages or just errors.", NULL },
- { "name", 'n', 0, G_OPTION_ARG_STRING, &uzbl.state.instance_name,
+ { "name", 'n', 0, G_OPTION_ARG_STRING, &uzbl.state.instance_name,
"Name of the current instance (defaults to Xorg window id)", "NAME" },
- { "config", 'c', 0, G_OPTION_ARG_STRING, &uzbl.state.config_file,
- "Config file (this is pretty much equivalent to uzbl < FILE )", "FILE" },
- { "socket", 's', 0, G_OPTION_ARG_INT, &uzbl.state.socket_id,
+ { "config", 'c', 0, G_OPTION_ARG_STRING, &uzbl.state.config_file,
+ "Path to config file or '-' for stdin", "FILE" },
+ { "socket", 's', 0, G_OPTION_ARG_INT, &uzbl.state.socket_id,
"Socket ID", "SOCKET" },
- { "geometry", 'g', 0, G_OPTION_ARG_STRING, &uzbl.gui.geometry,
+ { "geometry", 'g', 0, G_OPTION_ARG_STRING, &uzbl.gui.geometry,
"Set window geometry (format: WIDTHxHEIGHT+-X+-Y)", "GEOMETRY" },
{ "version", 'V', 0, G_OPTION_ARG_NONE, &uzbl.behave.print_version,
"Print the version and exit", NULL },
@@ -84,6 +82,8 @@ GOptionEntry entries[] =
/* associate command names to their properties */
typedef const struct {
+ /* TODO: Make this ambiguous void **ptr into a union { char *char_p; int *int_p; float *float_p; } val;
+ the PTR() macro is kind of preventing this change at the moment. */
void **ptr;
int type;
int dump;
@@ -119,8 +119,8 @@ const struct {
{ "status_pbar_pending", PTR_V(uzbl.gui.sbar.progress_u, STR, 1, update_title)},
{ "status_pbar_width", PTR_V(uzbl.gui.sbar.progress_w, INT, 1, update_title)},
{ "status_background", PTR_V(uzbl.behave.status_background, STR, 1, update_title)},
- { "insert_indicator", PTR_V(uzbl.behave.insert_indicator, STR, 1, update_title)},
- { "command_indicator", PTR_V(uzbl.behave.cmd_indicator, STR, 1, update_title)},
+ { "insert_indicator", PTR_V(uzbl.behave.insert_indicator, STR, 1, update_indicator)},
+ { "command_indicator", PTR_V(uzbl.behave.cmd_indicator, STR, 1, update_indicator)},
{ "title_format_long", PTR_V(uzbl.behave.title_format_long, STR, 1, update_title)},
{ "title_format_short", PTR_V(uzbl.behave.title_format_short, STR, 1, update_title)},
{ "icon", PTR_V(uzbl.gui.icon, STR, 1, set_icon)},
@@ -203,8 +203,7 @@ const struct {
};
-/* construct a hash from the var_name_to_ptr and the const_name_to_ptr array
- * for quick access */
+/* construct a hash from the var_name_to_ptr array for quick access */
void
make_var_to_name_hash() {
uzbl.comm.proto_var = g_hash_table_new(g_str_hash, g_str_equal);
@@ -215,9 +214,8 @@ make_var_to_name_hash() {
}
/* --- UTILITY FUNCTIONS --- */
-
enum {EXP_ERR, EXP_SIMPLE_VAR, EXP_BRACED_VAR, EXP_EXPR, EXP_JS, EXP_ESCAPE};
-static guint
+guint
get_exp_type(gchar *s) {
/* variables */
if(*(s+1) == '(')
@@ -308,9 +306,10 @@ expand(char *s, guint recurse) {
if(c->type == TYPE_STR && *c->ptr != NULL) {
g_string_append(buf, (gchar *)*c->ptr);
} else if(c->type == TYPE_INT) {
- char *b = itos((uintptr_t)*c->ptr);
- g_string_append(buf, b);
- g_free(b);
+ g_string_append_printf(buf, "%d", (int)*c->ptr);
+ }
+ else if(c->type == TYPE_FLOAT) {
+ g_string_append_printf(buf, "%f", *(float *)c->ptr);
}
}
@@ -383,13 +382,13 @@ itos(int val) {
return g_strdup(tmp);
}
-static gchar*
+gchar*
strfree(gchar *str) { g_free(str); return NULL; } // for freeing & setting to null in one go
-static gchar*
+gchar*
argv_idx(const GArray *a, const guint idx) { return g_array_index(a, gchar*, idx); }
-static char *
+char *
str_replace (const char* search, const char* replace, const char* string) {
gchar **buf;
char *ret;
@@ -401,7 +400,7 @@ str_replace (const char* search, const char* replace, const char* string) {
return ret;
}
-static GArray*
+GArray*
read_file_by_line (gchar *path) {
GIOChannel *chan = NULL;
gchar *readbuf = NULL;
@@ -427,8 +426,8 @@ read_file_by_line (gchar *path) {
return lines;
}
-static
-gchar* parseenv (char* string) {
+gchar*
+parseenv (char* string) {
extern char** environ;
gchar* tmpstr = NULL;
int i = 0;
@@ -453,7 +452,7 @@ gchar* parseenv (char* string) {
return string;
}
-static sigfunc*
+sigfunc*
setup_signal(int signr, sigfunc *shandler) {
struct sigaction nh, oh;
@@ -467,7 +466,7 @@ setup_signal(int signr, sigfunc *shandler) {
return NULL;
}
-static void
+void
clean_up(void) {
if (uzbl.behave.fifo_dir)
unlink (uzbl.comm.fifo_path);
@@ -484,7 +483,7 @@ clean_up(void) {
* be sure to extend this function to use
* more timers if needed in other places
*/
-static void
+void
set_timeout(int seconds) {
struct itimerval t;
memset(&t, 0, sizeof t);
@@ -496,20 +495,20 @@ set_timeout(int seconds) {
/* --- SIGNAL HANDLER --- */
-static void
+void
catch_sigterm(int s) {
(void) s;
clean_up();
}
-static void
+void
catch_sigint(int s) {
(void) s;
clean_up();
exit(EXIT_SUCCESS);
}
-static void
+void
catch_alrm(int s) {
(void) s;
@@ -520,7 +519,7 @@ catch_alrm(int s) {
/* --- CALLBACKS --- */
-static gboolean
+gboolean
new_window_cb (WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, WebKitWebNavigationAction *navigation_action, WebKitWebPolicyDecision *policy_decision, gpointer user_data) {
(void) web_view;
(void) frame;
@@ -534,7 +533,7 @@ new_window_cb (WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequ
return TRUE;
}
-static gboolean
+gboolean
mime_policy_cb(WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, gchar *mime_type, WebKitWebPolicyDecision *policy_decision, gpointer user_data) {
(void) frame;
(void) request;
@@ -567,7 +566,7 @@ create_web_view_cb (WebKitWebView *web_view, WebKitWebFrame *frame, gpointer us
return (NULL);
}
-static gboolean
+gboolean
download_cb (WebKitWebView *web_view, GObject *download, gpointer user_data) {
(void) web_view;
(void) user_data;
@@ -582,7 +581,7 @@ download_cb (WebKitWebView *web_view, GObject *download, gpointer user_data) {
}
/* scroll a bar in a given direction */
-static void
+void
scroll (GtkAdjustment* bar, GArray *argv) {
gchar *end;
gdouble max_value;
@@ -604,38 +603,38 @@ scroll (GtkAdjustment* bar, GArray *argv) {
gtk_adjustment_set_value (bar, value);
}
-static void
+void
scroll_begin(WebKitWebView* page, GArray *argv, GString *result) {
(void) page; (void) argv; (void) result;
gtk_adjustment_set_value (uzbl.gui.bar_v, gtk_adjustment_get_lower(uzbl.gui.bar_v));
}
-static void
+void
scroll_end(WebKitWebView* page, GArray *argv, GString *result) {
(void) page; (void) argv; (void) result;
gtk_adjustment_set_value (uzbl.gui.bar_v, gtk_adjustment_get_upper(uzbl.gui.bar_v) -
gtk_adjustment_get_page_size(uzbl.gui.bar_v));
}
-static void
+void
scroll_vert(WebKitWebView* page, GArray *argv, GString *result) {
(void) page; (void) result;
scroll(uzbl.gui.bar_v, argv);
}
-static void
+void
scroll_horz(WebKitWebView* page, GArray *argv, GString *result) {
(void) page; (void) result;
scroll(uzbl.gui.bar_h, argv);
}
-static void
+void
cmd_set_geometry() {
if(!gtk_window_parse_geometry(GTK_WINDOW(uzbl.gui.main_window), uzbl.gui.geometry)) {
if(uzbl.state.verbose)
printf("Error in geometry string: %s\n", uzbl.gui.geometry);
}
- /* update geometry var with the actual geometry
+ /* update geometry var with the actual geometry
this is necessary as some WMs don't seem to honour
the above setting and we don't want to end up with
wrong geometry information
@@ -643,7 +642,7 @@ cmd_set_geometry() {
retrieve_geometry();
}
-static void
+void
cmd_set_status() {
if (!uzbl.behave.show_status) {
gtk_widget_hide(uzbl.gui.mainbar);
@@ -653,7 +652,7 @@ cmd_set_status() {
update_title();
}
-static void
+void
toggle_zoom_type (WebKitWebView* page, GArray *argv, GString *result) {
(void)page;
(void)argv;
@@ -662,7 +661,7 @@ toggle_zoom_type (WebKitWebView* page, GArray *argv, GString *result) {
webkit_web_view_set_full_content_zoom (page, !webkit_web_view_get_full_content_zoom (page));
}
-static void
+void
toggle_status_cb (WebKitWebView* page, GArray *argv, GString *result) {
(void)page;
(void)argv;
@@ -677,7 +676,7 @@ toggle_status_cb (WebKitWebView* page, GArray *argv, GString *result) {
update_title();
}
-static void
+void
link_hover_cb (WebKitWebView* page, const gchar* title, const gchar* link, gpointer data) {
(void) page;
(void) title;
@@ -691,7 +690,7 @@ link_hover_cb (WebKitWebView* page, const gchar* title, const gchar* link, gpoin
update_title();
}
-static void
+void
title_change_cb (WebKitWebView* web_view, GParamSpec param_spec) {
(void) web_view;
(void) param_spec;
@@ -714,7 +713,7 @@ progress_change_cb (WebKitWebView* page, gint progress, gpointer data) {
update_title();
}
-static void
+void
load_finish_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data) {
(void) page;
(void) frame;
@@ -728,7 +727,7 @@ void clear_keycmd() {
uzbl.state.keycmd = g_strdup("");
}
-static void
+void
load_start_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data) {
(void) page;
(void) frame;
@@ -739,7 +738,7 @@ load_start_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data) {
run_handler(uzbl.behave.load_start_handler, "");
}
-static void
+void
load_commit_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data) {
(void) page;
(void) data;
@@ -754,14 +753,14 @@ load_commit_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data) {
run_handler(uzbl.behave.load_commit_handler, uzbl.state.uri);
}
-static void
+void
destroy_cb (GtkWidget* widget, gpointer data) {
(void) widget;
(void) data;
gtk_main_quit ();
}
-static void
+void
log_history_cb () {
if (uzbl.behave.history_handler) {
time_t rawtime;
@@ -776,7 +775,7 @@ log_history_cb () {
/* VIEW funcs (little webkit wrappers) */
-#define VIEWFUNC(name) static void view_##name(WebKitWebView *page, GArray *argv, GString *result){(void)argv; (void)result; webkit_web_view_##name(page);}
+#define VIEWFUNC(name) void view_##name(WebKitWebView *page, GArray *argv, GString *result){(void)argv; (void)result; webkit_web_view_##name(page);}
VIEWFUNC(reload)
VIEWFUNC(reload_bypass_cache)
VIEWFUNC(stop_loading)
@@ -787,7 +786,7 @@ VIEWFUNC(go_forward)
#undef VIEWFUNC
/* -- command to callback/function map for things we cannot attach to any signals */
-static struct {char *key; CommandInfo value;} cmdlist[] =
+struct {char *key; CommandInfo value;} cmdlist[] =
{ /* key function no_split */
{ "back", {view_go_back, 0} },
{ "forward", {view_go_forward, 0} },
@@ -825,7 +824,7 @@ static struct {char *key; CommandInfo value;} cmdlist[] =
{ "print", {print, TRUE} }
};
-static void
+void
commands_hash(void)
{
unsigned int i;
@@ -859,12 +858,12 @@ new_action(const gchar *name, const gchar *param) {
return action;
}
-static bool
+bool
file_exists (const char * filename) {
return (access(filename, F_OK) == 0);
}
-static void
+void
set_var(WebKitWebView *page, GArray *argv, GString *result) {
(void) page; (void) result;
gchar **split = g_strsplit(argv_idx(argv, 0), "=", 2);
@@ -876,7 +875,7 @@ set_var(WebKitWebView *page, GArray *argv, GString *result) {
g_strfreev(split);
}
-static void
+void
print(WebKitWebView *page, GArray *argv, GString *result) {
(void) page; (void) result;
gchar* buf;
@@ -886,7 +885,7 @@ print(WebKitWebView *page, GArray *argv, GString *result) {
g_free(buf);
}
-static void
+void
act_bind(WebKitWebView *page, GArray *argv, GString *result) {
(void) page; (void) result;
gchar **split = g_strsplit(argv_idx(argv, 0), " = ", 2);
@@ -897,27 +896,36 @@ act_bind(WebKitWebView *page, GArray *argv, GString *result) {
}
-static void
+void
act_dump_config() {
dump_config();
}
-void set_keycmd() {
+void
+set_keycmd() {
run_keycmd(FALSE);
update_title();
}
-void set_mode_indicator() {
+void
+set_mode_indicator() {
uzbl.gui.sbar.mode_indicator = (uzbl.behave.insert_mode ?
uzbl.behave.insert_indicator : uzbl.behave.cmd_indicator);
}
-void set_insert_mode(gboolean mode) {
+void
+update_indicator() {
+ set_mode_indicator();
+ update_title();
+}
+
+void
+set_insert_mode(gboolean mode) {
uzbl.behave.insert_mode = mode;
set_mode_indicator();
}
-static void
+void
toggle_insert_mode(WebKitWebView *page, GArray *argv, GString *result) {
(void) page; (void) result;
@@ -934,7 +942,7 @@ toggle_insert_mode(WebKitWebView *page, GArray *argv, GString *result) {
update_title();
}
-static void
+void
load_uri (WebKitWebView *web_view, GArray *argv, GString *result) {
(void) result;
@@ -952,10 +960,9 @@ load_uri (WebKitWebView *web_view, GArray *argv, GString *result) {
}
}
-
/* Javascript*/
-static JSValueRef
+JSValueRef
js_run_command (JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject,
size_t argumentCount, const JSValueRef arguments[],
JSValueRef* exception) {
@@ -983,11 +990,11 @@ js_run_command (JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject,
return JSValueMakeString(ctx, js_result_string);
}
-static JSStaticFunction js_static_functions[] = {
+JSStaticFunction js_static_functions[] = {
{"run", js_run_command, kJSPropertyAttributeNone},
};
-static void
+void
js_init() {
/* This function creates the class and its definition, only once */
if (!uzbl.js.initialized) {
@@ -1000,7 +1007,7 @@ js_init() {
}
-static void
+void
eval_js(WebKitWebView * web_view, gchar *script, GString *result) {
WebKitWebFrame *frame;
JSGlobalContextRef context;
@@ -1047,14 +1054,13 @@ eval_js(WebKitWebView * web_view, gchar *script, GString *result) {
JSStringRelease(js_script);
}
-static void
+void
run_js (WebKitWebView * web_view, GArray *argv, GString *result) {
-
if (argv_idx(argv, 0))
eval_js(web_view, argv_idx(argv, 0), result);
}
-static void
+void
run_external_js (WebKitWebView * web_view, GArray *argv, GString *result) {
(void) result;
if (argv_idx(argv, 0)) {
@@ -1088,7 +1094,7 @@ run_external_js (WebKitWebView * web_view, GArray *argv, GString *result) {
}
}
-static void
+void
search_text (WebKitWebView *page, GArray *argv, const gboolean forward) {
if (argv_idx(argv, 0) && (*argv_idx(argv, 0) != '\0')) {
if (g_strcmp0 (uzbl.state.searchtx, argv_idx(argv, 0)) != 0) {
@@ -1106,26 +1112,26 @@ search_text (WebKitWebView *page, GArray *argv, const gboolean forward) {
}
}
-static void
+void
search_forward_text (WebKitWebView *page, GArray *argv, GString *result) {
(void) result;
search_text(page, argv, TRUE);
}
-static void
+void
search_reverse_text (WebKitWebView *page, GArray *argv, GString *result) {
(void) result;
search_text(page, argv, FALSE);
}
-static void
+void
dehilight (WebKitWebView *page, GArray *argv, GString *result) {
(void) argv; (void) result;
webkit_web_view_set_highlight_text_matches (page, FALSE);
}
-static void
+void
new_window_load_uri (const gchar * uri) {
if (uzbl.behave.new_window) {
GString *s = g_string_new ("");
@@ -1150,7 +1156,7 @@ new_window_load_uri (const gchar * uri) {
g_string_free (to_execute, TRUE);
}
-static void
+void
chain (WebKitWebView *page, GArray *argv, GString *result) {
(void) page; (void) result;
gchar *a = NULL;
@@ -1158,12 +1164,13 @@ chain (WebKitWebView *page, GArray *argv, GString *result) {
guint i = 0;
while ((a = argv_idx(argv, i++))) {
parts = g_strsplit (a, " ", 2);
- parse_command(parts[0], parts[1], result);
+ if (parts[0])
+ parse_command(parts[0], parts[1], result);
g_strfreev (parts);
}
}
-static void
+void
keycmd (WebKitWebView *page, GArray *argv, GString *result) {
(void)page;
(void)argv;
@@ -1173,7 +1180,7 @@ keycmd (WebKitWebView *page, GArray *argv, GString *result) {
update_title();
}
-static void
+void
keycmd_nl (WebKitWebView *page, GArray *argv, GString *result) {
(void)page;
(void)argv;
@@ -1183,7 +1190,7 @@ keycmd_nl (WebKitWebView *page, GArray *argv, GString *result) {
update_title();
}
-static void
+void
keycmd_bs (WebKitWebView *page, GArray *argv, GString *result) {
gchar *prev;
(void)page;
@@ -1196,7 +1203,7 @@ keycmd_bs (WebKitWebView *page, GArray *argv, GString *result) {
update_title();
}
-static void
+void
close_uzbl (WebKitWebView *page, GArray *argv, GString *result) {
(void)page;
(void)argv;
@@ -1205,7 +1212,7 @@ close_uzbl (WebKitWebView *page, GArray *argv, GString *result) {
}
/* --Statusbar functions-- */
-static char*
+char*
build_progressbar_ascii(int percent) {
int width=uzbl.gui.sbar.progress_w;
int i;
@@ -1225,14 +1232,14 @@ build_progressbar_ascii(int percent) {
}
/* --End Statusbar functions-- */
-static void
+void
sharg_append(GArray *a, const gchar *str) {
const gchar *s = (str ? str : "");
g_array_append_val(a, s);
}
// make sure that the args string you pass can properly be interpreted (eg properly escaped against whitespace, quotes etc)
-static gboolean
+gboolean
run_command (const gchar *command, const guint npre, const gchar **args,
const gboolean sync, char **output_stdout) {
//command <uzbl conf> <uzbl pid> <uzbl win id> <uzbl fifo file> <uzbl socket file> [args]
@@ -1289,7 +1296,7 @@ run_command (const gchar *command, const guint npre, const gchar **args,
return result;
}
-static gchar**
+gchar**
split_quoted(const gchar* src, const gboolean unquote) {
/* split on unquoted space, return array of strings;
remove a layer of quotes and backslashes if unquote */
@@ -1326,7 +1333,7 @@ split_quoted(const gchar* src, const gboolean unquote) {
return ret;
}
-static void
+void
spawn(WebKitWebView *web_view, GArray *argv, GString *result) {
(void)web_view; (void)result;
//TODO: allow more control over argument order so that users can have some arguments before the default ones from run_command, and some after
@@ -1334,7 +1341,7 @@ spawn(WebKitWebView *web_view, GArray *argv, GString *result) {
run_command(argv_idx(argv, 0), 0, ((const gchar **) (argv->data + sizeof(gchar*))), FALSE, NULL);
}
-static void
+void
spawn_sync(WebKitWebView *web_view, GArray *argv, GString *result) {
(void)web_view; (void)result;
@@ -1343,7 +1350,7 @@ spawn_sync(WebKitWebView *web_view, GArray *argv, GString *result) {
TRUE, &uzbl.comm.sync_stdout);
}
-static void
+void
spawn_sh(WebKitWebView *web_view, GArray *argv, GString *result) {
(void)web_view; (void)result;
if (!uzbl.behave.shell_cmd) {
@@ -1364,7 +1371,7 @@ spawn_sh(WebKitWebView *web_view, GArray *argv, GString *result) {
g_strfreev (cmd);
}
-static void
+void
spawn_sh_sync(WebKitWebView *web_view, GArray *argv, GString *result) {
(void)web_view; (void)result;
if (!uzbl.behave.shell_cmd) {
@@ -1420,7 +1427,7 @@ parse_command(const char *cmd, const char *param, GString *result) {
g_printerr ("command \"%s\" not understood. ignoring.\n", cmd);
}
-static void
+void
set_proxy_url() {
SoupURI *suri;
@@ -1439,7 +1446,7 @@ set_proxy_url() {
return;
}
-static void
+void
set_icon() {
if(file_exists(uzbl.gui.icon)) {
if (uzbl.gui.main_window)
@@ -1449,7 +1456,7 @@ set_icon() {
}
}
-static void
+void
cmd_load_uri() {
GArray *a = g_array_new (TRUE, FALSE, sizeof(gchar*));
g_array_append_val (a, uzbl.state.uri);
@@ -1457,25 +1464,25 @@ cmd_load_uri() {
g_array_free (a, TRUE);
}
-static void
+void
cmd_always_insert_mode() {
set_insert_mode(uzbl.behave.always_insert_mode);
update_title();
}
-static void
+void
cmd_max_conns() {
g_object_set(G_OBJECT(uzbl.net.soup_session),
SOUP_SESSION_MAX_CONNS, uzbl.net.max_conns, NULL);
}
-static void
+void
cmd_max_conns_host() {
g_object_set(G_OBJECT(uzbl.net.soup_session),
SOUP_SESSION_MAX_CONNS_PER_HOST, uzbl.net.max_conns_host, NULL);
}
-static void
+void
cmd_http_debug() {
soup_session_remove_feature
(uzbl.net.soup_session, SOUP_SESSION_FEATURE(uzbl.net.soup_logger));
@@ -1487,12 +1494,12 @@ cmd_http_debug() {
SOUP_SESSION_FEATURE(uzbl.net.soup_logger));
}
-static WebKitWebSettings*
+WebKitWebSettings*
view_settings() {
return webkit_web_view_get_settings(uzbl.gui.web_view);
}
-static void
+void
cmd_font_size() {
WebKitWebSettings *ws = view_settings();
if (uzbl.behave.font_size > 0) {
@@ -1508,91 +1515,91 @@ cmd_font_size() {
}
}
-static void
+void
cmd_zoom_level() {
webkit_web_view_set_zoom_level (uzbl.gui.web_view, uzbl.behave.zoom_level);
}
-static void
+void
cmd_disable_plugins() {
g_object_set (G_OBJECT(view_settings()), "enable-plugins",
!uzbl.behave.disable_plugins, NULL);
}
-static void
+void
cmd_disable_scripts() {
g_object_set (G_OBJECT(view_settings()), "enable-scripts",
!uzbl.behave.disable_scripts, NULL);
}
-static void
+void
cmd_minimum_font_size() {
g_object_set (G_OBJECT(view_settings()), "minimum-font-size",
uzbl.behave.minimum_font_size, NULL);
}
-static void
+void
cmd_autoload_img() {
g_object_set (G_OBJECT(view_settings()), "auto-load-images",
uzbl.behave.autoload_img, NULL);
}
-static void
+void
cmd_autoshrink_img() {
g_object_set (G_OBJECT(view_settings()), "auto-shrink-images",
uzbl.behave.autoshrink_img, NULL);
}
-static void
+void
cmd_enable_spellcheck() {
g_object_set (G_OBJECT(view_settings()), "enable-spell-checking",
uzbl.behave.enable_spellcheck, NULL);
}
-static void
+void
cmd_enable_private() {
g_object_set (G_OBJECT(view_settings()), "enable-private-browsing",
uzbl.behave.enable_private, NULL);
}
-static void
+void
cmd_print_bg() {
g_object_set (G_OBJECT(view_settings()), "print-backgrounds",
uzbl.behave.print_bg, NULL);
}
-static void
+void
cmd_style_uri() {
g_object_set (G_OBJECT(view_settings()), "user-stylesheet-uri",
uzbl.behave.style_uri, NULL);
}
-static void
+void
cmd_resizable_txt() {
g_object_set (G_OBJECT(view_settings()), "resizable-text-areas",
uzbl.behave.resizable_txt, NULL);
}
-static void
+void
cmd_default_encoding() {
g_object_set (G_OBJECT(view_settings()), "default-encoding",
uzbl.behave.default_encoding, NULL);
}
-static void
+void
cmd_enforce_96dpi() {
g_object_set (G_OBJECT(view_settings()), "enforce-96-dpi",
uzbl.behave.enforce_96dpi, NULL);
}
-static void
+void
cmd_caret_browsing() {
g_object_set (G_OBJECT(view_settings()), "enable-caret-browsing",
uzbl.behave.caret_browsing, NULL);
}
-static void
+void
cmd_cookie_handler() {
gchar **split = g_strsplit(uzbl.behave.cookie_handler, " ", 2);
/* pitfall: doesn't handle chain actions; must the sync_ action manually */
@@ -1605,7 +1612,7 @@ cmd_cookie_handler() {
g_strfreev (split);
}
-static void
+void
cmd_new_window() {
gchar **split = g_strsplit(uzbl.behave.new_window, " ", 2);
/* pitfall: doesn't handle chain actions; must the sync_ action manually */
@@ -1618,17 +1625,17 @@ cmd_new_window() {
g_strfreev (split);
}
-static void
+void
cmd_fifo_dir() {
uzbl.behave.fifo_dir = init_fifo(uzbl.behave.fifo_dir);
}
-static void
+void
cmd_socket_dir() {
uzbl.behave.socket_dir = init_socket(uzbl.behave.socket_dir);
}
-static void
+void
cmd_inject_html() {
if(uzbl.behave.inject_html) {
webkit_web_view_load_html_string (uzbl.gui.web_view,
@@ -1636,7 +1643,7 @@ cmd_inject_html() {
}
}
-static void
+void
cmd_modkey() {
int i;
char *buf;
@@ -1665,7 +1672,7 @@ cmd_useragent() {
}
}
-static void
+void
move_statusbar() {
if (!uzbl.gui.scrolled_win &&
!uzbl.gui.mainbar)
@@ -1697,7 +1704,7 @@ set_var_value(gchar *name, gchar *val) {
char *buf = NULL;
if( (c = g_hash_table_lookup(uzbl.comm.proto_var, name)) ) {
- if(!c->writeable) return TRUE;
+ if(!c->writeable) return FALSE;
/* check for the variable type */
if (c->type == TYPE_STR) {
@@ -1722,7 +1729,7 @@ set_var_value(gchar *name, gchar *val) {
return TRUE;
}
-static void
+void
render_html() {
Behaviour *b = &uzbl.behave;
@@ -1735,7 +1742,7 @@ render_html() {
}
enum {M_CMD, M_HTML};
-static void
+void
parse_cmd_line(const char *ctl_line, GString *result) {
Behaviour *b = &uzbl.behave;
size_t len=0;
@@ -1775,7 +1782,7 @@ parse_cmd_line(const char *ctl_line, GString *result) {
}
}
-static gchar*
+gchar*
build_stream_name(int type, const gchar* dir) {
State *s = &uzbl.state;
gchar *str = NULL;
@@ -1790,7 +1797,7 @@ build_stream_name(int type, const gchar* dir) {
return str;
}
-static gboolean
+gboolean
control_fifo(GIOChannel *gio, GIOCondition condition) {
if (uzbl.state.verbose)
printf("triggered\n");
@@ -1816,7 +1823,7 @@ control_fifo(GIOChannel *gio, GIOCondition condition) {
return TRUE;
}
-static gchar*
+gchar*
init_fifo(gchar *dir) { /* return dir or, on error, free dir and return NULL */
if (uzbl.comm.fifo_path) { /* get rid of the old fifo if one exists */
if (unlink(uzbl.comm.fifo_path) == -1)
@@ -1825,11 +1832,6 @@ init_fifo(gchar *dir) { /* return dir or, on error, free dir and return NULL */
uzbl.comm.fifo_path = NULL;
}
- if (*dir == ' ') { /* space unsets the variable */
- g_free (dir);
- return NULL;
- }
-
GIOChannel *chan = NULL;
GError *error = NULL;
gchar *path = build_stream_name(FIFO, dir);
@@ -1856,7 +1858,7 @@ init_fifo(gchar *dir) { /* return dir or, on error, free dir and return NULL */
return NULL;
}
-static gboolean
+gboolean
control_stdin(GIOChannel *gio, GIOCondition condition) {
(void) condition;
gchar *ctl_line = NULL;
@@ -1872,7 +1874,7 @@ control_stdin(GIOChannel *gio, GIOCondition condition) {
return TRUE;
}
-static void
+void
create_stdin () {
GIOChannel *chan = NULL;
GError *error = NULL;
@@ -1891,7 +1893,7 @@ create_stdin () {
if (error) g_error_free (error);
}
-static gboolean
+gboolean
control_socket(GIOChannel *chan) {
struct sockaddr_un remote;
unsigned int t = sizeof(remote);
@@ -1909,7 +1911,7 @@ control_socket(GIOChannel *chan) {
return TRUE;
}
-static gboolean
+gboolean
control_client_socket(GIOChannel *clientchan) {
char *ctl_line;
GString *result = g_string_new("");
@@ -1945,7 +1947,7 @@ control_client_socket(GIOChannel *clientchan) {
return TRUE;
}
-static gchar*
+gchar*
init_socket(gchar *dir) { /* return dir or, on error, free dir and return NULL */
if (uzbl.comm.socket_path) { /* remove an existing socket should one exist */
if (unlink(uzbl.comm.socket_path) == -1)
@@ -1994,7 +1996,7 @@ init_socket(gchar *dir) { /* return dir or, on error, free dir and return NULL *
it will probably improve performance if we would "cache" the processed variant, but for now it works well enough...
*/
// this function may be called very early when the templates are not set (yet), hence the checks
-static void
+void
update_title (void) {
Behaviour *b = &uzbl.behave;
gchar *parsed;
@@ -2030,7 +2032,7 @@ update_title (void) {
}
}
-static gboolean
+gboolean
configure_event_cb(GtkWidget* window, GdkEventConfigure* event) {
(void) window;
(void) event;
@@ -2039,7 +2041,7 @@ configure_event_cb(GtkWidget* window, GdkEventConfigure* event) {
return FALSE;
}
-static gboolean
+gboolean
key_press_cb (GtkWidget* window, GdkEventKey* event)
{
//TRUE to stop other handlers from being invoked for the event. FALSE to propagate the event further.
@@ -2064,8 +2066,8 @@ key_press_cb (GtkWidget* window, GdkEventKey* event)
return TRUE;
}
- if (uzbl.behave.insert_mode &&
- ( ((event->state & uzbl.behave.modmask) != uzbl.behave.modmask) ||
+ if (uzbl.behave.insert_mode &&
+ ( ((event->state & uzbl.behave.modmask) != uzbl.behave.modmask) ||
(!uzbl.behave.modmask)
)
)
@@ -2114,7 +2116,7 @@ key_press_cb (GtkWidget* window, GdkEventKey* event)
return TRUE;
}
-static void
+void
run_keycmd(const gboolean key_ret) {
/* run the keycmd immediately if it isn't incremental and doesn't take args */
Action *act;
@@ -2153,7 +2155,7 @@ run_keycmd(const gboolean key_ret) {
g_string_free (short_keys_inc, TRUE);
}
-static void
+void
exec_paramcmd(const Action *act, const guint i) {
GString *parampart = g_string_new (uzbl.state.keycmd);
GString *actionname = g_string_new ("");
@@ -2170,16 +2172,11 @@ exec_paramcmd(const Action *act, const guint i) {
}
-GtkWidget*
+void
create_browser () {
GUI *g = &uzbl.gui;
- GtkWidget* scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- //main_window_ref = g_object_ref(scrolled_window);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_NEVER); //todo: some sort of display of position/total length. like what emacs does
-
g->web_view = WEBKIT_WEB_VIEW (webkit_web_view_new ());
- gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (g->web_view));
g_signal_connect (G_OBJECT (g->web_view), "notify::title", G_CALLBACK (title_change_cb), NULL);
g_signal_connect (G_OBJECT (g->web_view), "load-progress-changed", G_CALLBACK (progress_change_cb), g->web_view);
@@ -2192,11 +2189,9 @@ create_browser () {
g_signal_connect (G_OBJECT (g->web_view), "download-requested", G_CALLBACK (download_cb), g->web_view);
g_signal_connect (G_OBJECT (g->web_view), "create-web-view", G_CALLBACK (create_web_view_cb), g->web_view);
g_signal_connect (G_OBJECT (g->web_view), "mime-type-policy-decision-requested", G_CALLBACK (mime_policy_cb), g->web_view);
-
- return scrolled_window;
}
-static GtkWidget*
+GtkWidget*
create_mainbar () {
GUI *g = &uzbl.gui;
@@ -2215,8 +2210,8 @@ create_mainbar () {
return g->mainbar;
}
-static
-GtkWidget* create_window () {
+GtkWidget*
+create_window () {
GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
gtk_widget_set_name (window, "Uzbl browser");
@@ -2227,8 +2222,8 @@ GtkWidget* create_window () {
return window;
}
-static
-GtkPlug* create_plug () {
+GtkPlug*
+create_plug () {
GtkPlug* plug = GTK_PLUG (gtk_plug_new (uzbl.state.socket_id));
g_signal_connect (G_OBJECT (plug), "destroy", G_CALLBACK (destroy_cb), NULL);
g_signal_connect (G_OBJECT (plug), "key-press-event", G_CALLBACK (key_press_cb), NULL);
@@ -2237,7 +2232,7 @@ GtkPlug* create_plug () {
}
-static gchar**
+gchar**
inject_handler_args(const gchar *actname, const gchar *origargs, const gchar *newargs) {
/*
If actname is one that calls an external command, this function will inject
@@ -2245,7 +2240,7 @@ inject_handler_args(const gchar *actname, const gchar *origargs, const gchar *ne
come become after the body of the script (in sh) or after the name of
the command to execute (in spawn).
i.e. sh <body> <userargs> becomes sh <body> <ARGS> <userargs> and
- span <command> <userargs> becomes spawn <command> <ARGS> <userargs>.
+ spawn <command> <userargs> becomes spawn <command> <ARGS> <userargs>.
The return value consist of two strings: the action (sh, ...) and its args.
@@ -2253,6 +2248,7 @@ inject_handler_args(const gchar *actname, const gchar *origargs, const gchar *ne
gets duplicated.
*/
GArray *rets = g_array_new(TRUE, FALSE, sizeof(gchar*));
+ /* Arrr! Here be memory leaks */
gchar *actdup = g_strdup(actname);
g_array_append_val(rets, actdup);
@@ -2279,7 +2275,7 @@ inject_handler_args(const gchar *actname, const gchar *origargs, const gchar *ne
return (gchar**)g_array_free(rets, FALSE);
}
-static void
+void
run_handler (const gchar *act, const gchar *args) {
/* Consider this code a temporary hack to make the handlers usable.
In practice, all this splicing, injection, and reconstruction is
@@ -2357,7 +2353,7 @@ add_binding (const gchar *key, const gchar *act) {
g_strfreev(parts);
}
-static gchar*
+gchar*
get_xdg_var (XDG_Var xdg) {
const gchar* actual_value = getenv (xdg.environmental);
const gchar* home = getenv ("HOME");
@@ -2376,7 +2372,7 @@ get_xdg_var (XDG_Var xdg) {
return return_value;
}
-static gchar*
+gchar*
find_xdg_file (int xdg_type, char* filename) {
/* xdg_type = 0 => config
xdg_type = 1 => data
@@ -2409,7 +2405,7 @@ find_xdg_file (int xdg_type, char* filename) {
return NULL;
}
}
-static void
+void
settings_init () {
State *s = &uzbl.state;
Network *n = &uzbl.net;
@@ -2417,7 +2413,7 @@ settings_init () {
for (i = 0; default_config[i].command != NULL; i++) {
parse_cmd_line(default_config[i].command, NULL);
}
-
+
if (g_strcmp0(s->config_file, "-") == 0) {
s->config_file = NULL;
create_stdin();
@@ -2446,7 +2442,7 @@ settings_init () {
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){
+void handle_cookies (SoupSession *session, SoupMessage *msg, gpointer user_data){
(void) session;
(void) user_data;
if (!uzbl.behave.cookie_handler)
@@ -2455,7 +2451,7 @@ static void handle_cookies (SoupSession *session, SoupMessage *msg, gpointer use
soup_message_add_header_handler(msg, "got-headers", "Set-Cookie", G_CALLBACK(save_cookies), NULL);
GString *s = g_string_new ("");
SoupURI * soup_uri = soup_message_get_uri(msg);
- g_string_printf(s, "GET '%s' '%s'", soup_uri->host, soup_uri->path);
+ g_string_printf(s, "GET '%s' '%s' '%s'", soup_uri->scheme, soup_uri->host, soup_uri->path);
run_handler(uzbl.behave.cookie_handler, s->str);
if(uzbl.comm.sync_stdout && strcmp (uzbl.comm.sync_stdout, "") != 0) {
@@ -2469,7 +2465,7 @@ static void handle_cookies (SoupSession *session, SoupMessage *msg, gpointer use
g_string_free(s, TRUE);
}
-static void
+void
save_cookies (SoupMessage *msg, gpointer user_data){
(void) user_data;
GSList *ck;
@@ -2478,7 +2474,7 @@ save_cookies (SoupMessage *msg, gpointer user_data){
cookie = soup_cookie_to_set_cookie_header(ck->data);
SoupURI * soup_uri = soup_message_get_uri(msg);
GString *s = g_string_new ("");
- g_string_printf(s, "PUT '%s' '%s' '%s'", soup_uri->host, soup_uri->path, cookie);
+ g_string_printf(s, "PUT '%s' '%s' '%s' '%s'", soup_uri->scheme, soup_uri->host, soup_uri->path, cookie);
run_handler(uzbl.behave.cookie_handler, s->str);
g_free (cookie);
g_string_free(s, TRUE);
@@ -2487,14 +2483,14 @@ save_cookies (SoupMessage *msg, gpointer user_data){
}
/* --- WEBINSPECTOR --- */
-static void
+void
hide_window_cb(GtkWidget *widget, gpointer data) {
(void) data;
gtk_widget_hide(widget);
}
-static WebKitWebView*
+WebKitWebView*
create_inspector_cb (WebKitWebInspector* web_inspector, WebKitWebView* page, gpointer data){
(void) data;
(void) page;
@@ -2523,7 +2519,7 @@ create_inspector_cb (WebKitWebInspector* web_inspector, WebKitWebView* page, gpo
return WEBKIT_WEB_VIEW(new_web_view);
}
-static gboolean
+gboolean
inspector_show_window_cb (WebKitWebInspector* inspector){
(void) inspector;
gtk_widget_show(uzbl.gui.inspector_window);
@@ -2531,37 +2527,37 @@ inspector_show_window_cb (WebKitWebInspector* inspector){
}
/* TODO: Add variables and code to make use of these functions */
-static gboolean
+gboolean
inspector_close_window_cb (WebKitWebInspector* inspector){
(void) inspector;
return TRUE;
}
-static gboolean
+gboolean
inspector_attach_window_cb (WebKitWebInspector* inspector){
(void) inspector;
return FALSE;
}
-static gboolean
+gboolean
inspector_detach_window_cb (WebKitWebInspector* inspector){
(void) inspector;
return FALSE;
}
-static gboolean
+gboolean
inspector_uri_changed_cb (WebKitWebInspector* inspector){
(void) inspector;
return FALSE;
}
-static gboolean
+gboolean
inspector_inspector_destroyed_cb (WebKitWebInspector* inspector){
(void) inspector;
return FALSE;
}
-static void
+void
set_up_inspector() {
GUI *g = &uzbl.gui;
WebKitWebSettings *settings = view_settings();
@@ -2578,7 +2574,7 @@ set_up_inspector() {
g_signal_connect (G_OBJECT (g->inspector), "notify::inspected-uri", G_CALLBACK (inspector_uri_changed_cb), NULL);
}
-static void
+void
dump_var_hash(gpointer k, gpointer v, gpointer ud) {
(void) ud;
uzbl_cmdprop *c = v;
@@ -2587,12 +2583,14 @@ dump_var_hash(gpointer k, gpointer v, gpointer ud) {
return;
if(c->type == TYPE_STR)
- printf("set %s = %s\n", (char *)k, *c->ptr?(char *)*c->ptr:" ");
+ printf("set %s = %s\n", (char *)k, *c->ptr ? (char *)*c->ptr : " ");
else if(c->type == TYPE_INT)
printf("set %s = %d\n", (char *)k, (int)*c->ptr);
+ else if(c->type == TYPE_FLOAT)
+ printf("set %s = %f\n", (char *)k, *(float *)c->ptr);
}
-static void
+void
dump_key_hash(gpointer k, gpointer v, gpointer ud) {
(void) ud;
Action *a = v;
@@ -2601,14 +2599,14 @@ dump_key_hash(gpointer k, gpointer v, gpointer ud) {
(char *)a->name, a->param?(char *)a->param:"");
}
-static void
-dump_config() { //ADD "result" var so we can use this with uzblctrl
+void
+dump_config() {
g_hash_table_foreach(uzbl.comm.proto_var, dump_var_hash, NULL);
g_hash_table_foreach(uzbl.bindings, dump_key_hash, NULL);
}
-static void
-retrieve_geometry() {
+void
+retreive_geometry() {
int w, h, x, y;
GString *buf = g_string_new("");
@@ -2626,7 +2624,6 @@ retrieve_geometry() {
* external applications need to do anyhow */
void
initialize(int argc, char *argv[]) {
- gtk_init (&argc, &argv);
if (!g_thread_supported ())
g_thread_init (NULL);
uzbl.state.executable_path = g_strdup(argv[0]);
@@ -2657,7 +2654,7 @@ initialize(int argc, char *argv[]) {
if(setup_signal(SIGALRM, catch_alrm) == SIG_ERR)
fprintf(stderr, "uzbl: error hooking SIGALARM\n");
- uzbl.gui.sbar.progress_s = g_strdup("=");
+ uzbl.gui.sbar.progress_s = g_strdup("="); //TODO: move these to config.h
uzbl.gui.sbar.progress_u = g_strdup("·");
uzbl.gui.sbar.progress_w = 10;
@@ -2680,7 +2677,7 @@ initialize(int argc, char *argv[]) {
commands_hash ();
make_var_to_name_hash();
- uzbl.gui.scrolled_win = create_browser();
+ create_browser();
}
#ifndef UZBL_LIBRARY
@@ -2689,6 +2686,16 @@ int
main (int argc, char* argv[]) {
initialize(argc, argv);
+ gtk_init (&argc, &argv);
+
+ uzbl.gui.scrolled_win = gtk_scrolled_window_new (NULL, NULL);
+ //main_window_ref = g_object_ref(scrolled_window);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (uzbl.gui.scrolled_win),
+ GTK_POLICY_NEVER, GTK_POLICY_NEVER); //todo: some sort of display of position/total length. like what emacs does
+
+ gtk_container_add (GTK_CONTAINER (uzbl.gui.scrolled_win),
+ GTK_WIDGET (uzbl.gui.web_view));
+
uzbl.gui.vbox = gtk_vbox_new (FALSE, 0);
create_mainbar();
@@ -2735,6 +2742,8 @@ main (int argc, char* argv[]) {
retrieve_geometry();
gchar *uri_override = (uzbl.state.uri ? g_strdup(uzbl.state.uri) : NULL);
+ if (argc > 1 && !uzbl.state.uri)
+ uri_override = g_strdup(argv[1]);
gboolean verbose_override = uzbl.state.verbose;
settings_init ();
diff --git a/uzbl.h b/uzbl.h
index 6d8a43c..c9d81b2 100644
--- a/uzbl.h
+++ b/uzbl.h
@@ -183,7 +183,6 @@ typedef struct {
Info info;
Window xwin;
- GScanner *scan;
/* group bindings: key -> action */
GHashTable* bindings;
@@ -214,79 +213,76 @@ XDG_Var XDG[] =
};
/* Functions */
-void
-setup_scanner();
-
char *
itos(int val);
-static char *
+char *
str_replace (const char* search, const char* replace, const char* string);
-static GArray*
+GArray*
read_file_by_line (gchar *path);
-static
-gchar* parseenv (char* string);
+gchar*
+parseenv (char* string);
-static void
+void
clean_up(void);
-static void
+void
catch_sigterm(int s);
-static sigfunc *
+sigfunc *
setup_signal(int signe, sigfunc *shandler);
gboolean
set_var_value(gchar *name, gchar *val);
-static void
+void
print(WebKitWebView *page, GArray *argv, GString *result);
-static gboolean
+gboolean
new_window_cb (WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, WebKitWebNavigationAction *navigation_action, WebKitWebPolicyDecision *policy_decision, gpointer user_data);
-static gboolean
+gboolean
mime_policy_cb(WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, gchar *mime_type, WebKitWebPolicyDecision *policy_decision, gpointer user_data);
WebKitWebView*
create_web_view_cb (WebKitWebView *web_view, WebKitWebFrame *frame, gpointer user_data);
-static gboolean
+gboolean
download_cb (WebKitWebView *web_view, GObject *download, gpointer user_data);
-static void
+void
toggle_zoom_type (WebKitWebView* page, GArray *argv, GString *result);
-static void
+void
toggle_status_cb (WebKitWebView* page, GArray *argv, GString *result);
-static void
+void
link_hover_cb (WebKitWebView* page, const gchar* title, const gchar* link, gpointer data);
-static void
+void
title_change_cb (WebKitWebView* web_view, GParamSpec param_spec);
void
progress_change_cb (WebKitWebView* page, gint progress, gpointer data);
-static void
+void
load_commit_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data);
-static void
+void
load_start_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data);
-static void
+void
load_finish_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data);
-static void
+void
destroy_cb (GtkWidget* widget, gpointer data);
-static void
+void
log_history_cb ();
-static void
+void
commands_hash(void);
void
@@ -295,7 +291,7 @@ free_action(gpointer act);
Action*
new_action(const gchar *name, const gchar *param);
-static bool
+bool
file_exists (const char * filename);
void
@@ -305,180 +301,182 @@ void
set_mode_indicator();
void
+update_indicator();
+
+void
set_insert_mode(gboolean mode);
-static void
+void
toggle_insert_mode(WebKitWebView *page, GArray *argv, GString *result);
-static void
+void
load_uri (WebKitWebView * web_view, GArray *argv, GString *result);
-static void
+void
new_window_load_uri (const gchar * uri);
-static void
+void
chain (WebKitWebView *page, GArray *argv, GString *result);
-static void
+void
keycmd (WebKitWebView *page, GArray *argv, GString *result);
-static void
+void
keycmd_nl (WebKitWebView *page, GArray *argv, GString *result);
-static void
+void
keycmd_bs (WebKitWebView *page, GArray *argv, GString *result);
-static void
+void
close_uzbl (WebKitWebView *page, GArray *argv, GString *result);
-static gboolean
+gboolean
run_command(const gchar *command, const guint npre,
const gchar **args, const gboolean sync, char **output_stdout);
-static char*
+char*
build_progressbar_ascii(int percent);
-static void
+void
spawn(WebKitWebView *web_view, GArray *argv, GString *result);
-static void
+void
spawn_sh(WebKitWebView *web_view, GArray *argv, GString *result);
-static void
+void
spawn_sync(WebKitWebView *web_view, GArray *argv, GString *result);
-static void
+void
spawn_sh_sync(WebKitWebView *web_view, GArray *argv, GString *result);
void
parse_command(const char *cmd, const char *param, GString *result);
-static void
+void
parse_cmd_line(const char *ctl_line, GString *result);
-static gchar*
+gchar*
build_stream_name(int type, const gchar *dir);
-static gboolean
+gboolean
control_fifo(GIOChannel *gio, GIOCondition condition);
-static gchar*
+gchar*
init_fifo(gchar *dir);
-static gboolean
+gboolean
control_stdin(GIOChannel *gio, GIOCondition condition);
-static void
+void
create_stdin();
-static gchar*
+gchar*
init_socket(gchar *dir);
-static gboolean
+gboolean
control_socket(GIOChannel *chan);
-static gboolean
+gboolean
control_client_socket(GIOChannel *chan);
-static void
+void
update_title (void);
-static gboolean
+gboolean
key_press_cb (GtkWidget* window, GdkEventKey* event);
-static void
+void
run_keycmd(const gboolean key_ret);
-static void
+void
exec_paramcmd(const Action* act, const guint i);
void
initialize ();
-GtkWidget*
+void
create_browser ();
-static GtkWidget*
+GtkWidget*
create_mainbar ();
-static
-GtkWidget* create_window ();
+GtkWidget*
+create_window ();
-static
-GtkPlug* create_plug ();
+GtkPlug*
+create_plug ();
-static void
+void
run_handler (const gchar *act, const gchar *args);
void
add_binding (const gchar *key, const gchar *act);
-static gchar*
+gchar*
get_xdg_var (XDG_Var xdg);
-static gchar*
+gchar*
find_xdg_file (int xdg_type, char* filename);
-static void
+void
settings_init ();
-static void
+void
search_text (WebKitWebView *page, GArray *argv, const gboolean forward);
-static void
+void
search_forward_text (WebKitWebView *page, GArray *argv, GString *result);
-static void
+void
search_reverse_text (WebKitWebView *page, GArray *argv, GString *result);
-static void
+void
dehilight (WebKitWebView *page, GArray *argv, GString *result);
-static void
+void
run_js (WebKitWebView * web_view, GArray *argv, GString *result);
-static void
+void
run_external_js (WebKitWebView * web_view, GArray *argv, GString *result);
-static void
+void
eval_js(WebKitWebView * web_view, gchar *script, GString *result);
-static void handle_cookies (SoupSession *session,
+void handle_cookies (SoupSession *session,
SoupMessage *msg,
gpointer user_data);
-static void
+void
save_cookies (SoupMessage *msg,
gpointer user_data);
-static void
+void
set_var(WebKitWebView *page, GArray *argv, GString *result);
-static void
+void
act_bind(WebKitWebView *page, GArray *argv, GString *result);
-static void
+void
act_dump_config();
-static void
+void
render_html();
-static void
+void
set_timeout(int seconds);
-static void
+void
dump_var_hash(gpointer k, gpointer v, gpointer ud);
-static void
+void
dump_key_hash(gpointer k, gpointer v, gpointer ud);
-static void
+void
dump_config();
+void
+retreive_geometry();
-static void
-retrieve_geometry();
-
-static gboolean
+gboolean
configure_event_cb(GtkWidget* window, GdkEventConfigure* event);
typedef void (*Command)(WebKitWebView*, GArray *argv, GString *result);
@@ -488,102 +486,102 @@ typedef struct {
} CommandInfo;
/* Command callbacks */
-static void
+void
cmd_load_uri();
-static void
+void
cmd_set_status();
-static void
+void
set_proxy_url();
-static void
+void
set_icon();
-static void
+void
cmd_cookie_handler();
-static void
+void
cmd_new_window();
-static void
+void
move_statusbar();
-static void
+void
cmd_always_insert_mode();
-static void
+void
cmd_http_debug();
-static void
+void
cmd_max_conns();
-static void
+void
cmd_max_conns_host();
/* exported WebKitWebSettings properties */
-static void
+void
cmd_font_size();
-static void
+void
cmd_zoom_level();
-static void
+void
cmd_disable_plugins();
-static void
+void
cmd_disable_scripts();
-static void
+void
cmd_minimum_font_size();
-static void
+void
cmd_fifo_dir();
-static void
+void
cmd_socket_dir();
-static void
+void
cmd_modkey();
void
cmd_useragent() ;
-static void
+void
cmd_autoload_img();
-static void
+void
cmd_autoshrink_img();
-static void
+void
cmd_enable_spellcheck();
-static void
+void
cmd_enable_private();
-static void
+void
cmd_print_bg();
-static void
+void
cmd_style_uri();
-static void
+void
cmd_resizable_txt();
-static void
+void
cmd_default_encoding();
-static void
+void
cmd_enforce_96dpi();
-static void
+void
cmd_inject_html();
-static void
+void
cmd_caret_browsing();
-static void
+void
cmd_set_geometry();
/* vi: set et ts=4: */
diff --git a/uzblctrl.c b/uzblctrl.c
index 93584bc..e768b7f 100644
--- a/uzblctrl.c
+++ b/uzblctrl.c
@@ -33,27 +33,27 @@ main(int argc, char* argv[]) {
int s, len;
struct sockaddr_un remote;
char tmp;
-
+
if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) == -1) {
perror ("socket");
exit (1);
}
-
+
remote.sun_family = AF_UNIX;
strcpy (remote.sun_path, (char *) sockpath);
len = strlen (remote.sun_path) + sizeof (remote.sun_family);
-
+
if (connect (s, (struct sockaddr *) &remote, len) == -1) {
perror ("connect");
exit (1);
}
-
+
if ((send (s, command, strlen (command), 0) == -1) ||
(send (s, "\n", 1, 0) == -1)) {
perror ("send");
exit (1);
}
-
+
while ((len = recv (s, &tmp, 1, 0))) {
putchar(tmp);
if (tmp == '\n')
@@ -61,7 +61,7 @@ main(int argc, char* argv[]) {
}
close(s);
-
+
return 0;
} else {
fprintf(stderr, "Usage: uzblctrl -s /path/to/socket -c \"command\"");