diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/callbacks.c | 2 | ||||
-rw-r--r-- | src/events.c | 13 | ||||
-rwxr-xr-x | src/uzbl-browser | 2 | ||||
-rw-r--r-- | src/uzbl-core.c | 59 | ||||
-rw-r--r-- | src/uzbl-core.h | 3 |
5 files changed, 22 insertions, 57 deletions
diff --git a/src/callbacks.c b/src/callbacks.c index 803428d..bcbac00 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -411,6 +411,7 @@ title_change_cb (WebKitWebView* web_view, GParamSpec param_spec) { uzbl.gui.main_title = title ? g_strdup (title) : g_strdup ("(no title)"); update_title(); send_event(TITLE_CHANGED, uzbl.gui.main_title, NULL); + g_setenv("UZBL_TITLE", uzbl.gui.main_title, TRUE); } void @@ -436,6 +437,7 @@ load_status_change_cb (WebKitWebView* web_view, GParamSpec param_spec) { g_free (uzbl.state.uri); GString* newuri = g_string_new (webkit_web_frame_get_uri (frame)); uzbl.state.uri = g_string_free (newuri, FALSE); + g_setenv("UZBL_URI", uzbl.state.uri, TRUE); send_event(LOAD_COMMIT, webkit_web_frame_get_uri (frame), NULL); break; diff --git a/src/events.c b/src/events.c index 55775a8..b02cb89 100644 --- a/src/events.c +++ b/src/events.c @@ -137,24 +137,16 @@ send_event_stdout(GString *msg) { void send_event(int type, const gchar *details, const gchar *custom_event) { GString *event_message = g_string_new(""); - gchar *buf, *p_val = NULL; - - /* expand shell vars */ - if(details) { - buf = g_strdup(details); - p_val = parseenv(buf ? g_strchug(buf) : " "); - g_free(buf); - } /* check for custom events */ if(custom_event) { g_string_printf(event_message, "EVENT [%s] %s %s\n", - uzbl.state.instance_name, custom_event, p_val); + uzbl.state.instance_name, custom_event, details); } /* check wether we support the internal event */ else if(type < LAST_EVENT) { g_string_printf(event_message, "EVENT [%s] %s %s\n", - uzbl.state.instance_name, event_table[type], p_val); + uzbl.state.instance_name, event_table[type], details); } if(event_message->str) { @@ -164,7 +156,6 @@ send_event(int type, const gchar *details, const gchar *custom_event) { g_string_free(event_message, TRUE); } - g_free(p_val); } /* Transform gdk key events to our own events */ diff --git a/src/uzbl-browser b/src/uzbl-browser index 88d3742..3c9562d 100755 --- a/src/uzbl-browser +++ b/src/uzbl-browser @@ -8,6 +8,8 @@ # 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} diff --git a/src/uzbl-core.c b/src/uzbl-core.c index c960936..1110b02 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -415,36 +415,6 @@ find_existing_file(gchar* path_list) { return NULL; } - -/* Returns a new string with environment $variables expanded */ -gchar* -parseenv (gchar* string) { - extern char** environ; - gchar* tmpstr = NULL, * out; - int i = 0; - - if(!string) - return NULL; - - out = g_strdup(string); - while (environ[i] != NULL) { - gchar** env = g_strsplit (environ[i], "=", 2); - gchar* envname = g_strconcat ("$", env[0], NULL); - - if (g_strrstr (string, envname) != NULL) { - tmpstr = out; - out = str_replace(envname, env[1], out); - g_free (tmpstr); - } - - g_free (envname); - g_strfreev (env); // somebody said this breaks uzbl - i++; - } - - return out; -} - void clean_up(void) { if(uzbl.info.pid_str) { @@ -696,9 +666,8 @@ set_var(WebKitWebView *page, GArray *argv, GString *result) { gchar **split = g_strsplit(argv_idx(argv, 0), "=", 2); if (split[0] != NULL) { - gchar *value = parseenv(split[1] ? g_strchug(split[1]) : " "); + gchar *value = split[1] ? g_strchug(split[1]) : " "; set_var_value(g_strstrip(split[0]), value); - g_free(value); } g_strfreev(split); } @@ -928,14 +897,12 @@ void include(WebKitWebView *page, GArray *argv, GString *result) { (void) page; (void) result; - gchar *pe = NULL, - *path = NULL; + gchar *path = argv_idx(argv, 0); - if(!argv_idx(argv, 0)) + if(!path) return; - pe = parseenv(argv_idx(argv, 0)); - if((path = find_existing_file(pe))) { + if((path = find_existing_file(path))) { if(!for_each_line_in_file(path, parse_cmd_line_cb, NULL)) { gchar *tmp = g_strdup_printf("File %s can not be read.", path); send_event(COMMAND_ERROR, tmp, NULL); @@ -945,7 +912,6 @@ include(WebKitWebView *page, GArray *argv, GString *result) { send_event(FILE_INCLUDED, path, NULL); g_free(path); } - g_free(pe); } void @@ -1614,8 +1580,9 @@ init_fifo(gchar *dir) { /* return dir or, on error, free dir and return NULL */ if (g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_fifo, NULL)) { if (uzbl.state.verbose) printf ("init_fifo: created successfully as %s\n", path); - send_event(FIFO_SET, path, NULL); + send_event(FIFO_SET, path, NULL); uzbl.comm.fifo_path = path; + g_setenv("UZBL_FIFO", uzbl.comm.fifo_path, TRUE); return dir; } else g_warning ("init_fifo: could not add watch on %s\n", path); } else g_warning ("init_fifo: can't open: %s\n", error->message); @@ -1809,6 +1776,7 @@ init_socket(gchar *dir) { /* return dir or, on error, free dir and return NULL * g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_socket, chan); uzbl.comm.socket_path = path; send_event(SOCKET_SET, path, NULL); + g_setenv("UZBL_SOCKET", uzbl.comm.socket_path, TRUE); return dir; } } else g_warning ("init_socket: could not open in %s: %s\n", path, strerror(errno)); @@ -2076,6 +2044,7 @@ settings_init () { send_event(COMMAND_ERROR, tmp, NULL); g_free(tmp); } + g_setenv("UZBL_CONFIG", s->config_file, TRUE); } else if (uzbl.state.verbose) printf ("No configuration file loaded.\n"); @@ -2358,12 +2327,16 @@ main (int argc, char* argv[]) { "signal::changed", (GCallback)scroll_horiz_cb, NULL, NULL); + gchar *xwin = g_strdup_printf("%d", (int)uzbl.xwin); + g_setenv("UZBL_XID", xwin, TRUE); + if(!uzbl.state.instance_name) - uzbl.state.instance_name = itos((int)uzbl.xwin); + uzbl.state.instance_name = g_strdup(xwin); - GString *tmp = g_string_new(""); - g_string_printf(tmp, "%d", getpid()); - uzbl.info.pid_str = g_string_free(tmp, FALSE); + g_free(xwin); + + uzbl.info.pid_str = g_strdup_printf("%d", getpid()); + g_setenv("UZBL_PID", uzbl.info.pid_str, TRUE); send_event(INSTANCE_START, uzbl.info.pid_str, NULL); if(uzbl.state.plug_mode) { diff --git a/src/uzbl-core.h b/src/uzbl-core.h index a62c3a6..b521f93 100644 --- a/src/uzbl-core.h +++ b/src/uzbl-core.h @@ -229,9 +229,6 @@ itos(int val); gchar* strfree(gchar *str); -gchar* -parseenv (gchar* string); - void clean_up(void); |