about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMarco Peereboom <marco@conformal.com>2011-02-25 14:25:23 +0000
committerMarco Peereboom <marco@conformal.com>2011-02-25 14:25:23 +0000
commite9c3f6c86fb4ca17787efc973e61d58c19456379 (patch)
treed7bed59dff92c1e7dc5e7d957fc572308d39a9f8
parent88b500d174f7a7bb3276441a9c02b8345e608883 (diff)
downloadxombrero-e9c3f6c86fb4ca17787efc973e61d58c19456379.tar.gz
i have noticed that pages containing framesets have no title, no label and
are not added to the history.
example: http://www.htmlcodetutorial.com/frames/frameset.html

framesets never have a WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT
load-status, as only the frames themselfs (not the frameset) are visible.

From: Raphael Graf <r@undefined.ch>
-rw-r--r--xxxterm.c65
1 files changed, 30 insertions, 35 deletions
diff --git a/xxxterm.c b/xxxterm.c
index b6d403b..0befe97 100644
--- a/xxxterm.c
+++ b/xxxterm.c
@@ -5701,7 +5701,6 @@ notify_load_status_cb(WebKitWebView* wview, GParamSpec* pspec, struct tab *t)
 {
 	const gchar		*set = NULL, *uri = NULL, *title = NULL;
 	struct history		*h, find;
-	int			add = 0;
 	const gchar		*s_loading;
 	struct karg		a;
 
@@ -5759,46 +5758,29 @@ notify_load_status_cb(WebKitWebView* wview, GParamSpec* pspec, struct tab *t)
 
 	case WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT:
 		/* 3 */
-		title = webkit_web_view_get_title(wview);
-		uri = get_uri(wview);
-		if (title)
-			set = title;
-		else if (uri)
-			set = uri;
-		else
-			break;
+		break;
 
-		gtk_label_set_text(GTK_LABEL(t->label), set);
-		gtk_window_set_title(GTK_WINDOW(main_window), set);
+	case WEBKIT_LOAD_FINISHED:
+		/* 2 */
+		uri = get_uri(wview);
 
-		if (uri) {
-			if (!strncmp(uri, "http://", strlen("http://")) ||
-			    !strncmp(uri, "https://", strlen("https://")) ||
-			    !strncmp(uri, "file://", strlen("file://")))
-				add = 1;
-			if (add == 0)
-				break;
+		if (!strncmp(uri, "http://", strlen("http://")) ||
+		    !strncmp(uri, "https://", strlen("https://")) ||
+		    !strncmp(uri, "file://", strlen("file://"))) {
 			find.uri = uri;
 			h = RB_FIND(history_list, &hl, &find);
-			if (h)
-				break;
-
-			h = g_malloc(sizeof *h);
-			h->uri = g_strdup(uri);
-			if (title)
-				h->title = g_strdup(title);
-			else
-				h->title = g_strdup(uri);
-			RB_INSERT(history_list, &hl, h);
-			completion_add_uri(h->uri);
-			update_history_tabs(NULL);
+			if (!h) {
+				title = webkit_web_view_get_title(wview);
+				set = title ? title: uri;
+				h = g_malloc(sizeof *h);
+				h->uri = g_strdup(uri);
+				h->title = g_strdup(set);
+				RB_INSERT(history_list, &hl, h);
+				completion_add_uri(h->uri);
+				update_history_tabs(NULL);
+			}
 		}
 
-		break;
-
-	case WEBKIT_LOAD_FINISHED:
-		/* 2 */
-		uri = get_uri(wview);
 		set_status(t, (char *)uri, XT_STATUS_URI);
 #if WEBKIT_CHECK_VERSION(1, 1, 18)
 	case WEBKIT_LOAD_FAILED:
@@ -5830,6 +5812,17 @@ notify_load_status_cb(WebKitWebView* wview, GParamSpec* pspec, struct tab *t)
 }
 
 void
+notify_title_cb(WebKitWebView* wview, GParamSpec* pspec, struct tab *t)
+{
+	const gchar		*set = NULL, *title = NULL;
+
+	title = webkit_web_view_get_title(wview);
+	set = title ? title: get_uri(wview);
+	gtk_label_set_text(GTK_LABEL(t->label), set);
+	gtk_window_set_title(GTK_WINDOW(main_window), set);
+}
+
+void
 webview_load_finished_cb(WebKitWebView *wv, WebKitWebFrame *wf, struct tab *t)
 {
 	run_script(t, JS_HINTING);
@@ -6979,6 +6972,8 @@ create_new_tab(char *title, struct undo *u, int focus)
 	    (char *)NULL);
 	g_signal_connect(t->wv,
 	    "notify::load-status", G_CALLBACK(notify_load_status_cb), t);
+	g_signal_connect(t->wv,
+	    "notify::title", G_CALLBACK(notify_title_cb), t);
 
 	/* hijack the unused keys as if we were the browser */
 	g_object_connect(G_OBJECT(t->toolbar),