diff -Nru uzbl-0.0.0~git.20111001/debian/changelog uzbl-0.0.0~git.20111128/debian/changelog --- uzbl-0.0.0~git.20111001/debian/changelog 2011-12-26 18:37:22.000000000 +0000 +++ uzbl-0.0.0~git.20111128/debian/changelog 2011-12-26 18:37:22.000000000 +0000 @@ -1,3 +1,9 @@ +uzbl (0.0.0~git.20111128-1) unstable; urgency=low + + * New upstream version + + -- Luca Bruno Thu, 08 Dec 2011 18:46:55 +0100 + uzbl (0.0.0~git.20111001-1) unstable; urgency=low * New upstream version diff -Nru uzbl-0.0.0~git.20111001/docs/keybindings.html uzbl-0.0.0~git.20111128/docs/keybindings.html --- uzbl-0.0.0~git.20111001/docs/keybindings.html 1970-01-01 00:00:00.000000000 +0000 +++ uzbl-0.0.0~git.20111128/docs/keybindings.html 2011-11-29 04:26:27.000000000 +0000 @@ -0,0 +1,222 @@ +Uzbl Keybindings + + + +

Uzbl Keybindings

+ +

These keybindings are totally customizable. You can edit +$XDG_CONFIG_HOME/uzbl/config to modify them or add more.

+ +
+

Navigating the Web

+ +
+
o
+
Open a URL
+ +
O
+
Edit the current URL
+ +
S
+
Stop loading
+ +
b
+
Go back
+ +
f
+
Go forward
+ +
U
+
Search the history
+ +
r
+
Reload the current page
+ +
fl
+
Select a link or form element using the keyboard
+ +
Fl
+
Select a link to open in a new window using the keyboard
+ +
w
+
Open a new window
+ +
c
+
Clone the current window
+
+
+ +
+

Navigating the Page

+ +
+
j
+
Scroll down
+ +
k
+
Scroll up
+ +
h
+
Scroll left
+ +
l
+
Scroll right
+ +
<Page_Up>
+
<Ctrl>f
+
Page up
+ +
<Page_Down>
+
<Ctrl>b
+
Page down
+ +
<<
+
<Home>
+
Scroll to top
+ +
>>
+
<End>
+
Scroll to bottom
+ +
/
+
Search the current page
+ +
?
+
Search the current page in reverse
+ +
n
+
Next search result
+ +
n
+
Previous search result
+
+
+ +
+

Modes

+ +

Uzbl's default configuration is modal (although a completely modeless + configuration should be possible).

+ +

In "command" mode, everything you type is interpreted by uzbl as a + command.

+ +

In "insert" mode, everything you type is passed to the web page, for + form input or the web page's keybindings.

