/pidgin/main: f63b51e608fe: Fix debug filtering on appended items.

Elliott Sales de Andrade qulogic at pidgin.im
Tue Aug 14 04:03:25 EDT 2012


Changeset: f63b51e608fe26934d1202b435c72bfa3728c144
Author:	 Elliott Sales de Andrade <qulogic at pidgin.im>
Date:	 2012-08-11 03:05 -0400
Branch:	 default
URL: http://hg.pidgin.im/pidgin/main/rev/f63b51e608fe

Description:

Fix debug filtering on appended items.

diffstat:

 pidgin/gtkdebug.c |  51 ++++++++++++++++++++++++++-------------------------
 1 files changed, 26 insertions(+), 25 deletions(-)

diffs (75 lines):

diff --git a/pidgin/gtkdebug.c b/pidgin/gtkdebug.c
--- a/pidgin/gtkdebug.c
+++ b/pidgin/gtkdebug.c
@@ -623,6 +623,28 @@ toolbar_context(GtkWidget *toolbar, GdkE
 	return FALSE;
 }
 
+static void
+regex_html_appended_cb(GtkWebView *webview, WebKitDOMRange *range, DebugWindow *win)
+{
+	if (!win || !win->window)
+		return;
+
+	if (gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(win->filter))) {
+		WebKitDOMDocument *dom;
+		WebKitDOMHTMLElement *body;
+		WebKitDOMNode *div;
+
+		dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(win->text));
+		body = webkit_dom_document_get_body(dom);
+		div = webkit_dom_node_get_last_child(WEBKIT_DOM_NODE(body));
+
+		if (webkit_dom_element_webkit_matches_selector(WEBKIT_DOM_ELEMENT(div),
+		                                               "body>div:not(#pause)",
+		                                               NULL))
+			regex_match(win, dom, div);
+	}
+}
+
 static DebugWindow *
 debug_window_new(void)
 {
@@ -793,6 +815,9 @@ debug_window_new(void)
 	gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
 	gtk_widget_show(frame);
 
+	g_signal_connect(G_OBJECT(win->text), "html-appended",
+	                 G_CALLBACK(regex_html_appended_cb), win);
+
 	clear_cb(NULL, win);
 
 	gtk_widget_show_all(win->window);
@@ -990,31 +1015,7 @@ pidgin_debug_print(PurpleDebugLevel leve
 	g_free(esc_s);
 	g_free(tmp);
 
-	//XXX: gtk_webview_append_html does delayed insert of new div, which is
-	//     needed by filtering below
-	//gtk_webview_append_html(GTK_WEBVIEW(debug_win->text), s);
-	{
-		WebKitDOMDocument *dom = NULL;
-		WebKitDOMHTMLElement *body = NULL;
-		dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(debug_win->text));
-		if (dom)
-			body = webkit_dom_document_get_body(dom);
-		if (body)
-			webkit_dom_html_element_insert_adjacent_html(body, "beforeend", s, NULL);
-	}
-
-	if (gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(debug_win->filter))) {
-		WebKitDOMDocument *dom = NULL;
-		WebKitDOMHTMLElement *body = NULL;
-		WebKitDOMNode *div = NULL;
-		dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(debug_win->text));
-		if (dom)
-			body = webkit_dom_document_get_body(dom);
-		if (body)
-			div = webkit_dom_node_get_last_child(WEBKIT_DOM_NODE(body));
-		if (div)
-			regex_match(debug_win, dom, div);
-	}
+	gtk_webview_append_html(GTK_WEBVIEW(debug_win->text), s);
 
 	g_free(s);
 }



More information about the Commits mailing list