removed unneeded event listeners and reworked file opener.

This commit is contained in:
Enno Boland (Gottox) 2009-06-05 18:00:45 +02:00
parent da509312df
commit bc5d280efe
1 changed files with 13 additions and 20 deletions

21
surf.c
View File

@ -87,13 +87,12 @@ loadfile(gchar *f) {
GIOChannel *c = NULL; GIOChannel *c = NULL;
GError *e = NULL; GError *e = NULL;
GString *code = g_string_new(""); GString *code = g_string_new("");
GString *uri = g_string_new(f);
gchar *line; gchar *line;
/* cannot use fileno in c99 - workaround*/ /* cannot use fileno in c99 - workaround*/
if(strcmp(f, "-") == 0) if(strcmp(f, "-") == 0) {
c = g_io_channel_unix_new(STDIN_FILENO); c = g_io_channel_unix_new(STDIN_FILENO);
else
c = g_io_channel_new_file(f, "r", NULL);
if (c) { if (c) {
while(g_io_channel_read_line(c, &line, NULL, NULL, &e) == G_IO_STATUS_NORMAL) { while(g_io_channel_read_line(c, &line, NULL, NULL, &e) == G_IO_STATUS_NORMAL) {
g_string_append(code, line); g_string_append(code, line);
@ -102,6 +101,11 @@ loadfile(gchar *f) {
webkit_web_view_load_html_string(view, code->str, NULL); webkit_web_view_load_html_string(view, code->str, NULL);
g_io_channel_shutdown(c, FALSE, NULL); g_io_channel_shutdown(c, FALSE, NULL);
} }
}
else {
g_string_prepend(uri, "file://");
loaduri(uri->str);
}
} }
@ -131,10 +135,6 @@ linkhover(WebKitWebView* page, const gchar* t, const gchar* l, gpointer d) {
/* TODO */ /* TODO */
} }
void
loadstart(WebKitWebView *view, WebKitWebFrame *f, gpointer d) {
}
void void
loadcommit(WebKitWebView *view, WebKitWebFrame *f, gpointer d) { loadcommit(WebKitWebView *view, WebKitWebFrame *f, gpointer d) {
gchar *uri; gchar *uri;
@ -147,11 +147,6 @@ loadcommit(WebKitWebView *view, WebKitWebFrame *f, gpointer d) {
strlen(uri) + 1); strlen(uri) + 1);
} }
void
loadfinish(WebKitWebView *view, WebKitWebFrame *f, gpointer d) {
/* ??? TODO */
}
void void
progresschange(WebKitWebView* view, gint p, gpointer d) { progresschange(WebKitWebView* view, gint p, gpointer d) {
progress = p; progress = p;
@ -208,8 +203,6 @@ void setup(void) {
g_signal_connect(G_OBJECT(view), "title-changed", G_CALLBACK(titlechange), view); g_signal_connect(G_OBJECT(view), "title-changed", G_CALLBACK(titlechange), view);
g_signal_connect(G_OBJECT(view), "load-progress-changed", G_CALLBACK(progresschange), view); g_signal_connect(G_OBJECT(view), "load-progress-changed", G_CALLBACK(progresschange), view);
g_signal_connect(G_OBJECT(view), "load-committed", G_CALLBACK(loadcommit), view); g_signal_connect(G_OBJECT(view), "load-committed", G_CALLBACK(loadcommit), view);
g_signal_connect(G_OBJECT(view), "load-started", G_CALLBACK(loadstart), view);
g_signal_connect(G_OBJECT(view), "load-finished", G_CALLBACK(loadfinish), view);
g_signal_connect(G_OBJECT(view), "hovering-over-link", G_CALLBACK(linkhover), view); g_signal_connect(G_OBJECT(view), "hovering-over-link", G_CALLBACK(linkhover), view);
g_signal_connect(G_OBJECT(view), "new-window-policy-decision-requested", G_CALLBACK(newwindow), view); g_signal_connect(G_OBJECT(view), "new-window-policy-decision-requested", G_CALLBACK(newwindow), view);
g_signal_connect(G_OBJECT(view), "download-requested", G_CALLBACK(download), view); g_signal_connect(G_OBJECT(view), "download-requested", G_CALLBACK(download), view);