+ +
+
<Ctrl>i
+
i
+
Switch to insert mode
+ +
<Escape>
+
<Ctrl>[
+
Return to command mode
+
Clear the current command
+
+
+ +
+

uzbl-tabbed

+ +

TODO: Write me.

+
+ +
+

Clipboard

+ +

The terminology here is a bit confusing, please look at + this article + if you're not familiar with X selections.

+ +

For these commands to work, xclip must be installed.

+ +
+
yu
+
Copy the current URL to the primary selection
+ +
yU
+
Copy the URL of the hovered link to the primary selection
+ +
yy
+
Copy the page title to the primary selection
+ +
p
+
Go to the URL in the primary selection
+ +
P
+
Go to the URL in the clipboard selection
+ +
'p
+
Open the URL in the primary selection in a new window
+ +
<Shift><Insert>
+
Command mode: Paste the primary selection into the status bar
+
Insert mode: Paste the primary selection into the active form + element.
+
+
+ +
+

Advanced Commands

+ +
+
s
+
Set a variable
+ +
:
+
Issue an uzbl command
+ +
!reload
+
Reload configuration file
+ +
<Ctrl><Mod1>t
+
Open a terminal that prints events and can issue commands to uzbl
+
+
diff -Nru uzbl-0.0.0~git.20111001/examples/config/config uzbl-0.0.0~git.20111128/examples/config/config --- uzbl-0.0.0~git.20111001/examples/config/config 2011-09-27 15:16:28.000000000 +0000 +++ uzbl-0.0.0~git.20111128/examples/config/config 2011-11-29 04:26:27.000000000 +0000 @@ -42,6 +42,7 @@ # These handlers can't be moved to the new event system yet as we don't # support events that can wait for a response from a script. set scheme_handler = sync_spawn @scripts_dir/scheme.py +#set request_handler = sync_spawn @scripts_dir/request.py set authentication_handler = sync_spawn @scripts_dir/auth.py set download_handler = sync_spawn @scripts_dir/download.sh @@ -143,6 +144,16 @@ # Drop google analytics tracking cookies (applied after whitelists if any) #request BLACKLIST_COOKIE name '^__utm.$' +# === SSL related configuration ============================================== + +# Set it to certificates store of your distribution, or your own CAfile. +set ssl_ca_file = /etc/ssl/certs/ca-certificates.crt +set ssl_verify = 1 +# Command to toggle ssl_verify value: +@cbind !ssl = chain 'toggle ssl_verify' 'reload' +# Example SSL error handler: +@on_event LOAD_ERROR js var patt=new RegExp('SSL handshake failed'); if (patt.test('%3')) {alert ('%3');} + # === Key binding configuration ============================================== # --- Internal modmapping and ignoring --------------------------------------- @@ -238,6 +249,8 @@ @cbind ^ = scroll horizontal begin @cbind $ = scroll horizontal end @cbind = scroll vertical end +@cbind G_ = scroll vertical %r! +@cbind _G_ = scroll horizontal %r! # Navigation binds @cbind b = back @@ -249,12 +262,12 @@ # Zoom binds @cbind + = zoom_in @cbind - = zoom_out -@cbind T = toggle_zoom_type +@cbind T = toggle zoom_type @cbind 1 = set zoom_level = 1.0 @cbind 2 = set zoom_level = 2.0 # Appearance binds -@cbind t = toggle_status +@cbind t = toggle show_status # Page searching binds @cbind /* = search %s diff -Nru uzbl-0.0.0~git.20111001/examples/data/scripts/follow.js uzbl-0.0.0~git.20111128/examples/data/scripts/follow.js --- uzbl-0.0.0~git.20111001/examples/data/scripts/follow.js 2011-09-27 15:16:28.000000000 +0000 +++ uzbl-0.0.0~git.20111128/examples/data/scripts/follow.js 2011-11-29 04:26:27.000000000 +0000 @@ -288,11 +288,10 @@ // we're opening a new window using the URL attached to this element var uri = el.src || el.href; if(uri.match(/javascript:/)) return; - window.open(uri); - return "XXXRESET_MODEXXX" + return "XXXNEW_WINDOWXXX " + uri; } else { - // we're just going to click the element - return this.clickElem(el); + // we're just going to click the element + return this.clickElem(el); } } diff -Nru uzbl-0.0.0~git.20111001/examples/data/scripts/follow.sh uzbl-0.0.0~git.20111128/examples/data/scripts/follow.sh --- uzbl-0.0.0~git.20111001/examples/data/scripts/follow.sh 2011-09-27 15:16:28.000000000 +0000 +++ uzbl-0.0.0~git.20111128/examples/data/scripts/follow.sh 2011-11-29 04:26:27.000000000 +0000 @@ -13,6 +13,9 @@ # a link was selected, reset uzbl's input mode printf 'set mode=\nevent KEYCMD_CLEAR\n' > "$UZBL_FIFO" ;; + XXXNEW_WINDOWXXX*) + printf "set mode=\nevent KEYCMD_CLEAR\nevent NEW_WINDOW $@\n" > "$UZBL_FIFO" + ;; XXXRETURNED_URIXXX*) uriaction=$1 uri=${result#XXXRETURNED_URIXXX} diff -Nru uzbl-0.0.0~git.20111001/examples/data/scripts/formfiller.js uzbl-0.0.0~git.20111128/examples/data/scripts/formfiller.js --- uzbl-0.0.0~git.20111001/examples/data/scripts/formfiller.js 2011-09-27 15:16:28.000000000 +0000 +++ uzbl-0.0.0~git.20111128/examples/data/scripts/formfiller.js 2011-11-29 04:26:27.000000000 +0000 @@ -29,6 +29,9 @@ for( var k = 0; k < inputs.length; ++k ) { var input = inputs[k]; + if ( ! input.name ) { + continue + } if ( uzbl.formfiller.inputTypeIsText(input.type) ) { rv += '%' + escape(input.name) + '(' + input.type + '):' + input.value + '\n'; } else if ( input.type == 'checkbox' || input.type == 'radio' ) { @@ -39,8 +42,10 @@ var textareas = allFrames[j].document.getElementsByTagName("textarea"); for( var k = 0; k < textareas.length; ++k ) { var textarea = textareas[k]; - rv += '%' + escape(textarea.name) + '(textarea):\n' + textarea.value.replace(/\n%/g,"\n\\%") + '\n%\n'; - rv += '%' + escape(textarea.name) + '(textarea):\n' + textarea.value.replace(/\n\\/g,"\n\\\\").replace(/\n%/g,"\n\\%") + '%\n'; + if ( ! textarea.name ) { + continue + } + rv += '%' + escape(textarea.name) + '(textarea):\n' + textarea.value.replace(/(^|\n)\\/g,"$1\\\\").replace(/(^|\n)%/g,"$1\\%") + '\n%\n'; } } catch (err) { } diff -Nru uzbl-0.0.0~git.20111001/examples/data/scripts/formfiller.sh uzbl-0.0.0~git.20111128/examples/data/scripts/formfiller.sh --- uzbl-0.0.0~git.20111001/examples/data/scripts/formfiller.sh 2011-09-27 15:16:28.000000000 +0000 +++ uzbl-0.0.0~git.20111128/examples/data/scripts/formfiller.sh 2011-11-29 04:26:27.000000000 +0000 @@ -63,6 +63,9 @@ awk '/^%/ { sub ( /%/, "" ) + gsub ( /\\/, "\\\\\\\\" ) + gsub ( /@/, "\\@" ) + gsub ( /"/, "\\\"" ) split( $0, parts, /\(|\)|\{|\}/ ) @@ -73,15 +76,24 @@ printf( "js uzbl.formfiller.insert(\"%s\",\"%s\",\"%s\",%s);\n", parts[1], parts[2], parts[3], field ) - else if ( parts[2] ~ /^textarea$/ ) { + else if ( parts[2] == "textarea" ) { field = "" while (getline) { if ( /^%/ ) break sub ( /^\\/, "" ) + # JavaScript escape + gsub ( /\\/, "\\\\\\\\" ) gsub ( /"/, "\\\"" ) - gsub ( /\\/, "\\\\" ) - field = field $0 "\\\\n" + # To support the possibility of the last line of the textarea + # not being terminated by a newline, we add the newline here. + # The "if (field)" is so that this does not happen in the first + # iteration. + if (field) field = field "\\n" + field = field $0 } + # Uzbl escape + gsub ( /\\/, "\\\\\\\\", field ) + gsub ( /@/, "\\@", field ) printf( "js uzbl.formfiller.insert(\"%s\",\"%s\",\"%s\",0);\n", parts[1], parts[2], field ) } @@ -120,7 +132,6 @@ ParseProfile $option < "$file" \ | ParseFields \ - | sed 's/@/\\@/g' \ > "$UZBL_FIFO" } @@ -136,7 +147,6 @@ test -e "$tmpfile" && ParseFields < "$tmpfile" \ - | sed 's/@/\\@/g' \ > "$UZBL_FIFO" } diff -Nru uzbl-0.0.0~git.20111001/examples/data/scripts/load_cookies.sh uzbl-0.0.0~git.20111128/examples/data/scripts/load_cookies.sh --- uzbl-0.0.0~git.20111001/examples/data/scripts/load_cookies.sh 2011-09-27 15:16:28.000000000 +0000 +++ uzbl-0.0.0~git.20111128/examples/data/scripts/load_cookies.sh 2011-11-29 04:26:27.000000000 +0000 @@ -13,9 +13,11 @@ scheme["FALSE"] = "http"; } $0 ~ /^#HttpOnly_/ { + gsub(/@/, "\\@") printf("add_cookie \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"\n", substr($1,length("#HttpOnly_"),length($1)), $3, $6, $7, scheme[$4], $5) } $0 !~ /^#/ { + gsub(/@/, "\\@") printf("add_cookie \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"\n", $1, $3, $6, $7, scheme[$4], $5) } ' "$cookie_file" diff -Nru uzbl-0.0.0~git.20111001/extras/vim/syntax/uzbl.vim uzbl-0.0.0~git.20111128/extras/vim/syntax/uzbl.vim --- uzbl-0.0.0~git.20111001/extras/vim/syntax/uzbl.vim 2011-09-27 15:16:28.000000000 +0000 +++ uzbl-0.0.0~git.20111128/extras/vim/syntax/uzbl.vim 2011-11-29 04:26:27.000000000 +0000 @@ -26,8 +26,8 @@ endif syn keyword uzblKeyword back forward scroll reload reload_ign_cache stop -syn keyword uzblKeyword zoom_in zoom_out toggle_zoom_type uri script -syn keyword uzblKeyword toggle_status spawn sync_spawn sync_sh sync_spawn_exec +syn keyword uzblKeyword zoom_in zoom_out toggle uri script +syn keyword uzblKeyword spawn sync_spawn sync_sh sync_spawn_exec syn keyword uzblKeyword exit search search_reverse search_clear dehilight set syn keyword uzblKeyword dump_config dump_config_as_events chain print event syn keyword uzblKeyword request menu_add menu_link_add menu_image_add diff -Nru uzbl-0.0.0~git.20111001/Makefile uzbl-0.0.0~git.20111128/Makefile --- uzbl-0.0.0~git.20111001/Makefile 2011-09-27 15:16:28.000000000 +0000 +++ uzbl-0.0.0~git.20111128/Makefile 2011-11-29 04:26:27.000000000 +0000 @@ -10,7 +10,7 @@ USE_GTK3 = $(shell pkg-config --exists gtk+-3.0 webkitgtk-3.0 && echo 1) ifeq ($(USE_GTK3),1) - REQ_PKGS += gtk+-3.0 webkitgtk-3.0 + REQ_PKGS += gtk+-3.0 webkitgtk-3.0 javascriptcoregtk-3.0 CPPFLAGS = -DG_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED else REQ_PKGS += gtk+-2.0 webkit-1.0 diff -Nru uzbl-0.0.0~git.20111001/misc/hash.sh uzbl-0.0.0~git.20111128/misc/hash.sh --- uzbl-0.0.0~git.20111001/misc/hash.sh 2011-09-27 15:16:28.000000000 +0000 +++ uzbl-0.0.0~git.20111128/misc/hash.sh 2011-11-29 04:26:27.000000000 +0000 @@ -5,7 +5,7 @@ # alternatively, you could also git get-tar-commit-id < tarball (but that's a bit dirtier) # the `%` expansions possible here are described in `man git-log` -FROM_ARCHIVE=9576f59 +FROM_ARCHIVE=e93bd72 # ... but try to use whatever git tells us if there is a .git folder if [ -d .git -a -r .git ] diff -Nru uzbl-0.0.0~git.20111001/README uzbl-0.0.0~git.20111128/README --- uzbl-0.0.0~git.20111001/README 2011-09-27 15:16:28.000000000 +0000 +++ uzbl-0.0.0~git.20111128/README 2011-11-29 04:26:27.000000000 +0000 @@ -141,6 +141,7 @@ - argument can be `begin`, `end`, or an amount given in pixels(?) or as a percentage of the size of the view - set the amount to 100% to scroll a whole page + - argument can be appended with a `!` to scroll absolutely * `reload` - Reload the current page. * `reload_ign_cache` @@ -151,11 +152,6 @@ - Increase the zoom level. * `zoom_out` - Decrease the zoom level. -* `toggle_zoom_type` - - Toggles the variable `zoom_type` between "full-content" and "text-only" - zoom. In "text-only" zoom, only the text of the page is zoomed, while in - "full-content" zoom, images and other page elements are zoomed along with - the text. * `uri
` - Attempt to load `
`. This is equivalent to `set uri =
`. * `js ` @@ -163,8 +159,6 @@ - Remember that the commands must not contain line breaks. * `script ` - Execute the JavaScript in ``. -* `toggle_status` - - Toggle the display of the status bar. * `spawn ` TODO explain path-alike expansion - Runs a command; see EXTERNAL SCRIPTS for details. - `$PATH` is searched, so giving the full path to commands is not necessary. @@ -201,6 +195,11 @@ the status bar react immediately. - If you want to unset a string, use `set` with one space after the equals sign. +* `toggle [possibilities]` + - Cycles the variable `var` through the list of options given in + `possibilities`. + - If `possibilities` are not given and the variable is an int or a float, + toggles between 0 and 1. * `dump_config` - Dumps the current config (which may have been changed at runtime) to stdout. - Uses a format which can be piped into `uzbl` again or saved as a config @@ -313,6 +312,9 @@ - `data`: The cookie data. Only included for "PUT" requests. * `scheme_handler`: handler to execute for each URI navigated to - the navigation request will be ignored if handler prints "USED\n" +* `request_handler`: Executed whenever any request is made. The handler can + print a URI to redirect the request (or `about:blank` to effectively cancel it). + If the handler does nothing, the request will continue unchanged. * `download_handler`: executed when a download is started. the handler script should print a path that the download should be saved to, or print nothing to cancel the download. @@ -354,6 +356,9 @@ * `autoshrink_images`: Shrink images to window size (default 0). * `enable_spellcheck`: Whether to enable spell checking while typing (default 0). +* `spellcheck_languages`: The languages (in locale `lang_COUNTRY` form, e.g. + `en_CA` or `pt_BR`) to be used for spell checking, separated by commas. + Defaults to the value returned by `gtk_get_default_language`. * `enable_private`: Whether to enable private browsing mode (default 0). * `print_backgrounds`: Print background images? (default 0). * `stylesheet_uri`: Use this to override the pagelayout with a custom @@ -368,6 +373,9 @@ access the contents of other `file://` URIs. (default 0). * `follow_hint_keys`: keys for keyboard-based navigation and link highlighting +* `ssl_ca_file`: File that contains CA certificates. +* `ssl_verify`: If set to 1, uzbl won't connect to "https" url unless it can + validate certificate presented by remote server against `ssl_ca_file`. #### Constants (not dumpable or writeable) @@ -504,8 +512,9 @@ * `$UZBL_URI`: The URI of the current page. * `$UZBL_TITLE`: The current page title. -Handler scripts (`download_handler`, `cookie_handler`, `scheme_handler` and -`authentication_handler`) are called with special arguments: +Handler scripts (`download_handler`, `cookie_handler`, `scheme_handler`, +`request_handler`, and `authentication_handler`) are called with special +arguments: * download handler @@ -534,6 +543,10 @@ - `$1 URI` of the page to be navigated to +* request handler + + - `$1 URI` of the resource which is being requested + * authentication handler: - `$1`: authentication zone unique identifier diff -Nru uzbl-0.0.0~git.20111001/src/callbacks.c uzbl-0.0.0~git.20111128/src/callbacks.c --- uzbl-0.0.0~git.20111001/src/callbacks.c 2011-09-27 15:16:28.000000000 +0000 +++ uzbl-0.0.0~git.20111128/src/callbacks.c 2011-11-29 04:26:27.000000000 +0000 @@ -165,12 +165,13 @@ gboolean propagate = FALSE, sendev = FALSE; + context = get_click_context(NULL); + if(event->type == GDK_BUTTON_PRESS) { if(uzbl.state.last_button) gdk_event_free((GdkEvent *)uzbl.state.last_button); uzbl.state.last_button = (GdkEventButton *)gdk_event_copy((GdkEvent *)event); - context = get_click_context(NULL); /* left click */ if(event->button == 1) { if((context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE)) @@ -357,7 +358,31 @@ (void) response; (void) user_data; + const gchar* uri = webkit_network_request_get_uri (request); + + if (uzbl.state.verbose) + printf("Request starting -> %s\n", uri); send_event (REQUEST_STARTING, NULL, TYPE_STR, webkit_network_request_get_uri(request), NULL); + + if (uzbl.behave.request_handler) { + GString *result = g_string_new (""); + GArray *a = g_array_new (TRUE, FALSE, sizeof(gchar*)); + const CommandInfo *c = parse_command_parts(uzbl.behave.request_handler, a); + + if(c) { + g_array_append_val(a, uri); + run_parsed_command(c, a, result); + } + g_array_free(a, TRUE); + + if(result->len > 0) { + char *p = strchr(result->str, '\n' ); + if ( p != NULL ) *p = '\0'; + webkit_network_request_set_uri(request, result->str); + } + + g_string_free(result, TRUE); + } } void diff -Nru uzbl-0.0.0~git.20111001/src/commands.c uzbl-0.0.0~git.20111128/src/commands.c --- uzbl-0.0.0~git.20111001/src/commands.c 2011-09-27 15:16:28.000000000 +0000 +++ uzbl-0.0.0~git.20111128/src/commands.c 2011-11-29 04:26:27.000000000 +0000 @@ -34,6 +34,7 @@ { "search_clear", search_clear, TRUE }, { "dehilight", dehilight, 0 }, { "set", set_var, TRUE }, + { "toggle", toggle_var, 0 }, { "dump_config", act_dump_config, 0 }, { "dump_config_as_events", act_dump_config_as_events, 0 }, { "chain", chain, 0 }, @@ -116,6 +117,7 @@ * scroll vertical 20 * scroll vertical 20% * scroll vertical -40 + * scroll vertical 20! * scroll vertical begin * scroll vertical end * scroll horizontal 10 @@ -164,6 +166,112 @@ g_strfreev(split); } +void +toggle_var(WebKitWebView *page, GArray *argv, GString *result) { + (void) page; (void) result; + + if(!argv_idx(argv, 0)) + return; + + const gchar *var_name = argv_idx(argv, 0); + + uzbl_cmdprop *c = get_var_c(var_name); + + if(!c) { + set_var_value(var_name, argv_idx(argv, 1)); + return; + } + + switch(c->type) { + case TYPE_STR: + { + const gchar *next; + + if(argv->len >= 3) { + gchar *current = get_var_value_string_c(c); + + guint i = 2; + const gchar *first = argv_idx(argv, 1); + const gchar *this = first; + next = argv_idx(argv, 2); + + while(next && strcmp(current, this)) { + this = next; + next = argv_idx(argv, ++i); + } + + if(!next) + next = first; + + g_free(current); + } else + next = ""; + + set_var_value_string_c(c, next); + break; + } + case TYPE_INT: + { + int current = get_var_value_int_c(c); + int next; + + if(argv->len >= 3) { + guint i = 2; + + int first = strtoul(argv_idx(argv, 1), NULL, 10); + int this = first; + + const gchar *next_s = argv_idx(argv, 2); + + while(next_s && this != current) { + this = strtoul(next_s, NULL, 10); + next_s = argv_idx(argv, ++i); + } + + if(next_s) + next = strtoul(next_s, NULL, 10); + else + next = first; + } else + next = !current; + + set_var_value_int_c(c, next); + break; + } + case TYPE_FLOAT: + { + float current = get_var_value_float_c(c); + float next; + + if(argv->len >= 3) { + guint i = 2; + + float first = strtod(argv_idx(argv, 1), NULL); + float this = first; + + const gchar *next_s = argv_idx(argv, 2); + + while(next_s && this != current) { + this = strtod(next_s, NULL); + next_s = argv_idx(argv, ++i); + } + + if(next_s) + next = strtod(next_s, NULL); + else + next = first; + } else + next = !current; + + set_var_value_float_c(c, next); + break; + } + default: + g_assert_not_reached(); + } + + send_set_var_event(var_name, c); +} void event(WebKitWebView *page, GArray *argv, GString *result) { diff -Nru uzbl-0.0.0~git.20111001/src/commands.h uzbl-0.0.0~git.20111128/src/commands.h --- uzbl-0.0.0~git.20111001/src/commands.h 2011-09-27 15:16:28.000000000 +0000 +++ uzbl-0.0.0~git.20111128/src/commands.h 2011-11-29 04:26:27.000000000 +0000 @@ -58,6 +58,7 @@ void clear_cookies(WebKitWebView *pag, GArray *argv, GString *result); void download(WebKitWebView *pag, GArray *argv, GString *result); void set_var(WebKitWebView *page, GArray *argv, GString *result); +void toggle_var(WebKitWebView *page, GArray *argv, GString *result); void run_js (WebKitWebView * web_view, GArray *argv, GString *result); void run_external_js (WebKitWebView * web_view, GArray *argv, GString *result); void toggle_zoom_type (WebKitWebView* page, GArray *argv, GString *result); diff -Nru uzbl-0.0.0~git.20111001/src/uzbl-core.c uzbl-0.0.0~git.20111128/src/uzbl-core.c --- uzbl-0.0.0~git.20111001/src/uzbl-core.c 2011-09-27 15:16:28.000000000 +0000 +++ uzbl-0.0.0~git.20111128/src/uzbl-core.c 2011-11-29 04:26:27.000000000 +0000 @@ -331,11 +331,15 @@ if (*end == '%') value += page_size * amount * 0.01; + else if (*end == '!') + value = amount; else value += amount; max_value = gtk_adjustment_get_upper(bar) - page_size; + if (value < 0) + value = 0; /* don't scroll past the beginning of the page */ if (value > max_value) value = max_value; /* don't scroll past the end of the page */ @@ -813,7 +817,6 @@ GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (window), 800, 600); - gtk_widget_set_name (window, "Uzbl"); gtk_window_set_title(GTK_WINDOW(window), "Uzbl"); #if GTK_CHECK_VERSION(3,0,0) @@ -963,9 +966,10 @@ if (uzbl.state.socket_id || uzbl.state.embed) uzbl.state.plug_mode = TRUE; +#if !GLIB_CHECK_VERSION(2, 31, 0) if (!g_thread_supported()) g_thread_init(NULL); - +#endif /* TODO: move the handler setup to event_buffer_timeout and disarm the * handler in empty_event_buffer? */ @@ -1034,10 +1038,12 @@ if (uzbl.state.plug_mode) { /* Embedded mode */ uzbl.gui.plug = create_plug(); + gtk_widget_set_name (GTK_WIDGET(uzbl.gui.plug), "Uzbl"); gtk_container_add (GTK_CONTAINER (uzbl.gui.plug), uzbl.gui.vbox); } else { /* Windowed mode */ uzbl.gui.main_window = create_window(); + gtk_widget_set_name (uzbl.gui.main_window, "Uzbl"); gtk_container_add (GTK_CONTAINER (uzbl.gui.main_window), uzbl.gui.vbox); /* We need to ensure there is a window, before we can get XID */ diff -Nru uzbl-0.0.0~git.20111001/src/uzbl-core.h uzbl-0.0.0~git.20111128/src/uzbl-core.h --- uzbl-0.0.0~git.20111001/src/uzbl-core.h 2011-09-27 15:16:28.000000000 +0000 +++ uzbl-0.0.0~git.20111128/src/uzbl-core.h 2011-11-29 04:26:27.000000000 +0000 @@ -130,6 +130,11 @@ gint max_conns_host; } Network; +/* ssl */ +typedef struct { + gchar *ca_file; + gchar *verify_cert; +} Ssl; /* Behaviour */ typedef struct { @@ -150,6 +155,7 @@ /* Handlers */ gchar* authentication_handler; gchar* scheme_handler; + gchar* request_handler; gchar* download_handler; gboolean forward_keys; @@ -184,6 +190,7 @@ GUI gui; State state; Network net; + Ssl ssl; Behaviour behave; Communication comm; Info info; diff -Nru uzbl-0.0.0~git.20111001/src/variables.c uzbl-0.0.0~git.20111128/src/variables.c --- uzbl-0.0.0~git.20111001/src/variables.c 2011-09-27 15:16:28.000000000 +0000 +++ uzbl-0.0.0~git.20111128/src/variables.c 2011-11-29 04:26:27.000000000 +0000 @@ -5,6 +5,11 @@ #include "io.h" #include "util.h" +uzbl_cmdprop * +get_var_c(const gchar *name) { + return g_hash_table_lookup(uzbl.behave.proto_var, name); +} + void send_set_var_event(const char *name, const uzbl_cmdprop *c) { /* check for the variable type */ @@ -41,8 +46,8 @@ void expand_variable(GString *buf, const gchar *name) { - uzbl_cmdprop* c; - if((c = g_hash_table_lookup(uzbl.behave.proto_var, name))) { + uzbl_cmdprop* c = get_var_c(name); + if(c) { if(c->type == TYPE_STR) { gchar *v = get_var_value_string_c(c); g_string_append(buf, v); @@ -54,50 +59,59 @@ } } +void +set_var_value_string_c(uzbl_cmdprop *c, const gchar *val) { + if(c->setter) + ((void (*)(const gchar *))c->setter)(val); + else { + g_free(*(c->ptr.s)); + *(c->ptr.s) = g_strdup(val); + } +} + +void +set_var_value_int_c(uzbl_cmdprop *c, int i) { + if(c->setter) + ((void (*)(int))c->setter)(i); + else + *(c->ptr.i) = i; +} + +void +set_var_value_float_c(uzbl_cmdprop *c, float f) { + if(c->setter) + ((void (*)(float))c->setter)(f); + else + *(c->ptr.f) = f; +} + gboolean set_var_value(const gchar *name, gchar *val) { - uzbl_cmdprop *c = NULL; - g_assert(val != NULL); - if( (c = g_hash_table_lookup(uzbl.behave.proto_var, name)) ) { + uzbl_cmdprop *c = get_var_c(name); + + if(c) { if(!c->writeable) return FALSE; - if(c->setter) { - switch(c->type) { - case TYPE_STR: - ((void (*)(const gchar *))c->setter)(val); - break; - case TYPE_INT: - { - int i = (int)strtoul(val, NULL, 10); - ((void (*)(int))c->setter)(i); - break; - } - case TYPE_FLOAT: - { - float f = strtod(val, NULL); - ((void (*)(float))c->setter)(f); - break; - } - default: - g_assert_not_reached(); - } - } else { - switch(c->type) { - case TYPE_STR: - g_free(*(c->ptr.s)); - *(c->ptr.s) = g_strdup(val); - break; - case TYPE_INT: - *(c->ptr.i) = (int)strtoul(val, NULL, 10); - break; - case TYPE_FLOAT: - *(c->ptr.f) = strtod(val, NULL); - break; - default: - g_assert_not_reached(); - } + switch(c->type) { + case TYPE_STR: + set_var_value_string_c(c, val); + break; + case TYPE_INT: + { + int i = (int)strtoul(val, NULL, 10); + set_var_value_int_c(c, i); + break; + } + case TYPE_FLOAT: + { + float f = strtod(val, NULL); + set_var_value_float_c(c, f); + break; + } + default: + g_assert_not_reached(); } send_set_var_event(name, c); @@ -148,7 +162,7 @@ gchar* get_var_value_string(const gchar *name) { - uzbl_cmdprop *c = g_hash_table_lookup(uzbl.behave.proto_var, name); + uzbl_cmdprop *c = get_var_c(name); return get_var_value_string_c(c); } @@ -166,7 +180,7 @@ int get_var_value_int(const gchar *name) { - uzbl_cmdprop *c = g_hash_table_lookup(uzbl.behave.proto_var, name); + uzbl_cmdprop *c = get_var_c(name); return get_var_value_int_c(c); } @@ -184,7 +198,7 @@ float get_var_value_float(const gchar *name) { - uzbl_cmdprop *c = g_hash_table_lookup(uzbl.behave.proto_var, name); + uzbl_cmdprop *c = get_var_c(name); return get_var_value_float_c(c); } @@ -357,6 +371,30 @@ SOUP_SESSION_FEATURE(uzbl.net.soup_logger)); } +void +set_ca_file(gchar *path) { + g_object_set (uzbl.net.soup_session, "ssl-ca-file", path, NULL); +} + +gchar * +get_ca_file() { + gchar *path; + g_object_get (uzbl.net.soup_session, "ssl-ca-file", &path, NULL); + return path; +} + +void +set_verify_cert(int strict) { + g_object_set (uzbl.net.soup_session, "ssl-strict", strict, NULL); +} + +int +get_verify_cert() { + int strict; + g_object_get (uzbl.net.soup_session, "ssl-strict", &strict, NULL); + return strict; +} + #define EXPOSE_WEBKIT_VIEW_SETTINGS(SYM, PROPERTY, TYPE) \ void set_##SYM(TYPE val) { \ g_object_set(view_settings(), (PROPERTY), val, NULL); \ @@ -629,7 +667,7 @@ set_accept_languages(const gchar *accept_languages) { g_free(uzbl.net.accept_languages); - if (*uzbl.net.accept_languages == ' ') { + if (*accept_languages == ' ') { uzbl.net.accept_languages = NULL; } else { uzbl.net.accept_languages = g_strdup(accept_languages); @@ -711,6 +749,7 @@ { "authentication_handler", PTR_V_STR(uzbl.behave.authentication_handler, 1, set_authentication_handler)}, { "scheme_handler", PTR_V_STR(uzbl.behave.scheme_handler, 1, NULL)}, + { "request_handler", PTR_V_STR(uzbl.behave.request_handler, 1, NULL)}, { "download_handler", PTR_V_STR(uzbl.behave.download_handler, 1, NULL)}, { "fifo_dir", PTR_V_STR(uzbl.behave.fifo_dir, 1, set_fifo_dir)}, @@ -727,6 +766,9 @@ { "view_source", PTR_V_INT(uzbl.behave.view_source, 0, set_view_source)}, + { "ssl_ca_file", PTR_V_STR_GETSET(ca_file)}, + { "ssl_verify", PTR_V_INT_GETSET(verify_cert)}, + /* exported WebKitWebSettings properties */ { "javascript_windows", PTR_V_INT_GETSET(javascript_windows)}, { "zoom_level", PTR_V_FLOAT_GETSET(zoom_level)}, diff -Nru uzbl-0.0.0~git.20111001/src/variables.h uzbl-0.0.0~git.20111128/src/variables.h --- uzbl-0.0.0~git.20111001/src/variables.h 2011-09-27 15:16:28.000000000 +0000 +++ uzbl-0.0.0~git.20111128/src/variables.h 2011-11-29 04:26:27.000000000 +0000 @@ -10,6 +10,8 @@ #include "type.h" +uzbl_cmdprop *get_var_c(const gchar *name); + gboolean set_var_value(const gchar *name, gchar *val); void expand_variable(GString *buf, const gchar *name); void variables_hash(); @@ -21,6 +23,12 @@ float get_var_value_float_c(const uzbl_cmdprop *c); float get_var_value_float(const char *name); +void set_var_value_string_c(uzbl_cmdprop *c, const gchar *val); +void set_var_value_int_c(uzbl_cmdprop *c, int f); +void set_var_value_float_c(uzbl_cmdprop *c, float f); + +void send_set_var_event(const char *name, const uzbl_cmdprop *c); + void dump_config(); void dump_config_as_events(); diff -Nru uzbl-0.0.0~git.20111001/tests/test-command.c uzbl-0.0.0~git.20111128/tests/test-command.c --- uzbl-0.0.0~git.20111001/tests/test-command.c 2011-09-27 15:16:28.000000000 +0000 +++ uzbl-0.0.0~git.20111128/tests/test-command.c 2011-11-29 04:26:27.000000000 +0000 @@ -253,11 +253,11 @@ g_assert(!get_show_status()); /* status bar can be toggled on */ - parse_cmd_line("toggle_status", NULL); + parse_cmd_line("toggle show_status", NULL); g_assert(get_show_status()); /* status bar can be toggled back off */ - parse_cmd_line("toggle_status", NULL); + parse_cmd_line("toggle show_status", NULL); g_assert(!get_show_status()); } @@ -308,6 +308,57 @@ /* if we didn't crash then we're ok! */ } +// TODO: test toggling emits an event +void +test_toggle_int (void) { + g_assert_cmpint(0, ==, uzbl.behave.forward_keys); + + parse_cmd_line("toggle forward_keys", NULL); + g_assert_cmpint(1, ==, uzbl.behave.forward_keys); + + parse_cmd_line("toggle forward_keys", NULL); + g_assert_cmpint(0, ==, uzbl.behave.forward_keys); + + // if cycle values are specified it should use those + parse_cmd_line("toggle forward_keys 1 2", NULL); + g_assert_cmpint(1, ==, uzbl.behave.forward_keys); + + parse_cmd_line("toggle forward_keys 1 2", NULL); + g_assert_cmpint(2, ==, uzbl.behave.forward_keys); + + // and wrap to the first value when it reaches the end. + parse_cmd_line("toggle forward_keys 1 2", NULL); + g_assert_cmpint(1, ==, uzbl.behave.forward_keys); +} + +void +test_toggle_string (void) { + parse_cmd_line("set useragent = something interesting", NULL); + g_assert_cmpstr("something interesting", ==, uzbl.net.useragent); + + // when something was set, it gets reset + parse_cmd_line("toggle useragent", NULL); + g_assert_cmpstr("", ==, uzbl.net.useragent); + + // if cycle values are specified it should use those + parse_cmd_line("set useragent = something interesting", NULL); + parse_cmd_line("toggle useragent 'x' 'y'", NULL); + g_assert_cmpstr("x", ==, uzbl.net.useragent); + + parse_cmd_line("toggle useragent 'x' 'y'", NULL); + g_assert_cmpstr("y", ==, uzbl.net.useragent); + + // and wrap to the first value when it reaches the end. + parse_cmd_line("toggle useragent 'x' 'y'", NULL); + g_assert_cmpstr("x", ==, uzbl.net.useragent); + + // user-defined variables can be toggled too. + parse_cmd_line("toggle new_variable 'x' 'y'", NULL); + gchar *value = get_var_value_string("new_variable"); + g_assert_cmpstr("x", ==, value); + g_free(value); +} + int main (int argc, char *argv[]) { /* set up tests */ @@ -329,6 +380,10 @@ g_test_add_func("/test-command/no-such-command", test_no_such_command); + g_test_add_func("/test-command/toggle-int", test_toggle_int); + // we should probably test toggle float, but meh. + g_test_add_func("/test-command/toggle-string", test_toggle_string); + /* set up uzbl */ initialize(argc, argv);