SHARE
TWEET

pidgin-debug-window

tomkiewicz Nov 15th, 2012 18 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/pidgin/gtkdebug.c b/pidgin/gtkdebug.c
  2. --- a/pidgin/gtkdebug.c
  3. +++ b/pidgin/gtkdebug.c
  4. @@ -76,7 +76,24 @@
  5.         /* Regex */ \
  6.         "div.hide{display:none;}" \
  7.         "span.regex{background-color:#ffafaf;font-weight:bold;}" \
  8. -       "</style></head><body class=l%d></body></html>"
  9. +       "</style><script>" \
  10. +       "function append(level, time, cat, msg) {" \
  11. +               "var div = document.createElement('div');" \
  12. +               "div.className = 'l' + level;" \
  13. +               "div.appendChild(document.createTextNode(time + ' '));" \
  14. +               "if (cat) {" \
  15. +                       "var cat_n = document.createElement('b');" \
  16. +                       "cat_n.appendChild(document.createTextNode(cat + ':'));" \
  17. +                       "div.appendChild(cat_n);" \
  18. +               "}" \
  19. +               "div.appendChild(document.createTextNode(' ' + msg));" \
  20. +               "document.body.appendChild(div);" \
  21. +       "}" \
  22. +       "</script></head><body class=l%d></body></html>"
  23. +
  24. +
  25. +
  26. +
  27.  
  28.  static DebugWindow *debug_win = NULL;
  29.  static guint debug_enabled_timer = 0;
  30. @@ -831,8 +848,10 @@
  31.         gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
  32.         gtk_widget_show(frame);
  33.  
  34. +/*
  35.         g_signal_connect(G_OBJECT(win->text), "html-appended",
  36.                          G_CALLBACK(regex_html_appended_cb), win);
  37. +*/
  38.  
  39.         clear_cb(NULL, win);
  40.  
  41. @@ -1001,10 +1020,10 @@
  42.  pidgin_debug_print(PurpleDebugLevel level, const char *category,
  43.                                          const char *arg_s)
  44.  {
  45. -       gchar *ts_s;
  46. -       gchar *esc_s, *cat_s, *tmp, *s;
  47. +       gchar *esc_s, *cat_s, *tmp;
  48.         const char *mdate;
  49.         time_t mtime;
  50. +       gchar *js;
  51.  
  52.         if (debug_win == NULL ||
  53.                 !purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/enabled"))
  54. @@ -1014,26 +1033,31 @@
  55.  
  56.         mtime = time(NULL);
  57.         mdate = purple_utf8_strftime("%H:%M:%S", localtime(&mtime));
  58. -       ts_s = g_strdup_printf("(%s) ", mdate);
  59. +
  60. +       /* TODO: new str_escape_js-like function */
  61. +       tmp = purple_utf8_try_convert(arg_s);
  62. +       esc_s = purple_strreplace(tmp, "\\", "\\\\");
  63. +       g_free(tmp); tmp = esc_s;
  64. +       esc_s = purple_strreplace(esc_s, "'", "\\'");
  65. +       g_free(tmp); tmp = esc_s;
  66. +       esc_s = purple_strreplace(esc_s, "\n", "\\n");
  67. +       g_free(tmp); tmp = esc_s;
  68. +       esc_s = purple_strreplace(esc_s, "\r", "");
  69. +       g_free(tmp);
  70. +
  71.         if (category == NULL)
  72. -               cat_s = g_strdup("");
  73. +               cat_s = g_strdup("null");
  74.         else
  75. -               cat_s = g_strdup_printf("<b>%s:</b> ", category);
  76. +               cat_s = g_strdup_printf("'%s'", category);
  77.  
  78. -       tmp = purple_utf8_try_convert(arg_s);
  79. -       esc_s = g_markup_escape_text(tmp, -1);
  80. +       js = g_strdup_printf("append(%d, '%s', %s, '%s');",
  81. +               level, mdate, cat_s, esc_s);
  82.  
  83. -       s = g_strdup_printf("<div class=\"l%d\">%s%s%s</div>",
  84. -                           level, ts_s, cat_s, esc_s);
  85. -
  86. -       g_free(ts_s);
  87.         g_free(cat_s);
  88.         g_free(esc_s);
  89. -       g_free(tmp);
  90.  
  91. -       gtk_webview_append_html(GTK_WEBVIEW(debug_win->text), s);
  92. -
  93. -       g_free(s);
  94. +       gtk_webview_safe_execute_script(GTK_WEBVIEW(debug_win->text), js);
  95. +       g_free(js);
  96.  }
  97.  
  98.  static gboolean
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top