diff options
-rw-r--r-- | README | 80 | ||||
-rw-r--r-- | callbacks.c | 22 | ||||
-rw-r--r-- | callbacks.h | 3 | ||||
-rw-r--r-- | events.c | 4 | ||||
-rw-r--r-- | events.h | 1 | ||||
-rw-r--r-- | examples/config/uzbl/config | 5 | ||||
-rwxr-xr-x | uzbl-browser | 2 | ||||
-rw-r--r-- | uzbl-core.c | 25 | ||||
-rw-r--r-- | uzbl-core.h | 4 |
9 files changed, 104 insertions, 42 deletions
@@ -164,18 +164,23 @@ The following commands are recognized: - update the contents of the status and title bars * `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_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_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_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 + - open print dialog ### VARIABLES AND CONSTANTS @@ -442,74 +447,89 @@ for now we still use the handler code) Basically all events have this format: - EVENT EVENT_NAME [uzbl_instance_name] event_details + EVENT [uzbl_instance_name] EVENT_NAME event_details Reported events and their specific format: - on start uzbl will generate: - EVENT INSTANCE_START [uzbl_instance_name] process_id + EVENT [uzbl_instance_name] INSTANCE_START process_id - on exit: - EVENT INSTANCE_EXIT [uzbl_instance_name] process_id + EVENT [uzbl_instance_name] INSTANCE_EXIT process_id - whenever an uzbl variable is set: - EVENT VARIABLE_SET [uzbl_instance_name] variable_name str|int|float variable_value + 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 COMMAND_EXECUTED [uzbl_instance_name] command_name optional_command_arguments + EVENT [uzbl_instance_name] COMMAND_EXECUTED command_name optional_command_arguments - when the size or position of the uzbl window changes: - EVENT GEOMETRY_CHANGED [uzbl_instance_name] WIDTHxHEIGHT+X_POSITION+Y_POSITION + EVENT [uzbl_instance_name] GEOMETRY_CHANGED WIDTHxHEIGHT+X_POSITION+Y_POSITION - when the fifo and/or the socket path is set or changed: - EVENT FIFO_SET [uzbl_instance_name] path_to_fifo - EVENT SOCKET_SET [uzbl_instance_name] path_to_socket + 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 LOAD_COMMIT [uzbl_instance_name] uri - EVENT LOAD_START [uzbl_instance_name] uri - EVENT LOAD_FINISHED [uzbl_instance_name] uri - EVENT LOAD_ERROR [uzbl_instance_name] reason_of_error + 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 TITLE_CHANGED [uzbl_instance_name] title_name + EVENT [uzbl_instance_name] TITLE_CHANGED title_name - when content needs to be downloaded: - EVENT DOWNLOAD_REQUEST [uzbl_instance_name] download_uri + EVENT [uzbl_instance_name] DOWNLOAD_REQUEST download_uri - when you hover with the mouse over a link: - EVENT LINK_HOVER [uzbl_instance_name] uri + EVENT [uzbl_instance_name] LINK_HOVER uri + EVENT [uzbl_instance_name] LINK_UNHOVER uri - when you press or release a key: - EVENT KEY_PRESS [uzbl_instance_name] key_name - EVENT KEY_RELEASE [uzbl_instance_name] key_name + 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 SELECTION_CHANGED [uzbl_instance_name] selected_text + EVENT [uzbl_instance_name] SELECTION_CHANGED selected_text - when a new uzbl window is created: - EVENT NEW_WINDOW [uzbl_instance_name] uri + EVENT [uzbl_instance_name] NEW_WINDOW uri - upon opening/closing of the webinspector window: - EVENT WEBINSPECTOR [uzbl_instance_name] open - EVENT WEBINSPECTOR [uzbl_instance_name] close + 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 + ### COMMAND LINE ARGUMENTS diff --git a/callbacks.c b/callbacks.c index 593fdac..175f4a3 100644 --- a/callbacks.c +++ b/callbacks.c @@ -450,13 +450,33 @@ gboolean configure_event_cb(GtkWidget* window, GdkEventConfigure* event) { (void) window; (void) event; + gchar *lastgeo = NULL; + lastgeo = g_strdup(uzbl.gui.geometry); retrieve_geometry(); - send_event(GEOMETRY_CHANGED, uzbl.gui.geometry, NULL); + + if(strcmp(lastgeo, uzbl.gui.geometry)) + send_event(GEOMETRY_CHANGED, uzbl.gui.geometry, NULL); + g_free(lastgeo); + return FALSE; } gboolean +focus_cb(GtkWidget* window, GdkEventFocus* event, void *ud) { + (void) window; + (void) event; + (void) ud; + + if(event->in) + send_event(FOCUS_GAINED, "", NULL); + else + send_event(FOCUS_LOST, "", NULL); + + return TRUE; +} + +gboolean key_press_cb (GtkWidget* window, GdkEventKey* event) { (void) window; diff --git a/callbacks.h b/callbacks.h index 7222eaf..72361ba 100644 --- a/callbacks.h +++ b/callbacks.h @@ -192,3 +192,6 @@ populate_popup_cb(WebKitWebView *v, GtkMenu *m, void *c); gboolean button_press_cb (GtkWidget* window, GdkEventButton* event); +gboolean +focus_cb(GtkWidget* window, GdkEventFocus* event, void *ud); + @@ -37,7 +37,9 @@ const char *event_table[LAST_EVENT] = { "LOAD_PROGRESS" , "LINK_UNHOVER" , "FORM_ACTIVE" , - "ROOT_ACTIVE" + "ROOT_ACTIVE" , + "FOCUS_LOST" , + "FOCUS_GAINED" }; void @@ -12,6 +12,7 @@ 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, /* must be last entry */ LAST_EVENT diff --git a/examples/config/uzbl/config b/examples/config/uzbl/config index 1ca1770..a1fc9c1 100644 --- a/examples/config/uzbl/config +++ b/examples/config/uzbl/config @@ -42,9 +42,8 @@ set new_window = sh 'uzbl-browser -u $8' # equivalent to the default beh @on_event LOAD_FINISH @set_status <span foreground="gold">done</span> @on_event LOAD_FINISH spawn @scripts_dir/history.sh -# Generate a FORM_ACTIVE event if a text element on the loaded site -# has initial focus unfortunatelly this only works for text elements, -# yet due to webkit limitations +# Generate a FORM_ACTIVE event if an editable +# element on the loaded site has initial focus @on_event LOAD_FINISH js if(document.activeElement.type == 'text') {Uzbl.run("event FORM_ACTIVE");} # Switch to insert mode if a (editable) html form is clicked diff --git a/uzbl-browser b/uzbl-browser index 02ea6c9..b1205ac 100755 --- a/uzbl-browser +++ b/uzbl-browser @@ -36,4 +36,4 @@ DAEMON_PID=$XDG_CACHE_HOME/uzbl/event_daemon.pid uzbl-daemon start #fi -uzbl-core "$@" --connect-socket $DAEMON_SOCKET +uzbl-core "$@" --connect-socket $DAEMON_SOCKET 1>/dev/null diff --git a/uzbl-core.c b/uzbl-core.c index ef9852b..3b8c407 100644 --- a/uzbl-core.c +++ b/uzbl-core.c @@ -634,9 +634,6 @@ struct {const char *key; CommandInfo value;} cmdlist[] = { "chain", {chain, 0} }, { "print", {print, TRUE} }, { "event", {event, TRUE} }, - /* a request is just semantic sugar to make things more obvious for - * the user, technically events and requests are the very same thin g - */ { "request", {event, TRUE} }, { "update_gui", {update_gui, TRUE} }, { "menu_add", {menu_add, TRUE} }, @@ -650,7 +647,8 @@ struct {const char *key; CommandInfo value;} cmdlist[] = { "menu_remove", {menu_remove, TRUE} }, { "menu_link_remove", {menu_remove_link, TRUE} }, { "menu_image_remove", {menu_remove_image, TRUE} }, - { "menu_editable_remove", {menu_remove_edit, TRUE} } + { "menu_editable_remove", {menu_remove_edit, TRUE} }, + { "hardcopy", {hardcopy, TRUE} } }; void @@ -889,6 +887,14 @@ print(WebKitWebView *page, GArray *argv, GString *result) { } void +hardcopy(WebKitWebView *page, GArray *argv, GString *result) { + (void) argv; + (void) result; + + webkit_web_frame_print(webkit_web_view_get_main_frame(page)); +} + +void act_dump_config() { dump_config(); } @@ -1896,7 +1902,7 @@ create_browser () { g_object_connect((GObject*)g->web_view, "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-press-event", (GCallback)button_press_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, @@ -1911,6 +1917,8 @@ create_browser () { "signal::create-web-view", (GCallback)create_web_view_cb, NULL, "signal::mime-type-policy-decision-requested", (GCallback)mime_policy_cb, NULL, "signal::populate-popup", (GCallback)populate_popup_cb, NULL, + "signal::focus-in-event", (GCallback)focus_cb, NULL, + "signal::focus-out-event", (GCallback)focus_cb, NULL, NULL); } @@ -1934,12 +1942,17 @@ create_mainbar () { return g->mainbar; } + GtkWidget* create_window () { GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_default_size (GTK_WINDOW (window), 800, 600); + gtk_window_set_wmclass(GTK_WINDOW(window), "uzbl", "uzbl"); gtk_widget_set_name (window, "Uzbl browser"); - g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy_cb), NULL); + + g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy_cb), NULL); + g_signal_connect (G_OBJECT (window), "configure-event", G_CALLBACK (configure_event_cb), NULL); return window; } diff --git a/uzbl-core.h b/uzbl-core.h index 43d5a3b..ea78f20 100644 --- a/uzbl-core.h +++ b/uzbl-core.h @@ -460,7 +460,11 @@ menu_remove_edit(WebKitWebView *page, GArray *argv, GString *result); gint get_click_context(); +void +hardcopy(WebKitWebView *page, GArray *argv, GString *result); + typedef void (*Command)(WebKitWebView*, GArray *argv, GString *result); + typedef struct { Command function; gboolean no_split; |