aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README263
-rw-r--r--callbacks.c56
-rw-r--r--callbacks.h6
-rw-r--r--config.h5
-rw-r--r--docs/COMMUNITY1
-rw-r--r--docs/INSTALL2
-rw-r--r--events.c40
-rw-r--r--events.h3
-rw-r--r--examples/config/uzbl/config10
-rw-r--r--examples/data/uzbl/plugins/bind.py21
-rw-r--r--examples/data/uzbl/plugins/keycmd.py35
-rwxr-xr-xexamples/data/uzbl/scripts/event_manager.py7
-rw-r--r--tests/test-expand.c7
-rwxr-xr-xuzbl-browser18
-rw-r--r--uzbl-core.c173
-rw-r--r--uzbl-core.h11
16 files changed, 371 insertions, 287 deletions
diff --git a/README b/README
index 816fff4..e751d42 100644
--- a/README
+++ b/README
@@ -159,23 +159,25 @@ The following commands are recognized:
- 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
* `event <event_name> [event_details]`
- send custom event
-* menu_add <label> = <uzbl command>
-* menu_link_add <label> = <uzbl command>
-* menu_image_add <label> = <uzbl command>
-* menu_editable_add <label> = <uzbl command>
+* `menu_add <label> = <uzbl command>`
+* `menu_link_add <label> = <uzbl command>`
+* `menu_image_add <label> = <uzbl command>`
+* `menu_editable_add <label> = <uzbl command>`
- add a new entry "label" that will execute "uzbl command" to one of the right click context menus
-* menu_separator <label>
-* menu_link_separator <label>
-* menu_image_separator <label>
-* menu_editable_separator <label>
+* `menu_separator <label>`
+* `menu_link_separator <label>`
+* `menu_image_separator <label>`
+* `menu_editable_separator <label>`
- adds a separator line to one of the right click context menus
-* menu_remove <label>
-* menu_link_remove <label>
-* menu_image_remove <label>
-* menu_editable_remove <label>
+* `menu_remove <label>`
+* `menu_link_remove <label>`
+* `menu_image_remove <label>`
+* `menu_editable_remove <label>`
- removes the entry "label" from one of the right click context menus
-* hardcopy
+* `hardcopy`
- open print dialog
+* `include <file>`
+ - read contents of file and interprete commands
### VARIABLES AND CONSTANTS
@@ -187,65 +189,62 @@ Some variables have callback functions which will get called after setting the v
Besides the builtin variables you can also define your own ones and use them in the exact same way as the buitin ones.
* Variables:
- - uri (callback: load the uri)
- - verbose: affects output on stdout
- - inject_html
- - 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 TODO plugin variable
- - command_indicator: string to denote command mode TODO plugin variable
- - 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
- - forward_keys: whether uzbl-core should send key events to the webkit view
- - insert_mode: whether insert mode is active TODO explain plugin variable
- - always_insert_mode: set this to true if you don't like modal (vim-like) interfaces TODO explain plugin variable
- - reset_command_mode: automatically revert to command mode on pageload (unless always_insert_mode is set) TODO explain plugin variable
- - modkey: modkey which can be pressed to activate keybind from inside insert mode
- - load_finish_handler
- - load_start_handler
- - load_commit_handler
- - download_handler
- - cookie_handler
- - new_window: handler to execute to invoke new uzbl window (TODO better name)
- - scheme_handler: handler to execute for each URI navigated to - the navigation request will be ignored if handler prints "USED\n"
- - 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 simultaneous connections (default: 100)
- - max_conns_host: max simultaneous connections per hostname (default: 6)
- - 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
- - default_font_family = sans-serif
- - monospace_font_family = monospace (example "Aerial Mono" )
- - cursive_font_family = sans
- - fantasy_font_family = "Pterra"
- - serif_font_family = serif (example "DejaVu Serif")
- - sans_serif_font_family = sans (example "DejaVu Sans")
+ - `uri`: (callback: load the uri)
+ - `verbose`: affects output on stdout
+ - `inject_html`
+ - `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 TODO plugin variable
+ - `command_indicator`: string to denote command mode TODO plugin variable
+ - `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
+ - `forward_keys`: whether uzbl-core should send key events to the webkit view
+ - `insert_mode`: whether insert mode is active TODO explain plugin variable
+ - `always_insert_mode`: set this to true if you don't like modal (vim-like) interfaces TODO explain plugin variable
+ - `reset_command_mode`: automatically revert to command mode on pageload (unless always_insert_mode is set) TODO explain plugin variable
+ - `modkey`: modkey which can be pressed to activate keybind from inside insert mode
+ - `download_handler`
+ - `cookie_handler`
+ - `new_window`: handler to execute to invoke new uzbl window (TODO better name)
+ - `scheme_handler`: handler to execute for each URI navigated to - the navigation request will be ignored if handler prints "USED\n"
+ - `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 simultaneous connections (default: 100)
+ - `max_conns_host`: max simultaneous connections per hostname (default: 6)
+ - `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`
+ - `default_font_family` = sans-serif
+ - `monospace_font_family` = monospace (example "Aerial Mono" )
+ - `cursive_font_family` = sans
+ - `fantasy_font_family` = "Pterra"
+ - `serif_font_family` = serif (example "DejaVu Serif")
+ - `sans_serif_font_family` = sans (example "DejaVu Sans")
* Constants (not dumpable or writeable):
@@ -259,7 +258,10 @@ Besides the builtin variables you can also define your own ones and use them in
- 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?)
+ - NAME: name of the uzbl instance (TODO: can't we make this a variable?)
+ * default: Xorg window id
+ * overridable with cmdline arg
+ * in GtkSocket mode, this is a random number to prevent name clashes
### VARIABLE EXPANSION AND COMMAND/JAVA SCRIPT SUBSTITUTION
@@ -429,7 +431,8 @@ Copying the Uzbl object and creating public functions should be taken with care
### EVENTS ###
unlike commands, events are not handled in uzbl itself, but are propagated (dispatched) asynchronously through
-a text stream on stdout. You'll usually use uzbl by piping it's output to a so called 'event handler'
+a text stream on stdout and/or through a socket. You'll usually use uzbl by piping it's output to a so called 'event manager'
+or by having the EM listen to a socket.
- makes it possible to use whichever language you want for event handling (python, perl, bash, .. you name it).
you'll usually send commands (see above) back to uzbl through its fifo or socket
- keybindings use x keysyms
@@ -437,94 +440,42 @@ a text stream on stdout. You'll usually use uzbl by piping it's output to a so
- see example event_handler.py
Note: cookie events are not sent to an event handler but handled internally through the cookie handler because of their synchronous nature.
-Cookie events are really something completely different from all other events. maybe someday we'll use http proxies or something for cookies, but
-for now we still use the handler code)
+Cookie events are really something completely different from all other events. maybe someday we'll use http proxies or something for cookies
+or synchronous events (which also have other nice use cases), but for now we still use the handler code)
Basically all events have this format:
EVENT [uzbl_instance_name] EVENT_NAME event_details
-Reported events and their specific format:
-
-- on start uzbl will generate:
-
- EVENT [uzbl_instance_name] INSTANCE_START process_id
-
-- on exit:
-
- EVENT [uzbl_instance_name] INSTANCE_EXIT process_id
-
-- whenever an uzbl variable is set:
-
- EVENT [uzbl_instance_name] VARIABLE_SET variable_name str|int|float variable_value
-
- Note: str|int|float denote the type of variable_value
-
-- upon execution of an uzbl command:
-
- EVENT [uzbl_instance_name] COMMAND_EXECUTED command_name optional_command_arguments
-
-- when the size or position of the uzbl window changes:
-
- EVENT [uzbl_instance_name] GEOMETRY_CHANGED WIDTHxHEIGHT+X_POSITION+Y_POSITION
-
-- when the fifo and/or the socket path is set or changed:
-
- EVENT [uzbl_instance_name] FIFO_SET path_to_fifo
- EVENT [uzbl_instance_name] SOCKET_SET path_to_socket
-
-- when a website is being loaded:
-
- EVENT [uzbl_instance_name] LOAD_COMMIT uri
- EVENT [uzbl_instance_name] LOAD_START uri
- EVENT [uzbl_instance_name] LOAD_FINISHED uri
- EVENT [uzbl_instance_name] LOAD_ERROR reason_of_error
-
-- when the title of the uzbl window changes:
-
- EVENT [uzbl_instance_name] TITLE_CHANGED title_name
-
-- when content needs to be downloaded:
-
- EVENT [uzbl_instance_name] DOWNLOAD_REQUEST download_uri
-
-- when you hover with the mouse over a link:
-
- EVENT [uzbl_instance_name] LINK_HOVER uri
- EVENT [uzbl_instance_name] LINK_UNHOVER uri
-
-- when you press or release a key:
-
- EVENT [uzbl_instance_name] KEY_PRESS key_name
- EVENT [uzbl_instance_name] KEY_RELEASE key_name
-
-- when you select some text inside the uzbl window:
-
- EVENT [uzbl_instance_name] SELECTION_CHANGED selected_text
-
-- when a new uzbl window is created:
-
- EVENT [uzbl_instance_name] NEW_WINDOW uri
-
-- upon opening/closing of the webinspector window:
-
- EVENT [uzbl_instance_name] WEBINSPECTOR open
- EVENT [uzbl_instance_name] WEBINSPECTOR close
-
-- when the uzbl windows gained/lost keyboard focus
-
- EVENT [uzbl_instance_name] FOCUS_GAINED
- EVENT [uzbl_instance_name] FOCUS_LOST
-
-- when a editable HTML is clicked
-
- EVENT [uzbl_instance_name] FORM_ACTIVE
-
-- when the document body or any non-editable element is clicked
-
- EVENT [uzbl_instance_name] ROOT_ACTIVE
-
+* Reported events:
+ - `EVENT [uzbl_instance_name] INSTANCE_START process_id`: uzbl startup
+ - `EVENT [uzbl_instance_name] INSTANCE_EXIT process_id`: uzbl shutdown
+ - `EVENT [uzbl_instance_name] VARIABLE_SET variable_name str|int|float variable_value`. Note: str|int|float denote the type of variable_value
+ - `EVENT [uzbl_instance_name] COMMAND_EXECUTED command_name optional_command_arguments`
+ - `EVENT [uzbl_instance_name] GEOMETRY_CHANGED WIDTHxHEIGHT+X_POSITION+Y_POSITION`: when the size or position of the uzbl window changes
+ - `EVENT [uzbl_instance_name] FIFO_SET path_to_fifo`
+ - `EVENT [uzbl_instance_name] SOCKET_SET path_to_socket`
+ - `EVENT [uzbl_instance_name] LOAD_COMMIT uri`
+ - `EVENT [uzbl_instance_name] LOAD_START uri`
+ - `EVENT [uzbl_instance_name] LOAD_FINISHED uri`
+ - `EVENT [uzbl_instance_name] LOAD_ERROR reason_of_error`
+ - `EVENT [uzbl_instance_name] TITLE_CHANGED title_name`: when the title of the webpage (and hence maybe, the window title) changed
+ - `EVENT [uzbl_instance_name] DOWNLOAD_REQUEST download_uri`: when content needs to be downloaded
+ - `EVENT [uzbl_instance_name] LINK_HOVER uri`: mouse hovers over a link
+ - `EVENT [uzbl_instance_name] LINK_UNHOVER uri`: same but unhover.
+ - `EVENT [uzbl_instance_name] KEY_PRESS key_name`: press of a keyboard key or mouse button
+ - `EVENT [uzbl_instance_name] KEY_RELEASE key_name`: release of keyboard key or mouse button
+ - `EVENT [uzbl_instance_name] SELECTION_CHANGED selected_text`: when you select text inside the uzbl window
+ - `EVENT [uzbl_instance_name] NEW_WINDOW uri`: creation of new uzbl window
+ - `EVENT [uzbl_instance_name] WEBINSPECTOR open`: upon opening webinspector window
+ - `EVENT [uzbl_instance_name] WEBINSPECTOR close`: upon closing webinspector window
+ - `EVENT [uzbl_instance_name] FOCUS_GAINED`: when uzbl window gained keyboard focus
+ - `EVENT [uzbl_instance_name] FOCUS_LOST`: when uzbl window lost keyboard focus
+ - `EVENT [uzbl_instance_name] FORM_ACTIVE`: when a editable HTML is clicked
+ - `EVENT [uzbl_instance_name] ROOT_ACTIVE`: when the document body or any non-editable element is clicked
+ - `EVENT [uzbl_instance_name] FILE_INCLUDED /path/to/file`: when the include commands succesfully loads a file
+ - `EVENT [uzbl_instance_name] PLUG_CREATED plug-id`: when uzbl-core is in xembed mode
### COMMAND LINE ARGUMENTS
diff --git a/callbacks.c b/callbacks.c
index a699c1d..db738f7 100644
--- a/callbacks.c
+++ b/callbacks.c
@@ -38,10 +38,15 @@ set_icon() {
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);
- }
+ int ret=0, x=0, y=0;
+ unsigned int w=0, h=0;
+ /* we used to use gtk_window_parse_geometry() but that didn't work how it was supposed to */
+ ret = XParseGeometry(uzbl.gui.geometry, &x, &y, &w, &h);
+ if(ret & XValue)
+ gtk_window_move((GtkWindow *)uzbl.gui.main_window, x, y);
+ if(ret & WidthValue)
+ gtk_window_resize((GtkWindow *)uzbl.gui.main_window, w, h);
+
/* 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
@@ -267,8 +272,15 @@ cmd_view_source() {
}
void
+cmd_set_zoom_type () {
+ if(uzbl.behave.zoom_type)
+ webkit_web_view_set_full_content_zoom (uzbl.gui.web_view, TRUE);
+ else
+ webkit_web_view_set_full_content_zoom (uzbl.gui.web_view, FALSE);
+}
+
+void
toggle_zoom_type (WebKitWebView* page, GArray *argv, GString *result) {
- (void)page;
(void)argv;
(void)result;
@@ -347,8 +359,6 @@ progress_change_cb (WebKitWebView* page, gint progress, gpointer data) {
prg_str = itos(progress);
send_event(LOAD_PROGRESS, prg_str, NULL);
g_free(prg_str);
-
- update_title();
}
void
@@ -367,9 +377,6 @@ load_finish_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data) {
(void) page;
(void) data;
- if (uzbl.behave.load_finish_handler)
- run_handler(uzbl.behave.load_finish_handler, "");
-
send_event(LOAD_FINISH, webkit_web_frame_get_uri(frame), NULL);
}
@@ -378,9 +385,6 @@ load_start_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data) {
(void) page;
(void) frame;
(void) data;
- uzbl.gui.sbar.load_progress = 0;
- if (uzbl.behave.load_start_handler)
- run_handler(uzbl.behave.load_start_handler, "");
send_event(LOAD_START, uzbl.state.uri, NULL);
}
@@ -406,10 +410,6 @@ load_commit_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data) {
GString* newuri = g_string_new (webkit_web_frame_get_uri (frame));
uzbl.state.uri = g_string_free (newuri, FALSE);
- if (uzbl.behave.load_commit_handler)
- run_handler(uzbl.behave.load_commit_handler, uzbl.state.uri);
-
- /* event message */
send_event(LOAD_COMMIT, webkit_web_frame_get_uri (frame), NULL);
}
@@ -467,13 +467,14 @@ key_release_cb (GtkWidget* window, GdkEventKey* event) {
if(event->type == GDK_KEY_RELEASE)
key_to_event(event->keyval, GDK_KEY_RELEASE);
- return TRUE;
+ return uzbl.behave.forward_keys ? FALSE : TRUE;
}
gboolean
button_press_cb (GtkWidget* window, GdkEventButton* event) {
(void) window;
gint context;
+ gchar *details;
if(event->type == GDK_BUTTON_PRESS) {
if(uzbl.state.last_button)
@@ -489,6 +490,23 @@ button_press_cb (GtkWidget* window, GdkEventButton* event) {
else if((context & WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT))
send_event(ROOT_ACTIVE, "button1", NULL);
}
+ details = g_strdup_printf("Button%d", event->button);
+ send_event(KEY_PRESS, details, NULL);
+ g_free(details);
+ }
+
+ return FALSE;
+}
+
+gboolean
+button_release_cb (GtkWidget* window, GdkEventButton* event) {
+ (void) window;
+ gchar *details;
+
+ if(event->type == GDK_BUTTON_RELEASE) {
+ details = g_strdup_printf("Button%d", event->button);
+ send_event(KEY_RELEASE, details, NULL);
+ g_free(details);
}
return FALSE;
@@ -588,8 +606,8 @@ download_cb (WebKitWebView *web_view, GObject *download, gpointer user_data) {
const gchar* uri = webkit_download_get_uri ((WebKitDownload*)download);
if (uzbl.state.verbose)
printf("Download -> %s\n",uri);
- /* if urls not escaped, we may have to escape and quote uri before this call */
+ /* if urls not escaped, we may have to escape and quote uri before this call */
GString *args = g_string_new(uri);
if (uzbl.net.proxy_url) {
diff --git a/callbacks.h b/callbacks.h
index 05dc618..3f318f2 100644
--- a/callbacks.h
+++ b/callbacks.h
@@ -53,6 +53,9 @@ void
cmd_zoom_level();
void
+cmd_set_zoom_type();
+
+void
cmd_disable_plugins();
void
@@ -187,5 +190,8 @@ gboolean
button_press_cb (GtkWidget* window, GdkEventButton* event);
gboolean
+button_release_cb (GtkWidget* window, GdkEventButton* event);
+
+gboolean
focus_cb(GtkWidget* window, GdkEventFocus* event, void *ud);
diff --git a/config.h b/config.h
index c43e8ea..e9b9a8e 100644
--- a/config.h
+++ b/config.h
@@ -1,9 +1,8 @@
const struct {
/*@null@*/ char *command;
} default_config[] = {
-{ "set reset_command_mode = 1"},
-{ "set status_format = <span background=\"darkblue\" foreground=\"white\"> \\@MODE </span> <span background=\"red\" foreground=\"white\">\\@[\\@keycmd]\\@</span> (\\@LOAD_PROGRESS%) <b>\\@[\\@TITLE]\\@</b> - Uzbl browser"},
-{ "set title_format_long = \\@keycmd \\@MODE \\@TITLE - Uzbl browser <\\@NAME> > \\@SELECTED_URI"},
+{ "set status_format = <span background=\"red\" foreground=\"white\">\\@[\\@keycmd]\\@</span> <b>\\@[\\@TITLE]\\@</b> - Uzbl browser"},
+{ "set title_format_long = \\@keycmd \\@TITLE - Uzbl browser <\\@NAME> > \\@SELECTED_URI"},
{ "set title_format_short = \\@TITLE - Uzbl browser <\\@NAME>"},
{ "set max_conns = 100"}, /* WebkitGTK default: 10 */
{ "set max_conns_host = 6"}, /* WebkitGTK default: 2 */
diff --git a/docs/COMMUNITY b/docs/COMMUNITY
index 7f86c7b..e1498bb 100644
--- a/docs/COMMUNITY
+++ b/docs/COMMUNITY
@@ -10,6 +10,7 @@ COMMUNITY
### IRC
* `#uzbl` on irc.freenode.net
+* [Archive](http://www.uzbl.org/irc-log)
### Website
diff --git a/docs/INSTALL b/docs/INSTALL
index 059155b..2e736cf 100644
--- a/docs/INSTALL
+++ b/docs/INSTALL
@@ -33,7 +33,7 @@ If you want the specific subprojects, you can issue:
Dependencies
------------
Dependencies which are optional for uzbl-core are marked with an asterisk. (i.e. these are needed for extra scripts)
-* libwebkit 1.1.4 or higher
+* libwebkit 1.1.15 or higher
* libsoup 2.24 or higher (dep for webkit/gtk+)
* gtk 2.14 or higher
* socat (for socket communication) [*]
diff --git a/events.c b/events.c
index 966cd15..2663091 100644
--- a/events.c
+++ b/events.c
@@ -39,7 +39,9 @@ const char *event_table[LAST_EVENT] = {
"FORM_ACTIVE" ,
"ROOT_ACTIVE" ,
"FOCUS_LOST" ,
- "FOCUS_GAINED"
+ "FOCUS_GAINED" ,
+ "FILE_INCLUDED" ,
+ "PLUG_CREATED"
};
void
@@ -78,25 +80,22 @@ send_event_socket(GString *msg) {
tmp->str, tmp->len,
&len, &error);
- if (ret == G_IO_STATUS_ERROR) {
+ if (ret == G_IO_STATUS_ERROR)
g_warning ("Error sending event to socket: %s", error->message);
- }
- g_io_channel_flush(gio, &error);
+ else
+ g_io_channel_flush(gio, &error);
}
}
if(msg) {
- while(!ret ||
- ret == G_IO_STATUS_AGAIN) {
- ret = g_io_channel_write_chars (gio,
- msg->str, msg->len,
- &len, &error);
- }
+ ret = g_io_channel_write_chars (gio,
+ msg->str, msg->len,
+ &len, &error);
- if (ret == G_IO_STATUS_ERROR) {
+ if (ret == G_IO_STATUS_ERROR)
g_warning ("Error sending event to socket: %s", error->message);
- }
- g_io_channel_flush(gio, &error);
+ else
+ g_io_channel_flush(gio, &error);
}
}
}
@@ -122,15 +121,14 @@ send_event_socket(GString *msg) {
ret = 0;
if(gio && gio->is_writeable && msg) {
- while(!ret || ret == G_IO_STATUS_AGAIN) {
- ret = g_io_channel_write_chars (gio,
- msg->str, msg->len,
- &len, &error);
- }
+ ret = g_io_channel_write_chars (gio,
+ msg->str, msg->len,
+ &len, &error);
if (ret == G_IO_STATUS_ERROR)
g_warning ("Error sending event to socket: %s", error->message);
- g_io_channel_flush(gio, &error);
+ else
+ g_io_channel_flush(gio, &error);
}
}
}
@@ -182,11 +180,11 @@ send_event(int type, const gchar *details, const gchar *custom_event) {
/* Transform gdk key events to our own events */
void
key_to_event(guint keyval, gint mode) {
- char byte[2];
+ char byte[2] = {0, 0};
/* check for Latin-1 characters (1:1 mapping) */
if ((keyval > 0x0020 && keyval <= 0x007e) ||
- (keyval >= 0x00a0 && keyval <= 0x00ff)) {
+ (keyval >= 0x0080 && keyval <= 0x00ff)) {
sprintf(byte, "%c", keyval);
send_event(mode == GDK_KEY_PRESS ? KEY_PRESS : KEY_RELEASE,
byte, NULL);
diff --git a/events.h b/events.h
index 9a3225b..a2ae2bb 100644
--- a/events.h
+++ b/events.h
@@ -12,7 +12,8 @@ enum event_type {
VARIABLE_SET, FIFO_SET, SOCKET_SET,
INSTANCE_START, INSTANCE_EXIT, LOAD_PROGRESS,
LINK_UNHOVER, FORM_ACTIVE, ROOT_ACTIVE,
- FOCUS_LOST, FOCUS_GAINED,
+ FOCUS_LOST, FOCUS_GAINED, FILE_INCLUDED,
+ PLUG_CREATED,
/* must be last entry */
LAST_EVENT
diff --git a/examples/config/uzbl/config b/examples/config/uzbl/config
index fffc8b6..7668963 100644
--- a/examples/config/uzbl/config
+++ b/examples/config/uzbl/config
@@ -206,6 +206,7 @@ set formfiller = spawn @scripts_dir/formfiller
# Examples using multi-stage-bindings with text prompts.
@bind o<uri:>_ = uri %s
+@bind O<uri:\@uri>_ = uri %s
# multi-stage binding way to write bookmarks to file from inside uzbl.
@bind <Ctrl>b<tags:>_ = sh 'echo -e "$6 %s" >> $XDG_DATA_HOME/uzbl/bookmarks'
@@ -214,12 +215,19 @@ set formfiller = spawn @scripts_dir/formfiller
@bind <Ctrl>a<:><Ctrl>q = exit
@bind <Ctrl>a<:><Ctrl>h = uri http://uzbl.org/
+# Inject handy values into the keycmd.
+@bind <Ctrl>su = event INJECT_KEYCMD \@uri
+@bind <Ctrl>st = event INJECT_KEYCMD \@TITLE
+# Or append.
+@bind <Ctrl>du = event APPEND_KEYCMD \@uri
+@bind <Ctrl>dt = event APPEND_KEYCMD \@TITLE
+
# === command editing configuration ==========================================
# you'll want this at the very least
@bind <Return> = event KEYCMD_EXEC_CURRENT
-@bind <Escape> = event @set_mode
+@bind <Escape> = @set_mode
# basic searching
@bind <Home> = event SET_CURSOR_POS 0
diff --git a/examples/data/uzbl/plugins/bind.py b/examples/data/uzbl/plugins/bind.py
index 8c932be..b8494fe 100644
--- a/examples/data/uzbl/plugins/bind.py
+++ b/examples/data/uzbl/plugins/bind.py
@@ -21,7 +21,7 @@ UZBLS = {}
# Commonly used regular expressions.
starts_with_mod = re.compile('^<([A-Z][A-Za-z0-9-_]*)>')
-find_prompts = re.compile('<([^:>]*):>').split
+find_prompts = re.compile('<([^:>]*):(\"[^\"]*\"|\'[^\']*\'|[^>]*)>').split
# For accessing a bind glob stack.
MOD_CMD, ON_EXEC, HAS_ARGS, GLOB, MORE = range(5)
@@ -159,22 +159,28 @@ class Bind(object):
self.bid = self.nextbid()
self.split = split = find_prompts(glob)
- self.prompts = split[1::2]
+ self.prompts = []
+ for (prompt, set) in zip(split[1::3], split[2::3]):
+ if set and set[0] == set[-1] and set[0] in ['"', "'"]:
+ # Remove quotes around set.
+ set = set[1:-1]
+
+ self.prompts.append((prompt, set))
# Check that there is nothing like: fl*<int:>*
- for glob in split[:-1:2]:
+ for glob in split[:-1:3]:
if glob.endswith('*'):
msg = "token '*' not at the end of a prompt bind: %r" % split
raise BindParseError(msg)
# Check that there is nothing like: fl<prompt1:><prompt2:>_
- for glob in split[2::2]:
+ for glob in split[3::3]:
if not glob:
msg = 'found null segment after first prompt: %r' % split
raise BindParseError(msg)
stack = []
- for (index, glob) in enumerate(reversed(split[::2])):
+ for (index, glob) in enumerate(reversed(split[::3])):
# Is the binding a MODCMD or KEYCMD:
mod_cmd = ismodbind(glob)
@@ -282,6 +288,7 @@ def parse_bind_event(uzbl, args):
def set_stack_mode(uzbl, prompt):
+ prompt, set = prompt
if uzbl.get_mode() != 'stack':
uzbl.set_mode('stack')
@@ -290,6 +297,10 @@ def set_stack_mode(uzbl, prompt):
uzbl.set('keycmd_prompt', prompt)
+ if set:
+ # Go through uzbl-core to expand potential @-variables
+ uzbl.send('event SET_KEYCMD %s' % set)
+
def clear_stack(uzbl, mode):
bind_dict = get_bind_dict(uzbl)
diff --git a/examples/data/uzbl/plugins/keycmd.py b/examples/data/uzbl/plugins/keycmd.py
index d01d2ac..8961f74 100644
--- a/examples/data/uzbl/plugins/keycmd.py
+++ b/examples/data/uzbl/plugins/keycmd.py
@@ -227,11 +227,10 @@ def update_event(uzbl, k, execute=True):
uzbl.set('keycmd', KEYCMD_FORMAT % tuple(map(uzbl_escape, chunks)))
-def inject_char(str, index, char):
- '''Inject character into string at at given index.'''
+def inject_str(str, index, inj):
+ '''Inject a string into string at at given index.'''
- assert len(char) == 1
- return "%s%s%s" % (str[:index], char, str[index:])
+ return "%s%s%s" % (str[:index], inj, str[index:])
def key_press(uzbl, key):
@@ -253,13 +252,13 @@ def key_press(uzbl, key):
return
if key == 'Space' and not k.held and k.keycmd:
- k.keycmd = inject_char(k.keycmd, k.cursor, ' ')
+ k.keycmd = inject_str(k.keycmd, k.cursor, ' ')
k.cursor += 1
elif not k.held and len(key) == 1:
config = uzbl.get_config()
if 'keycmd_events' not in config or config['keycmd_events'] == '1':
- k.keycmd = inject_char(k.keycmd, k.cursor, key)
+ k.keycmd = inject_str(k.keycmd, k.cursor, key)
k.cursor += 1
elif k.keycmd:
@@ -317,6 +316,26 @@ def set_keycmd(uzbl, keycmd):
update_event(uzbl, k, False)
+def inject_keycmd(uzbl, keycmd):
+ '''Allow injecting of a string into the keycmd at the cursor position.'''
+
+ k = get_keylet(uzbl)
+ k.keycmd = inject_str(k.keycmd, k.cursor, keycmd)
+ k._repr_cache = None
+ k.cursor += len(keycmd)
+ update_event(uzbl, k, False)
+
+
+def append_keycmd(uzbl, keycmd):
+ '''Allow appening of a string to the keycmd.'''
+
+ k = get_keylet(uzbl)
+ k.keycmd += keycmd
+ k._repr_cache = None
+ k.cursor = len(k.keycmd)
+ update_event(uzbl, k, False)
+
+
def keycmd_strip_word(uzbl, sep):
''' Removes the last word from the keycmd, similar to readline ^W '''
@@ -406,6 +425,8 @@ def init(uzbl):
'SET_CURSOR_POS': set_cursor_pos,
'FOCUS_LOST': focus_changed,
'FOCUS_GAINED': focus_changed,
- 'MODMAP': modmap_parse}
+ 'MODMAP': modmap_parse,
+ 'APPEND_KEYCMD': append_keycmd,
+ 'INJECT_KEYCMD': inject_keycmd}
uzbl.connect_dict(connects)
diff --git a/examples/data/uzbl/scripts/event_manager.py b/examples/data/uzbl/scripts/event_manager.py
index 9c269c7..dee42c5 100755
--- a/examples/data/uzbl/scripts/event_manager.py
+++ b/examples/data/uzbl/scripts/event_manager.py
@@ -813,7 +813,8 @@ if __name__ == "__main__":
config['verbose'] = True
if options.plugin_dirs:
- plugin_dirs = map(str.strip, options.plugin_dirs.split(':'))
+ plugin_dirs = map(os.path.realpath, map(str.strip,
+ options.plugin_dirs.split(':')))
config['plugin_dirs'] = plugin_dirs
echo("plugin search dirs: %r" % plugin_dirs)
@@ -842,11 +843,11 @@ if __name__ == "__main__":
echo('will auto close.')
if options.pid:
- config['pid_file'] = options.pid
+ config['pid_file'] = os.path.realpath(options.pid)
echo("pid file location: %r" % config['pid_file'])
if options.socket:
- config['server_socket'] = options.socket
+ config['server_socket'] = os.path.realpath(options.socket)
echo("daemon socket location: %s" % config['server_socket'])
if options.daemon:
diff --git a/tests/test-expand.c b/tests/test-expand.c
index 428ee23..855d9b4 100644
--- a/tests/test-expand.c
+++ b/tests/test-expand.c
@@ -46,12 +46,6 @@ test_uri (void) {
}
void
-test_LOAD_PROGRESS (void) {
- uzbl.gui.sbar.load_progress = 50;
- g_assert_cmpstr(expand("@LOAD_PROGRESS", 0), ==, "50");
-}
-
-void
test_TITLE (void) {
uzbl.gui.main_title = "Lorem Ipsum";
g_assert_cmpstr(expand("@TITLE", 0), ==, "Lorem Ipsum");
@@ -193,7 +187,6 @@ main (int argc, char *argv[]) {
g_test_add_func("/test-expand/@keycmd", test_keycmd);
g_test_add_func("/test-expand/@status_message", test_status_message);
g_test_add_func("/test-expand/@uri", test_uri);
- g_test_add_func("/test-expand/@LOAD_PROGRESS", test_LOAD_PROGRESS);
g_test_add_func("/test-expand/@TITLE", test_TITLE);
g_test_add_func("/test-expand/@SELECTED_URI", test_SELECTED_URI);
g_test_add_func("/test-expand/@NAME", test_NAME);
diff --git a/uzbl-browser b/uzbl-browser
index 7cc8002..5ff72e9 100755
--- a/uzbl-browser
+++ b/uzbl-browser
@@ -35,17 +35,17 @@ do
echo "could not create $dir" >&2
exit 2
fi
- # if we're initialising a new config directory, put the default (recommended) config in it
- if [ "$dir" == $XDG_CONFIG_HOME/uzbl ]
- then
- if ! cp $PREFIX/share/uzbl/examples/config/uzbl/config $XDG_CONFIG_HOME/uzbl/config
- then
- echo "Could not copy default config to $XDG_CONFIG_HOME/uzbl/config" >&2
- exit 3
- fi
- fi
fi
done
+# if no config exists yet in the recommended location, put the default (recommended) config there
+if [ ! -f $XDG_CONFIG_HOME/uzbl/config ]
+then
+ if ! cp $PREFIX/share/uzbl/examples/config/uzbl/config $XDG_CONFIG_HOME/uzbl/config
+ then
+ echo "Could not copy default config to $XDG_CONFIG_HOME/uzbl/config" >&2
+ exit 3
+ fi
+fi
if [ ! -S $XDG_CACHE_HOME/uzbl/cookie_daemon_socket ]
then
diff --git a/uzbl-core.c b/uzbl-core.c
index 3a59574..5f4e136 100644
--- a/uzbl-core.c
+++ b/uzbl-core.c
@@ -46,13 +46,13 @@ GOptionEntry entries[] =
{ "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 of the current instance (defaults to Xorg window id)", "NAME" },
+ "Name of the current instance (defaults to Xorg window id or random for GtkSocket mode)", "NAME" },
{ "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" },
{ "connect-socket", 0, 0, G_OPTION_ARG_STRING_ARRAY, &uzbl.state.connect_socket_names,
- "Socket Name", "CSOCKET" },
+ "Connect to server socket", "CSOCKET" },
{ "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,
@@ -69,8 +69,6 @@ XDG_Var XDG[] =
{ "XDG_DATA_DIRS", "/usr/local/share/:/usr/share/" },
};
-/* associate command names to their properties */
-
/* abbreviations to help keep the table's width humane */
#define PTR_V_STR(var, d, fun) { .ptr.s = &(var), .type = TYPE_STR, .dump = d, .writeable = 1, .func = fun }
#define PTR_V_INT(var, d, fun) { .ptr.i = (int*)&(var), .type = TYPE_INT, .dump = d, .writeable = 1, .func = fun }
@@ -89,19 +87,16 @@ const struct var_name_to_ptr_t {
{ "verbose", PTR_V_INT(uzbl.state.verbose, 1, NULL)},
{ "inject_html", PTR_V_STR(uzbl.behave.inject_html, 0, cmd_inject_html)},
{ "geometry", PTR_V_STR(uzbl.gui.geometry, 1, cmd_set_geometry)},
- { "keycmd", PTR_V_STR(uzbl.state.keycmd, 1, update_title)},
- { "status_message", PTR_V_STR(uzbl.gui.sbar.msg, 1, update_title)},
+ { "keycmd", PTR_V_STR(uzbl.state.keycmd, 1, NULL)},
+ { "status_message", PTR_V_STR(uzbl.gui.sbar.msg, 1, NULL)},
{ "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, update_title)},
- { "status_background", PTR_V_STR(uzbl.behave.status_background, 1, update_title)},
- { "title_format_long", PTR_V_STR(uzbl.behave.title_format_long, 1, update_title)},
- { "title_format_short", PTR_V_STR(uzbl.behave.title_format_short, 1, update_title)},
+ { "status_format", PTR_V_STR(uzbl.behave.status_format, 1, NULL)},
+ { "status_background", PTR_V_STR(uzbl.behave.status_background, 1, NULL)},
+ { "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)},
{ "icon", PTR_V_STR(uzbl.gui.icon, 1, set_icon)},
{ "forward_keys", PTR_V_INT(uzbl.behave.forward_keys, 1, NULL)},
- { "load_finish_handler", PTR_V_STR(uzbl.behave.load_finish_handler, 1, NULL)},
- { "load_start_handler", PTR_V_STR(uzbl.behave.load_start_handler, 1, NULL)},
- { "load_commit_handler", PTR_V_STR(uzbl.behave.load_commit_handler, 1, NULL)},
{ "download_handler", PTR_V_STR(uzbl.behave.download_handler, 1, NULL)},
{ "cookie_handler", PTR_V_STR(uzbl.behave.cookie_handler, 1, NULL)},
{ "new_window", PTR_V_STR(uzbl.behave.new_window, 1, NULL)},
@@ -119,6 +114,7 @@ const struct var_name_to_ptr_t {
/* exported WebKitWebSettings properties */
{ "zoom_level", PTR_V_FLOAT(uzbl.behave.zoom_level, 1, cmd_zoom_level)},
+ { "zoom_type", PTR_V_INT(uzbl.behave.zoom_type, 1, cmd_set_zoom_type)},
{ "font_size", PTR_V_INT(uzbl.behave.font_size, 1, cmd_font_size)},
{ "default_font_family", PTR_V_STR(uzbl.behave.default_font_family, 1, cmd_default_font_family)},
{ "monospace_font_family", PTR_V_STR(uzbl.behave.monospace_font_family, 1, cmd_monospace_font_family)},
@@ -141,13 +137,12 @@ const struct var_name_to_ptr_t {
{ "enforce_96_dpi", PTR_V_INT(uzbl.behave.enforce_96dpi, 1, cmd_enforce_96dpi)},
{ "caret_browsing", PTR_V_INT(uzbl.behave.caret_browsing, 1, cmd_caret_browsing)},
- /* constants (not dumpable or writeable) */
+ /* constants (not dumpable or writeable) */
{ "WEBKIT_MAJOR", PTR_C_INT(uzbl.info.webkit_major, NULL)},
{ "WEBKIT_MINOR", PTR_C_INT(uzbl.info.webkit_minor, NULL)},
{ "WEBKIT_MICRO", PTR_C_INT(uzbl.info.webkit_micro, NULL)},
{ "ARCH_UZBL", PTR_C_STR(uzbl.info.arch, NULL)},
{ "COMMIT", PTR_C_STR(uzbl.info.commit, NULL)},
- { "LOAD_PROGRESS", PTR_C_INT(uzbl.gui.sbar.load_progress, NULL)},
{ "TITLE", PTR_C_STR(uzbl.gui.main_title, NULL)},
{ "SELECTED_URI", PTR_C_STR(uzbl.state.selected_url, NULL)},
{ "NAME", PTR_C_STR(uzbl.state.instance_name, NULL)},
@@ -155,6 +150,7 @@ const struct var_name_to_ptr_t {
{ NULL, {.ptr.s = NULL, .type = TYPE_INT, .dump = 0, .writeable = 0, .func = NULL}}
};
+
/* construct a hash from the var_name_to_ptr array for quick access */
void
create_var_to_name_hash() {
@@ -529,13 +525,13 @@ catch_sigalrm(int s) {
/* scroll a bar in a given direction */
void
-scroll (GtkAdjustment* bar, GArray *argv) {
+scroll (GtkAdjustment* bar, gchar *amount_str) {
gchar *end;
gdouble max_value;
gdouble page_size = gtk_adjustment_get_page_size(bar);
gdouble value = gtk_adjustment_get_value(bar);
- gdouble amount = g_ascii_strtod(g_array_index(argv, gchar*, 0), &end);
+ gdouble amount = g_ascii_strtod(amount_str, &end);
if (*end == '%')
value += page_size * amount * 0.01;
@@ -550,29 +546,46 @@ scroll (GtkAdjustment* bar, GArray *argv) {
gtk_adjustment_set_value (bar, value);
}
+/*
+ * scroll vertical 20
+ * scroll vertical 20%
+ * scroll vertical -40
+ * scroll vertical begin
+ * scroll vertical end
+ * scroll horizontal 10
+ * scroll horizontal -500
+ * scroll horizontal begin
+ * scroll horizontal end
+ */
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));
-}
-
-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));
-}
-
-void
-scroll_vert(WebKitWebView* page, GArray *argv, GString *result) {
- (void) page; (void) result;
- scroll(uzbl.gui.bar_v, argv);
-}
-
-void
-scroll_horz(WebKitWebView* page, GArray *argv, GString *result) {
+scroll_cmd(WebKitWebView* page, GArray *argv, GString *result) {
(void) page; (void) result;
- scroll(uzbl.gui.bar_h, argv);
+ gchar *direction = g_array_index(argv, gchar*, 0);
+ gchar *argv1 = g_array_index(argv, gchar*, 1);
+
+ if (g_strcmp0(direction, "horizontal") == 0)
+ {
+ if (g_strcmp0(argv1, "begin") == 0)
+ gtk_adjustment_set_value(uzbl.gui.bar_h, gtk_adjustment_get_lower(uzbl.gui.bar_h));
+ else if (g_strcmp0(argv1, "end") == 0)
+ gtk_adjustment_set_value (uzbl.gui.bar_h, gtk_adjustment_get_upper(uzbl.gui.bar_h) -
+ gtk_adjustment_get_page_size(uzbl.gui.bar_h));
+ else
+ scroll(uzbl.gui.bar_h, argv1);
+ }
+ else if (g_strcmp0(direction, "vertical") == 0)
+ {
+ if (g_strcmp0(argv1, "begin") == 0)
+ gtk_adjustment_set_value(uzbl.gui.bar_v, gtk_adjustment_get_lower(uzbl.gui.bar_v));
+ else if (g_strcmp0(argv1, "end") == 0)
+ 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));
+ else
+ scroll(uzbl.gui.bar_v, argv1);
+ }
+ else
+ if(uzbl.state.verbose)
+ puts("Unrecognized scroll format");
}
@@ -593,10 +606,7 @@ struct {const char *key; CommandInfo value;} cmdlist[] =
{ /* key function no_split */
{ "back", {view_go_back, 0} },
{ "forward", {view_go_forward, 0} },
- { "scroll_vert", {scroll_vert, 0} },
- { "scroll_horz", {scroll_horz, 0} },
- { "scroll_begin", {scroll_begin, 0} },
- { "scroll_end", {scroll_end, 0} },
+ { "scroll", {scroll_cmd, 0} },
{ "reload", {view_reload, 0}, },
{ "reload_ign_cache", {view_reload_bypass_cache, 0} },
{ "stop", {view_stop_loading, 0}, },
@@ -635,7 +645,8 @@ struct {const char *key; CommandInfo value;} cmdlist[] =
{ "menu_link_remove", {menu_remove_link, TRUE} },
{ "menu_image_remove", {menu_remove_image, TRUE} },
{ "menu_editable_remove", {menu_remove_edit, TRUE} },
- { "hardcopy", {hardcopy, TRUE} }
+ { "hardcopy", {hardcopy, TRUE} },
+ { "include", {include, TRUE} }
};
void
@@ -843,8 +854,12 @@ void
event(WebKitWebView *page, GArray *argv, GString *result) {
(void) page; (void) result;
GString *event_name;
- gchar **split = g_strsplit(argv_idx(argv, 0), " ", 2);
-
+ gchar **split = NULL;
+
+ if(!argv_idx(argv, 0))
+ return;
+
+ split = g_strsplit(argv_idx(argv, 0), " ", 2);
if(split[0])
event_name = g_string_ascii_up(g_string_new(split[0]));
else
@@ -875,6 +890,35 @@ hardcopy(WebKitWebView *page, GArray *argv, GString *result) {
}
void
+include(WebKitWebView *page, GArray *argv, GString *result) {
+ (void) page;
+ (void) result;
+ gchar *pe = NULL,
+ *path = NULL,
+ *line;
+ int i=0;
+
+ if(!argv_idx(argv, 0))
+ return;
+
+ pe = parseenv(argv_idx(argv, 0));
+ if((path = find_existing_file(pe))) {
+ GArray* lines = read_file_by_line(path);
+
+ while ((line = g_array_index(lines, gchar*, i))) {
+ parse_cmd_line (line, NULL);
+ i++;
+ g_free (line);
+ }
+ g_array_free (lines, TRUE);
+
+ send_event(FILE_INCLUDED, path, NULL);
+ g_free(path);
+ }
+ g_free(pe);
+}
+
+void
act_dump_config() {
dump_config();
}
@@ -1078,11 +1122,18 @@ new_window_load_uri (const gchar * uri) {
g_string_append_printf (to_execute, "%s --uri '%s'", uzbl.state.executable_path, uri);
int i;
for (i = 0; entries[i].long_name != NULL; i++) {
- if ((entries[i].arg == G_OPTION_ARG_STRING) && (strcmp(entries[i].long_name,"uri")!=0) && (strcmp(entries[i].long_name,"name")!=0)) {
+ if ((entries[i].arg == G_OPTION_ARG_STRING) &&
+ !strcmp(entries[i].long_name,"uri") &&
+ !strcmp(entries[i].long_name,"name")) {
gchar** str = (gchar**)entries[i].arg_data;
- if (*str!=NULL) {
+ if (*str!=NULL)
g_string_append_printf (to_execute, " --%s '%s'", entries[i].long_name, *str);
- }
+ }
+ else if(entries[i].arg == G_OPTION_ARG_STRING_ARRAY) {
+ int j;
+ gchar **str = *((gchar ***)entries[i].arg_data);
+ for(j=0; str[j]; j++)
+ g_string_append_printf(to_execute, " --%s '%s'", entries[i].long_name, str[j]);
}
}
if (uzbl.state.verbose)
@@ -1890,6 +1941,7 @@ create_browser () {
"signal::key-press-event", (GCallback)key_press_cb, NULL,
"signal::key-release-event", (GCallback)key_release_cb, NULL,
"signal::button-press-event", (GCallback)button_press_cb, NULL,
+ "signal::button-release-event", (GCallback)button_release_cb, NULL,
"signal::title-changed", (GCallback)title_change_cb, NULL,
"signal::selection-changed", (GCallback)selection_changed_cb, NULL,
"signal::load-progress-changed", (GCallback)progress_change_cb, NULL,
@@ -2268,6 +2320,15 @@ retrieve_geometry() {
* external applications need to do anyhow */
void
initialize(int argc, char *argv[]) {
+ int i;
+
+ for(i=0; i<argc; ++i) {
+ if(!strcmp(argv[i], "-s") || !strcmp(argv[i], "--socket")) {
+ uzbl.state.plug_mode = TRUE;
+ break;
+ }
+ }
+
if (!g_thread_supported ())
g_thread_init (NULL);
gtk_init (&argc, &argv);
@@ -2367,10 +2428,18 @@ main (int argc, char* argv[]) {
gtk_box_pack_start (GTK_BOX (uzbl.gui.vbox), uzbl.gui.scrolled_win, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (uzbl.gui.vbox), uzbl.gui.mainbar, FALSE, TRUE, 0);
- if (uzbl.state.socket_id) {
+ if (uzbl.state.plug_mode) {
uzbl.gui.plug = create_plug ();
gtk_container_add (GTK_CONTAINER (uzbl.gui.plug), uzbl.gui.vbox);
gtk_widget_show_all (GTK_WIDGET (uzbl.gui.plug));
+ /* in xembed mode the window has no unique id and thus
+ * socket/fifo names aren't unique either.
+ * we use a custom randomizer to create a random id
+ */
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ srand((unsigned int)tv.tv_sec*tv.tv_usec);
+ uzbl.xwin = rand();
} else {
uzbl.gui.main_window = create_window ();
gtk_container_add (GTK_CONTAINER (uzbl.gui.main_window), uzbl.gui.vbox);
@@ -2392,6 +2461,12 @@ main (int argc, char* argv[]) {
uzbl.info.pid_str = g_string_free(tmp, FALSE);
send_event(INSTANCE_START, uzbl.info.pid_str, NULL);
+ if(uzbl.state.plug_mode) {
+ char *t = itos(gtk_plug_get_id(uzbl.gui.plug));
+ send_event(PLUG_CREATED, t, NULL);
+ g_free(t);
+ }
+
gtk_widget_grab_focus (GTK_WIDGET (uzbl.gui.web_view));
if (uzbl.state.verbose) {
diff --git a/uzbl-core.h b/uzbl-core.h
index 51b415b..48c99ae 100644
--- a/uzbl-core.h
+++ b/uzbl-core.h
@@ -43,7 +43,6 @@
/* status bar elements */
typedef struct {
- gint load_progress;
gchar *msg;
} StatusBar;
@@ -81,7 +80,7 @@ enum { FIFO, SOCKET};
typedef struct {
gchar *fifo_path;
gchar *socket_path;
- /* stores (key)"variable name" -> (value)"pointer to this var*/
+ /* stores (key)"variable name" -> (value)"pointer to var*/
GHashTable *proto_var;
gchar *sync_stdout;
@@ -105,6 +104,7 @@ typedef struct {
GPtrArray *event_buffer;
gchar** connect_socket_names;
GdkEventButton *last_button;
+ gboolean plug_mode;
} State;
@@ -121,9 +121,6 @@ typedef struct {
/* behaviour */
typedef struct {
- gchar* load_finish_handler;
- gchar* load_start_handler;
- gchar* load_commit_handler;
gchar* status_format;
gchar* title_format_short;
gchar* title_format_long;
@@ -152,6 +149,7 @@ typedef struct {
guint monospace_size;
guint minimum_font_size;
gfloat zoom_level;
+ gboolean zoom_type;
guint disable_plugins;
guint disable_scripts;
guint autoload_img;
@@ -476,6 +474,9 @@ get_click_context();
void
hardcopy(WebKitWebView *page, GArray *argv, GString *result);
+void
+include(WebKitWebView *page, GArray *argv, GString *result);
+
typedef void (*Command)(WebKitWebView*, GArray *argv, GString *result);
typedef struct {