/pidgin/main: 61f997b47954: Split debug window HTML into a separ...
Elliott Sales de Andrade
qulogic at pidgin.im
Thu May 9 02:56:35 EDT 2013
Changeset: 61f997b479543abf5ada5c8ae8a9138d2e507311
Author: Elliott Sales de Andrade <qulogic at pidgin.im>
Date: 2013-05-06 17:09 -0400
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/61f997b47954
Description:
Split debug window HTML into a separate file.
This has a few advantages:
* No need to wrap it in quotes and maintain the macro.
* Syntax highlighting works since it's not a string.
* Indenting and whitespace looks nicer.
* I can test it in a real browser.
It strips all leading whitespace and compresses remaining whitespace to
a single space to save room, so don't rely on whitespace. Also, it
requires the xxd program, though once we use a new enough GLib, we can
just use their GResource stuff. BTW, someone will have to fix Windows.
diffstat:
.hgignore | 1 +
configure.ac | 1 +
pidgin/Makefile.am | 8 ++++++
pidgin/gtkdebug.c | 56 ++--------------------------------------------
pidgin/gtkdebug.html | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 75 insertions(+), 53 deletions(-)
diffs (187 lines):
diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -88,6 +88,7 @@ pidgin-.*.tar.gz
pidgin.apspec$
pidgin.desktop$
pidgin.spec$
+pidgin/.*\.html\.h$
pidgin/pidgin$
pidgin/pixmaps/emotes/default/24/theme
pidgin/pixmaps/emotes/none/theme
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -102,6 +102,7 @@ GNT_LT_VERSION_INFO="gnt_lt_current:gnt_
AC_SUBST(GNT_LT_VERSION_INFO)
AC_PATH_PROG(sedpath, sed)
+AC_PATH_PROG(xxdpath, xxd)
dnl Storing configure arguments
AC_DEFINE_UNQUOTED(CONFIG_ARGS, "$ac_configure_args", [configure arguments])
diff --git a/pidgin/Makefile.am b/pidgin/Makefile.am
--- a/pidgin/Makefile.am
+++ b/pidgin/Makefile.am
@@ -152,6 +152,14 @@ pidginincludedir=$(includedir)/pidgin
pidgininclude_HEADERS = \
$(pidgin_headers)
+pidgin_builtheaders = gtkdebug.html.h
+
+BUILT_SOURCES = $(pidgin_builtheaders)
+
+%.html.h: %.html
+ $(AM_V_GEN)echo "static const char $*_html[] = {" > $@
+ $(AM_V_at)$(sedpath) -e 's/^[ ]\+//g' -e 's/[ ]\+/ /g' $< | $(xxdpath) -i | sed -e 's/\(0x[0-9a-f][0-9a-f]\)$$/\1, 0x00/' >> $@
+ $(AM_V_at)echo "};" >> $@
pidgin_DEPENDENCIES = @LIBOBJS@
pidgin_LDFLAGS = -export-dynamic
diff --git a/pidgin/gtkdebug.c b/pidgin/gtkdebug.c
--- a/pidgin/gtkdebug.c
+++ b/pidgin/gtkdebug.c
@@ -41,6 +41,8 @@
#include "gtk3compat.h"
+#include "gtkdebug.html.h"
+
typedef struct
{
GtkWidget *window;
@@ -57,58 +59,6 @@ typedef struct
GRegex *regex;
} DebugWindow;
-#define EMPTY_HTML \
- "<html><head><style>" \
- "body{white-space:pre-wrap;}" \
- "div.l0{color:#000000;}" /* All debug levels. */ \
- "div.l1{color:#666666;}" /* Misc. */ \
- "div.l2{color:#000000;}" /* Information. */ \
- "div.l3{color:#660000;}" /* Warnings. */ \
- "div.l4{color:#FF0000;}" /* Errors. */ \
- "div.l5{color:#FF0000;font-weight:bold;}" /* Fatal errors. */ \
- /* Filter levels */ \
- "div#pause~div{display:none;}" \
- "body.l1 div.l0{display:none;}" \
- "body.l2 div.l0,body.l2 div.l1{display:none;}" \
- "body.l3 div.l0,body.l3 div.l1,body.l3 div.l2{display:none;}" \
- "body.l4 div.l0,body.l4 div.l1,body.l4 div.l2,body.l4 div.l3{display:none;}" \
- "body.l5 div.l0,body.l5 div.l1,body.l5 div.l2,body.l5 div.l3,body.l5 div.l4{display:none;}" \
- /* Regex */ \
- "div.hide{display:none;}" \
- "span.regex{background-color:#ffafaf;font-weight:bold;}" \
- "</style><script>" \
- "function append(level, time, cat, msg) {" \
- "var div = document.createElement('div');" \
- "div.className = 'l' + level;" \
- "div.appendChild(document.createTextNode('(' + time + ') '));" \
- "if (cat) {" \
- "var cat_n = document.createElement('b');" \
- "cat_n.appendChild(document.createTextNode(cat + ':'));" \
- "div.appendChild(cat_n);" \
- "div.appendChild(document.createTextNode(' '));" \
- "}" \
- "div.appendChild(document.createTextNode(msg));" \
- "document.body.appendChild(div);" \
- "alert('appended');" \
- "}" \
- "function clear() {" \
- "document.body.innerHTML = '';" \
- "}" \
- "function pauseOutput() {" \
- "document.body.insertAdjacentHTML('beforeEnd', '<div id=pause></div>');" \
- "}" \
- "function resumeOutput() {" \
- "var pause = document.getElementById('pause');" \
- "if (pause) {" \
- "var parent = pause.parentNode;" \
- "parent.removeChild(pause);" \
- "}" \
- "}" \
- "function setFilterLevel(l) {" \
- "document.body.className = 'l'+l;" \
- "}" \
- "</script></head><body class=l0></body></html>"
-
static DebugWindow *debug_win = NULL;
static guint debug_enabled_timer = 0;
@@ -845,7 +795,7 @@ debug_window_new(void)
gtk_webview_set_format_functions(GTK_WEBVIEW(win->text),
GTK_WEBVIEW_ALL ^ GTK_WEBVIEW_SMILEY ^ GTK_WEBVIEW_IMAGE);
gtk_webview_set_autoscroll(GTK_WEBVIEW(win->text), TRUE);
- gtk_webview_load_html_string(GTK_WEBVIEW(win->text), EMPTY_HTML);
+ gtk_webview_load_html_string(GTK_WEBVIEW(win->text), gtkdebug_html);
gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
gtk_widget_show(frame);
diff --git a/pidgin/gtkdebug.html b/pidgin/gtkdebug.html
new file mode 100644
--- /dev/null
+++ b/pidgin/gtkdebug.html
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <style>
+ body{white-space:pre-wrap;}
+ div.l0{color:#000000;} /* All debug levels. */
+ div.l1{color:#666666;} /* Misc. */
+ div.l2{color:#000000;} /* Information. */
+ div.l3{color:#660000;} /* Warnings. */
+ div.l4{color:#FF0000;} /* Errors. */
+ div.l5{color:#FF0000;font-weight:bold;} /* Fatal errors. */
+ /* Filter levels */
+ div#pause~div{display:none;}
+ body.l1 div.l0{display:none;}
+ body.l2 div.l0,body.l2 div.l1{display:none;}
+ body.l3 div.l0,body.l3 div.l1,body.l3 div.l2{display:none;}
+ body.l4 div.l0,body.l4 div.l1,body.l4 div.l2,body.l4 div.l3{display:none;}
+ body.l5 div.l0,body.l5 div.l1,body.l5 div.l2,body.l5 div.l3,body.l5 div.l4{display:none;}
+ /* Regex */
+ div.hide{display:none;}
+ span.regex{background-color:#ffafaf;font-weight:bold;}
+ </style>
+ <script>
+ function append(level, time, cat, msg) {
+ var div = document.createElement('div');
+ div.className = 'l' + level;
+ div.appendChild(document.createTextNode('(' + time + ') '));
+ if (cat) {
+ var cat_n = document.createElement('b');
+ cat_n.appendChild(document.createTextNode(cat + ':'));
+ div.appendChild(cat_n);
+ div.appendChild(document.createTextNode(' '));
+ }
+ div.appendChild(document.createTextNode(msg));
+ document.body.appendChild(div);
+ alert('appended');
+ }
+
+ function clear() {
+ document.body.innerHTML = '';
+ }
+
+ function pauseOutput() {
+ document.body.insertAdjacentHTML('beforeEnd', '<div id=pause></div>');
+ }
+
+ function resumeOutput() {
+ var pause = document.getElementById('pause');
+ if (pause) {
+ var parent = pause.parentNode;
+ parent.removeChild(pause);
+ }
+ }
+
+ function setFilterLevel(l) {
+ document.body.className = 'l'+l;
+ }
+ </script>
+ </head>
+ <body class=l0></body>
+</html>
+
More information about the Commits
mailing list