aboutsummaryrefslogtreecommitdiffhomepage
path: root/uzbl.c
diff options
context:
space:
mode:
authorGravatar Dieter Plaetinck <dieter@plaetinck.be>2009-04-27 23:36:20 +0200
committerGravatar Dieter Plaetinck <dieter@plaetinck.be>2009-04-27 23:36:20 +0200
commitb6b60c7b63baa5e900fcfa88bfbc8f2504d1b80e (patch)
tree48ad0f8124ed134e6223e3ac1b07ec04cd79ebb6 /uzbl.c
parent89e242634be901f0f0ff17d535483da0d4a0cc67 (diff)
fix for http:// adding automatically. segfaults
Diffstat (limited to 'uzbl.c')
-rw-r--r--uzbl.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/uzbl.c b/uzbl.c
index 895d880..e98d10e 100644
--- a/uzbl.c
+++ b/uzbl.c
@@ -107,6 +107,9 @@ char *XDG_CONFIG_DIRS_default = "/etc/xdg";
static void
update_title (GtkWindow* window);
+static void
+load_uri ( WebKitWebView * web_view, gchar * uri);
+
static gboolean
run_command(const char *command, const char *args);
@@ -207,13 +210,25 @@ static Command commands[] =
{ "stop", &webkit_web_view_stop_loading, NULL },
{ "zoom_in", &webkit_web_view_zoom_in, NULL }, //Can crash (when max zoom reached?).
{ "zoom_out", &webkit_web_view_zoom_out, NULL },
- { "uri", NULL, &webkit_web_view_load_uri },
+ { "uri", NULL, &load_uri },
{ "toggle_status", &toggle_status_cb, NULL }
//{ "get uri", &webkit_web_view_get_uri},
};
/* -- CORE FUNCTIONS -- */
+static gchar*
+uricheck (gchar* uri) {
+ if (g_strrstr (uri,"://") == NULL){
+ GString* newuri = g_string_new (uri);
+ free(uri);
+ g_string_prepend (newuri, "http://");
+ uri = g_string_free (newuri, FALSE);
+ }
+ return (uri);
+}
+
+
static bool
file_exists (const char * filename)
{
@@ -225,6 +240,12 @@ file_exists (const char * filename)
return false;
}
+static void
+load_uri ( WebKitWebView * web_view, gchar * uri) {
+ webkit_web_view_load_uri (web_view, uricheck(uri));
+}
+
+
// make sure to put '' around args, so that if there is whitespace we can still keep arguments together.
static gboolean
run_command(const char *command, const char *args) {
@@ -605,7 +626,7 @@ main (int argc, char* argv[]) {
main_window = create_window ();
gtk_container_add (GTK_CONTAINER (main_window), vbox);
- webkit_web_view_load_uri (web_view, uri);
+ load_uri (web_view, uri);
gtk_widget_grab_focus (GTK_WIDGET (web_view));
gtk_widget_show_all (main_window);