From 948908bb0c26f9211d744203ed89c0469f0039c8 Mon Sep 17 00:00:00 2001 From: keis Date: Sun, 18 Oct 2009 22:13:15 +0200 Subject: parseenv always returns a new string. --- uzbl-core.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'uzbl-core.h') diff --git a/uzbl-core.h b/uzbl-core.h index a7a8126..c261074 100644 --- a/uzbl-core.h +++ b/uzbl-core.h @@ -231,7 +231,7 @@ GArray* read_file_by_line (const gchar *path); gchar* -parseenv (char* string); +parseenv (gchar* string); void clean_up(void); @@ -242,9 +242,6 @@ catch_sigterm(int s); sigfunc * setup_signal(int signe, sigfunc *shandler); -gchar* -parseenv (char* string); - gboolean set_var_value(const gchar *name, gchar *val); -- cgit v1.2.3 From 1efb501becab71721c2c4d9d48b63fc8127575c1 Mon Sep 17 00:00:00 2001 From: keis Date: Sun, 18 Oct 2009 22:18:03 +0200 Subject: Add general load_uri function. Wrap special cases around this. --- callbacks.c | 5 +---- uzbl-core.c | 69 ++++++++++++++++++++++++++++++++----------------------------- uzbl-core.h | 3 +++ 3 files changed, 40 insertions(+), 37 deletions(-) (limited to 'uzbl-core.h') diff --git a/callbacks.c b/callbacks.c index d65d09a..9b1131b 100644 --- a/callbacks.c +++ b/callbacks.c @@ -62,10 +62,7 @@ cmd_set_status() { void cmd_load_uri() { - GArray *a = g_array_new (TRUE, FALSE, sizeof(gchar*)); - g_array_append_val (a, uzbl.state.uri); - load_uri(uzbl.gui.web_view, a, NULL); - g_array_free (a, TRUE); + load_uri_imp (uzbl.state.uri); } void diff --git a/uzbl-core.c b/uzbl-core.c index 29f9af3..5a7cd0a 100644 --- a/uzbl-core.c +++ b/uzbl-core.c @@ -720,37 +720,8 @@ act_dump_config_as_events() { void load_uri (WebKitWebView *web_view, GArray *argv, GString *result) { - (void) result; - - if (argv_idx(argv, 0)) { - GString* newuri = g_string_new (argv_idx(argv, 0)); - if (g_strstr_len (argv_idx(argv, 0), 11, "javascript:") != NULL) { - run_js(web_view, argv, NULL); - return; - } - if (!soup_uri_new(argv_idx(argv, 0))) { - GString* fullpath = g_string_new (""); - if (g_path_is_absolute (newuri->str)) - g_string_assign (fullpath, newuri->str); - else { - gchar* wd; - wd = g_get_current_dir (); - g_string_assign (fullpath, g_build_filename (wd, newuri->str, NULL)); - g_free(wd); - } - struct stat stat_result; - if (! g_stat(fullpath->str, &stat_result)) { - g_string_prepend (fullpath, "file://"); - g_string_assign (newuri, fullpath->str); - } - else - g_string_prepend (newuri, "http://"); - g_string_free (fullpath, TRUE); - } - /* if we do handle cookies, ask our handler for them */ - webkit_web_view_load_uri (web_view, newuri->str); - g_string_free (newuri, TRUE); - } + (void) web_view; (void) result; + load_uri_imp (argv_idx (argv, 0)); } /* Javascript*/ @@ -2089,6 +2060,39 @@ initialize(int argc, char *argv[]) { create_browser(); } +void +load_uri_imp(gchar *uri) { + GString* newuri; + if (g_strstr_len (uri, 11, "javascript:") != NULL) { + eval_js(uzbl.gui.web_view, uri, NULL); + return; + } + newuri = g_string_new (uri); + if (!soup_uri_new(uri)) { + GString* fullpath = g_string_new (""); + if (g_path_is_absolute (newuri->str)) + g_string_assign (fullpath, newuri->str); + else { + gchar* wd; + wd = g_get_current_dir (); + g_string_assign (fullpath, g_build_filename (wd, newuri->str, NULL)); + free(wd); + } + struct stat stat_result; + if (! g_stat(fullpath->str, &stat_result)) { + g_string_prepend (fullpath, "file://"); + g_string_assign (newuri, fullpath->str); + } + else + g_string_prepend (newuri, "http://"); + g_string_free (fullpath, TRUE); + } + /* if we do handle cookies, ask our handler for them */ + webkit_web_view_load_uri (uzbl.gui.web_view, newuri->str); + g_string_free (newuri, TRUE); +} + + #ifndef UZBL_LIBRARY /** -- MAIN -- **/ int @@ -2178,8 +2182,7 @@ main (int argc, char* argv[]) { if (uri_override) { set_var_value("uri", uri_override); g_free(uri_override); - } else if (uzbl.state.uri) - cmd_load_uri(); + } gtk_main (); clean_up(); diff --git a/uzbl-core.h b/uzbl-core.h index c261074..51cf4e1 100644 --- a/uzbl-core.h +++ b/uzbl-core.h @@ -245,6 +245,9 @@ setup_signal(int signe, sigfunc *shandler); gboolean set_var_value(const gchar *name, gchar *val); +void +load_uri_imp(gchar *uri); + void print(WebKitWebView *page, GArray *argv, GString *result); -- cgit v1.2.3 From ac94640f72277e23cf82183227dcef8bce196f49 Mon Sep 17 00:00:00 2001 From: keis Date: Sun, 18 Oct 2009 22:22:43 +0200 Subject: Remove unused actions code. --- uzbl-core.c | 22 ---------------------- uzbl-core.h | 11 ----------- 2 files changed, 33 deletions(-) (limited to 'uzbl-core.h') diff --git a/uzbl-core.c b/uzbl-core.c index 5a7cd0a..606dc5a 100644 --- a/uzbl-core.c +++ b/uzbl-core.c @@ -635,28 +635,6 @@ commands_hash(void) /* -- CORE FUNCTIONS -- */ -void -free_action(gpointer act) { - Action *action = (Action*)act; - g_free(action->name); - if (action->param) - g_free(action->param); - g_free(action); -} - -Action* -new_action(const gchar *name, const gchar *param) { - Action *action = g_new(Action, 1); - - action->name = g_strdup(name); - if (param) - action->param = g_strdup(param); - else - action->param = NULL; - - return action; -} - bool file_exists (const char * filename) { return (access(filename, F_OK) == 0); diff --git a/uzbl-core.h b/uzbl-core.h index 51cf4e1..1c1a287 100644 --- a/uzbl-core.h +++ b/uzbl-core.h @@ -205,11 +205,6 @@ extern UzblCore uzbl; typedef void sigfunc(int); -typedef struct { - char* name; - char* param; -} Action; - /* XDG Stuff */ typedef struct { gchar* environmental; @@ -254,12 +249,6 @@ print(WebKitWebView *page, GArray *argv, GString *result); void commands_hash(void); -void -free_action(gpointer act); - -Action* -new_action(const gchar *name, const gchar *param); - bool file_exists (const char * filename); -- cgit v1.2.3