From e44414affde4e5497386ce398cc2c40356c4e466 Mon Sep 17 00:00:00 2001 From: keis Date: Mon, 28 Feb 2011 22:03:26 +0100 Subject: add clear_cookies command --- src/uzbl-core.c | 15 ++++++++++++++- src/uzbl-core.h | 4 +--- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/uzbl-core.c b/src/uzbl-core.c index bc75d87..3303797 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -551,7 +551,8 @@ CommandInfo cmdlist[] = { "include", include, TRUE }, { "show_inspector", show_inspector, 0 }, { "add_cookie", add_cookie, 0 }, - { "delete_cookie", delete_cookie, 0 } + { "delete_cookie", delete_cookie, 0 }, + { "clear_cookies", clear_cookies, 0 } }; void @@ -725,6 +726,18 @@ delete_cookie(WebKitWebView *page, GArray *argv, GString *result) { uzbl.net.soup_cookie_jar->in_manual_add = 0; } + +void +clear_cookies(WebKitWebView *page, GArray *argv, GString *result) { + (void) page; (void) argv; (void) result; + + // Replace the current cookie jar with a new empty jar + soup_session_remove_feature (uzbl.net.soup_session, uzbl.net.soup_cookie_jar); + g_object_unref (G_OBJECT (uzbl.net.soup_cookie_jar)); + uzbl.net.soup_cookie_jar = uzbl_cookie_jar_new (); + soup_session_add_feature(uzbl.net.soup_session, uzbl.net.soup_cookie_jar); +} + void act_dump_config() { dump_config(); diff --git a/src/uzbl-core.h b/src/uzbl-core.h index a4e055f..56f4fac 100644 --- a/src/uzbl-core.h +++ b/src/uzbl-core.h @@ -315,9 +315,6 @@ void handle_authentication (SoupSession *session, SoupAuth *auth, gboolean retrying, gpointer user_data); -void handle_cookies (SoupSession *session, - SoupMessage *msg, - gpointer user_data); gboolean valid_name(const gchar* name); void set_var(WebKitWebView *page, GArray *argv, GString *result); void act_dump_config(); @@ -339,6 +336,7 @@ void include(WebKitWebView *page, GArray *argv, GString *result); void show_inspector(WebKitWebView *page, GArray *argv, GString *result); void add_cookie(WebKitWebView *page, GArray *argv, GString *result); void delete_cookie(WebKitWebView *page, GArray *argv, GString *result); +void clear_cookies(WebKitWebView *pag, GArray *argv, GString *result); void builtins(); typedef void (*Command)(WebKitWebView*, GArray *argv, GString *result); -- cgit v1.2.3 From 49ce876c744ee3d6a424c50d9f2db439acbe3f28 Mon Sep 17 00:00:00 2001 From: keis Date: Thu, 17 Mar 2011 20:24:02 +0100 Subject: fix clear_cookies warning --- src/uzbl-core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/uzbl-core.c b/src/uzbl-core.c index c879602..ec2d347 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -732,10 +732,12 @@ clear_cookies(WebKitWebView *page, GArray *argv, GString *result) { (void) page; (void) argv; (void) result; // Replace the current cookie jar with a new empty jar - soup_session_remove_feature (uzbl.net.soup_session, uzbl.net.soup_cookie_jar); + soup_session_remove_feature (uzbl.net.soup_session, + SOUP_SESSION_FEATURE (uzbl.net.soup_cookie_jar)); g_object_unref (G_OBJECT (uzbl.net.soup_cookie_jar)); uzbl.net.soup_cookie_jar = uzbl_cookie_jar_new (); - soup_session_add_feature(uzbl.net.soup_session, uzbl.net.soup_cookie_jar); + soup_session_add_feature(uzbl.net.soup_session, + SOUP_SESSION_FEATURE (uzbl.net.soup_cookie_jar)); } void -- cgit v1.2.3 From 2926b0f55122b131e0b9d2cf857d2b78d202c5ab Mon Sep 17 00:00:00 2001 From: Olof-Joachim Frahm Date: Mon, 21 Mar 2011 06:23:23 +0100 Subject: Fixed array bug. When e.g. spawn_sh modifies the array, invalid stuff is send to the python script, which then breaks while decoding them. --- src/uzbl-core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/uzbl-core.c b/src/uzbl-core.c index c879602..ba062b6 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -1129,8 +1129,6 @@ spawn_sh_sync(WebKitWebView *web_view, GArray *argv, GString *result) { void run_parsed_command(const CommandInfo *c, GArray *a, GString *result) { - c->function(uzbl.gui.web_view, a, result); - /* send the COMMAND_EXECUTED event, except for set and event/request commands */ if(strcmp("set", c->key) && strcmp("event", c->key) && @@ -1141,12 +1139,18 @@ run_parsed_command(const CommandInfo *c, GArray *a, GString *result) { guint i = 0; while ((p = argv_idx(a, i++))) g_string_append_printf(param, " '%s'", p); + + /* might be destructive on array a */ + c->function(uzbl.gui.web_view, a, result); + send_event(COMMAND_EXECUTED, NULL, TYPE_NAME, c->key, TYPE_FORMATTEDSTR, param->str, NULL); g_string_free(param, TRUE); } + else + c->function(uzbl.gui.web_view, a, result); if(result) { g_free(uzbl.state.last_result); -- cgit v1.2.3 From e7578e27ccb638ca59ad250bc7a8049b3aa25df4 Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Sat, 2 Apr 2011 08:14:56 -0600 Subject: fix returning to default encoding ("set current_encoding =") --- src/callbacks.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/callbacks.c b/src/callbacks.c index deda426..360b0c4 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -292,8 +292,11 @@ cmd_caret_browsing() { void set_current_encoding() { - webkit_web_view_set_custom_encoding(uzbl.gui.web_view, - uzbl.behave.current_encoding); + gchar *encoding = uzbl.behave.current_encoding; + if(strlen(encoding) == 0) + encoding = NULL; + + webkit_web_view_set_custom_encoding(uzbl.gui.web_view, encoding); } -- cgit v1.2.3 From 8126f371f3976a253d0b40e1788762ff68c273cb Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Mon, 11 Apr 2011 19:52:49 -0600 Subject: autoinstall style.css --- src/uzbl-browser | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/uzbl-browser b/src/uzbl-browser index 81645ca..fb9a368 100755 --- a/src/uzbl-browser +++ b/src/uzbl-browser @@ -42,7 +42,7 @@ then echo "Error: Global config not found; please check if your distribution ships them separately" exit 3 fi - if ! cp "$EXAMPLES"/config/config "$XDG_CONFIG_HOME"/uzbl/config + if ! cp "$EXAMPLES"/config/* "$XDG_CONFIG_HOME"/uzbl/ then echo "Could not copy default config to $XDG_CONFIG_HOME/uzbl/config" >&2 # Run with the global config as a last resort -- cgit v1.2.3 From 54d90f3711abd0ad864fcb9767b27ca1f25541b2 Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Mon, 11 Apr 2011 19:55:30 -0600 Subject: move src/uzbl-browser to bin/uzbl-browser --- Makefile | 4 +-- bin/uzbl-browser | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/uzbl-browser | 75 -------------------------------------------------------- 3 files changed, 77 insertions(+), 77 deletions(-) create mode 100755 bin/uzbl-browser delete mode 100755 src/uzbl-browser (limited to 'src') diff --git a/Makefile b/Makefile index 91b66b6..a3597df 100644 --- a/Makefile +++ b/Makefile @@ -68,7 +68,7 @@ test-uzbl-core: uzbl-core ./uzbl-core --uri http://www.uzbl.org --verbose test-uzbl-browser: uzbl-browser - ./src/uzbl-browser --uri http://www.uzbl.org --verbose + ./bin/uzbl-browser --uri http://www.uzbl.org --verbose test-uzbl-core-sandbox: uzbl-core make DESTDIR=./sandbox RUN_PREFIX=`pwd`/sandbox/usr/local install-uzbl-core @@ -134,7 +134,7 @@ install-uzbl-core: all install-dirs install -m755 uzbl-core $(INSTALLDIR)/bin/uzbl-core install-uzbl-browser: install-dirs - install -m755 src/uzbl-browser $(INSTALLDIR)/bin/uzbl-browser + install -m755 bin/uzbl-browser $(INSTALLDIR)/bin/uzbl-browser install -m755 examples/data/scripts/uzbl-event-manager $(INSTALLDIR)/bin/uzbl-event-manager mv $(INSTALLDIR)/bin/uzbl-browser $(INSTALLDIR)/bin/uzbl-browser.bak sed 's#^PREFIX=.*#PREFIX=$(RUN_PREFIX)#' < $(INSTALLDIR)/bin/uzbl-browser.bak > $(INSTALLDIR)/bin/uzbl-browser diff --git a/bin/uzbl-browser b/bin/uzbl-browser new file mode 100755 index 0000000..fb9a368 --- /dev/null +++ b/bin/uzbl-browser @@ -0,0 +1,75 @@ +#!/bin/sh +# +# This script implements a more useful out-of-the-box "browsing experience". +# It does so by combining uzbl-core with a set of "recommended" tools and +# practices. See docs for more info. +# +# If you want to customize the behavior any of the helper tools, copy them +# to your $XDG_DATA_HOME/uzbl/scripts/ and edit them + +PREFIX=/usr/local +export PREFIX + +EXAMPLES=$PREFIX/share/uzbl/examples + +XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share} +export XDG_DATA_HOME + +XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache} +export XDG_CACHE_HOME + +XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config} +export XDG_CONFIG_HOME + +# assure the relevant directories exist. +for dir in "$XDG_CACHE_HOME"/uzbl "$XDG_DATA_HOME"/uzbl "$XDG_CONFIG_HOME"/uzbl +do + if [ ! -d "$dir" ] + then + if ! mkdir -p "$dir" + then + echo "could not create $dir" >&2 + exit 2 + 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 [ ! -r "$EXAMPLES"/config/config ] + then + echo "Error: Global config not found; please check if your distribution ships them separately" + exit 3 + fi + if ! cp "$EXAMPLES"/config/* "$XDG_CONFIG_HOME"/uzbl/ + then + echo "Could not copy default config to $XDG_CONFIG_HOME/uzbl/config" >&2 + # Run with the global config as a last resort + config_file=$EXAMPLES/config/config + fi +fi + +# this variable is used by the default helper scripts as a location to +# load shared code from +if [ -z "$UZBL_UTIL_DIR" ] +then + if [ -d "$XDG_DATA_HOME"/uzbl/scripts/util ] + then + UZBL_UTIL_DIR=$XDG_DATA_HOME/uzbl/scripts/util + elif [ -d $EXAMPLES/data/scripts/util ] + then + UZBL_UTIL_DIR=$EXAMPLES/data/scripts/util + fi + export UZBL_UTIL_DIR +fi + +# uzbl-event-manager will exit if one is already running. +# we could also check if its pid file exists to avoid having to spawn it. +DAEMON_SOCKET="$XDG_CACHE_HOME"/uzbl/event_daemon +#if [ ! -f "$DAEMON_SOCKET".pid ] +#then + ${UZBL_EVENT_MANAGER:-uzbl-event-manager -va start} +#fi + +exec uzbl-core "$@" ${config_file:+--config "$config_file"} --connect-socket $DAEMON_SOCKET diff --git a/src/uzbl-browser b/src/uzbl-browser deleted file mode 100755 index fb9a368..0000000 --- a/src/uzbl-browser +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/sh -# -# This script implements a more useful out-of-the-box "browsing experience". -# It does so by combining uzbl-core with a set of "recommended" tools and -# practices. See docs for more info. -# -# If you want to customize the behavior any of the helper tools, copy them -# to your $XDG_DATA_HOME/uzbl/scripts/ and edit them - -PREFIX=/usr/local -export PREFIX - -EXAMPLES=$PREFIX/share/uzbl/examples - -XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share} -export XDG_DATA_HOME - -XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache} -export XDG_CACHE_HOME - -XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config} -export XDG_CONFIG_HOME - -# assure the relevant directories exist. -for dir in "$XDG_CACHE_HOME"/uzbl "$XDG_DATA_HOME"/uzbl "$XDG_CONFIG_HOME"/uzbl -do - if [ ! -d "$dir" ] - then - if ! mkdir -p "$dir" - then - echo "could not create $dir" >&2 - exit 2 - 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 [ ! -r "$EXAMPLES"/config/config ] - then - echo "Error: Global config not found; please check if your distribution ships them separately" - exit 3 - fi - if ! cp "$EXAMPLES"/config/* "$XDG_CONFIG_HOME"/uzbl/ - then - echo "Could not copy default config to $XDG_CONFIG_HOME/uzbl/config" >&2 - # Run with the global config as a last resort - config_file=$EXAMPLES/config/config - fi -fi - -# this variable is used by the default helper scripts as a location to -# load shared code from -if [ -z "$UZBL_UTIL_DIR" ] -then - if [ -d "$XDG_DATA_HOME"/uzbl/scripts/util ] - then - UZBL_UTIL_DIR=$XDG_DATA_HOME/uzbl/scripts/util - elif [ -d $EXAMPLES/data/scripts/util ] - then - UZBL_UTIL_DIR=$EXAMPLES/data/scripts/util - fi - export UZBL_UTIL_DIR -fi - -# uzbl-event-manager will exit if one is already running. -# we could also check if its pid file exists to avoid having to spawn it. -DAEMON_SOCKET="$XDG_CACHE_HOME"/uzbl/event_daemon -#if [ ! -f "$DAEMON_SOCKET".pid ] -#then - ${UZBL_EVENT_MANAGER:-uzbl-event-manager -va start} -#fi - -exec uzbl-core "$@" ${config_file:+--config "$config_file"} --connect-socket $DAEMON_SOCKET -- cgit v1.2.3 From 1282b9cf99be29db65529eec3bfb14f6685b393b Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Tue, 12 Apr 2011 22:00:35 -0600 Subject: add a 'download' command that can download the current url or an arbitrary url --- src/uzbl-core.c | 19 ++++++++++++++++++- src/uzbl-core.h | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/uzbl-core.c b/src/uzbl-core.c index e498762..3a96482 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -552,7 +552,8 @@ CommandInfo cmdlist[] = { "show_inspector", show_inspector, 0 }, { "add_cookie", add_cookie, 0 }, { "delete_cookie", delete_cookie, 0 }, - { "clear_cookies", clear_cookies, 0 } + { "clear_cookies", clear_cookies, 0 }, + { "download", download, 0 } }; void @@ -740,6 +741,22 @@ clear_cookies(WebKitWebView *page, GArray *argv, GString *result) { SOUP_SESSION_FEATURE (uzbl.net.soup_cookie_jar)); } +void +download(WebKitWebView *web_view, GArray *argv, GString *result) { + (void) result; + + const gchar *uri = NULL; + + if(argv->len > 0) + uri = argv_idx(argv, 0); + else + uri = uzbl.state.uri; + + WebKitNetworkRequest *req = webkit_network_request_new(uri); + webkit_web_view_request_download(web_view, req); + g_object_unref(req); +} + void act_dump_config() { dump_config(); diff --git a/src/uzbl-core.h b/src/uzbl-core.h index affd334..be8fccd 100644 --- a/src/uzbl-core.h +++ b/src/uzbl-core.h @@ -325,6 +325,7 @@ void show_inspector(WebKitWebView *page, GArray *argv, GString *result); void add_cookie(WebKitWebView *page, GArray *argv, GString *result); void delete_cookie(WebKitWebView *page, GArray *argv, GString *result); void clear_cookies(WebKitWebView *pag, GArray *argv, GString *result); +void download(WebKitWebView *pag, GArray *argv, GString *result); void builtins(); typedef void (*Command)(WebKitWebView*, GArray *argv, GString *result); -- cgit v1.2.3 From bdfb2fb35c4d6fa407361dcc99aefb00ff185e6d Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Tue, 12 Apr 2011 22:35:42 -0600 Subject: allow a second argument to the 'download' command that specifies a destination path --- examples/data/scripts/download.sh | 14 +++++++++++--- src/callbacks.c | 8 ++++++++ src/uzbl-core.c | 18 ++++++++++++------ 3 files changed, 31 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/examples/data/scripts/download.sh b/examples/data/scripts/download.sh index fe566ed..dbc9caf 100755 --- a/examples/data/scripts/download.sh +++ b/examples/data/scripts/download.sh @@ -1,9 +1,17 @@ #!/bin/sh # uzbl's example configuration sets this script up as its download_handler. -# when uzbl starts a download it runs this script. +# this script is run when uzbl encounters a URL that it can't display, and when +# a download is requested using the 'download' command. +# # if the script prints a file path to stdout, uzbl will save the download to -# that path. -# if nothing is printed to stdout, the download will be cancelled. +# that path using it's internal downloader. +# +# if nothing is printed to stdout, the internal download will be cancelled. +# you could do your own download handling in your script that way. + +# if $5 is set, it is the path that was passed to uzbl's "download" command. +# we want to use that if it's available. +[ -n "$5" ] && echo "$5" && exit . "$UZBL_UTIL_DIR/uzbl-dir.sh" diff --git a/src/callbacks.c b/src/callbacks.c index 360b0c4..703107b 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -837,6 +837,11 @@ download_cb(WebKitWebView *web_view, WebKitDownload *download, gpointer user_dat /* get the URI being downloaded */ const gchar *uri = webkit_download_get_uri(download); + /* get the destination path, if specified. + * this is only intended to be set when this function is trigger by an + * explicit download using uzbl's 'download' action. */ + const gchar *destination = user_data; + if (uzbl.state.verbose) printf("Download requested -> %s\n", uri); @@ -883,6 +888,9 @@ download_cb(WebKitWebView *web_view, WebKitDownload *download, gpointer user_dat gchar *total_size_s = g_strdup_printf("%d", total_size); g_array_append_val(a, total_size_s); + if(destination) + g_array_append_val(a, destination); + GString *result = g_string_new (""); run_parsed_command(c, a, result); diff --git a/src/uzbl-core.c b/src/uzbl-core.c index 3a96482..204c89c 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -745,15 +745,21 @@ void download(WebKitWebView *web_view, GArray *argv, GString *result) { (void) result; - const gchar *uri = NULL; + const gchar *uri = argv_idx(argv, 0); + const gchar *destination = NULL; + if(argv->len > 1) + destination = argv_idx(argv, 1); - if(argv->len > 0) - uri = argv_idx(argv, 0); + WebKitNetworkRequest *req = webkit_network_request_new(uri); + WebKitDownload *download = webkit_download_new(req); + + download_cb(web_view, download, destination); + + if(webkit_download_get_destination_uri(download)) + webkit_download_start(download); else - uri = uzbl.state.uri; + g_object_unref(download); - WebKitNetworkRequest *req = webkit_network_request_new(uri); - webkit_web_view_request_download(web_view, req); g_object_unref(req); } -- cgit v1.2.3 From 726e105a1269a9202690281471e5fa243223809b Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 14 Apr 2011 00:20:20 -0400 Subject: Avoid --name which GTK uses internally Addresses #170. --- src/uzbl-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/uzbl-core.c b/src/uzbl-core.c index e498762..e918451 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -47,7 +47,7 @@ GOptionEntry entries[] = { "Uri to load at startup (equivalent to 'uzbl ' or 'set uri = URI' after uzbl has launched)", "URI" }, { "verbose", 'v', 0, G_OPTION_ARG_NONE, &uzbl.state.verbose, "Whether to print all messages or just errors.", NULL }, - { "name", 'n', 0, G_OPTION_ARG_STRING, &uzbl.state.instance_name, + { "named", 'n', 0, G_OPTION_ARG_STRING, &uzbl.state.instance_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" }, -- cgit v1.2.3 From 4b106c13eb642f865c4bed2bc149c703e3fe7534 Mon Sep 17 00:00:00 2001 From: Rob Date: Fri, 19 Feb 2010 11:09:21 +0100 Subject: added modifier mask to key_press/release events --- src/callbacks.c | 4 ++-- src/events.c | 48 +++++++++++++++++++++++++++++++++++++++++++----- src/events.h | 2 +- 3 files changed, 46 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/callbacks.c b/src/callbacks.c index 703107b..c0064ec 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -549,7 +549,7 @@ key_press_cb (GtkWidget* window, GdkEventKey* event) { (void) window; if(event->type == GDK_KEY_PRESS) - key_to_event(event->keyval, GDK_KEY_PRESS); + key_to_event(event->keyval, event->is_modifier?0:event->state, GDK_KEY_PRESS); return uzbl.behave.forward_keys ? FALSE : TRUE; } @@ -559,7 +559,7 @@ key_release_cb (GtkWidget* window, GdkEventKey* event) { (void) window; if(event->type == GDK_KEY_RELEASE) - key_to_event(event->keyval, GDK_KEY_RELEASE); + key_to_event(event->keyval, event->is_modifier?0:event->state, GDK_KEY_RELEASE); return uzbl.behave.forward_keys ? FALSE : TRUE; } diff --git a/src/events.c b/src/events.c index 58dddfc..45b2ef1 100644 --- a/src/events.c +++ b/src/events.c @@ -202,11 +202,46 @@ send_event(int type, const gchar *custom_event, ...) { /* Transform gdk key events to our own events */ void -key_to_event(guint keyval, gint mode) { +key_to_event(guint keyval, guint state, gint mode) { gchar ucs[7]; gint ulen; gchar *keyname; guint32 ukval = gdk_keyval_to_unicode(keyval); + GString *modifiers = g_string_new(""); + gchar *details; + + /* check modifier state*/ + if(state & GDK_MODIFIER_MASK) { + if(state & GDK_SHIFT_MASK) + g_string_append(modifiers, "Shift|"); + if(state & GDK_LOCK_MASK) + g_string_append(modifiers, "ScrollLock|"); + if(state & GDK_CONTROL_MASK) + g_string_append(modifiers, "Ctrl|"); + if(state & GDK_MOD1_MASK) + g_string_append(modifiers,"Mod1|"); + if(state & GDK_MOD2_MASK) + g_string_append(modifiers,"Mod2|"); + if(state & GDK_MOD3_MASK) + g_string_append(modifiers,"Mod3|"); + if(state & GDK_MOD4_MASK) + g_string_append(modifiers,"Mod4|"); + if(state & GDK_MOD5_MASK) + g_string_append(modifiers,"Mod5|"); + if(state & GDK_BUTTON1_MASK) + g_string_append(modifiers,"Button1|"); + if(state & GDK_BUTTON2_MASK) + g_string_append(modifiers,"Button2|"); + if(state & GDK_BUTTON3_MASK) + g_string_append(modifiers,"Button3|"); + if(state & GDK_BUTTON4_MASK) + g_string_append(modifiers,"Button4|"); + if(state & GDK_BUTTON5_MASK) + g_string_append(modifiers,"Button5|"); + + if(modifiers->str[modifiers->len-1] == '|') + g_string_overwrite(modifiers, modifiers->len-1, " "); + } /* check for printable unicode char */ /* TODO: Pass the keyvals through a GtkIMContext so that @@ -216,15 +251,18 @@ key_to_event(guint keyval, gint mode) { ulen = g_unichar_to_utf8(ukval, ucs); ucs[ulen] = 0; - send_event(mode == GDK_KEY_PRESS ? KEY_PRESS : KEY_RELEASE, - NULL, TYPE_FORMATTEDSTR, ucs, NULL); + send_event(mode == GDK_KEY_PRESS ? KEY_PRESS : KEY_RELEASE, NULL, + TYPE_STR, modifiers->str, TYPE_FORMATTEDSTR, ucs, NULL); } /* send keysym for non-printable chars */ else if((keyname = gdk_keyval_name(keyval))){ - send_event(mode == GDK_KEY_PRESS ? KEY_PRESS : KEY_RELEASE, - NULL, TYPE_NAME, keyname , NULL); + send_event(mode == GDK_KEY_PRESS ? KEY_PRESS : KEY_RELEASE, NULL, + TYPE_STR, modifiers->str, TYPE_NAME, keyname , NULL); } + g_string_free(modifiers, TRUE); + g_free(details); + } /* vi: set et ts=4: */ diff --git a/src/events.h b/src/events.h index bd519a6..97ed0a0 100644 --- a/src/events.h +++ b/src/events.h @@ -42,6 +42,6 @@ void send_event(int type, const gchar *custom_event, ...) G_GNUC_NULL_TERMINATED; void -key_to_event(guint keyval, gint mode); +key_to_event(guint keyval, guint state, int mode); #endif -- cgit v1.2.3 From 60b4e20512df7b29e19aa3bb17532fd177928d4d Mon Sep 17 00:00:00 2001 From: Rob Date: Fri, 19 Feb 2010 12:44:37 +0100 Subject: added MOD_PRESS/RELEASE events that denote X modifier keys --- src/callbacks.c | 4 ++-- src/events.c | 15 +++++++++------ src/events.h | 5 +++-- 3 files changed, 14 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/callbacks.c b/src/callbacks.c index c0064ec..4c150ec 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -549,7 +549,7 @@ key_press_cb (GtkWidget* window, GdkEventKey* event) { (void) window; if(event->type == GDK_KEY_PRESS) - key_to_event(event->keyval, event->is_modifier?0:event->state, GDK_KEY_PRESS); + key_to_event(event->keyval, event->is_modifier?0:event->state, event->is_modifier, GDK_KEY_PRESS); return uzbl.behave.forward_keys ? FALSE : TRUE; } @@ -559,7 +559,7 @@ key_release_cb (GtkWidget* window, GdkEventKey* event) { (void) window; if(event->type == GDK_KEY_RELEASE) - key_to_event(event->keyval, event->is_modifier?0:event->state, GDK_KEY_RELEASE); + key_to_event(event->keyval, event->is_modifier?0:event->state, event->is_modifier, GDK_KEY_RELEASE); return uzbl.behave.forward_keys ? FALSE : TRUE; } diff --git a/src/events.c b/src/events.c index 45b2ef1..013bd85 100644 --- a/src/events.c +++ b/src/events.c @@ -23,6 +23,8 @@ const char *event_table[LAST_EVENT] = { "REQUEST_STARTING" , "KEY_PRESS" , "KEY_RELEASE" , + "MOD_PRESS" , + "MOD_RELEASE" , "COMMAND_EXECUTED" , "LINK_HOVER" , "TITLE_CHANGED" , @@ -202,13 +204,12 @@ send_event(int type, const gchar *custom_event, ...) { /* Transform gdk key events to our own events */ void -key_to_event(guint keyval, guint state, gint mode) { +key_to_event(guint keyval, guint state, guint is_modifier, gint mode) { gchar ucs[7]; gint ulen; gchar *keyname; guint32 ukval = gdk_keyval_to_unicode(keyval); GString *modifiers = g_string_new(""); - gchar *details; /* check modifier state*/ if(state & GDK_MODIFIER_MASK) { @@ -256,13 +257,15 @@ key_to_event(guint keyval, guint state, gint mode) { } /* send keysym for non-printable chars */ else if((keyname = gdk_keyval_name(keyval))){ - send_event(mode == GDK_KEY_PRESS ? KEY_PRESS : KEY_RELEASE, NULL, - TYPE_STR, modifiers->str, TYPE_NAME, keyname , NULL); + if(is_modifier) + send_event(mode == GDK_KEY_PRESS ? MOD_PRESS : MOD_RELEASE, NULL, + TYPE_STR, modifiers->str, TYPE_NAME, keyname , NULL); + else + send_event(mode == GDK_KEY_PRESS ? KEY_PRESS : KEY_RELEASE, NULL, + TYPE_STR, modifiers->str, TYPE_NAME, keyname , NULL); } g_string_free(modifiers, TRUE); - g_free(details); - } /* vi: set et ts=4: */ diff --git a/src/events.h b/src/events.h index 97ed0a0..35e0ecd 100644 --- a/src/events.h +++ b/src/events.h @@ -13,7 +13,8 @@ enum event_type { LOAD_START, LOAD_COMMIT, LOAD_FINISH, LOAD_ERROR, REQUEST_STARTING, - KEY_PRESS, KEY_RELEASE, COMMAND_EXECUTED, + KEY_PRESS, KEY_RELEASE, MOD_PRESS, MOD_RELEASE, + COMMAND_EXECUTED, LINK_HOVER, TITLE_CHANGED, GEOMETRY_CHANGED, WEBINSPECTOR, NEW_WINDOW, SELECTION_CHANGED, VARIABLE_SET, FIFO_SET, SOCKET_SET, @@ -42,6 +43,6 @@ void send_event(int type, const gchar *custom_event, ...) G_GNUC_NULL_TERMINATED; void -key_to_event(guint keyval, guint state, int mode); +key_to_event(guint keyval, guint state, guint is_modifier, int mode); #endif -- cgit v1.2.3 From 5a46390e61faaea2d88ec49a1a81997672f4150b Mon Sep 17 00:00:00 2001 From: Rob Date: Mon, 22 Feb 2010 09:03:15 +0100 Subject: show modmask on MOD_PRESS/RELEASE --- src/callbacks.c | 4 ++-- src/events.c | 33 +++++++++++++++++++++------------ src/events.h | 3 +++ 3 files changed, 26 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/callbacks.c b/src/callbacks.c index 4c150ec..6821700 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -549,7 +549,7 @@ key_press_cb (GtkWidget* window, GdkEventKey* event) { (void) window; if(event->type == GDK_KEY_PRESS) - key_to_event(event->keyval, event->is_modifier?0:event->state, event->is_modifier, GDK_KEY_PRESS); + key_to_event(event->keyval, event->state, event->is_modifier, GDK_KEY_PRESS); return uzbl.behave.forward_keys ? FALSE : TRUE; } @@ -559,7 +559,7 @@ key_release_cb (GtkWidget* window, GdkEventKey* event) { (void) window; if(event->type == GDK_KEY_RELEASE) - key_to_event(event->keyval, event->is_modifier?0:event->state, event->is_modifier, GDK_KEY_RELEASE); + key_to_event(event->keyval, event->state, event->is_modifier, GDK_KEY_RELEASE); return uzbl.behave.forward_keys ? FALSE : TRUE; } diff --git a/src/events.c b/src/events.c index 013bd85..12f9d83 100644 --- a/src/events.c +++ b/src/events.c @@ -202,16 +202,10 @@ send_event(int type, const gchar *custom_event, ...) { va_end (vargs); } -/* Transform gdk key events to our own events */ -void -key_to_event(guint keyval, guint state, guint is_modifier, gint mode) { - gchar ucs[7]; - gint ulen; - gchar *keyname; - guint32 ukval = gdk_keyval_to_unicode(keyval); +gchar * +get_modifier_mask(guint state) { GString *modifiers = g_string_new(""); - /* check modifier state*/ if(state & GDK_MODIFIER_MASK) { if(state & GDK_SHIFT_MASK) g_string_append(modifiers, "Shift|"); @@ -244,6 +238,21 @@ key_to_event(guint keyval, guint state, guint is_modifier, gint mode) { g_string_overwrite(modifiers, modifiers->len-1, " "); } + return g_string_free(modifiers, FALSE); +} + +/* Transform gdk key events to our own events */ +void +key_to_event(guint keyval, guint state, guint is_modifier, gint mode) { + gchar ucs[7]; + gint ulen; + gchar *keyname; + guint32 ukval = gdk_keyval_to_unicode(keyval); + gchar *modifiers = NULL; + + /* check modifier state*/ + modifiers = get_modifier_mask(state); + /* check for printable unicode char */ /* TODO: Pass the keyvals through a GtkIMContext so that * we also get combining chars right @@ -253,19 +262,19 @@ key_to_event(guint keyval, guint state, guint is_modifier, gint mode) { ucs[ulen] = 0; send_event(mode == GDK_KEY_PRESS ? KEY_PRESS : KEY_RELEASE, NULL, - TYPE_STR, modifiers->str, TYPE_FORMATTEDSTR, ucs, NULL); + TYPE_STR, modifiers, TYPE_FORMATTEDSTR, ucs, NULL); } /* send keysym for non-printable chars */ else if((keyname = gdk_keyval_name(keyval))){ if(is_modifier) send_event(mode == GDK_KEY_PRESS ? MOD_PRESS : MOD_RELEASE, NULL, - TYPE_STR, modifiers->str, TYPE_NAME, keyname , NULL); + TYPE_STR, modifiers, TYPE_NAME, keyname , NULL); else send_event(mode == GDK_KEY_PRESS ? KEY_PRESS : KEY_RELEASE, NULL, - TYPE_STR, modifiers->str, TYPE_NAME, keyname , NULL); + TYPE_STR, modifiers, TYPE_NAME, keyname , NULL); } - g_string_free(modifiers, TRUE); + g_free(modifiers); } /* vi: set et ts=4: */ diff --git a/src/events.h b/src/events.h index 35e0ecd..0c40206 100644 --- a/src/events.h +++ b/src/events.h @@ -42,6 +42,9 @@ vsend_event(int type, const gchar *custom_event, va_list vargs); void send_event(int type, const gchar *custom_event, ...) G_GNUC_NULL_TERMINATED; +gchar * +get_modifier_mask(guint state); + void key_to_event(guint keyval, guint state, guint is_modifier, int mode); -- cgit v1.2.3 From 891786d26677ba535d454839e40b0660636b7039 Mon Sep 17 00:00:00 2001 From: keis Date: Fri, 11 Mar 2011 22:41:39 +0100 Subject: drop extra whitespace in key events --- src/events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/events.c b/src/events.c index 12f9d83..a6b1776 100644 --- a/src/events.c +++ b/src/events.c @@ -235,7 +235,7 @@ get_modifier_mask(guint state) { g_string_append(modifiers,"Button5|"); if(modifiers->str[modifiers->len-1] == '|') - g_string_overwrite(modifiers, modifiers->len-1, " "); + g_string_truncate(modifiers, modifiers->len-1); } return g_string_free(modifiers, FALSE); -- cgit v1.2.3 From 3f8b387500eca9f108883b5c3fbf68099f5abbe6 Mon Sep 17 00:00:00 2001 From: keis Date: Tue, 15 Mar 2011 17:56:08 +0100 Subject: placeholder translation of keyval to mod --- src/events.c | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/events.c b/src/events.c index a6b1776..5ff9a52 100644 --- a/src/events.c +++ b/src/events.c @@ -241,6 +241,30 @@ get_modifier_mask(guint state) { return g_string_free(modifiers, FALSE); } +guint key_to_modifier(guint keyval) { + /* FIXME + * Should really use XGetModifierMapping and/or Xkb to get actual mod keys + */ + switch(keyval) { + case GDK_KEY_Shift_L: + case GDK_KEY_Shift_R: + return GDK_SHIFT_MASK; + case GDK_KEY_Control_L: + case GDK_KEY_Control_R: + return GDK_CONTROL_MASK; + case GDK_KEY_Alt_L: + case GDK_KEY_Alt_R: + return GDK_MOD1_MASK; + case GDK_KEY_Super_L: + case GDK_KEY_Super_R: + return GDK_MOD4_MASK; + case GDK_KEY_ISO_Level3_Shift: + return GDK_MOD5_MASK; + default: + return 0; + } +} + /* Transform gdk key events to our own events */ void key_to_event(guint keyval, guint state, guint is_modifier, gint mode) { @@ -249,15 +273,22 @@ key_to_event(guint keyval, guint state, guint is_modifier, gint mode) { gchar *keyname; guint32 ukval = gdk_keyval_to_unicode(keyval); gchar *modifiers = NULL; + guint mod; /* check modifier state*/ modifiers = get_modifier_mask(state); + if(is_modifier && (mod = key_to_modifier (keyval))) { + send_event(mode == GDK_KEY_PRESS ? MOD_PRESS : MOD_RELEASE, NULL, + TYPE_STR, modifiers, + TYPE_NAME, get_modifier_mask (mod), + NULL); + } /* check for printable unicode char */ /* TODO: Pass the keyvals through a GtkIMContext so that * we also get combining chars right */ - if(g_unichar_isgraph(ukval)) { + else if(g_unichar_isgraph(ukval)) { ulen = g_unichar_to_utf8(ukval, ucs); ucs[ulen] = 0; @@ -266,12 +297,8 @@ key_to_event(guint keyval, guint state, guint is_modifier, gint mode) { } /* send keysym for non-printable chars */ else if((keyname = gdk_keyval_name(keyval))){ - if(is_modifier) - send_event(mode == GDK_KEY_PRESS ? MOD_PRESS : MOD_RELEASE, NULL, - TYPE_STR, modifiers, TYPE_NAME, keyname , NULL); - else - send_event(mode == GDK_KEY_PRESS ? KEY_PRESS : KEY_RELEASE, NULL, - TYPE_STR, modifiers, TYPE_NAME, keyname , NULL); + send_event(mode == GDK_KEY_PRESS ? KEY_PRESS : KEY_RELEASE, NULL, + TYPE_STR, modifiers, TYPE_NAME, keyname, NULL); } g_free(modifiers); -- cgit v1.2.3 From d2c7da7a03c8f9b76f78636a2374f439dae5c72d Mon Sep 17 00:00:00 2001 From: keis Date: Wed, 16 Mar 2011 19:42:22 +0100 Subject: use updated modstate for key events --- examples/data/plugins/keycmd.py | 2 -- src/events.c | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/examples/data/plugins/keycmd.py b/examples/data/plugins/keycmd.py index 99f92af..5fb7e8a 100644 --- a/examples/data/plugins/keycmd.py +++ b/examples/data/plugins/keycmd.py @@ -273,11 +273,9 @@ def key_release(uzbl, key): 2. Update the keycmd uzbl variable if anything changed.''' k = uzbl.keylet modstate, key = parse_key_event(uzbl, key) - modstate = set([m for m in modstate if not k.key_ignored(m)]) if len(key) > 1: if k.is_modcmd: - modstate.remove('<%s>' % key) uzbl.event('MODCMD_EXEC', modstate, k) clear_modcmd(uzbl) diff --git a/src/events.c b/src/events.c index 5ff9a52..c588729 100644 --- a/src/events.c +++ b/src/events.c @@ -273,12 +273,12 @@ key_to_event(guint keyval, guint state, guint is_modifier, gint mode) { gchar *keyname; guint32 ukval = gdk_keyval_to_unicode(keyval); gchar *modifiers = NULL; - guint mod; + guint mod = key_to_modifier (keyval); - /* check modifier state*/ - modifiers = get_modifier_mask(state); + /* Get modifier state including this key press/release */ + modifiers = get_modifier_mask(mode == GDK_KEY_PRESS ? state | mod : state & ~mod); - if(is_modifier && (mod = key_to_modifier (keyval))) { + if(is_modifier && mod) { send_event(mode == GDK_KEY_PRESS ? MOD_PRESS : MOD_RELEASE, NULL, TYPE_STR, modifiers, TYPE_NAME, get_modifier_mask (mod), -- cgit v1.2.3 From 169f53f110ca096d78c986402b5f9237924b8fbc Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Mon, 18 Apr 2011 20:11:10 -0600 Subject: escape ' in KEY_PRESS/RELEASE events --- src/events.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/events.c b/src/events.c index c588729..62d6414 100644 --- a/src/events.c +++ b/src/events.c @@ -160,11 +160,13 @@ vsend_event(int type, const gchar *custom_event, va_list vargs) { g_string_append_printf (event_message, "%d", va_arg (vargs, int)); break; case TYPE_STR: + /* a string that needs to be escaped */ g_string_append_c (event_message, '\''); append_escaped (event_message, va_arg (vargs, char*)); g_string_append_c (event_message, '\''); break; case TYPE_FORMATTEDSTR: + /* a string has already been escaped */ g_string_append (event_message, va_arg (vargs, char*)); break; case TYPE_NAME: @@ -293,7 +295,7 @@ key_to_event(guint keyval, guint state, guint is_modifier, gint mode) { ucs[ulen] = 0; send_event(mode == GDK_KEY_PRESS ? KEY_PRESS : KEY_RELEASE, NULL, - TYPE_STR, modifiers, TYPE_FORMATTEDSTR, ucs, NULL); + TYPE_STR, modifiers, TYPE_STR, ucs, NULL); } /* send keysym for non-printable chars */ else if((keyname = gdk_keyval_name(keyval))){ -- cgit v1.2.3 From d0b919ed5fb7fd42f6f4851443790e5c87116128 Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Sun, 24 Apr 2011 00:48:53 -0600 Subject: allow processes other than uzbl-tabbed to start uzbl-browser instances that appear in -tabbed not entirely sure that this is useful yet. --- bin/uzbl-tabbed | 47 ++++++++++++++++++++++++++++++++--------------- src/uzbl-core.c | 8 ++++++-- src/uzbl-core.h | 1 + 3 files changed, 39 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/bin/uzbl-tabbed b/bin/uzbl-tabbed index a15967a..d63d6de 100755 --- a/bin/uzbl-tabbed +++ b/bin/uzbl-tabbed @@ -303,12 +303,13 @@ class SocketClient: # List of UzblInstance objects not already linked with a SocketClient instances_queue = {} - def __init__(self, socket): + def __init__(self, socket, uzbl_tabbed): self._buffer = "" self._socket = socket self._watchers = [io_add_watch(socket, IO_IN, self._socket_recv),\ io_add_watch(socket, IO_HUP, self._socket_closed)] self.uzbl = None + self.uzbl_tabbed = uzbl_tabbed def _socket_recv(self, fd, condition): @@ -341,13 +342,17 @@ class SocketClient: if cmd: self.uzbl.parse_command(cmd) else: - name = re.findall('^EVENT \[(\d+-\d+)\] INSTANCE_START \d+$', self._buffer, re.M) + name = re.findall('^EVENT \[([^]]+)\] INSTANCE_START \d+$', self._buffer, re.M) uzbl = self.instances_queue.get(name[0]) if uzbl: + # we've found the uzbl we were waiting for del self.instances_queue[name[0]] - self.uzbl = uzbl - self.uzbl.got_socket(self) - self._feed("") + else: + # an unsolicited uzbl has connected, how exciting! + uzbl = UzblInstance(self.uzbl_tabbed, None, '', '', False) + self.uzbl = uzbl + self.uzbl.got_socket(self) + self._feed("") def send(self, data): '''Child socket send function.''' @@ -376,6 +381,12 @@ class EventDispatcher: return method(*args) + def plug_created(self, plug_id): + if not self.uzbl.tab: + tab = self.parent.create_tab() + tab.add_id(int(plug_id)) + self.uzbl.set_tab(tab) + def title_changed(self, title): self.uzbl.title = title.strip() self.uzbl.title_changed(False) @@ -477,10 +488,10 @@ class EventDispatcher: class UzblInstance: '''Uzbl instance meta-data/meta-action object.''' - def __init__(self, parent, tab, name, uri, title, switch): + def __init__(self, parent, name, uri, title, switch): self.parent = parent - self.tab = tab + self.tab = None self.dispatcher = EventDispatcher(self) self.name = name @@ -490,8 +501,11 @@ class UzblInstance: self._client = None self._switch = switch # Switch to tab after loading ? - self.title_changed() + def set_tab(self, tab): + self.tab = tab + self.title_changed() + self.parent.tabs[self.tab] = self def got_socket(self, client): '''Uzbl instance is now connected''' @@ -763,7 +777,7 @@ class UzblTabbed: '''A new uzbl instance was created''' client, _ = sock.accept() - self.clients[client] = SocketClient(client) + self.clients[client] = SocketClient(client, self) return True @@ -1045,6 +1059,12 @@ class UzblTabbed: return False + def create_tab(self, next = False): + tab = gtk.Socket() + tab.show() + self.notebook.insert_page(tab, position=next and self.notebook.get_current_page() + 1 or -1) + self.notebook.set_tab_reorderable(tab, True) + return tab def new_tab(self, uri='', title='', switch=None, next=False): '''Add a new tab to the notebook and start a new instance of uzbl. @@ -1052,10 +1072,7 @@ class UzblTabbed: when you need to load multiple tabs at a time (I.e. like when restoring a session from a file).''' - tab = gtk.Socket() - tab.show() - self.notebook.insert_page(tab, position=next and self.notebook.get_current_page() + 1 or -1) - self.notebook.set_tab_reorderable(tab, True) + tab = self.create_tab(next) sid = tab.get_id() uri = uri.strip() name = "%d-%d" % (os.getpid(), self.next_pid()) @@ -1070,9 +1087,9 @@ class UzblTabbed: '--connect-socket', self.socket_path, '--uri', str(uri)] gobject.spawn_async(cmd, flags=gobject.SPAWN_SEARCH_PATH) - uzbl = UzblInstance(self, tab, name, uri, title, switch) + uzbl = UzblInstance(self, name, uri, title, switch) + uzbl.set_tab(tab) SocketClient.instances_queue[name] = uzbl - self.tabs[tab] = uzbl def clean_slate(self): diff --git a/src/uzbl-core.c b/src/uzbl-core.c index c095a7f..e461a4c 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -51,8 +51,11 @@ GOptionEntry entries[] = { "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" }, + /* TODO: explain the difference between these two options */ { "socket", 's', 0, G_OPTION_ARG_INT, &uzbl.state.socket_id, - "Xembed Socket ID", "SOCKET" }, + "Xembed socket ID, this window should embed itself", "SOCKET" }, + { "embed", 'e', 0, G_OPTION_ARG_NONE, &uzbl.state.embed, + "Whether this window should expect to be embedded", NULL }, { "connect-socket", 0, 0, G_OPTION_ARG_STRING_ARRAY, &uzbl.state.connect_socket_names, "Connect to server socket for event managing", "CSOCKET" }, { "print-events", 'p', 0, G_OPTION_ARG_NONE, &uzbl.state.events_stdout, @@ -1540,6 +1543,7 @@ create_window() { GtkPlug* create_plug() { + if(uzbl.state.embed) uzbl.state.socket_id = 0; GtkPlug* plug = GTK_PLUG (gtk_plug_new (uzbl.state.socket_id)); g_signal_connect (G_OBJECT (plug), "destroy", G_CALLBACK (destroy_cb), NULL); g_signal_connect (G_OBJECT (plug), "key-press-event", G_CALLBACK (key_press_cb), NULL); @@ -1746,7 +1750,7 @@ initialize(int argc, char** argv) { } /* Embedded mode */ - if (uzbl.state.socket_id) + if (uzbl.state.socket_id || uzbl.state.embed) uzbl.state.plug_mode = TRUE; if (!g_thread_supported()) diff --git a/src/uzbl-core.h b/src/uzbl-core.h index be8fccd..07b6f99 100644 --- a/src/uzbl-core.h +++ b/src/uzbl-core.h @@ -109,6 +109,7 @@ typedef struct { gchar* executable_path; gchar* searchtx; gboolean verbose; + gboolean embed; GdkEventButton* last_button; gchar* last_result; gboolean plug_mode; -- cgit v1.2.3