diff options
author | Ben Murdoch <benm@google.com> | 2010-06-15 19:36:43 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-06-16 14:52:28 +0100 |
commit | 545e470e52f0ac6a3a072bf559c796b42c6066b6 (patch) | |
tree | c0c14763654d84d37577dde512c3d3b4699a9e86 /WebKitTools/GtkLauncher | |
parent | 719298a66237d38ea5c05f1547123ad8aacbc237 (diff) | |
download | external_webkit-545e470e52f0ac6a3a072bf559c796b42c6066b6.zip external_webkit-545e470e52f0ac6a3a072bf559c796b42c6066b6.tar.gz external_webkit-545e470e52f0ac6a3a072bf559c796b42c6066b6.tar.bz2 |
Merge webkit.org at r61121: Initial merge by git.
Change-Id: Icd6db395c62285be384d137164d95d7466c98760
Diffstat (limited to 'WebKitTools/GtkLauncher')
-rw-r--r-- | WebKitTools/GtkLauncher/main.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/WebKitTools/GtkLauncher/main.c b/WebKitTools/GtkLauncher/main.c index 2f9350d..e6d69a9 100644 --- a/WebKitTools/GtkLauncher/main.c +++ b/WebKitTools/GtkLauncher/main.c @@ -25,6 +25,7 @@ */ #include <gtk/gtk.h> +#include <stdlib.h> #include <webkit/webkit.h> static GtkWidget* main_window; @@ -186,6 +187,21 @@ create_window () return window; } +static gchar* filenameToURL(const char* filename) +{ + if (!g_file_test(filename, G_FILE_TEST_EXISTS)) + return 0; + + gchar *fullPath = realpath(filename, 0); + if (!fullPath) + return 0; + + gchar *fileURL = g_filename_to_uri(fullPath, 0, 0); + free(fullPath); + + return fileURL; +} + int main (int argc, char* argv[]) { @@ -201,8 +217,11 @@ main (int argc, char* argv[]) main_window = create_window (); gtk_container_add (GTK_CONTAINER (main_window), vbox); - gchar* uri = (gchar*) (argc > 1 ? argv[1] : "http://www.google.com/"); - webkit_web_view_load_uri (web_view, uri); + gchar *uri = (gchar*) (argc > 1 ? argv[1] : "http://www.google.com/"); + gchar *fileURL = filenameToURL(uri); + + webkit_web_view_load_uri(web_view, fileURL ? fileURL : uri); + g_free(fileURL); gtk_widget_grab_focus (GTK_WIDGET (web_view)); gtk_widget_show_all (main_window); |