pidgin/gtkdebug.c

Sat, 04 May 2013 23:21:21 -0400

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Sat, 04 May 2013 23:21:21 -0400
changeset 33921
d1e2fdbc3d56
parent 33920
6a4eaacdd207
child 33922
61f997b47954
permissions
-rw-r--r--

Rewrite debug window filtering in JS.

5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /**
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * @file gtkdebug.c GTK+ Debug API
16254
eeb2bba4dc94 Rename the Doxygen group from gtkui to pidgin.
Richard Laager <rlaager@pidgin.im>
parents: 16123
diff changeset
3 * @ingroup pidgin
20147
66f05a854eee applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
4 */
66f05a854eee applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
5
66f05a854eee applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
6 /* pidgin
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 *
15931
716b5fac1895 Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
8 * Pidgin is the legal property of its developers, whose names are too numerous
8046
c581b20a47d6 [gaim-migrate @ 8730]
Sean Egan <seanegan@pidgin.im>
parents: 8002
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
c581b20a47d6 [gaim-migrate @ 8730]
Sean Egan <seanegan@pidgin.im>
parents: 8002
diff changeset
10 * source distribution.
7152
112d0e52d04b [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
11 *
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * (at your option) any later version.
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 *
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * GNU General Public License for more details.
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 *
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19065
diff changeset
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 */
9791
f5c5bda0b96b [gaim-migrate @ 10659]
Gary Kramlich <grim@pidgin.im>
parents: 9709
diff changeset
26 #include "internal.h"
15577
b8129373f65e More pidgin changes
Sean Egan <seanegan@pidgin.im>
parents: 15571
diff changeset
27 #include "pidgin.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5818
diff changeset
28
9480
b4d46aa1be7d [gaim-migrate @ 10305]
Mark Doliner <markdoliner@pidgin.im>
parents: 8953
diff changeset
29 #include "notify.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5818
diff changeset
30 #include "prefs.h"
8953
6705ad4595b0 [gaim-migrate @ 9726]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8735
diff changeset
31 #include "request.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5818
diff changeset
32 #include "util.h"
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5818
diff changeset
33
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34 #include "gtkdebug.h"
9709
2e73f176cc80 [gaim-migrate @ 10570]
Mark Doliner <markdoliner@pidgin.im>
parents: 9504
diff changeset
35 #include "gtkdialogs.h"
8953
6705ad4595b0 [gaim-migrate @ 9726]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8735
diff changeset
36 #include "gtkutils.h"
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
37 #include "gtkwebview.h"
15883
969b74a3e27a According to etags, pidgin/ should be completely clean of references to 'gaim' as a client
Sean Egan <seanegan@pidgin.im>
parents: 15882
diff changeset
38 #include "pidginstock.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5818
diff changeset
39
11473
38b35dc600ce [gaim-migrate @ 13714]
Gary Kramlich <grim@reaperworld.com>
parents: 11450
diff changeset
40 #include <gdk/gdkkeysyms.h>
38b35dc600ce [gaim-migrate @ 13714]
Gary Kramlich <grim@reaperworld.com>
parents: 11450
diff changeset
41
33170
ce4447562d64 Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33167
diff changeset
42 #include "gtk3compat.h"
ce4447562d64 Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33167
diff changeset
43
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44 typedef struct
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45 {
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46 GtkWidget *window;
5428
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
47 GtkWidget *text;
33092
a68f8b2b6873 Always use GRegex in the Debug Window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33091
diff changeset
48 GtkWidget *filter;
a68f8b2b6873 Always use GRegex in the Debug Window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33091
diff changeset
49 GtkWidget *expression;
a68f8b2b6873 Always use GRegex in the Debug Window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33091
diff changeset
50 GtkWidget *filterlevel;
5428
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
51
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
52 gboolean paused;
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
54 gboolean invert;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
55 gboolean highlight;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
56 guint timer;
30795
4fc1b7cc2e06 Use GRegex where available. Fixes #12601.
Eion Robb <eion@robbmob.com>
parents: 29747
diff changeset
57 GRegex *regex;
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 } DebugWindow;
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
60 #define EMPTY_HTML \
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
61 "<html><head><style>" \
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
62 "body{white-space:pre-wrap;}" \
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
63 "div.l0{color:#000000;}" /* All debug levels. */ \
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
64 "div.l1{color:#666666;}" /* Misc. */ \
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
65 "div.l2{color:#000000;}" /* Information. */ \
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
66 "div.l3{color:#660000;}" /* Warnings. */ \
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
67 "div.l4{color:#FF0000;}" /* Errors. */ \
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
68 "div.l5{color:#FF0000;font-weight:bold;}" /* Fatal errors. */ \
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
69 /* Filter levels */ \
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
70 "div#pause~div{display:none;}" \
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
71 "body.l1 div.l0{display:none;}" \
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
72 "body.l2 div.l0,body.l2 div.l1{display:none;}" \
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
73 "body.l3 div.l0,body.l3 div.l1,body.l3 div.l2{display:none;}" \
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
74 "body.l4 div.l0,body.l4 div.l1,body.l4 div.l2,body.l4 div.l3{display:none;}" \
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
75 "body.l5 div.l0,body.l5 div.l1,body.l5 div.l2,body.l5 div.l3,body.l5 div.l4{display:none;}" \
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
76 /* Regex */ \
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
77 "div.hide{display:none;}" \
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
78 "span.regex{background-color:#ffafaf;font-weight:bold;}" \
33537
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
79 "</style><script>" \
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
80 "function append(level, time, cat, msg) {" \
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
81 "var div = document.createElement('div');" \
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
82 "div.className = 'l' + level;" \
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
83 "div.appendChild(document.createTextNode('(' + time + ') '));" \
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
84 "if (cat) {" \
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
85 "var cat_n = document.createElement('b');" \
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
86 "cat_n.appendChild(document.createTextNode(cat + ':'));" \
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
87 "div.appendChild(cat_n);" \
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
88 "div.appendChild(document.createTextNode(' '));" \
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
89 "}" \
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
90 "div.appendChild(document.createTextNode(msg));" \
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
91 "document.body.appendChild(div);" \
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
92 "alert('appended');" \
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
93 "}" \
33919
9f3f19ab8342 Rewrite debug window clearing in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33683
diff changeset
94 "function clear() {" \
9f3f19ab8342 Rewrite debug window clearing in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33683
diff changeset
95 "document.body.innerHTML = '';" \
9f3f19ab8342 Rewrite debug window clearing in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33683
diff changeset
96 "}" \
33920
6a4eaacdd207 Rewrite debug window pausing in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33919
diff changeset
97 "function pauseOutput() {" \
6a4eaacdd207 Rewrite debug window pausing in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33919
diff changeset
98 "document.body.insertAdjacentHTML('beforeEnd', '<div id=pause></div>');" \
6a4eaacdd207 Rewrite debug window pausing in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33919
diff changeset
99 "}" \
6a4eaacdd207 Rewrite debug window pausing in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33919
diff changeset
100 "function resumeOutput() {" \
6a4eaacdd207 Rewrite debug window pausing in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33919
diff changeset
101 "var pause = document.getElementById('pause');" \
6a4eaacdd207 Rewrite debug window pausing in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33919
diff changeset
102 "if (pause) {" \
6a4eaacdd207 Rewrite debug window pausing in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33919
diff changeset
103 "var parent = pause.parentNode;" \
6a4eaacdd207 Rewrite debug window pausing in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33919
diff changeset
104 "parent.removeChild(pause);" \
6a4eaacdd207 Rewrite debug window pausing in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33919
diff changeset
105 "}" \
6a4eaacdd207 Rewrite debug window pausing in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33919
diff changeset
106 "}" \
33921
d1e2fdbc3d56 Rewrite debug window filtering in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33920
diff changeset
107 "function setFilterLevel(l) {" \
d1e2fdbc3d56 Rewrite debug window filtering in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33920
diff changeset
108 "document.body.className = 'l'+l;" \
d1e2fdbc3d56 Rewrite debug window filtering in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33920
diff changeset
109 "}" \
33919
9f3f19ab8342 Rewrite debug window clearing in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33683
diff changeset
110 "</script></head><body class=l0></body></html>"
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 static DebugWindow *debug_win = NULL;
17232
8593d66c708b When the /pidgin/debug/enabled pref is toggled, wait until the next
Mark Doliner <markdoliner@pidgin.im>
parents: 17040
diff changeset
113 static guint debug_enabled_timer = 0;
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115 static gint
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 debug_window_destroy(GtkWidget *w, GdkEvent *event, void *unused)
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
118 purple_prefs_disconnect_by_handle(pidgin_debug_get_handle());
9502
d43f69354213 [gaim-migrate @ 10329]
Mark Doliner <markdoliner@pidgin.im>
parents: 9501
diff changeset
119
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
120 if(debug_win->timer != 0) {
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
121 const gchar *text;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
122
26753
a8dca8faae69 A patch from Arunan Balasubramaniam to use timeouts in seconds instead of
Arunan Balasubramaniam <foss@abala.me>
parents: 26482
diff changeset
123 purple_timeout_remove(debug_win->timer);
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
124
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
125 text = gtk_entry_get_text(GTK_ENTRY(debug_win->expression));
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
126 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/debug/regex", text);
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
127 }
33539
12e93808f35d Fix some warnings in debug and conv windows
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33538
diff changeset
128 if (debug_win->regex != NULL)
12e93808f35d Fix some warnings in debug and conv windows
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33538
diff changeset
129 g_regex_unref(debug_win->regex);
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
130
9502
d43f69354213 [gaim-migrate @ 10329]
Mark Doliner <markdoliner@pidgin.im>
parents: 9501
diff changeset
131 /* If the "Save Log" dialog is open then close it */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
132 purple_request_close_with_handle(debug_win);
5704
3170b0bd2b40 [gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
133
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 g_free(debug_win);
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 debug_win = NULL;
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
137 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/debug/enabled", FALSE);
9480
b4d46aa1be7d [gaim-migrate @ 10305]
Mark Doliner <markdoliner@pidgin.im>
parents: 8953
diff changeset
138
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
139 return FALSE;
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
140 }
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
142 static gboolean
5794
ebdbb7dc6658 [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5738
diff changeset
143 configure_cb(GtkWidget *w, GdkEventConfigure *event, DebugWindow *win)
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
144 {
32913
af2c726febce Fix all deprecated GTK_WIDGET_* macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32912
diff changeset
145 if (gtk_widget_get_visible(w)) {
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
146 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/debug/width", event->width);
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
147 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/debug/height", event->height);
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
148 }
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150 return FALSE;
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 }
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152
8953
6705ad4595b0 [gaim-migrate @ 9726]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8735
diff changeset
153 static void
9502
d43f69354213 [gaim-migrate @ 10329]
Mark Doliner <markdoliner@pidgin.im>
parents: 9501
diff changeset
154 save_writefile_cb(void *user_data, const char *filename)
8953
6705ad4595b0 [gaim-migrate @ 9726]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8735
diff changeset
155 {
9502
d43f69354213 [gaim-migrate @ 10329]
Mark Doliner <markdoliner@pidgin.im>
parents: 9501
diff changeset
156 DebugWindow *win = (DebugWindow *)user_data;
9489
3ee8fdcdbac9 [gaim-migrate @ 10314]
Mark Doliner <markdoliner@pidgin.im>
parents: 9486
diff changeset
157 FILE *fp;
8953
6705ad4595b0 [gaim-migrate @ 9726]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8735
diff changeset
158 char *tmp;
6705ad4595b0 [gaim-migrate @ 9726]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8735
diff changeset
159
10589
4e10236e06d4 [gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents: 10448
diff changeset
160 if ((fp = g_fopen(filename, "w+")) == NULL) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
161 purple_notify_error(win, NULL, _("Unable to open file."), NULL);
8953
6705ad4595b0 [gaim-migrate @ 9726]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8735
diff changeset
162 return;
9480
b4d46aa1be7d [gaim-migrate @ 10305]
Mark Doliner <markdoliner@pidgin.im>
parents: 8953
diff changeset
163 }
8953
6705ad4595b0 [gaim-migrate @ 9726]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8735
diff changeset
164
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
165 tmp = gtk_webview_get_body_text(GTK_WEBVIEW(win->text));
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
166 fprintf(fp, "Pidgin Debug Log : %s\n", purple_date_format_full(NULL));
8953
6705ad4595b0 [gaim-migrate @ 9726]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8735
diff changeset
167 fprintf(fp, "%s", tmp);
6705ad4595b0 [gaim-migrate @ 9726]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8735
diff changeset
168 g_free(tmp);
6705ad4595b0 [gaim-migrate @ 9726]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8735
diff changeset
169
6705ad4595b0 [gaim-migrate @ 9726]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8735
diff changeset
170 fclose(fp);
6705ad4595b0 [gaim-migrate @ 9726]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8735
diff changeset
171 }
6705ad4595b0 [gaim-migrate @ 9726]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8735
diff changeset
172
6705ad4595b0 [gaim-migrate @ 9726]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8735
diff changeset
173 static void
6705ad4595b0 [gaim-migrate @ 9726]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8735
diff changeset
174 save_cb(GtkWidget *w, DebugWindow *win)
6705ad4595b0 [gaim-migrate @ 9726]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8735
diff changeset
175 {
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
176 purple_request_file(win, _("Save Debug Log"), "purple-debug.log", TRUE,
16490
68c22924d66b Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents: 16478
diff changeset
177 G_CALLBACK(save_writefile_cb), NULL,
68c22924d66b Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents: 16478
diff changeset
178 NULL, NULL, NULL,
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
179 win);
8953
6705ad4595b0 [gaim-migrate @ 9726]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8735
diff changeset
180 }
6705ad4595b0 [gaim-migrate @ 9726]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8735
diff changeset
181
6705ad4595b0 [gaim-migrate @ 9726]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8735
diff changeset
182 static void
5794
ebdbb7dc6658 [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5738
diff changeset
183 clear_cb(GtkWidget *w, DebugWindow *win)
5428
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
184 {
33919
9f3f19ab8342 Rewrite debug window clearing in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33683
diff changeset
185 gtk_webview_safe_execute_script(GTK_WEBVIEW(win->text), "clear();");
5428
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
186 }
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
187
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
188 static void
5794
ebdbb7dc6658 [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5738
diff changeset
189 pause_cb(GtkWidget *w, DebugWindow *win)
5428
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
190 {
29746
f7a7722bee2f Remove GTK_CHECK_VERSION(2,4,0) checks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29745
diff changeset
191 win->paused = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(w));
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
192
33920
6a4eaacdd207 Rewrite debug window pausing in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33919
diff changeset
193 if (win->paused)
6a4eaacdd207 Rewrite debug window pausing in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33919
diff changeset
194 gtk_webview_safe_execute_script(GTK_WEBVIEW(win->text), "pauseOutput();");
6a4eaacdd207 Rewrite debug window pausing in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33919
diff changeset
195 else
6a4eaacdd207 Rewrite debug window pausing in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33919
diff changeset
196 gtk_webview_safe_execute_script(GTK_WEBVIEW(win->text), "resumeOutput();");
5428
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
197 }
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
198
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
199 /******************************************************************************
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
200 * regex stuff
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
201 *****************************************************************************/
11033
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 10739
diff changeset
202 static void
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
203 regex_clear_color(GtkWidget *w) {
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
204 gtk_widget_modify_base(w, GTK_STATE_NORMAL, NULL);
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
205 }
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
206
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
207 static void
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
208 regex_change_color(GtkWidget *w, guint16 r, guint16 g, guint16 b) {
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
209 GdkColor color;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
210
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
211 color.red = r;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
212 color.green = g;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
213 color.blue = b;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
214
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
215 gtk_widget_modify_base(w, GTK_STATE_NORMAL, &color);
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
216 }
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
217
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
218 static void
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
219 regex_toggle_div(WebKitDOMNode *div)
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
220 {
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
221 WebKitDOMDOMTokenList *classes;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
222
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
223 if (!WEBKIT_DOM_IS_HTML_ELEMENT(div))
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
224 return;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
225
33497
6c0ecaf82229 Workaround WebKit API bug.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
226 #if (WEBKIT_MAJOR_VERSION == 1 && \
6c0ecaf82229 Workaround WebKit API bug.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
227 WEBKIT_MINOR_VERSION == 9 && \
6c0ecaf82229 Workaround WebKit API bug.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
228 WEBKIT_MICRO_VERSION == 90)
6c0ecaf82229 Workaround WebKit API bug.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
229 /* Workaround WebKit API bug. */
6c0ecaf82229 Workaround WebKit API bug.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
230 classes = webkit_dom_element_get_class_list(WEBKIT_DOM_ELEMENT(div));
6c0ecaf82229 Workaround WebKit API bug.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
231 #else
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
232 classes = webkit_dom_html_element_get_class_list(WEBKIT_DOM_HTML_ELEMENT(div));
33497
6c0ecaf82229 Workaround WebKit API bug.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33247
diff changeset
233 #endif
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
234 webkit_dom_dom_token_list_toggle(classes, "hide", NULL);
33501
c224f6403237 Fix leaks of WebKit Lists.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33497
diff changeset
235 g_object_unref(classes);
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
236 }
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
237
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
238 static void
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
239 regex_highlight_clear(WebKitDOMDocument *dom)
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
240 {
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
241 WebKitDOMNodeList *nodes;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
242 gulong i;
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
243
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
244 /* Remove highlighting SPANs */
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
245 nodes = webkit_dom_document_get_elements_by_class_name(dom, "regex");
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
246 i = webkit_dom_node_list_get_length(nodes);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
247 while (i--) {
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
248 WebKitDOMNode *span, *parent;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
249 char *content;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
250 WebKitDOMText *text;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
251 GError *err = NULL;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
252
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
253 span = webkit_dom_node_list_item(nodes, i);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
254 parent = webkit_dom_node_get_parent_node(span);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
255
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
256 content = webkit_dom_node_get_text_content(span);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
257 text = webkit_dom_document_create_text_node(dom, content);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
258 g_free(content);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
259
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
260 webkit_dom_node_replace_child(parent, WEBKIT_DOM_NODE(text), span, &err);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
261 }
33501
c224f6403237 Fix leaks of WebKit Lists.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33497
diff changeset
262
c224f6403237 Fix leaks of WebKit Lists.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33497
diff changeset
263 g_object_unref(nodes);
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
264 }
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
265
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
266 static void
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
267 regex_highlight_text_nodes(WebKitDOMDocument *dom, WebKitDOMNode *div,
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
268 gint start_pos, gint end_pos)
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
269 {
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
270 GSList *data = NULL;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
271 WebKitDOMNode *node;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
272 WebKitDOMRange *range;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
273 WebKitDOMElement *span;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
274 gint ind, end_ind;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
275 gint this_start, this_end;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
276
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
277 ind = 0;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
278 webkit_dom_node_normalize(div);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
279 node = div;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
280
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
281 /* First, find the container nodes and offsets to apply highlighting. */
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
282 do {
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
283 if (webkit_dom_node_get_node_type(node) == 3/*TEXT_NODE*/) {
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
284 /* The GObject model does not correctly reflect the type, hence the
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
285 regular cast. */
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
286 end_ind = ind + webkit_dom_character_data_get_length((WebKitDOMCharacterData*)node);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
287
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
288 if (start_pos <= ind)
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
289 this_start = 0;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
290 else if (start_pos < end_ind)
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
291 this_start = start_pos - ind;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
292 else
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
293 this_start = -1;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
294
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
295 if (end_pos < end_ind)
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
296 this_end = end_pos - ind;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
297 else
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
298 this_end = end_ind - ind;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
299
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
300 if (this_start != -1 && this_start < this_end) {
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
301 data = g_slist_prepend(data, GINT_TO_POINTER(this_end));
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
302 data = g_slist_prepend(data, GINT_TO_POINTER(this_start));
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
303 data = g_slist_prepend(data, node);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
304 }
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
305
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
306 ind = end_ind;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
307 }
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
308
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
309 if (webkit_dom_node_has_child_nodes(node)) {
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
310 node = webkit_dom_node_get_first_child(node);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
311 } else {
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
312 while (node != div) {
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
313 WebKitDOMNode *next;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
314
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
315 next = webkit_dom_node_get_next_sibling(node);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
316 if (next) {
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
317 node = next;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
318 break;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
319 } else {
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
320 node = webkit_dom_node_get_parent_node(node);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
321 }
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
322 }
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
323 }
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
324 } while (node != div);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
325
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
326 /* Second, apply highlighting to saved sections. Changing the DOM is
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
327 automatically reflected in all WebKit API, so we have to do this after
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
328 finding the offsets, or things could get complicated. */
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
329 while (data) {
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
330 node = WEBKIT_DOM_NODE(data->data);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
331 data = g_slist_delete_link(data, data);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
332 this_start = GPOINTER_TO_INT(data->data);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
333 data = g_slist_delete_link(data, data);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
334 this_end = GPOINTER_TO_INT(data->data);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
335 data = g_slist_delete_link(data, data);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
336
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
337 range = webkit_dom_document_create_range(dom);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
338 webkit_dom_range_set_start(range, node, this_start, NULL);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
339 webkit_dom_range_set_end(range, node, this_end, NULL);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
340 span = webkit_dom_document_create_element(dom, "span", NULL);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
341 webkit_dom_html_element_set_class_name(WEBKIT_DOM_HTML_ELEMENT(span),
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
342 "regex");
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
343 webkit_dom_range_surround_contents(range, WEBKIT_DOM_NODE(span), NULL);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
344 }
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
345 }
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
346
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
347 static void
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
348 regex_match(DebugWindow *win, WebKitDOMDocument *dom, WebKitDOMNode *div)
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
349 {
30795
4fc1b7cc2e06 Use GRegex where available. Fixes #12601.
Eion Robb <eion@robbmob.com>
parents: 29747
diff changeset
350 GMatchInfo *match_info;
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
351 gchar *text;
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
352 gchar *plaintext;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
353
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
354 text = webkit_dom_node_get_text_content(div);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
355 if (!text)
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
356 return;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
357
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
358 /* I don't like having to do this, but we need it for highlighting. Plus
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
359 * it makes the ^ and $ operators work :)
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
360 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
361 plaintext = purple_markup_strip_html(text);
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
362
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
363 /* We do a first pass to see if it matches at all. If it does we work out
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
364 * the offsets to highlight.
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
365 */
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
366 if (g_regex_match(win->regex, plaintext, 0, &match_info) != win->invert) {
11312
73ee18523c44 [gaim-migrate @ 13512]
Gary Kramlich <grim@reaperworld.com>
parents: 11311
diff changeset
367 /* If we're not highlighting or the expression is inverted, we're
11311
0deea6aaea65 [gaim-migrate @ 13511]
Gary Kramlich <grim@reaperworld.com>
parents: 11310
diff changeset
368 * done and move on.
11310
18461cc48950 [gaim-migrate @ 13510]
Gary Kramlich <grim@reaperworld.com>
parents: 11262
diff changeset
369 */
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
370 if (!win->highlight || win->invert) {
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
371 g_free(plaintext);
30795
4fc1b7cc2e06 Use GRegex where available. Fixes #12601.
Eion Robb <eion@robbmob.com>
parents: 29747
diff changeset
372 g_match_info_free(match_info);
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
373 return;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
374 }
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
375
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
376 do {
33094
33197cba2b9d Better handling of parenthesized searches.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33093
diff changeset
377 gint m, count;
30795
4fc1b7cc2e06 Use GRegex where available. Fixes #12601.
Eion Robb <eion@robbmob.com>
parents: 29747
diff changeset
378 gint start_pos, end_pos;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30795
diff changeset
379
30795
4fc1b7cc2e06 Use GRegex where available. Fixes #12601.
Eion Robb <eion@robbmob.com>
parents: 29747
diff changeset
380 if (!g_match_info_matches(match_info))
4fc1b7cc2e06 Use GRegex where available. Fixes #12601.
Eion Robb <eion@robbmob.com>
parents: 29747
diff changeset
381 break;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30795
diff changeset
382
33094
33197cba2b9d Better handling of parenthesized searches.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33093
diff changeset
383 count = g_match_info_get_match_count(match_info);
33197cba2b9d Better handling of parenthesized searches.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33093
diff changeset
384 if (count == 1)
33197cba2b9d Better handling of parenthesized searches.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33093
diff changeset
385 m = 0;
33197cba2b9d Better handling of parenthesized searches.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33093
diff changeset
386 else
33197cba2b9d Better handling of parenthesized searches.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33093
diff changeset
387 m = 1;
33197cba2b9d Better handling of parenthesized searches.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33093
diff changeset
388
33197cba2b9d Better handling of parenthesized searches.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33093
diff changeset
389 for (; m < count; m++)
30795
4fc1b7cc2e06 Use GRegex where available. Fixes #12601.
Eion Robb <eion@robbmob.com>
parents: 29747
diff changeset
390 {
4fc1b7cc2e06 Use GRegex where available. Fixes #12601.
Eion Robb <eion@robbmob.com>
parents: 29747
diff changeset
391 g_match_info_fetch_pos(match_info, m, &start_pos, &end_pos);
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30795
diff changeset
392
30795
4fc1b7cc2e06 Use GRegex where available. Fixes #12601.
Eion Robb <eion@robbmob.com>
parents: 29747
diff changeset
393 if (end_pos == -1)
4fc1b7cc2e06 Use GRegex where available. Fixes #12601.
Eion Robb <eion@robbmob.com>
parents: 29747
diff changeset
394 break;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30795
diff changeset
395
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
396 regex_highlight_text_nodes(dom, div, start_pos, end_pos);
30795
4fc1b7cc2e06 Use GRegex where available. Fixes #12601.
Eion Robb <eion@robbmob.com>
parents: 29747
diff changeset
397 }
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
398 } while (g_match_info_next(match_info, NULL));
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30795
diff changeset
399
30795
4fc1b7cc2e06 Use GRegex where available. Fixes #12601.
Eion Robb <eion@robbmob.com>
parents: 29747
diff changeset
400 g_match_info_free(match_info);
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
401 } else {
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
402 regex_toggle_div(div);
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
403 }
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
404
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
405 g_free(plaintext);
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
406 g_free(text);
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
407 }
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
408
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
409 static void
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
410 regex_toggle_filter(DebugWindow *win, gboolean filter)
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
411 {
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
412 WebKitDOMDocument *dom;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
413 WebKitDOMNodeList *list;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
414 gulong i;
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
415
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
416 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(win->text));
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
417
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
418 if (win->highlight)
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
419 regex_highlight_clear(dom);
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
420
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
421 /* Re-show debug lines that didn't match regex */
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
422 list = webkit_dom_document_get_elements_by_class_name(dom, "hide");
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
423 i = webkit_dom_node_list_get_length(list);
33501
c224f6403237 Fix leaks of WebKit Lists.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33497
diff changeset
424
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
425 while (i--) {
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
426 WebKitDOMNode *div = webkit_dom_node_list_item(list, i);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
427 regex_toggle_div(div);
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
428 }
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
429
33501
c224f6403237 Fix leaks of WebKit Lists.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33497
diff changeset
430 g_object_unref(list);
c224f6403237 Fix leaks of WebKit Lists.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33497
diff changeset
431
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
432 if (filter) {
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
433 list = webkit_dom_document_get_elements_by_tag_name(dom, "div");
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
434
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
435 for (i = 0; i < webkit_dom_node_list_get_length(list); i++) {
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
436 WebKitDOMNode *div = webkit_dom_node_list_item(list, i);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
437 regex_match(win, dom, div);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
438 }
33501
c224f6403237 Fix leaks of WebKit Lists.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33497
diff changeset
439
c224f6403237 Fix leaks of WebKit Lists.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33497
diff changeset
440 g_object_unref(list);
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
441 }
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
442 }
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
443
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
444 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
445 regex_pref_filter_cb(const gchar *name, PurplePrefType type,
12816
5f93e09fa9a6 [gaim-migrate @ 15164]
Mark Doliner <markdoliner@pidgin.im>
parents: 12231
diff changeset
446 gconstpointer val, gpointer data)
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
447 {
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
448 DebugWindow *win = (DebugWindow *)data;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
449 gboolean active = GPOINTER_TO_INT(val), current;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
450
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
451 if (!win || !win->window)
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
452 return;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
453
29746
f7a7722bee2f Remove GTK_CHECK_VERSION(2,4,0) checks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29745
diff changeset
454 current = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(win->filter));
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
455 if (active != current)
29746
f7a7722bee2f Remove GTK_CHECK_VERSION(2,4,0) checks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29745
diff changeset
456 gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(win->filter), active);
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
457 }
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
458
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
459 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
460 regex_pref_expression_cb(const gchar *name, PurplePrefType type,
12816
5f93e09fa9a6 [gaim-migrate @ 15164]
Mark Doliner <markdoliner@pidgin.im>
parents: 12231
diff changeset
461 gconstpointer val, gpointer data)
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
462 {
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
463 DebugWindow *win = (DebugWindow *)data;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
464 const gchar *exp = (const gchar *)val;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
465
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
466 gtk_entry_set_text(GTK_ENTRY(win->expression), exp);
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
467 }
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
468
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
469 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
470 regex_pref_invert_cb(const gchar *name, PurplePrefType type,
12816
5f93e09fa9a6 [gaim-migrate @ 15164]
Mark Doliner <markdoliner@pidgin.im>
parents: 12231
diff changeset
471 gconstpointer val, gpointer data)
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
472 {
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
473 DebugWindow *win = (DebugWindow *)data;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
474 gboolean active = GPOINTER_TO_INT(val);
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
475
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
476 win->invert = active;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
477
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
478 if (gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(win->filter)))
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
479 regex_toggle_filter(win, TRUE);
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
480 }
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
481
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
482 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
483 regex_pref_highlight_cb(const gchar *name, PurplePrefType type,
12816
5f93e09fa9a6 [gaim-migrate @ 15164]
Mark Doliner <markdoliner@pidgin.im>
parents: 12231
diff changeset
484 gconstpointer val, gpointer data)
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
485 {
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
486 DebugWindow *win = (DebugWindow *)data;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
487 gboolean active = GPOINTER_TO_INT(val);
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
488
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
489 win->highlight = active;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
490
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
491 if (gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(win->filter)))
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
492 regex_toggle_filter(win, TRUE);
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
493 }
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
494
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
495 static gboolean
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
496 regex_timer_cb(DebugWindow *win) {
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
497 const gchar *text;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
498
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
499 text = gtk_entry_get_text(GTK_ENTRY(win->expression));
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
500 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/debug/regex", text);
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
501
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
502 win->timer = 0;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
503
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
504 return FALSE;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
505 }
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
506
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
507 static void
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
508 regex_changed_cb(GtkWidget *w, DebugWindow *win) {
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
509 const gchar *text;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
510
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
511 if (gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(win->filter))) {
29746
f7a7722bee2f Remove GTK_CHECK_VERSION(2,4,0) checks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29745
diff changeset
512 gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(win->filter),
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
513 FALSE);
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
514 }
11033
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 10739
diff changeset
515
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
516 if (win->timer == 0)
26753
a8dca8faae69 A patch from Arunan Balasubramaniam to use timeouts in seconds instead of
Arunan Balasubramaniam <foss@abala.me>
parents: 26482
diff changeset
517 win->timer = purple_timeout_add_seconds(5, (GSourceFunc)regex_timer_cb, win);
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
518
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
519 text = gtk_entry_get_text(GTK_ENTRY(win->expression));
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
520
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
521 if (text == NULL || *text == '\0') {
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
522 regex_clear_color(win->expression);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
523 gtk_widget_set_sensitive(win->filter, FALSE);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
524 return;
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
525 }
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
526
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
527 if (win->regex)
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
528 g_regex_unref(win->regex);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
529 win->regex = g_regex_new(text, G_REGEX_CASELESS, 0, NULL);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
530 if (win->regex == NULL) {
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
531 /* failed to compile */
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
532 regex_change_color(win->expression, 0xFFFF, 0xAFFF, 0xAFFF);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
533 gtk_widget_set_sensitive(win->filter, FALSE);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
534 } else {
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
535 /* compiled successfully */
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
536 regex_change_color(win->expression, 0xAFFF, 0xFFFF, 0xAFFF);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
537 gtk_widget_set_sensitive(win->filter, TRUE);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
538 }
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
539 }
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
540
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
541 static void
11450
52e566659430 [gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents: 11312
diff changeset
542 regex_key_release_cb(GtkWidget *w, GdkEventKey *e, DebugWindow *win) {
33133
9a31f084f259 Fix some merge errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33132
diff changeset
543 if(e->keyval == GDK_KEY_Return &&
32913
af2c726febce Fix all deprecated GTK_WIDGET_* macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32912
diff changeset
544 gtk_widget_is_sensitive(win->filter) &&
29746
f7a7722bee2f Remove GTK_CHECK_VERSION(2,4,0) checks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29745
diff changeset
545 !gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(win->filter)))
11450
52e566659430 [gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents: 11312
diff changeset
546 {
29746
f7a7722bee2f Remove GTK_CHECK_VERSION(2,4,0) checks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29745
diff changeset
547 gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(win->filter), TRUE);
11450
52e566659430 [gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents: 11312
diff changeset
548 }
52e566659430 [gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents: 11312
diff changeset
549 }
52e566659430 [gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents: 11312
diff changeset
550
52e566659430 [gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents: 11312
diff changeset
551 static void
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
552 regex_menu_cb(GtkWidget *item, const gchar *pref) {
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
553 gboolean active;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
554
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
555 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item));
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
556
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
557 purple_prefs_set_bool(pref, active);
11033
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 10739
diff changeset
558 }
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 10739
diff changeset
559
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
560 static void
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
561 regex_popup_cb(GtkEntry *entry, GtkWidget *menu, DebugWindow *win) {
15568
cd19bb5a51b8 gtkutils changes
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
562 pidgin_separator(menu);
cd19bb5a51b8 gtkutils changes
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
563 pidgin_new_check_item(menu, _("Invert"),
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
564 G_CALLBACK(regex_menu_cb),
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
565 PIDGIN_PREFS_ROOT "/debug/invert", win->invert);
15568
cd19bb5a51b8 gtkutils changes
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
566 pidgin_new_check_item(menu, _("Highlight matches"),
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
567 G_CALLBACK(regex_menu_cb),
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
568 PIDGIN_PREFS_ROOT "/debug/highlight", win->highlight);
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
569 }
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
570
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
571 static void
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
572 regex_filter_toggled_cb(GtkToggleToolButton *button, DebugWindow *win)
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
573 {
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
574 gboolean active;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
575
29746
f7a7722bee2f Remove GTK_CHECK_VERSION(2,4,0) checks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29745
diff changeset
576 active = gtk_toggle_tool_button_get_active(button);
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
577
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
578 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/debug/filter", active);
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
579
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
580 if (!GTK_IS_WEBVIEW(win->text))
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
581 return;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
582
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
583 regex_toggle_filter(win, active);
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
584 }
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
585
14541
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
586 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
587 filter_level_pref_changed(const char *name, PurplePrefType type, gconstpointer value, gpointer data)
14541
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
588 {
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
589 DebugWindow *win = data;
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
590 int level = GPOINTER_TO_INT(value);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
591 char *tmp;
14541
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
592
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
593 if (level != gtk_combo_box_get_active(GTK_COMBO_BOX(win->filterlevel)))
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
594 gtk_combo_box_set_active(GTK_COMBO_BOX(win->filterlevel), level);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
595
33921
d1e2fdbc3d56 Rewrite debug window filtering in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33920
diff changeset
596 tmp = g_strdup_printf("setFilterLevel('%d');", level);
d1e2fdbc3d56 Rewrite debug window filtering in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33920
diff changeset
597 gtk_webview_safe_execute_script(GTK_WEBVIEW(win->text), tmp);
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
598 g_free(tmp);
14541
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
599 }
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
600
14541
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
601 static void
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
602 filter_level_changed_cb(GtkWidget *combo, gpointer null)
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
603 {
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
604 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/debug/filterlevel",
14541
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
605 gtk_combo_box_get_active(GTK_COMBO_BOX(combo)));
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
606 }
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
607
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
608 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
609 toolbar_style_pref_changed_cb(const char *name, PurplePrefType type, gconstpointer value, gpointer data)
14541
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
610 {
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
611 gtk_toolbar_set_style(GTK_TOOLBAR(data), GPOINTER_TO_INT(value));
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
612 }
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
613
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
614 static void
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
615 toolbar_icon_pref_changed(GtkWidget *item, GtkWidget *toolbar)
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
616 {
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
617 int style = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(item), "user_data"));
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
618 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/debug/style", style);
14541
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
619 }
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
620
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
621 static gboolean
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
622 toolbar_context(GtkWidget *toolbar, GdkEventButton *event, gpointer null)
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
623 {
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
624 GtkWidget *menu, *item;
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
625 const char *text[3];
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
626 GtkToolbarStyle value[3];
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
627 int i;
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
628
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
629 if (!(event->button == 3 && event->type == GDK_BUTTON_PRESS))
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
630 return FALSE;
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
631
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
632 text[0] = _("_Icon Only"); value[0] = GTK_TOOLBAR_ICONS;
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
633 text[1] = _("_Text Only"); value[1] = GTK_TOOLBAR_TEXT;
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
634 text[2] = _("_Both Icon & Text"); value[2] = GTK_TOOLBAR_BOTH_HORIZ;
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
635
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
636 menu = gtk_menu_new();
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
637
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
638 for (i = 0; i < 3; i++) {
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
639 item = gtk_check_menu_item_new_with_mnemonic(text[i]);
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
640 g_object_set_data(G_OBJECT(item), "user_data", GINT_TO_POINTER(value[i]));
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
641 g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(toolbar_icon_pref_changed), toolbar);
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
642 if (value[i] == purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/style"))
14541
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
643 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
644 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
645 }
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
646
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
647 gtk_widget_show_all(menu);
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
648
33110
a2923f41d05a We have the exact button and event time to use here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33095
diff changeset
649 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, event->time);
14541
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
650 return FALSE;
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
651 }
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
652
33242
f63b51e608fe Fix debug filtering on appended items.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33238
diff changeset
653 static void
33537
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
654 debug_window_appended(DebugWindow *win)
33242
f63b51e608fe Fix debug filtering on appended items.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33238
diff changeset
655 {
33537
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
656 WebKitDOMDocument *dom;
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
657 WebKitDOMHTMLElement *body;
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
658 WebKitDOMNode *div;
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
659
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
660 if (!gtk_toggle_tool_button_get_active(
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
661 GTK_TOGGLE_TOOL_BUTTON(win->filter)))
33242
f63b51e608fe Fix debug filtering on appended items.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33238
diff changeset
662 return;
f63b51e608fe Fix debug filtering on appended items.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33238
diff changeset
663
33537
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
664 dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(win->text));
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
665 body = webkit_dom_document_get_body(dom);
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
666 div = webkit_dom_node_get_last_child(WEBKIT_DOM_NODE(body));
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
667
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
668 if (webkit_dom_element_webkit_matches_selector(
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
669 WEBKIT_DOM_ELEMENT(div), "body>div:not(#pause)", NULL))
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
670 regex_match(win, dom, div);
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
671 }
33242
f63b51e608fe Fix debug filtering on appended items.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33238
diff changeset
672
33537
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
673 static gboolean debug_window_alert_cb(WebKitWebView *webview,
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
674 WebKitWebFrame *frame, gchar *message, gpointer _win)
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
675 {
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
676 DebugWindow *win = _win;
33242
f63b51e608fe Fix debug filtering on appended items.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33238
diff changeset
677
33537
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
678 if (!win || !win->window)
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
679 return FALSE;
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
680
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
681 if (g_strcmp0(message, "appended") == 0) {
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
682 debug_window_appended(win);
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
683 return TRUE;
33242
f63b51e608fe Fix debug filtering on appended items.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33238
diff changeset
684 }
33537
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
685
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
686 return FALSE;
33242
f63b51e608fe Fix debug filtering on appended items.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33238
diff changeset
687 }
f63b51e608fe Fix debug filtering on appended items.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33238
diff changeset
688
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
689 static DebugWindow *
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
690 debug_window_new(void)
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
691 {
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
692 DebugWindow *win;
5428
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
693 GtkWidget *vbox;
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
694 GtkWidget *toolbar;
10175
2bf5ed145e8a [gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents: 10087
diff changeset
695 GtkWidget *frame;
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
696 gint width, height;
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
697 void *handle;
29745
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
698 GtkToolItem *item;
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
699
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
700 win = g_new0(DebugWindow, 1);
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
701
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
702 width = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/width");
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
703 height = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/height");
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
704
29321
c089a3e0092e De-dialogify the file-transfer and debug windows.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29287
diff changeset
705 win->window = pidgin_create_window(_("Debug Window"), 0, "debug", TRUE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
706 purple_debug_info("gtkdebug", "Setting dimensions to %d, %d\n",
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
707 width, height);
5642
d7b8b62542a3 [gaim-migrate @ 6056]
Christian Hammond <chipx86@chipx86.com>
parents: 5636
diff changeset
708
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
709 gtk_window_set_default_size(GTK_WINDOW(win->window), width, height);
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
710
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
711 g_signal_connect(G_OBJECT(win->window), "delete_event",
11033
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 10739
diff changeset
712 G_CALLBACK(debug_window_destroy), NULL);
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
713 g_signal_connect(G_OBJECT(win->window), "configure_event",
11033
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 10739
diff changeset
714 G_CALLBACK(configure_cb), win);
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
715
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15512
diff changeset
716 handle = pidgin_debug_get_handle();
22099
8e70e3ba6096 Modified patch from Gabriel (Sylar?) Schulof to deprecate PIDGIN_DIALOG. Closes #4535. (PS: I am aware of --author).
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 21743
diff changeset
717
5428
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
718 /* Setup the vbox */
29321
c089a3e0092e De-dialogify the file-transfer and debug windows.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29287
diff changeset
719 vbox = gtk_vbox_new(FALSE, 0);
c089a3e0092e De-dialogify the file-transfer and debug windows.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 29287
diff changeset
720 gtk_container_add(GTK_CONTAINER(win->window), vbox);
5428
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
721
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
722 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/toolbar")) {
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
723 /* Setup our top button bar thingie. */
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
724 toolbar = gtk_toolbar_new();
14541
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
725 gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar), TRUE);
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
726 g_signal_connect(G_OBJECT(toolbar), "button-press-event", G_CALLBACK(toolbar_context), win);
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
727
11033
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 10739
diff changeset
728 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar),
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
729 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/style"));
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
730 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/style",
14541
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
731 toolbar_style_pref_changed_cb, toolbar);
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
732 gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar),
11033
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 10739
diff changeset
733 GTK_ICON_SIZE_SMALL_TOOLBAR);
5428
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
734
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
735 gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
5428
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
736
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
737 /* Save */
29745
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
738 item = gtk_tool_button_new_from_stock(GTK_STOCK_SAVE);
29747
4256b05bd720 Set debug window tool items to be "important" so that they show text when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29746
diff changeset
739 gtk_tool_item_set_is_important(item, TRUE);
29745
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
740 gtk_tool_item_set_tooltip_text(item, _("Save"));
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
741 g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(save_cb), win);
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
742 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
5428
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
743
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
744 /* Clear button */
29745
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
745 item = gtk_tool_button_new_from_stock(GTK_STOCK_CLEAR);
29747
4256b05bd720 Set debug window tool items to be "important" so that they show text when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29746
diff changeset
746 gtk_tool_item_set_is_important(item, TRUE);
29745
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
747 gtk_tool_item_set_tooltip_text(item, _("Clear"));
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
748 g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(clear_cb), win);
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
749 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
5428
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
750
29745
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
751 item = gtk_separator_tool_item_new();
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
752 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
5428
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
753
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
754 /* Pause */
29745
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
755 item = gtk_toggle_tool_button_new_from_stock(PIDGIN_STOCK_PAUSE);
29747
4256b05bd720 Set debug window tool items to be "important" so that they show text when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29746
diff changeset
756 gtk_tool_item_set_is_important(item, TRUE);
29745
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
757 gtk_tool_item_set_tooltip_text(item, _("Pause"));
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
758 g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(pause_cb), win);
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
759 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
5428
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
760
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
761 /* regex stuff */
29745
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
762 item = gtk_separator_tool_item_new();
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
763 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
11033
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 10739
diff changeset
764
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
765 /* regex toggle button */
29747
4256b05bd720 Set debug window tool items to be "important" so that they show text when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29746
diff changeset
766 item = gtk_toggle_tool_button_new_from_stock(GTK_STOCK_FIND);
4256b05bd720 Set debug window tool items to be "important" so that they show text when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29746
diff changeset
767 gtk_tool_item_set_is_important(item, TRUE);
4256b05bd720 Set debug window tool items to be "important" so that they show text when
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29746
diff changeset
768 win->filter = GTK_WIDGET(item);
29745
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
769 gtk_tool_button_set_label(GTK_TOOL_BUTTON(win->filter), _("Filter"));
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
770 gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(win->filter), _("Filter"));
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
771 g_signal_connect(G_OBJECT(win->filter), "clicked", G_CALLBACK(regex_filter_toggled_cb), win);
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
772 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(win->filter));
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
773
11450
52e566659430 [gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents: 11312
diff changeset
774 /* we purposely disable the toggle button here in case
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
775 * /purple/gtk/debug/expression has an empty string. If it does not have
11450
52e566659430 [gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents: 11312
diff changeset
776 * an empty string, the change signal will get called and make the
52e566659430 [gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents: 11312
diff changeset
777 * toggle button sensitive.
52e566659430 [gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents: 11312
diff changeset
778 */
52e566659430 [gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents: 11312
diff changeset
779 gtk_widget_set_sensitive(win->filter, FALSE);
29746
f7a7722bee2f Remove GTK_CHECK_VERSION(2,4,0) checks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29745
diff changeset
780 gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(win->filter),
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
781 purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/filter"));
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
782 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/filter",
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
783 regex_pref_filter_cb, win);
8953
6705ad4595b0 [gaim-migrate @ 9726]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 8735
diff changeset
784
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
785 /* regex entry */
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
786 win->expression = gtk_entry_new();
29745
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
787 item = gtk_tool_item_new();
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
788 gtk_widget_set_tooltip_text(win->expression, _("Right click for more options."));
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
789 gtk_container_add(GTK_CONTAINER(item), GTK_WIDGET(win->expression));
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
790 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
29746
f7a7722bee2f Remove GTK_CHECK_VERSION(2,4,0) checks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29745
diff changeset
791
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
792 /* this needs to be before the text is set from the pref if we want it
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
793 * to colorize a stored expression.
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
794 */
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
795 g_signal_connect(G_OBJECT(win->expression), "changed",
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
796 G_CALLBACK(regex_changed_cb), win);
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
797 gtk_entry_set_text(GTK_ENTRY(win->expression),
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
798 purple_prefs_get_string(PIDGIN_PREFS_ROOT "/debug/regex"));
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
799 g_signal_connect(G_OBJECT(win->expression), "populate-popup",
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
800 G_CALLBACK(regex_popup_cb), win);
11450
52e566659430 [gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents: 11312
diff changeset
801 g_signal_connect(G_OBJECT(win->expression), "key-release-event",
52e566659430 [gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents: 11312
diff changeset
802 G_CALLBACK(regex_key_release_cb), win);
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
803 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/regex",
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
804 regex_pref_expression_cb, win);
11033
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 10739
diff changeset
805
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
806 /* connect the rest of our pref callbacks */
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
807 win->invert = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/invert");
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
808 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/invert",
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
809 regex_pref_invert_cb, win);
11033
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 10739
diff changeset
810
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
811 win->highlight = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/highlight");
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
812 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/highlight",
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
813 regex_pref_highlight_cb, win);
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
814
29745
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
815 item = gtk_separator_tool_item_new();
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
816 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
14541
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
817
29745
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
818 item = gtk_tool_item_new();
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
819 gtk_container_add(GTK_CONTAINER(item), gtk_label_new(_("Level ")));
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
820 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
29746
f7a7722bee2f Remove GTK_CHECK_VERSION(2,4,0) checks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29745
diff changeset
821
33133
9a31f084f259 Fix some merge errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33132
diff changeset
822 win->filterlevel = gtk_combo_box_text_new();
29745
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
823 item = gtk_tool_item_new();
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
824 gtk_widget_set_tooltip_text(win->filterlevel, _("Select the debug filter level."));
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
825 gtk_container_add(GTK_CONTAINER(item), win->filterlevel);
ebf70b1934f1 New-fangled toolbar code and all that.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29694
diff changeset
826 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
29746
f7a7722bee2f Remove GTK_CHECK_VERSION(2,4,0) checks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29745
diff changeset
827
33133
9a31f084f259 Fix some merge errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33132
diff changeset
828 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(win->filterlevel), _("All"));
9a31f084f259 Fix some merge errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33132
diff changeset
829 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(win->filterlevel), _("Misc"));
9a31f084f259 Fix some merge errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33132
diff changeset
830 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(win->filterlevel), _("Info"));
9a31f084f259 Fix some merge errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33132
diff changeset
831 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(win->filterlevel), _("Warning"));
9a31f084f259 Fix some merge errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33132
diff changeset
832 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(win->filterlevel), _("Error "));
9a31f084f259 Fix some merge errors.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33132
diff changeset
833 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(win->filterlevel), _("Fatal Error"));
14541
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
834 gtk_combo_box_set_active(GTK_COMBO_BOX(win->filterlevel),
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
835 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/filterlevel"));
33092
a68f8b2b6873 Always use GRegex in the Debug Window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33091
diff changeset
836
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
837 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/filterlevel",
14541
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
838 filter_level_pref_changed, win);
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
839 g_signal_connect(G_OBJECT(win->filterlevel), "changed",
b4b96a041230 [gaim-migrate @ 17198]
Peter McCurdy <cpirate@users.sourceforge.net>
parents: 14253
diff changeset
840 G_CALLBACK(filter_level_changed_cb), NULL);
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
841 }
5428
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
842
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
843 /* Add the gtkwebview */
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
844 frame = pidgin_create_webview(FALSE, &win->text, NULL, NULL);
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
845 gtk_webview_set_format_functions(GTK_WEBVIEW(win->text),
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
846 GTK_WEBVIEW_ALL ^ GTK_WEBVIEW_SMILEY ^ GTK_WEBVIEW_IMAGE);
33247
d8d6e87ce594 Add autoscrolling for the debug window.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33242
diff changeset
847 gtk_webview_set_autoscroll(GTK_WEBVIEW(win->text), TRUE);
33919
9f3f19ab8342 Rewrite debug window clearing in JS.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33683
diff changeset
848 gtk_webview_load_html_string(GTK_WEBVIEW(win->text), EMPTY_HTML);
10175
2bf5ed145e8a [gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents: 10087
diff changeset
849 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
2bf5ed145e8a [gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents: 10087
diff changeset
850 gtk_widget_show(frame);
5428
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
851
33537
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
852 g_signal_connect(G_OBJECT(win->text), "script-alert",
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
853 G_CALLBACK(debug_window_alert_cb), win);
33242
f63b51e608fe Fix debug filtering on appended items.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33238
diff changeset
854
33111
e05551721abf Obey the filter level when the Debug Window is first opened.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33110
diff changeset
855 clear_cb(NULL, win);
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
856
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
857 gtk_widget_show_all(win->window);
5428
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
858
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
859 return win;
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
860 }
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
861
17232
8593d66c708b When the /pidgin/debug/enabled pref is toggled, wait until the next
Mark Doliner <markdoliner@pidgin.im>
parents: 17040
diff changeset
862 static gboolean
8593d66c708b When the /pidgin/debug/enabled pref is toggled, wait until the next
Mark Doliner <markdoliner@pidgin.im>
parents: 17040
diff changeset
863 debug_enabled_timeout_cb(gpointer data)
8593d66c708b When the /pidgin/debug/enabled pref is toggled, wait until the next
Mark Doliner <markdoliner@pidgin.im>
parents: 17040
diff changeset
864 {
8593d66c708b When the /pidgin/debug/enabled pref is toggled, wait until the next
Mark Doliner <markdoliner@pidgin.im>
parents: 17040
diff changeset
865 debug_enabled_timer = 0;
8593d66c708b When the /pidgin/debug/enabled pref is toggled, wait until the next
Mark Doliner <markdoliner@pidgin.im>
parents: 17040
diff changeset
866
8593d66c708b When the /pidgin/debug/enabled pref is toggled, wait until the next
Mark Doliner <markdoliner@pidgin.im>
parents: 17040
diff changeset
867 if (data)
8593d66c708b When the /pidgin/debug/enabled pref is toggled, wait until the next
Mark Doliner <markdoliner@pidgin.im>
parents: 17040
diff changeset
868 pidgin_debug_window_show();
8593d66c708b When the /pidgin/debug/enabled pref is toggled, wait until the next
Mark Doliner <markdoliner@pidgin.im>
parents: 17040
diff changeset
869 else
8593d66c708b When the /pidgin/debug/enabled pref is toggled, wait until the next
Mark Doliner <markdoliner@pidgin.im>
parents: 17040
diff changeset
870 pidgin_debug_window_hide();
8593d66c708b When the /pidgin/debug/enabled pref is toggled, wait until the next
Mark Doliner <markdoliner@pidgin.im>
parents: 17040
diff changeset
871
8593d66c708b When the /pidgin/debug/enabled pref is toggled, wait until the next
Mark Doliner <markdoliner@pidgin.im>
parents: 17040
diff changeset
872 return FALSE;
8593d66c708b When the /pidgin/debug/enabled pref is toggled, wait until the next
Mark Doliner <markdoliner@pidgin.im>
parents: 17040
diff changeset
873 }
8593d66c708b When the /pidgin/debug/enabled pref is toggled, wait until the next
Mark Doliner <markdoliner@pidgin.im>
parents: 17040
diff changeset
874
5625
ac8c09def58a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
875 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
876 debug_enabled_cb(const char *name, PurplePrefType type,
12816
5f93e09fa9a6 [gaim-migrate @ 15164]
Mark Doliner <markdoliner@pidgin.im>
parents: 12231
diff changeset
877 gconstpointer value, gpointer data)
5625
ac8c09def58a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
878 {
17232
8593d66c708b When the /pidgin/debug/enabled pref is toggled, wait until the next
Mark Doliner <markdoliner@pidgin.im>
parents: 17040
diff changeset
879 debug_enabled_timer = g_timeout_add(0, debug_enabled_timeout_cb, GINT_TO_POINTER(GPOINTER_TO_INT(value)));
5625
ac8c09def58a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
880 }
ac8c09def58a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
881
7150
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
882 static void
15880
d275b025481c More Gaim to Pidgin changes
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
883 pidgin_glib_log_handler(const gchar *domain, GLogLevelFlags flags,
7150
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
884 const gchar *msg, gpointer user_data)
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
885 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
886 PurpleDebugLevel level;
7150
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
887 char *new_msg = NULL;
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
888 char *new_domain = NULL;
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
889
7152
112d0e52d04b [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
890 if ((flags & G_LOG_LEVEL_ERROR) == G_LOG_LEVEL_ERROR)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
891 level = PURPLE_DEBUG_ERROR;
7152
112d0e52d04b [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
892 else if ((flags & G_LOG_LEVEL_CRITICAL) == G_LOG_LEVEL_CRITICAL)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
893 level = PURPLE_DEBUG_FATAL;
7152
112d0e52d04b [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
894 else if ((flags & G_LOG_LEVEL_WARNING) == G_LOG_LEVEL_WARNING)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
895 level = PURPLE_DEBUG_WARNING;
7152
112d0e52d04b [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
896 else if ((flags & G_LOG_LEVEL_MESSAGE) == G_LOG_LEVEL_MESSAGE)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
897 level = PURPLE_DEBUG_INFO;
7152
112d0e52d04b [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
898 else if ((flags & G_LOG_LEVEL_INFO) == G_LOG_LEVEL_INFO)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
899 level = PURPLE_DEBUG_INFO;
7152
112d0e52d04b [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
900 else if ((flags & G_LOG_LEVEL_DEBUG) == G_LOG_LEVEL_DEBUG)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
901 level = PURPLE_DEBUG_MISC;
7152
112d0e52d04b [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
902 else
112d0e52d04b [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
903 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
904 purple_debug_warning("gtkdebug",
7150
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
905 "Unknown glib logging level in %d\n", flags);
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
906
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
907 level = PURPLE_DEBUG_MISC; /* This will never happen. */
7150
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
908 }
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
909
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
910 if (msg != NULL)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
911 new_msg = purple_utf8_try_convert(msg);
7150
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
912
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
913 if (domain != NULL)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
914 new_domain = purple_utf8_try_convert(domain);
7150
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
915
7152
112d0e52d04b [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
916 if (new_msg != NULL)
112d0e52d04b [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
917 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
918 purple_debug(level, (new_domain != NULL ? new_domain : "g_log"),
7152
112d0e52d04b [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
919 "%s\n", new_msg);
7150
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
920
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
921 g_free(new_msg);
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
922 }
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
923
14097
0c340861ab79 [gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents: 13988
diff changeset
924 g_free(new_domain);
7150
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
925 }
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
926
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
927 #ifdef _WIN32
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
928 static void
15880
d275b025481c More Gaim to Pidgin changes
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
929 pidgin_glib_dummy_print_handler(const gchar *string)
7150
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
930 {
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
931 }
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
932 #endif
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
933
5625
ac8c09def58a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
934 void
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15512
diff changeset
935 pidgin_debug_init(void)
5625
ac8c09def58a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
936 {
5684
10b916deb20c [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
937 /* Debug window preferences. */
10b916deb20c [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
938 /*
10b916deb20c [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
939 * NOTE: This must be set before prefs are loaded, and the callbacks
10b916deb20c [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
940 * set after they are loaded, since prefs sets the enabled
10b916deb20c [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
941 * preference here and that loads the window, which calls the
8735
01248ea222d3 [gaim-migrate @ 9490]
Jonathan Champ <royanee@users.sourceforge.net>
parents: 8046
diff changeset
942 * configure event, which overrides the width and height! :P
5684
10b916deb20c [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
943 */
10b916deb20c [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
944
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
945 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/debug");
10307
f3ba80364053 [gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents: 10297
diff changeset
946
f3ba80364053 [gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents: 10297
diff changeset
947 /* Controls printing to the debug window */
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
948 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/debug/enabled", FALSE);
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
949 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/debug/filterlevel", PURPLE_DEBUG_ALL);
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
950 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/debug/style", GTK_TOOLBAR_BOTH_HORIZ);
10307
f3ba80364053 [gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents: 10297
diff changeset
951
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
952 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/debug/toolbar", TRUE);
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
953 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/debug/width", 450);
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
954 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/debug/height", 250);
5684
10b916deb20c [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
955
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
956 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/debug/regex", "");
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
957 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/debug/filter", FALSE);
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
958 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/debug/invert", FALSE);
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
959 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/debug/case_insensitive", FALSE);
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
960 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/debug/highlight", FALSE);
11256
fe82a0c5e5ec [gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents: 11243
diff changeset
961
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
962 purple_prefs_connect_callback(NULL, PIDGIN_PREFS_ROOT "/debug/enabled",
5794
ebdbb7dc6658 [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5738
diff changeset
963 debug_enabled_cb, NULL);
7150
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
964
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
965 #define REGISTER_G_LOG_HANDLER(name) \
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
966 g_log_set_handler((name), G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL \
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
967 | G_LOG_FLAG_RECURSION, \
15880
d275b025481c More Gaim to Pidgin changes
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
968 pidgin_glib_log_handler, NULL)
7150
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
969
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
970 /* Register the glib/gtk log handlers. */
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
971 REGISTER_G_LOG_HANDLER(NULL);
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
972 REGISTER_G_LOG_HANDLER("Gdk");
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
973 REGISTER_G_LOG_HANDLER("Gtk");
7229
0f85b503c030 [gaim-migrate @ 7799]
Herman Bloggs <herman@bluedigits.com>
parents: 7152
diff changeset
974 REGISTER_G_LOG_HANDLER("GdkPixbuf");
7150
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
975 REGISTER_G_LOG_HANDLER("GLib");
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
976 REGISTER_G_LOG_HANDLER("GModule");
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
977 REGISTER_G_LOG_HANDLER("GLib-GObject");
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
978 REGISTER_G_LOG_HANDLER("GThread");
33532
66962f44ff47 Add JSON debug messages to our log
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33501
diff changeset
979 REGISTER_G_LOG_HANDLER("Json");
21743
7a0caaf628ff applied changes from 10f341962a83e2380243c4e44bb685105e3091a2
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21630
diff changeset
980 #ifdef USE_GSTREAMER
7a0caaf628ff applied changes from 10f341962a83e2380243c4e44bb685105e3091a2
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21630
diff changeset
981 REGISTER_G_LOG_HANDLER("GStreamer");
7a0caaf628ff applied changes from 10f341962a83e2380243c4e44bb685105e3091a2
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21630
diff changeset
982 #endif
7150
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
983
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
984 #ifdef _WIN32
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
985 if (!purple_debug_is_enabled())
15880
d275b025481c More Gaim to Pidgin changes
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
986 g_set_print_handler(pidgin_glib_dummy_print_handler);
7150
25deb3b41da3 [gaim-migrate @ 7717]
Sean Egan <seanegan@pidgin.im>
parents: 7108
diff changeset
987 #endif
5625
ac8c09def58a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
988 }
ac8c09def58a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
989
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
990 void
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15512
diff changeset
991 pidgin_debug_uninit(void)
11033
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 10739
diff changeset
992 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
993 purple_debug_set_ui_ops(NULL);
17232
8593d66c708b When the /pidgin/debug/enabled pref is toggled, wait until the next
Mark Doliner <markdoliner@pidgin.im>
parents: 17040
diff changeset
994
8593d66c708b When the /pidgin/debug/enabled pref is toggled, wait until the next
Mark Doliner <markdoliner@pidgin.im>
parents: 17040
diff changeset
995 if (debug_enabled_timer != 0)
8593d66c708b When the /pidgin/debug/enabled pref is toggled, wait until the next
Mark Doliner <markdoliner@pidgin.im>
parents: 17040
diff changeset
996 g_source_remove(debug_enabled_timer);
11033
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 10739
diff changeset
997 }
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 10739
diff changeset
998
dc68e074f10d [gaim-migrate @ 12919]
Etan Reisner <deryni@pidgin.im>
parents: 10739
diff changeset
999 void
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15512
diff changeset
1000 pidgin_debug_window_show(void)
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1001 {
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1002 if (debug_win == NULL)
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1003 debug_win = debug_window_new();
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1004
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1005 gtk_widget_show(debug_win->window);
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
1006
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
1007 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/debug/enabled", TRUE);
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1008 }
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1009
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1010 void
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15512
diff changeset
1011 pidgin_debug_window_hide(void)
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1012 {
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1013 if (debug_win != NULL) {
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1014 gtk_widget_destroy(debug_win->window);
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1015 debug_window_destroy(NULL, NULL, NULL);
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1016 }
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1017 }
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1018
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1019 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
1020 pidgin_debug_print(PurpleDebugLevel level, const char *category,
33537
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
1021 const char *arg_s)
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1022 {
33537
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
1023 gchar *esc_s;
17040
cb33027a36e4 Force timestamps always on for debug log and debug window. Making this
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16752
diff changeset
1024 const char *mdate;
cb33027a36e4 Force timestamps always on for debug log and debug window. Making this
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16752
diff changeset
1025 time_t mtime;
33537
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
1026 gchar *js;
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
1027
33537
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
1028 if (debug_win == NULL)
10307
f3ba80364053 [gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents: 10297
diff changeset
1029 return;
33537
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
1030 if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/enabled"))
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
1031 return;
10307
f3ba80364053 [gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents: 10297
diff changeset
1032
17040
cb33027a36e4 Force timestamps always on for debug log and debug window. Making this
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16752
diff changeset
1033 mtime = time(NULL);
cb33027a36e4 Force timestamps always on for debug log and debug window. Making this
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16752
diff changeset
1034 mdate = purple_utf8_strftime("%H:%M:%S", localtime(&mtime));
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1035
33537
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
1036 esc_s = purple_escape_js(arg_s);
5428
5788d3bc050a [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
1037
33538
cbeb76707f12 Better implementation of purple_escape_js
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33537
diff changeset
1038 js = g_strdup_printf("append(%d, '%s', '%s', %s);",
33537
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
1039 level, mdate, category ? category : "", esc_s);
10307
f3ba80364053 [gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents: 10297
diff changeset
1040 g_free(esc_s);
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1041
33537
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
1042 gtk_webview_safe_execute_script(GTK_WEBVIEW(debug_win->text), js);
4998e86453d0 GTK debug window: append using js, not html
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33532
diff changeset
1043 g_free(js);
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1044 }
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1045
16044
257072807aa8 Add a whimpy ui op to the debug API that returns TRUE if debugging
Mark Doliner <markdoliner@pidgin.im>
parents: 15931
diff changeset
1046 static gboolean
257072807aa8 Add a whimpy ui op to the debug API that returns TRUE if debugging
Mark Doliner <markdoliner@pidgin.im>
parents: 15931
diff changeset
1047 pidgin_debug_is_enabled(PurpleDebugLevel level, const char *category)
257072807aa8 Add a whimpy ui op to the debug API that returns TRUE if debugging
Mark Doliner <markdoliner@pidgin.im>
parents: 15931
diff changeset
1048 {
16045
d9add5eda4cd Check if debug_win is != NULL before checking the preference. This
Mark Doliner <markdoliner@pidgin.im>
parents: 16044
diff changeset
1049 return (debug_win != NULL &&
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16045
diff changeset
1050 purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/enabled"));
16044
257072807aa8 Add a whimpy ui op to the debug API that returns TRUE if debugging
Mark Doliner <markdoliner@pidgin.im>
parents: 15931
diff changeset
1051 }
257072807aa8 Add a whimpy ui op to the debug API that returns TRUE if debugging
Mark Doliner <markdoliner@pidgin.im>
parents: 15931
diff changeset
1052
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
1053 static PurpleDebugUiOps ops =
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1054 {
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15512
diff changeset
1055 pidgin_debug_print,
16752
e6bcb1628c57 Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 16490
diff changeset
1056 pidgin_debug_is_enabled,
e6bcb1628c57 Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 16490
diff changeset
1057 NULL,
e6bcb1628c57 Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 16490
diff changeset
1058 NULL,
e6bcb1628c57 Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 16490
diff changeset
1059 NULL,
e6bcb1628c57 Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents: 16490
diff changeset
1060 NULL
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1061 };
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1062
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
1063 PurpleDebugUiOps *
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15512
diff changeset
1064 pidgin_debug_get_ui_ops(void)
5212
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1065 {
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1066 return &ops;
ad90ea13028b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1067 }
10087
e5b80a38939d [gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9791
diff changeset
1068
e5b80a38939d [gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9791
diff changeset
1069 void *
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15512
diff changeset
1070 pidgin_debug_get_handle() {
10087
e5b80a38939d [gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9791
diff changeset
1071 static int handle;
e5b80a38939d [gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9791
diff changeset
1072
e5b80a38939d [gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9791
diff changeset
1073 return &handle;
e5b80a38939d [gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9791
diff changeset
1074 }
33095
1e0b4fac0fed Convert the Debug Window to a GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33094
diff changeset
1075

mercurial