Mercurial > pidgin.yaz
annotate src/gtkdebug.c @ 11429:835dbb1b3337
[gaim-migrate @ 13666]
use async dns
committer: Tailor Script <tailor@pidgin.im>
author | Thomas Butter <tbutter> |
---|---|
date | Fri, 02 Sep 2005 19:48:26 +0000 |
parents | a546498f7adc |
children | b7978afe81d0 |
rev | line source |
---|---|
5212 | 1 /** |
2 * @file gtkdebug.c GTK+ Debug API | |
3 * @ingroup gtkui | |
4 * | |
5 * gaim | |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
10 * |
5212 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
9791 | 25 #include "internal.h" |
26 #include "gtkgaim.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5818
diff
changeset
|
27 |
9480 | 28 #include "notify.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5818
diff
changeset
|
29 #include "prefs.h" |
8953 | 30 #include "request.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5818
diff
changeset
|
31 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5818
diff
changeset
|
32 |
5212 | 33 #include "gtkdebug.h" |
9709 | 34 #include "gtkdialogs.h" |
5212 | 35 #include "gtkimhtml.h" |
8953 | 36 #include "gtkutils.h" |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10175
diff
changeset
|
37 #include "gtkstock.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5818
diff
changeset
|
38 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
39 #ifdef HAVE_REGEX_H |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
40 # include <regex.h> |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
41 #endif /* HAVE_REGEX_H */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
42 |
5212 | 43 typedef struct |
44 { | |
45 GtkWidget *window; | |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
46 GtkWidget *text; |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
47 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
48 GtkListStore *store; |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
49 |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
50 gboolean timestamps; |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
51 gboolean paused; |
5212 | 52 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
53 #ifdef HAVE_REGEX_H |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
54 GtkWidget *filter; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
55 GtkWidget *expression; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
56 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
57 gboolean invert; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
58 gboolean highlight; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
59 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
60 guint timer; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
61 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
62 regex_t regex; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
63 #else |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
64 GtkWidget *find; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
65 #endif /* HAVE_REGEX_H */ |
5212 | 66 } DebugWindow; |
67 | |
68 static char debug_fg_colors[][8] = { | |
69 "#000000", /**< All debug levels. */ | |
7150 | 70 "#666666", /**< Misc. */ |
5212 | 71 "#000000", /**< Information. */ |
72 "#660000", /**< Warnings. */ | |
73 "#FF0000", /**< Errors. */ | |
74 "#FF0000", /**< Fatal errors. */ | |
75 }; | |
76 | |
77 static DebugWindow *debug_win = NULL; | |
78 | |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
79 #ifdef HAVE_REGEX_H |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
80 static void regex_filter_all(DebugWindow *win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
81 static void regex_show_all(DebugWindow *win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
82 #endif /* HAVE_REGEX_H */ |
8953 | 83 |
5212 | 84 static gint |
85 debug_window_destroy(GtkWidget *w, GdkEvent *event, void *unused) | |
86 { | |
10087 | 87 gaim_prefs_disconnect_by_handle(gaim_gtk_debug_get_handle()); |
9502 | 88 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
89 #ifdef HAVE_REGEX_H |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
90 if(debug_win->timer != 0) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
91 const gchar *text; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
92 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
93 g_source_remove(debug_win->timer); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
94 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
95 text = gtk_entry_get_text(GTK_ENTRY(debug_win->expression)); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
96 gaim_prefs_set_string("/gaim/gtk/debug/regex", text); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
97 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
98 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
99 regfree(&debug_win->regex); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
100 #endif |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
101 |
9502 | 102 /* If the "Save Log" dialog is open then close it */ |
103 gaim_request_close_with_handle(debug_win); | |
5704
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
104 |
5212 | 105 g_free(debug_win); |
106 debug_win = NULL; | |
107 | |
9480 | 108 gaim_prefs_set_bool("/gaim/gtk/debug/enabled", FALSE); |
109 | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
110 return FALSE; |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
111 } |
5212 | 112 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
113 static gboolean |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5738
diff
changeset
|
114 configure_cb(GtkWidget *w, GdkEventConfigure *event, DebugWindow *win) |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
115 { |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
116 if (GTK_WIDGET_VISIBLE(w)) { |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
117 gaim_prefs_set_int("/gaim/gtk/debug/width", event->width); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
118 gaim_prefs_set_int("/gaim/gtk/debug/height", event->height); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
119 } |
5212 | 120 |
121 return FALSE; | |
122 } | |
123 | |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
124 #ifndef HAVE_REGEX_H |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
125 struct _find { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
126 DebugWindow *window; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
127 GtkWidget *entry; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
128 }; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
129 |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
130 static void |
9482 | 131 do_find_cb(GtkWidget *widget, gint response, struct _find *f) |
8953 | 132 { |
9482 | 133 switch (response) { |
8953 | 134 case GTK_RESPONSE_OK: |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
135 gtk_imhtml_search_find(GTK_IMHTML(f->window->text), |
8953 | 136 gtk_entry_get_text(GTK_ENTRY(f->entry))); |
137 break; | |
138 | |
139 case GTK_RESPONSE_DELETE_EVENT: | |
140 case GTK_RESPONSE_CLOSE: | |
141 gtk_imhtml_search_clear(GTK_IMHTML(f->window->text)); | |
142 gtk_widget_destroy(f->window->find); | |
143 f->window->find = NULL; | |
144 g_free(f); | |
145 break; | |
146 } | |
147 } | |
148 | |
149 static void | |
150 find_cb(GtkWidget *w, DebugWindow *win) | |
151 { | |
152 GtkWidget *hbox, *img, *label; | |
153 struct _find *f; | |
154 | |
155 if(win->find) | |
156 { | |
157 gtk_window_present(GTK_WINDOW(win->find)); | |
158 return; | |
159 } | |
160 | |
161 f = g_malloc(sizeof(struct _find)); | |
162 f->window = win; | |
163 win->find = gtk_dialog_new_with_buttons(_("Find"), | |
164 GTK_WINDOW(win->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
165 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
166 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
167 gtk_dialog_set_default_response(GTK_DIALOG(win->find), | |
168 GTK_RESPONSE_OK); | |
169 g_signal_connect(G_OBJECT(win->find), "response", | |
170 G_CALLBACK(do_find_cb), f); | |
171 | |
11243 | 172 gtk_container_set_border_width(GTK_CONTAINER(win->find), GAIM_HIG_BOX_SPACE); |
8953 | 173 gtk_window_set_resizable(GTK_WINDOW(win->find), FALSE); |
174 gtk_dialog_set_has_separator(GTK_DIALOG(win->find), FALSE); | |
11243 | 175 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(win->find)->vbox), GAIM_HIG_BORDER); |
8953 | 176 gtk_container_set_border_width( |
11243 | 177 GTK_CONTAINER(GTK_DIALOG(win->find)->vbox), GAIM_HIG_BOX_SPACE); |
8953 | 178 |
11243 | 179 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
8953 | 180 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(win->find)->vbox), |
181 hbox); | |
182 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, | |
183 GTK_ICON_SIZE_DIALOG); | |
184 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
185 | |
186 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
187 gtk_dialog_set_response_sensitive(GTK_DIALOG(win->find), | |
188 GTK_RESPONSE_OK, FALSE); | |
189 | |
190 label = gtk_label_new(NULL); | |
191 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); | |
192 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
193 | |
194 f->entry = gtk_entry_new(); | |
195 gtk_entry_set_activates_default(GTK_ENTRY(f->entry), TRUE); | |
196 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(f->entry)); | |
197 g_signal_connect(G_OBJECT(f->entry), "changed", | |
198 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
199 win->find); | |
200 gtk_box_pack_start(GTK_BOX(hbox), f->entry, FALSE, FALSE, 0); | |
201 | |
202 gtk_widget_show_all(win->find); | |
203 gtk_widget_grab_focus(f->entry); | |
204 } | |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
205 #endif /* HAVE_REGEX_H */ |
8953 | 206 |
207 static void | |
9502 | 208 save_writefile_cb(void *user_data, const char *filename) |
8953 | 209 { |
9502 | 210 DebugWindow *win = (DebugWindow *)user_data; |
9489 | 211 FILE *fp; |
8953 | 212 char *tmp; |
213 | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10448
diff
changeset
|
214 if ((fp = g_fopen(filename, "w+")) == NULL) { |
9502 | 215 gaim_notify_error(win, NULL, _("Unable to open file."), NULL); |
8953 | 216 return; |
9480 | 217 } |
8953 | 218 |
9489 | 219 tmp = gtk_imhtml_get_text(GTK_IMHTML(win->text), NULL, NULL); |
8953 | 220 fprintf(fp, "Gaim Debug log : %s\n", gaim_date_full()); |
221 fprintf(fp, "%s", tmp); | |
222 g_free(tmp); | |
223 | |
224 fclose(fp); | |
225 } | |
226 | |
227 static void | |
228 save_cb(GtkWidget *w, DebugWindow *win) | |
229 { | |
9502 | 230 gaim_request_file(win, _("Save Debug Log"), "gaim-debug.log", TRUE, |
231 G_CALLBACK(save_writefile_cb), NULL, win); | |
8953 | 232 } |
233 | |
234 static void | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5738
diff
changeset
|
235 clear_cb(GtkWidget *w, DebugWindow *win) |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
236 { |
6280
d330afe3ccf0
[gaim-migrate @ 6779]
Christian Hammond <chipx86@chipx86.com>
parents:
6094
diff
changeset
|
237 gtk_imhtml_clear(GTK_IMHTML(win->text)); |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
238 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
239 #ifdef HAVE_REGEX_H |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
240 gtk_list_store_clear(win->store); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
241 #endif /* HAVE_REGEX_H */ |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
242 } |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
243 |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
244 static void |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5738
diff
changeset
|
245 pause_cb(GtkWidget *w, DebugWindow *win) |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
246 { |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
247 win->paused = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)); |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
248 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
249 #ifdef HAVE_REGEX_H |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
250 if(!win->paused) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
251 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
252 regex_filter_all(win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
253 else |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
254 regex_show_all(win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
255 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
256 #endif /* HAVE_REGEX_H */ |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
257 } |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
258 |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
259 static void |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5738
diff
changeset
|
260 timestamps_cb(GtkWidget *w, DebugWindow *win) |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
261 { |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
262 win->timestamps = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
263 |
10307 | 264 gaim_prefs_set_bool("/core/debug/timestamps", win->timestamps); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
265 } |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
266 |
5704
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
267 static void |
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
268 timestamps_pref_cb(const char *name, GaimPrefType type, gpointer value, |
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
269 gpointer data) |
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
270 { |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
271 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data), GPOINTER_TO_INT(value)); |
5704
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
272 } |
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
273 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
274 /****************************************************************************** |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
275 * regex stuff |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
276 *****************************************************************************/ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
277 #ifdef HAVE_REGEX_H |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
278 static void |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
279 regex_clear_color(GtkWidget *w) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
280 gtk_widget_modify_base(w, GTK_STATE_NORMAL, NULL); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
281 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
282 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
283 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
284 regex_change_color(GtkWidget *w, guint16 r, guint16 g, guint16 b) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
285 GdkColor color; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
286 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
287 color.red = r; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
288 color.green = g; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
289 color.blue = b; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
290 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
291 gtk_widget_modify_base(w, GTK_STATE_NORMAL, &color); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
292 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
293 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
294 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
295 regex_highlight_clear(DebugWindow *win) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
296 GtkIMHtml *imhtml = GTK_IMHTML(win->text); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
297 GtkTextIter s, e; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
298 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
299 gtk_text_buffer_get_start_iter(imhtml->text_buffer, &s); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
300 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &e); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
301 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "regex", &s, &e); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
302 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
303 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
304 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
305 regex_match(DebugWindow *win, const gchar *text) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
306 GtkIMHtml *imhtml = GTK_IMHTML(win->text); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
307 regmatch_t matches[4]; /* adjust if necessary */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
308 size_t n_matches = sizeof(matches) / sizeof(matches[0]); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
309 gchar *plaintext; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
310 gint inverted; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
311 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
312 if(!text) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
313 return; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
314 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
315 inverted = (win->invert) ? REG_NOMATCH : 0; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
316 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
317 /* I don't like having to do this, but we need it for highlighting. Plus |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
318 * it makes the ^ and $ operators work :) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
319 */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
320 plaintext = gaim_markup_strip_html(text); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
321 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
322 /* we do a first pass to see if it matches at all. If it does we append |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
323 * it, and work out the offsets to highlight. |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
324 */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
325 if(regexec(&win->regex, plaintext, n_matches, matches, 0) == inverted) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
326 GtkTextIter ins; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
327 gchar *p = plaintext; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
328 gint i, offset = 0; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
329 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
330 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &ins, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
331 gtk_text_buffer_get_insert(imhtml->text_buffer)); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
332 i = gtk_text_iter_get_offset(&ins); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
333 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
334 gtk_imhtml_append_text(imhtml, text, 0); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
335 |
11312
a546498f7adc
[gaim-migrate @ 13512]
Gary Kramlich <grim@reaperworld.com>
parents:
11311
diff
changeset
|
336 /* If we're not highlighting or the expression is inverted, we're |
11311
674abdc2b9be
[gaim-migrate @ 13511]
Gary Kramlich <grim@reaperworld.com>
parents:
11310
diff
changeset
|
337 * done and move on. |
11310
0058b0737e76
[gaim-migrate @ 13510]
Gary Kramlich <grim@reaperworld.com>
parents:
11262
diff
changeset
|
338 */ |
0058b0737e76
[gaim-migrate @ 13510]
Gary Kramlich <grim@reaperworld.com>
parents:
11262
diff
changeset
|
339 if(!win->highlight || inverted == REG_NOMATCH) { |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
340 g_free(plaintext); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
341 return; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
342 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
343 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
344 /* we use a do-while to highlight the first match, and then continue |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
345 * if necessary... |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
346 */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
347 do { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
348 gint m; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
349 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
350 for(m = 0; m < n_matches; m++) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
351 GtkTextIter ms, me; |
11310
0058b0737e76
[gaim-migrate @ 13510]
Gary Kramlich <grim@reaperworld.com>
parents:
11262
diff
changeset
|
352 |
0058b0737e76
[gaim-migrate @ 13510]
Gary Kramlich <grim@reaperworld.com>
parents:
11262
diff
changeset
|
353 if(matches[m].rm_eo == -1) |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
354 break; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
355 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
356 i += offset; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
357 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
358 gtk_text_buffer_get_iter_at_offset(imhtml->text_buffer, &ms, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
359 i + matches[m].rm_so); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
360 gtk_text_buffer_get_iter_at_offset(imhtml->text_buffer, &me, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
361 i + matches[m].rm_eo); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
362 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "regex", |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
363 &ms, &me); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
364 offset = matches[m].rm_eo; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
365 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
366 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
367 p += offset; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
368 } while(regexec(&win->regex, p, n_matches, matches, REG_NOTBOL) == inverted); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
369 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
370 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
371 g_free(plaintext); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
372 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
373 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
374 static gboolean |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
375 regex_filter_all_cb(GtkTreeModel *m, GtkTreePath *p, GtkTreeIter *iter, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
376 gpointer data) |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
377 { |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
378 DebugWindow *win = (DebugWindow *)data; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
379 gchar *text; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
380 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
381 gtk_tree_model_get(m, iter, 0, &text, -1); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
382 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
383 regex_match(win, text); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
384 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
385 g_free(text); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
386 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
387 return FALSE; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
388 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
389 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
390 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
391 regex_filter_all(DebugWindow *win) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
392 gtk_imhtml_clear(GTK_IMHTML(win->text)); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
393 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
394 if(win->highlight) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
395 regex_highlight_clear(win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
396 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
397 gtk_tree_model_foreach(GTK_TREE_MODEL(win->store), regex_filter_all_cb, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
398 win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
399 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
400 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
401 static gboolean |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
402 regex_show_all_cb(GtkTreeModel *m, GtkTreePath *p, GtkTreeIter *iter, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
403 gpointer data) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
404 { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
405 DebugWindow *win = (DebugWindow *)data; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
406 gchar *text; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
407 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
408 gtk_tree_model_get(m, iter, 0, &text, -1); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
409 gtk_imhtml_append_text(GTK_IMHTML(win->text), text, 0); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
410 g_free(text); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
411 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
412 return FALSE; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
413 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
414 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
415 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
416 regex_show_all(DebugWindow *win) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
417 gtk_imhtml_clear(GTK_IMHTML(win->text)); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
418 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
419 if(win->highlight) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
420 regex_highlight_clear(win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
421 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
422 gtk_tree_model_foreach(GTK_TREE_MODEL(win->store), regex_show_all_cb, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
423 win); |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
424 } |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
425 |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
426 static void |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
427 regex_compile(DebugWindow *win) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
428 const gchar *text; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
429 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
430 text = gtk_entry_get_text(GTK_ENTRY(win->expression)); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
431 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
432 if(text == NULL || *text == '\0') { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
433 regex_clear_color(win->expression); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
434 gtk_widget_set_sensitive(win->filter, FALSE); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
435 return; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
436 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
437 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
438 regfree(&win->regex); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
439 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
440 if(regcomp(&win->regex, text, REG_EXTENDED | REG_ICASE) != 0) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
441 /* failed to compile */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
442 regex_change_color(win->expression, 0xFFFF, 0xAFFF, 0xAFFF); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
443 gtk_widget_set_sensitive(win->filter, FALSE); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
444 } else { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
445 /* compiled successfully */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
446 regex_change_color(win->expression, 0xAFFF, 0xFFFF, 0xAFFF); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
447 gtk_widget_set_sensitive(win->filter, TRUE); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
448 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
449 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
450 /* we check if the filter is on in case it was only of the options that |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
451 * got changed, and not the expression. |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
452 */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
453 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
454 regex_filter_all(win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
455 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
456 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
457 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
458 regex_pref_filter_cb(const gchar *name, GaimPrefType type, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
459 gpointer val, gpointer data) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
460 { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
461 DebugWindow *win = (DebugWindow *)data; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
462 gboolean active = GPOINTER_TO_INT(val), current; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
463 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
464 if(!win || !win->window) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
465 return; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
466 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
467 current = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter)); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
468 if(active != current) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
469 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter), active); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
470 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
471 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
472 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
473 regex_pref_expression_cb(const gchar *name, GaimPrefType type, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
474 gpointer val, gpointer data) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
475 { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
476 DebugWindow *win = (DebugWindow *)data; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
477 const gchar *exp = (const gchar *)val; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
478 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
479 gtk_entry_set_text(GTK_ENTRY(win->expression), exp); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
480 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
481 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
482 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
483 regex_pref_invert_cb(const gchar *name, GaimPrefType type, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
484 gpointer val, gpointer data) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
485 { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
486 DebugWindow *win = (DebugWindow *)data; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
487 gboolean active = GPOINTER_TO_INT(val); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
488 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
489 win->invert = active; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
490 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
491 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
492 regex_filter_all(win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
493 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
494 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
495 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
496 regex_pref_highlight_cb(const gchar *name, GaimPrefType type, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
497 gpointer val, gpointer data) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
498 { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
499 DebugWindow *win = (DebugWindow *)data; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
500 gboolean active = GPOINTER_TO_INT(val); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
501 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
502 win->highlight = active; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
503 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
504 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
505 regex_filter_all(win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
506 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
507 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
508 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
509 regex_row_changed_cb(GtkTreeModel *model, GtkTreePath *path, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
510 GtkTreeIter *iter, DebugWindow *win) |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
511 { |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
512 gchar *text; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
513 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
514 if(!win || !win->window) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
515 return; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
516 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
517 /* If the debug window is paused, we just return since it's in the store. |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
518 * We don't call regex_match because it doesn't make sense to check the |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
519 * string if it's paused. When we unpause we clear the imhtml and |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
520 * reiterate over the store to handle matches that were outputted when |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
521 * we were paused. |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
522 */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
523 if(win->paused) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
524 return; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
525 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
526 gtk_tree_model_get(model, iter, 0, &text, -1); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
527 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
528 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
529 regex_match(win, text); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
530 } else { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
531 gtk_imhtml_append_text(GTK_IMHTML(win->text), text, 0); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
532 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
533 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
534 g_free(text); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
535 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
536 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
537 static gboolean |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
538 regex_timer_cb(DebugWindow *win) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
539 const gchar *text; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
540 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
541 text = gtk_entry_get_text(GTK_ENTRY(win->expression)); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
542 gaim_prefs_set_string("/gaim/gtk/debug/regex", text); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
543 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
544 win->timer = 0; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
545 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
546 return FALSE; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
547 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
548 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
549 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
550 regex_changed_cb(GtkWidget *w, DebugWindow *win) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
551 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
552 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter), |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
553 FALSE); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
554 } |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
555 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
556 if(win->timer == 0) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
557 win->timer = gaim_timeout_add(5000, (GSourceFunc)regex_timer_cb, win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
558 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
559 regex_compile(win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
560 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
561 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
562 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
563 regex_menu_cb(GtkWidget *item, const gchar *pref) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
564 gboolean active; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
565 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
566 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
567 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
568 gaim_prefs_set_bool(pref, active); |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
569 } |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
570 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
571 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
572 regex_popup_cb(GtkEntry *entry, GtkWidget *menu, DebugWindow *win) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
573 gaim_separator(menu); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
574 gaim_new_check_item(menu, _("Invert"), |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
575 G_CALLBACK(regex_menu_cb), |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
576 "/gaim/gtk/debug/invert", win->invert); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
577 gaim_new_check_item(menu, _("Highlight matches"), |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
578 G_CALLBACK(regex_menu_cb), |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
579 "/gaim/gtk/debug/highlight", win->highlight); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
580 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
581 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
582 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
583 regex_filter_toggled_cb(GtkToggleButton *button, DebugWindow *win) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
584 gboolean active; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
585 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
586 active = gtk_toggle_button_get_active(button); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
587 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
588 gaim_prefs_set_bool("/gaim/gtk/debug/filter", active); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
589 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
590 if(!GTK_IS_IMHTML(win->text)) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
591 return; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
592 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
593 if(active) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
594 regex_filter_all(win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
595 else |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
596 regex_show_all(win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
597 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
598 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
599 #endif /* HAVE_REGEX_H */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
600 |
5212 | 601 static DebugWindow * |
602 debug_window_new(void) | |
603 { | |
604 DebugWindow *win; | |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
605 GtkWidget *vbox; |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
606 GtkWidget *toolbar; |
10175 | 607 GtkWidget *frame; |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
608 GtkWidget *button; |
6094
538c522e36e1
[gaim-migrate @ 6553]
Christian Hammond <chipx86@chipx86.com>
parents:
6009
diff
changeset
|
609 GtkWidget *image; |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
610 gint width, height; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
611 void *handle; |
5212 | 612 |
613 win = g_new0(DebugWindow, 1); | |
614 | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
615 width = gaim_prefs_get_int("/gaim/gtk/debug/width"); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
616 height = gaim_prefs_get_int("/gaim/gtk/debug/height"); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
617 |
5212 | 618 GAIM_DIALOG(win->window); |
10309 | 619 gaim_debug_info("gtkdebug", "Setting dimensions to %d, %d\n", |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
620 width, height); |
5642
1693a3027dc8
[gaim-migrate @ 6056]
Christian Hammond <chipx86@chipx86.com>
parents:
5636
diff
changeset
|
621 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
622 gtk_window_set_default_size(GTK_WINDOW(win->window), width, height); |
5212 | 623 gtk_window_set_role(GTK_WINDOW(win->window), "debug"); |
624 gtk_window_set_title(GTK_WINDOW(win->window), _("Debug Window")); | |
625 | |
626 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
627 G_CALLBACK(debug_window_destroy), NULL); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
628 g_signal_connect(G_OBJECT(win->window), "configure_event", |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
629 G_CALLBACK(configure_cb), win); |
5212 | 630 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
631 handle = gaim_gtk_debug_get_handle(); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
632 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
633 #ifdef HAVE_REGEX_H |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
634 /* the list store for all the messages */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
635 win->store = gtk_list_store_new(1, G_TYPE_STRING); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
636 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
637 /* row-changed gets called when we do gtk_list_store_set, and row-inserted |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
638 * gets called with gtk_list_store_append, which is a |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
639 * completely empty row. So we just ignore row-inserted, and deal with row |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
640 * changed. -Gary |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
641 */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
642 g_signal_connect(G_OBJECT(win->store), "row-changed", |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
643 G_CALLBACK(regex_row_changed_cb), win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
644 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
645 #endif /* HAVE_REGEX_H */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
646 |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
647 /* Setup the vbox */ |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
648 vbox = gtk_vbox_new(FALSE, 0); |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
649 gtk_container_add(GTK_CONTAINER(win->window), vbox); |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
650 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
651 if (gaim_prefs_get_bool("/gaim/gtk/debug/toolbar")) { |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
652 /* Setup our top button bar thingie. */ |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
653 toolbar = gtk_toolbar_new(); |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
654 gtk_toolbar_set_tooltips(GTK_TOOLBAR(toolbar), TRUE); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
655 |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
656 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
657 GTK_TOOLBAR_BOTH_HORIZ); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
658 gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar), |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
659 GTK_ICON_SIZE_SMALL_TOOLBAR); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
660 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
661 gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
662 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
663 #ifndef HAVE_REGEX_H |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
664 /* Find button */ |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
665 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_FIND, |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
666 _("Find"), NULL, G_CALLBACK(find_cb), |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
667 win, -1); |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
668 #endif /* HAVE_REGEX_H */ |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
669 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
670 /* Save */ |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
671 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_SAVE, |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
672 _("Save"), NULL, G_CALLBACK(save_cb), |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
673 win, -1); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
674 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
675 /* Clear button */ |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
676 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_CLEAR, |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
677 _("Clear"), NULL, G_CALLBACK(clear_cb), |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
678 win, -1); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
679 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
680 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
681 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
682 /* Pause */ |
6094
538c522e36e1
[gaim-migrate @ 6553]
Christian Hammond <chipx86@chipx86.com>
parents:
6009
diff
changeset
|
683 image = gtk_image_new_from_stock(GAIM_STOCK_PAUSE, GTK_ICON_SIZE_MENU); |
538c522e36e1
[gaim-migrate @ 6553]
Christian Hammond <chipx86@chipx86.com>
parents:
6009
diff
changeset
|
684 button = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
685 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
686 NULL, _("Pause"), _("Pause"), |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
687 NULL, image, |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
688 G_CALLBACK(pause_cb), win); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
689 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
690 /* Timestamps */ |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
691 button = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
692 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
693 NULL, _("Timestamps"), |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
694 _("Timestamps"), NULL, NULL, |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
695 G_CALLBACK(timestamps_cb), |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
696 win); |
8953 | 697 |
698 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), | |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
699 gaim_prefs_get_bool("/core/debug/timestamps")); |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
700 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
701 gaim_prefs_connect_callback(handle, "/core/debug/timestamps", |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
702 timestamps_pref_cb, button); |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
703 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
704 #ifdef HAVE_REGEX_H |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
705 /* regex stuff */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
706 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1); |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
707 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
708 /* regex toggle button */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
709 win->filter = |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
710 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
711 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
712 NULL, _("Filter"), _("Filter"), |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
713 NULL, NULL, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
714 G_CALLBACK(regex_filter_toggled_cb), |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
715 win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
716 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter), |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
717 gaim_prefs_get_bool("/gaim/gtk/debug/filter")); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
718 gaim_prefs_connect_callback(handle, "/gaim/gtk/debug/filter", |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
719 regex_pref_filter_cb, win); |
8953 | 720 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
721 /* regex entry */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
722 win->expression = gtk_entry_new(); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
723 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
724 GTK_TOOLBAR_CHILD_WIDGET, win->expression, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
725 NULL, _("Right click for more options."), |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
726 NULL, NULL, NULL, NULL); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
727 /* this needs to be before the text is set from the pref if we want it |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
728 * to colorize a stored expression. |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
729 */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
730 g_signal_connect(G_OBJECT(win->expression), "changed", |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
731 G_CALLBACK(regex_changed_cb), win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
732 gtk_entry_set_text(GTK_ENTRY(win->expression), |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
733 gaim_prefs_get_string("/gaim/gtk/debug/regex")); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
734 g_signal_connect(G_OBJECT(win->expression), "populate-popup", |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
735 G_CALLBACK(regex_popup_cb), win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
736 gaim_prefs_connect_callback(handle, "/gaim/gtk/debug/regex", |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
737 regex_pref_expression_cb, win); |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
738 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
739 /* connect the rest of our pref callbacks */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
740 win->invert = gaim_prefs_get_bool("/gaim/gtk/debug/invert"); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
741 gaim_prefs_connect_callback(handle, "/gaim/gtk/debug/invert", |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
742 regex_pref_invert_cb, win); |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
743 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
744 win->highlight = gaim_prefs_get_bool("/gaim/gtk/debug/highlight"); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
745 gaim_prefs_connect_callback(handle, "/gaim/gtk/debug/highlight", |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
746 regex_pref_highlight_cb, win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
747 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
748 #endif /* HAVE_REGEX_H */ |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
749 } |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
750 |
10175 | 751 /* Add the gtkimhtml */ |
752 frame = gaim_gtk_create_imhtml(FALSE, &win->text, NULL); | |
10739 | 753 gtk_imhtml_set_format_functions(GTK_IMHTML(win->text), |
754 GTK_IMHTML_ALL ^ GTK_IMHTML_SMILEY ^ GTK_IMHTML_IMAGE); | |
10175 | 755 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
756 gtk_widget_show(frame); | |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
757 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
758 #ifdef HAVE_REGEX_H |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
759 /* add the tag for regex highlighting */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
760 gtk_text_buffer_create_tag(GTK_IMHTML(win->text)->text_buffer, "regex", |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
761 "background", "#FFAFAF", |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
762 "weight", "bold", |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
763 NULL); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
764 #endif /* HAVE_REGEX_H */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
765 |
5212 | 766 gtk_widget_show_all(win->window); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
767 |
5212 | 768 return win; |
769 } | |
770 | |
5625
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
771 static void |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
772 debug_enabled_cb(const char *name, GaimPrefType type, gpointer value, |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
773 gpointer data) |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
774 { |
5636 | 775 if (value) |
5625
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
776 gaim_gtk_debug_window_show(); |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
777 else |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
778 gaim_gtk_debug_window_hide(); |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
779 } |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
780 |
7150 | 781 static void |
782 gaim_glib_log_handler(const gchar *domain, GLogLevelFlags flags, | |
783 const gchar *msg, gpointer user_data) | |
784 { | |
785 GaimDebugLevel level; | |
786 char *new_msg = NULL; | |
787 char *new_domain = NULL; | |
788 | |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
789 if ((flags & G_LOG_LEVEL_ERROR) == G_LOG_LEVEL_ERROR) |
7150 | 790 level = GAIM_DEBUG_ERROR; |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
791 else if ((flags & G_LOG_LEVEL_CRITICAL) == G_LOG_LEVEL_CRITICAL) |
7150 | 792 level = GAIM_DEBUG_FATAL; |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
793 else if ((flags & G_LOG_LEVEL_WARNING) == G_LOG_LEVEL_WARNING) |
7150 | 794 level = GAIM_DEBUG_WARNING; |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
795 else if ((flags & G_LOG_LEVEL_MESSAGE) == G_LOG_LEVEL_MESSAGE) |
7150 | 796 level = GAIM_DEBUG_INFO; |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
797 else if ((flags & G_LOG_LEVEL_INFO) == G_LOG_LEVEL_INFO) |
7150 | 798 level = GAIM_DEBUG_INFO; |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
799 else if ((flags & G_LOG_LEVEL_DEBUG) == G_LOG_LEVEL_DEBUG) |
7150 | 800 level = GAIM_DEBUG_MISC; |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
801 else |
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
802 { |
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
803 gaim_debug_warning("gtkdebug", |
7150 | 804 "Unknown glib logging level in %d\n", flags); |
805 | |
806 level = GAIM_DEBUG_MISC; /* This will never happen. */ | |
807 } | |
808 | |
809 if (msg != NULL) | |
810 new_msg = gaim_utf8_try_convert(msg); | |
811 | |
812 if (domain != NULL) | |
813 new_domain = gaim_utf8_try_convert(domain); | |
814 | |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
815 if (new_msg != NULL) |
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
816 { |
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
817 gaim_debug(level, (new_domain != NULL ? new_domain : "g_log"), |
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
818 "%s\n", new_msg); |
7150 | 819 |
820 g_free(new_msg); | |
821 } | |
822 | |
823 if (new_domain != NULL) | |
824 g_free(new_domain); | |
825 } | |
826 | |
827 #ifdef _WIN32 | |
828 static void | |
829 gaim_glib_dummy_print_handler(const gchar *string) | |
830 { | |
831 } | |
832 #endif | |
833 | |
5625
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
834 void |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
835 gaim_gtk_debug_init(void) |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
836 { |
5684 | 837 /* Debug window preferences. */ |
838 /* | |
839 * NOTE: This must be set before prefs are loaded, and the callbacks | |
840 * set after they are loaded, since prefs sets the enabled | |
841 * preference here and that loads the window, which calls the | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
842 * configure event, which overrides the width and height! :P |
5684 | 843 */ |
844 | |
845 gaim_prefs_add_none("/gaim/gtk/debug"); | |
10307 | 846 |
847 /* Controls printing to the debug window */ | |
5684 | 848 gaim_prefs_add_bool("/gaim/gtk/debug/enabled", FALSE); |
10307 | 849 |
5684 | 850 gaim_prefs_add_bool("/gaim/gtk/debug/toolbar", TRUE); |
851 gaim_prefs_add_int("/gaim/gtk/debug/width", 450); | |
852 gaim_prefs_add_int("/gaim/gtk/debug/height", 250); | |
853 | |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
854 #ifdef HAVE_REGEX_H |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
855 gaim_prefs_add_string("/gaim/gtk/debug/regex", ""); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
856 gaim_prefs_add_bool("/gaim/gtk/debug/filter", FALSE); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
857 gaim_prefs_add_bool("/gaim/gtk/debug/invert", FALSE); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
858 gaim_prefs_add_bool("/gaim/gtk/debug/case_insensitive", FALSE); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
859 gaim_prefs_add_bool("/gaim/gtk/debug/highlight", FALSE); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
860 #endif /* HAVE_REGEX_H */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
861 |
10087 | 862 gaim_prefs_connect_callback(NULL, "/gaim/gtk/debug/enabled", |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5738
diff
changeset
|
863 debug_enabled_cb, NULL); |
7150 | 864 |
865 #define REGISTER_G_LOG_HANDLER(name) \ | |
866 g_log_set_handler((name), G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL \ | |
867 | G_LOG_FLAG_RECURSION, \ | |
868 gaim_glib_log_handler, NULL) | |
869 | |
870 /* Register the glib/gtk log handlers. */ | |
871 REGISTER_G_LOG_HANDLER(NULL); | |
872 REGISTER_G_LOG_HANDLER("Gdk"); | |
873 REGISTER_G_LOG_HANDLER("Gtk"); | |
7229
26fe5055e0b0
[gaim-migrate @ 7799]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7152
diff
changeset
|
874 REGISTER_G_LOG_HANDLER("GdkPixbuf"); |
7150 | 875 REGISTER_G_LOG_HANDLER("GLib"); |
876 REGISTER_G_LOG_HANDLER("GModule"); | |
877 REGISTER_G_LOG_HANDLER("GLib-GObject"); | |
878 REGISTER_G_LOG_HANDLER("GThread"); | |
879 | |
880 #ifdef _WIN32 | |
10314 | 881 if (!gaim_debug_is_enabled()) |
7150 | 882 g_set_print_handler(gaim_glib_dummy_print_handler); |
883 #endif | |
5625
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
884 } |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
885 |
5212 | 886 void |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
887 gaim_gtk_debug_uninit(void) |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
888 { |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
889 gaim_debug_set_ui_ops(NULL); |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
890 } |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
891 |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
892 void |
5212 | 893 gaim_gtk_debug_window_show(void) |
894 { | |
895 if (debug_win == NULL) | |
896 debug_win = debug_window_new(); | |
897 | |
898 gtk_widget_show(debug_win->window); | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
899 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
900 gaim_prefs_set_bool("/gaim/gtk/debug/enabled", TRUE); |
5212 | 901 } |
902 | |
903 void | |
904 gaim_gtk_debug_window_hide(void) | |
905 { | |
906 if (debug_win != NULL) { | |
907 gtk_widget_destroy(debug_win->window); | |
908 debug_window_destroy(NULL, NULL, NULL); | |
909 } | |
910 } | |
911 | |
912 static void | |
913 gaim_gtk_debug_print(GaimDebugLevel level, const char *category, | |
914 const char *format, va_list args) | |
915 { | |
11262 | 916 #ifdef HAVE_REGEX_H |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
917 GtkTreeIter iter; |
11262 | 918 #endif /* HAVE_REGEX_H */ |
10307 | 919 gboolean timestamps; |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
920 gchar *arg_s, *ts_s; |
10307 | 921 gchar *esc_s, *cat_s, *tmp, *s; |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
922 |
10307 | 923 if (!gaim_prefs_get_bool("/gaim/gtk/debug/enabled") || |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
924 (debug_win == NULL)) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
925 { |
10307 | 926 return; |
927 } | |
928 | |
929 timestamps = gaim_prefs_get_bool("/core/debug/timestamps"); | |
5212 | 930 |
931 arg_s = g_strdup_vprintf(format, args); | |
932 | |
10307 | 933 /* |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
934 * For some reason we only print the timestamp if category is |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
935 * not NULL. Why the hell do we do that? --Mark |
10307 | 936 */ |
937 if ((category != NULL) && (timestamps)) { | |
938 gchar mdate[64]; | |
939 | |
940 time_t mtime = time(NULL); | |
941 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | |
942 ts_s = g_strdup_printf("(%s) ", mdate); | |
943 } else { | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
944 ts_s = g_strdup(""); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
945 } |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
946 |
10307 | 947 if (category == NULL) |
948 cat_s = g_strdup(""); | |
949 else | |
950 cat_s = g_strdup_printf("<b>%s:</b> ", category); | |
5212 | 951 |
10307 | 952 esc_s = g_markup_escape_text(arg_s, -1); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
953 |
10307 | 954 g_free(arg_s); |
5212 | 955 |
10307 | 956 s = g_strdup_printf("<font color=\"%s\">%s%s%s</font>", |
957 debug_fg_colors[level], ts_s, cat_s, esc_s); | |
5212 | 958 |
10307 | 959 g_free(ts_s); |
960 g_free(cat_s); | |
961 g_free(esc_s); | |
5212 | 962 |
10307 | 963 tmp = gaim_utf8_try_convert(s); |
964 g_free(s); | |
965 s = tmp; | |
5212 | 966 |
10307 | 967 if (level == GAIM_DEBUG_FATAL) { |
968 tmp = g_strdup_printf("<b>%s</b>", s); | |
5212 | 969 g_free(s); |
10307 | 970 s = tmp; |
5212 | 971 } |
972 | |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
973 #ifdef HAVE_REGEX_H |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
974 /* add the text to the list store */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
975 gtk_list_store_append(debug_win->store, &iter); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
976 gtk_list_store_set(debug_win->store, &iter, 0, s, -1); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
977 #else /* HAVE_REGEX_H */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
978 if(!debug_win->paused) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
979 gtk_imhtml_append_text(GTK_IMHTML(debug_win->text), s, 0); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
980 #endif /* !HAVE_REGEX_H */ |
5212 | 981 |
10307 | 982 g_free(s); |
5212 | 983 } |
984 | |
985 static GaimDebugUiOps ops = | |
986 { | |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
987 gaim_gtk_debug_print, |
5212 | 988 }; |
989 | |
990 GaimDebugUiOps * | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
991 gaim_gtk_debug_get_ui_ops(void) |
5212 | 992 { |
993 return &ops; | |
994 } | |
10087 | 995 |
996 void * | |
997 gaim_gtk_debug_get_handle() { | |
998 static int handle; | |
999 | |
1000 return &handle; | |
1001 } |