From 718c13eb7528348f50b37a16599cec876d512cfa Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Thu, 30 Dec 2010 18:24:22 -0700 Subject: remove positional arguments from README --- README | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) (limited to 'README') diff --git a/README b/README index 35492da..e4e3cab 100644 --- a/README +++ b/README @@ -499,39 +499,36 @@ access to the following environment variables: * `$UZBL_URI`: The URI of the current page. * `$UZBL_TITLE`: The current page title. -These variables are also available as positional arguments `$1` through `$7`, -but this is deprecated and will be removed. - Handler scripts (`download_handler`, `cookie_handler`, `scheme_handler` and `authentication_handler`) are called with special arguments: * download handler - - `$8 url`: The URL of the item to be downloaded. - - `$9 suggested_filename`: A filename suggested by the server or based on the URL. - - `$10 content_type`: The mimetype of the file to be downloaded. - - `$11 total_size`: The size of the file to be downloaded in bytes. This may be inaccurate. + - `$1 url`: The URL of the item to be downloaded. + - `$2 suggested_filename`: A filename suggested by the server or based on the URL. + - `$3 content_type`: The mimetype of the file to be downloaded. + - `$4 total_size`: The size of the file to be downloaded in bytes. This may be inaccurate. * cookie handler - - `$8 GET/PUT`: Whether a cookie should be sent to the server (`GET`) or + - `$1 GET/PUT`: Whether a cookie should be sent to the server (`GET`) or stored by the browser (`PUT`). - - `$9 scheme`: Either `http` or `https`. - - `$10 host`: If current page URL is `www.example.com/somepage`, this could be + - `$2 scheme`: Either `http` or `https`. + - `$3 host`: If current page URL is `www.example.com/somepage`, this could be something else than `example.com`, eg advertising from another host. - - `$11 path`: The request address path. - - `$12 data`: The cookie data. Only included for `PUT` requests. + - `$4 path`: The request address path. + - `$5 data`: The cookie data. Only included for `PUT` requests. * scheme handler - - `$8 URI` of the page to be navigated to + - `$1 URI` of the page to be navigated to * authentication handler: - - `$8`: authentication zone unique identifier - - `$9`: domain part of URL that requests authentication - - `$10`: authentication realm - - `$11`: FALSE if this is the first attempt to authenticate, TRUE otherwise + - `$1`: authentication zone unique identifier + - `$2`: domain part of URL that requests authentication + - `$3`: authentication realm + - `$4`: FALSE if this is the first attempt to authenticate, TRUE otherwise ### Formfiller.sh @@ -577,15 +574,15 @@ Example: Script will be executed on each authentication request. It will receive four auth-related parameters: - $8 authentication zone unique identifier (may be used as 'key') - $9 domain part of URL that requests authentication - $10 authentication realm - $11 FALSE if this is the first attempt to authenticate, TRUE otherwise + $1 authentication zone unique identifier (may be used as 'key') + $2 domain part of URL that requests authentication + $3 authentication realm + $4 FALSE if this is the first attempt to authenticate, TRUE otherwise Script is expected to print exactly two lines of text on stdout (that means its output must contain exactly two '\n' bytes). The first line contains username, the second one - password. -If authentication fails, script will be executed again (with $11 = TRUE). +If authentication fails, script will be executed again (with $4 = TRUE). Non-interactive scripts should handle this case and do not try to authenticate again to avoid loops. If number of '\n' characters in scripts output does not equal 2, authentication will fail. @@ -594,7 +591,7 @@ That means 401 error will be displayed and uzbl won't try to authenticate anymor The simplest example of authentication handler script is: #!/bin/sh -[ "$11" == "TRUE ] && exit +[ "$4" == "TRUE ] && exit echo alice echo wonderland -- cgit v1.2.3 From 0f3d7ef6f8150e30ebab28895ddb4c4c3beefb8c Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Mon, 3 Jan 2011 10:52:41 -0700 Subject: add accept_languages setting --- README | 1 + src/callbacks.c | 11 +++++++++++ src/callbacks.h | 3 +++ src/uzbl-core.c | 1 + src/uzbl-core.h | 1 + 5 files changed, 17 insertions(+) (limited to 'README') diff --git a/README b/README index e4e3cab..98ae22c 100644 --- a/README +++ b/README @@ -329,6 +329,7 @@ file). rendered content. * `useragent`: The User-Agent to send to the browser, expands variables in its definition. +* `accept_languages`: The Accept-Language header to send with HTTP requests. * `zoom_level`: The factor by which elements in the page are scaled with respect to their original size. Setting this will resize the currently displayed page. * `zoom_type`: Whether to use "full-content" zoom (defaults to true). With diff --git a/src/callbacks.c b/src/callbacks.c index 673979e..7b06873 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -308,6 +308,17 @@ cmd_useragent() { } } +void +set_accept_languages() { + if (*uzbl.net.accept_languages == ' ') { + g_free (uzbl.net.accept_languages); + uzbl.net.accept_languages = NULL; + } else { + g_object_set(G_OBJECT(uzbl.net.soup_session), + SOUP_SESSION_ACCEPT_LANGUAGE, uzbl.net.accept_languages, NULL); + } +} + void cmd_javascript_windows() { g_object_set (G_OBJECT(view_settings()), "javascript-can-open-windows-automatically", diff --git a/src/callbacks.h b/src/callbacks.h index 40fa80d..899e959 100644 --- a/src/callbacks.h +++ b/src/callbacks.h @@ -82,6 +82,9 @@ cmd_socket_dir(); void cmd_useragent() ; +void +set_accept_languages(); + void cmd_autoload_img(); diff --git a/src/uzbl-core.c b/src/uzbl-core.c index b7b8b00..2a91563 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -102,6 +102,7 @@ const struct var_name_to_ptr_t { { "max_conns", PTR_V_INT(uzbl.net.max_conns, 1, cmd_max_conns)}, { "max_conns_host", PTR_V_INT(uzbl.net.max_conns_host, 1, cmd_max_conns_host)}, { "useragent", PTR_V_STR(uzbl.net.useragent, 1, cmd_useragent)}, + { "accept_languages", PTR_V_STR(uzbl.net.accept_languages, 1, set_accept_languages)}, { "javascript_windows", PTR_V_INT(uzbl.behave.javascript_windows, 1, cmd_javascript_windows)}, /* requires webkit >=1.1.14 */ { "view_source", PTR_V_INT(uzbl.behave.view_source, 0, cmd_view_source)}, diff --git a/src/uzbl-core.h b/src/uzbl-core.h index 129c6a5..7076095 100644 --- a/src/uzbl-core.h +++ b/src/uzbl-core.h @@ -111,6 +111,7 @@ typedef struct { SoupLogger *soup_logger; char *proxy_url; char *useragent; + char *accept_languages; gint max_conns; gint max_conns_host; } Network; -- cgit v1.2.3 From b869e6a8e127ff674600a1141fc2bae9b77067cb Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Thu, 6 Jan 2011 16:41:30 -0700 Subject: split the status bar into left-aligned and right-aligned parts (thanks k0ral) --- AUTHORS | 1 + README | 12 +++++---- src/uzbl-core.c | 75 +++++++++++++++++++++++++++++++++------------------------ src/uzbl-core.h | 13 ++++++++-- 4 files changed, 63 insertions(+), 38 deletions(-) (limited to 'README') diff --git a/AUTHORS b/AUTHORS index f7e4a16..6522237 100644 --- a/AUTHORS +++ b/AUTHORS @@ -52,6 +52,7 @@ In alphabetical order: Jan Kolkmeier (jouz) - scrolling, link following Jason Woofenden (JasonWoof) - geometry=maximized, link following Jochen Sprickerhof - session.sh enhancements + k0ral - split status bar Lars-Dominik Braun (PromyLOPh) - added ability to enable/disable the webkit page cache Laurence Withers (lwithers) - talk_to_socket Luca Bruno - bashims fixes diff --git a/README b/README index 98ae22c..051fe6b 100644 --- a/README +++ b/README @@ -291,8 +291,10 @@ file). * `keycmd`: Holds the input buffer (callback: update input buffer). * `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_format`: Marked up, to be expanded string for statusbar's left side + (callback: update statusbar). +* `status_format_right`: Marked up, to be expanded string for statusbar's right side + (callback: update statusbar). * `status_background`: color which can be used to override Gtk theme. * `title_format_long`: titlebar string when no statusbar shown (will be expanded). @@ -470,10 +472,10 @@ that should be evaluated on every update need to be escaped: set title_format_short = \\\@(date)\\\@ # the title will stay constant as a literal "@(date)@" -The `status_format` variable can contain +The `status_format` and `status_format_right` variables can contain [Pango](http://library.gnome.org/devel/pango/stable/PangoMarkupFormat.html) -markup . In the `status_format`, variables that might contain characters like -`<`, `&` and `>`, should be wrapped in a `@[ ]@` substitution so that they don't +markup . In these variables, expansions that might produce the characters `<`, +`&` or `>` should be wrapped in `@[ ]@` substitutions so that they don't interfere with the status bar's markup; see the sample config for examples. ### EXTERNAL SCRIPTS diff --git a/src/uzbl-core.c b/src/uzbl-core.c index 2a91563..4a1b071 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -85,6 +85,7 @@ const struct var_name_to_ptr_t { { "show_status", PTR_V_INT(uzbl.behave.show_status, 1, cmd_set_status)}, { "status_top", PTR_V_INT(uzbl.behave.status_top, 1, move_statusbar)}, { "status_format", PTR_V_STR(uzbl.behave.status_format, 1, NULL)}, + { "status_format_right", PTR_V_STR(uzbl.behave.status_format_right, 1, NULL)}, { "status_background", PTR_V_STR(uzbl.behave.status_background, 1, set_status_background)}, { "title_format_long", PTR_V_STR(uzbl.behave.title_format_long, 1, NULL)}, { "title_format_short", PTR_V_STR(uzbl.behave.title_format_short, 1, NULL)}, @@ -1873,42 +1874,43 @@ init_socket(gchar *dir) { /* return dir or, on error, free dir and return NULL * return NULL; } -/* - NOTE: we want to keep variables like b->title_format_long in their "unprocessed" state - 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 void update_title (void) { Behaviour *b = &uzbl.behave; - gchar *parsed; - const gchar *current_title; - /* this check is here because if we're starting up or shutting down it might not be a window */ - gboolean have_main_window = !uzbl.state.plug_mode && GTK_IS_WINDOW(uzbl.gui.main_window); - if(have_main_window) - current_title = gtk_window_get_title (GTK_WINDOW(uzbl.gui.main_window)); + const gchar *title_format = b->title_format_long; + /* Update the status bar if shown */ if (b->show_status) { - if (b->title_format_short && have_main_window) { - parsed = expand(b->title_format_short, 0); - if(!current_title || strcmp(current_title, parsed)) - gtk_window_set_title (GTK_WINDOW(uzbl.gui.main_window), parsed); - g_free(parsed); - } - if (b->status_format && GTK_IS_LABEL(uzbl.gui.mainbar_label)) { - parsed = expand(b->status_format, 0); - gtk_label_set_markup(GTK_LABEL(uzbl.gui.mainbar_label), parsed); + title_format = b->title_format_short; + + /* Left side */ + if (b->status_format && GTK_IS_LABEL(uzbl.gui.mainbar_label_left)) { + gchar *parsed = expand(b->status_format, 0); + gtk_label_set_markup(GTK_LABEL(uzbl.gui.mainbar_label_left), parsed); g_free(parsed); } - } else { - if (b->title_format_long && have_main_window) { - parsed = expand(b->title_format_long, 0); - if(!current_title || strcmp(current_title, parsed)) - gtk_window_set_title (GTK_WINDOW(uzbl.gui.main_window), parsed); + + /* Right side */ + if (b->status_format_right && GTK_IS_LABEL(uzbl.gui.mainbar_label_right)) { + gchar *parsed = expand(b->status_format_right, 0); + gtk_label_set_markup(GTK_LABEL(uzbl.gui.mainbar_label_right), parsed); g_free(parsed); } } + + /* Update window title */ + /* If we're starting up or shutting down there might not be a window yet. */ + gboolean have_main_window = !uzbl.state.plug_mode && GTK_IS_WINDOW(uzbl.gui.main_window); + if (title_format && have_main_window) { + gchar *parsed = expand(title_format, 0); + const gchar *current_title = gtk_window_get_title (GTK_WINDOW(uzbl.gui.main_window)); + /* xmonad hogs CPU if the window title updates too frequently, so we + * don't set it unless we need to. */ + if(!current_title || strcmp(current_title, parsed)) + gtk_window_set_title (GTK_WINDOW(uzbl.gui.main_window), parsed); + g_free(parsed); + } } void @@ -1946,12 +1948,23 @@ create_mainbar () { GUI *g = &uzbl.gui; g->mainbar = gtk_hbox_new (FALSE, 0); - g->mainbar_label = gtk_label_new (""); - gtk_label_set_selectable((GtkLabel *)g->mainbar_label, TRUE); - gtk_label_set_ellipsize(GTK_LABEL(g->mainbar_label), PANGO_ELLIPSIZE_END); - gtk_misc_set_alignment (GTK_MISC(g->mainbar_label), 0, 0); - gtk_misc_set_padding (GTK_MISC(g->mainbar_label), 2, 2); - gtk_box_pack_start (GTK_BOX (g->mainbar), g->mainbar_label, TRUE, TRUE, 0); + + /* Left panel */ + g->mainbar_label_left = gtk_label_new (""); + gtk_label_set_selectable(GTK_LABEL(g->mainbar_label_left), TRUE); + gtk_misc_set_alignment (GTK_MISC(g->mainbar_label_left), 0, 0); + gtk_misc_set_padding (GTK_MISC(g->mainbar_label_left), 2, 2); + + gtk_box_pack_start (GTK_BOX (g->mainbar), g->mainbar_label_left, FALSE, FALSE, 0); + + /* Right panel */ + g->mainbar_label_right = gtk_label_new (""); + gtk_label_set_selectable(GTK_LABEL(g->mainbar_label_right), TRUE); + gtk_misc_set_alignment (GTK_MISC(g->mainbar_label_right), 1, 0); + gtk_misc_set_padding (GTK_MISC(g->mainbar_label_right), 2, 2); + gtk_label_set_ellipsize(GTK_LABEL(g->mainbar_label_right), PANGO_ELLIPSIZE_START); + + gtk_box_pack_start (GTK_BOX (g->mainbar), g->mainbar_label_right, TRUE, TRUE, 0); g_object_connect((GObject*)g->mainbar, "signal::key-press-event", (GCallback)key_press_cb, NULL, diff --git a/src/uzbl-core.h b/src/uzbl-core.h index 7076095..f81722d 100644 --- a/src/uzbl-core.h +++ b/src/uzbl-core.h @@ -51,8 +51,12 @@ typedef struct { GtkPlug* plug; GtkWidget* scrolled_win; GtkWidget* vbox; + + /* Mainbar */ GtkWidget* mainbar; - GtkWidget* mainbar_label; + GtkWidget* mainbar_label_left; + GtkWidget* mainbar_label_right; + GtkScrollbar* scbar_v; // Horizontal and Vertical Scrollbar GtkScrollbar* scbar_h; // (These are still hidden) GtkAdjustment* bar_v; // Information about document length @@ -119,10 +123,15 @@ typedef struct { /* behaviour */ typedef struct { + /* Status bar */ gchar* status_format; + gchar* status_format_right; + gchar* status_background; + + /* Window title */ gchar* title_format_short; gchar* title_format_long; - gchar* status_background; + gchar* fifo_dir; gchar* socket_dir; gchar* cookie_handler; -- cgit v1.2.3 From f2c7c41f6cc70e1d509967c7487aec5126495557 Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Thu, 13 Jan 2011 11:59:23 -0700 Subject: remove the vestiges of Uzbl.run --- README | 19 ------------------- src/uzbl-core.c | 48 ------------------------------------------------ 2 files changed, 67 deletions(-) (limited to 'README') diff --git a/README b/README index 051fe6b..d1f2357 100644 --- a/README +++ b/README @@ -602,25 +602,6 @@ This script tries to authenticate as user alice with password wonderland once and never retries authentication. See examples for more sofisticated, interactive authentication handler. -### JAVASCRIPT HELPER OBJECT DISABLED BECAUSE OF SECURITY LEAK - -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 JavaScript code (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 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) - ### EVENTS Unlike commands, events are not handled in `uzbl` itself, but are propagated diff --git a/src/uzbl-core.c b/src/uzbl-core.c index 6bbed3c..c6443cc 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -979,52 +979,6 @@ load_uri (WebKitWebView *web_view, GArray *argv, GString *result) { } /* Javascript*/ - -JSValueRef -js_run_command (JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, - size_t argumentCount, const JSValueRef arguments[], - JSValueRef* exception) { - (void) function; - (void) thisObject; - (void) exception; - - JSStringRef js_result_string; - GString *result = g_string_new(""); - - if (argumentCount >= 1) { - JSStringRef arg = JSValueToStringCopy(ctx, arguments[0], NULL); - size_t arg_size = JSStringGetMaximumUTF8CStringSize(arg); - char ctl_line[arg_size]; - JSStringGetUTF8CString(arg, ctl_line, arg_size); - - parse_cmd_line(ctl_line, result); - - JSStringRelease(arg); - } - js_result_string = JSStringCreateWithUTF8CString(result->str); - - g_string_free(result, TRUE); - - return JSValueMakeString(ctx, js_result_string); -} - -JSStaticFunction js_static_functions[] = { - {"run", js_run_command, kJSPropertyAttributeNone}, -}; - -void -js_init() { - /* This function creates the class and its definition, only once */ - if (!uzbl.js.initialized) { - /* it would be pretty cool to make this dynamic */ - uzbl.js.classdef = kJSClassDefinitionEmpty; - uzbl.js.classdef.staticFunctions = js_static_functions; - - uzbl.js.classref = JSClassCreate(&uzbl.js.classdef); - } -} - - void eval_js(WebKitWebView * web_view, gchar *script, GString *result, const char *file) { WebKitWebFrame *frame; @@ -1037,8 +991,6 @@ eval_js(WebKitWebView * web_view, gchar *script, GString *result, const char *fi JSStringRef js_result_string; size_t js_result_size; - js_init(); - frame = webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(web_view)); context = webkit_web_frame_get_global_context(frame); globalobject = JSContextGetGlobalObject(context); -- cgit v1.2.3