# HG changeset patch # User Elliott Sales de Andrade # Date 1338444599 0 # Node ID b31f7945d9b6f768779b85f704fdbd7b54ac7f8e # Parent 43e89b279eb420175f8e8c1e0561c848f02f9e86 Use 'div's for indent which allows WebKit to do better word-wrapping. diff -r 43e89b279eb4 -r b31f7945d9b6 pidgin/plugins/xmppconsole.c --- a/pidgin/plugins/xmppconsole.c Thu May 31 05:45:28 2012 +0000 +++ b/pidgin/plugins/xmppconsole.c Thu May 31 06:09:59 2012 +0000 @@ -46,7 +46,8 @@ #define EMPTY_HTML \ "" static char * -xmlnode_to_pretty_str(xmlnode *node, int *len, int depth) +xmlnode_to_pretty_str(xmlnode *node, int *len) { GString *text = g_string_new(""); xmlnode *c; - char *node_name, *esc, *esc2, *tab = NULL; + char *node_name, *esc, *esc2; gboolean need_end = FALSE, pretty = TRUE; g_return_val_if_fail(node != NULL, NULL); - if (pretty && depth) { - tab = g_strnfill(depth, '\t'); - text = g_string_append(text, tab); - } - node_name = g_markup_escape_text(node->name, -1); g_string_append_printf(text, "<" @@ -115,11 +111,16 @@ ">%s", pretty ? "
" : ""); + need_end = FALSE; for (c = node->child; c; c = c->next) { if (c->type == XMLNODE_TYPE_TAG) { int esc_len; - esc = xmlnode_to_pretty_str(c, &esc_len, depth+1); + esc = xmlnode_to_pretty_str(c, &esc_len); + if (!need_end) { + g_string_append(text, "
"); + need_end = TRUE; + } text = g_string_append_len(text, esc, esc_len); g_free(esc); } else if (c->type == XMLNODE_TYPE_DATA && c->data_sz > 0) { @@ -129,8 +130,9 @@ } } - if(tab && pretty) - text = g_string_append(text, tab); + if (need_end) + g_string_append(text, "
"); + g_string_append_printf(text, "</" "%s" @@ -143,8 +145,6 @@ g_free(node_name); - g_free(tab); - if (len) *len = text->len; @@ -158,7 +158,7 @@ if (!console || console->gc != gc) return; - str = xmlnode_to_pretty_str(*packet, NULL, 0); + str = xmlnode_to_pretty_str(*packet, NULL); formatted = g_strdup_printf("
%s
", str); gtk_webview_append_html(GTK_WEBVIEW(console->webview), formatted); g_free(formatted); @@ -179,7 +179,7 @@ if (!node) return; - str = xmlnode_to_pretty_str(node, NULL, 0); + str = xmlnode_to_pretty_str(node, NULL); formatted = g_strdup_printf("
%s
", str); gtk_webview_append_html(GTK_WEBVIEW(console->webview), formatted); g_free(formatted); @@ -750,8 +750,6 @@ static void dropdown_changed_cb(GtkComboBox *widget, gpointer nul) { - PurpleAccount *account; - if (!console) return;