Mercurial > pidgin.yaz
annotate src/gtkdebug.c @ 11279:ed5302df41b0
[gaim-migrate @ 13474]
Patch by Sadrul Habib Chowdhury to fix tab dragging. Many thanks also to
Cae for helping to track down the exact behavior, and for helping to test
this patch so that Sadrul could provide a version that actually fixes the
bug. :-)
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Tue, 16 Aug 2005 18:54:40 +0000 |
parents | ecbbe6d18b0d |
children | 0058b0737e76 |
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 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
336 if(!win->highlight) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
337 g_free(plaintext); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
338 return; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
339 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
340 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
341 /* 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
|
342 * if necessary... |
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 do { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
345 gint m; |
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 for(m = 0; m < n_matches; m++) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
348 GtkTextIter ms, me; |
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 if(matches[m].rm_eo == -1) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
351 break; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
352 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
353 i += offset; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
354 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
355 gtk_text_buffer_get_iter_at_offset(imhtml->text_buffer, &ms, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
356 i + matches[m].rm_so); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
357 gtk_text_buffer_get_iter_at_offset(imhtml->text_buffer, &me, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
358 i + matches[m].rm_eo); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
359 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "regex", |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
360 &ms, &me); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
361 offset = matches[m].rm_eo; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
362 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
363 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
364 p += offset; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
365 } while(regexec(&win->regex, p, n_matches, matches, REG_NOTBOL) == inverted); |
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 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
368 g_free(plaintext); |
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 static gboolean |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
372 regex_filter_all_cb(GtkTreeModel *m, GtkTreePath *p, GtkTreeIter *iter, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
373 gpointer data) |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
374 { |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
375 DebugWindow *win = (DebugWindow *)data; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
376 gchar *text; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
377 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
378 gtk_tree_model_get(m, iter, 0, &text, -1); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
379 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
380 regex_match(win, text); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
381 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
382 g_free(text); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
383 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
384 return FALSE; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
385 } |
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 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
388 regex_filter_all(DebugWindow *win) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
389 gtk_imhtml_clear(GTK_IMHTML(win->text)); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
390 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
391 if(win->highlight) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
392 regex_highlight_clear(win); |
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 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
|
395 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 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
398 static gboolean |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
399 regex_show_all_cb(GtkTreeModel *m, GtkTreePath *p, GtkTreeIter *iter, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
400 gpointer data) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
401 { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
402 DebugWindow *win = (DebugWindow *)data; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
403 gchar *text; |
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 gtk_tree_model_get(m, iter, 0, &text, -1); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
406 gtk_imhtml_append_text(GTK_IMHTML(win->text), text, 0); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
407 g_free(text); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
408 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
409 return FALSE; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
410 } |
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 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
413 regex_show_all(DebugWindow *win) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
414 gtk_imhtml_clear(GTK_IMHTML(win->text)); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
415 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
416 if(win->highlight) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
417 regex_highlight_clear(win); |
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 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
|
420 win); |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
421 } |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
422 |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
423 static void |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
424 regex_compile(DebugWindow *win) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
425 const gchar *text; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
426 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
427 text = gtk_entry_get_text(GTK_ENTRY(win->expression)); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
428 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
429 if(text == NULL || *text == '\0') { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
430 regex_clear_color(win->expression); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
431 gtk_widget_set_sensitive(win->filter, FALSE); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
432 return; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
433 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
434 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
435 regfree(&win->regex); |
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 if(regcomp(&win->regex, text, REG_EXTENDED | REG_ICASE) != 0) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
438 /* failed to compile */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
439 regex_change_color(win->expression, 0xFFFF, 0xAFFF, 0xAFFF); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
440 gtk_widget_set_sensitive(win->filter, FALSE); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
441 } else { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
442 /* compiled successfully */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
443 regex_change_color(win->expression, 0xAFFF, 0xFFFF, 0xAFFF); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
444 gtk_widget_set_sensitive(win->filter, TRUE); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
445 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
446 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
447 /* 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
|
448 * got changed, and not the expression. |
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 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
451 regex_filter_all(win); |
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 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
454 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
455 regex_pref_filter_cb(const gchar *name, GaimPrefType type, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
456 gpointer val, gpointer data) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
457 { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
458 DebugWindow *win = (DebugWindow *)data; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
459 gboolean active = GPOINTER_TO_INT(val), current; |
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 if(!win || !win->window) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
462 return; |
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 current = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter)); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
465 if(active != current) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
466 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter), active); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
467 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
468 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
469 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
470 regex_pref_expression_cb(const gchar *name, GaimPrefType type, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
471 gpointer val, gpointer data) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
472 { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
473 DebugWindow *win = (DebugWindow *)data; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
474 const gchar *exp = (const gchar *)val; |
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 gtk_entry_set_text(GTK_ENTRY(win->expression), exp); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
477 } |
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 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
480 regex_pref_invert_cb(const gchar *name, GaimPrefType type, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
481 gpointer val, gpointer data) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
482 { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
483 DebugWindow *win = (DebugWindow *)data; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
484 gboolean active = GPOINTER_TO_INT(val); |
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 win->invert = active; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
487 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
488 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
489 regex_filter_all(win); |
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 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
492 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
493 regex_pref_highlight_cb(const gchar *name, GaimPrefType type, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
494 gpointer val, gpointer data) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
495 { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
496 DebugWindow *win = (DebugWindow *)data; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
497 gboolean active = GPOINTER_TO_INT(val); |
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 win->highlight = active; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
500 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
501 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
502 regex_filter_all(win); |
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 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
505 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
506 regex_row_changed_cb(GtkTreeModel *model, GtkTreePath *path, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
507 GtkTreeIter *iter, DebugWindow *win) |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
508 { |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
509 gchar *text; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
510 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
511 if(!win || !win->window) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
512 return; |
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 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
|
515 * 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
|
516 * 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
|
517 * reiterate over the store to handle matches that were outputted when |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
518 * we were paused. |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
519 */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
520 if(win->paused) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
521 return; |
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 gtk_tree_model_get(model, iter, 0, &text, -1); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
524 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
525 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
526 regex_match(win, text); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
527 } else { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
528 gtk_imhtml_append_text(GTK_IMHTML(win->text), text, 0); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
529 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
530 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
531 g_free(text); |
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 static gboolean |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
535 regex_timer_cb(DebugWindow *win) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
536 const gchar *text; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
537 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
538 text = gtk_entry_get_text(GTK_ENTRY(win->expression)); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
539 gaim_prefs_set_string("/gaim/gtk/debug/regex", 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 win->timer = 0; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
542 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
543 return FALSE; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
544 } |
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 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
547 regex_changed_cb(GtkWidget *w, DebugWindow *win) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
548 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
549 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter), |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
550 FALSE); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
551 } |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
552 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
553 if(win->timer == 0) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
554 win->timer = gaim_timeout_add(5000, (GSourceFunc)regex_timer_cb, win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
555 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
556 regex_compile(win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
557 } |
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 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
560 regex_menu_cb(GtkWidget *item, const gchar *pref) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
561 gboolean active; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
562 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
563 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
|
564 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
565 gaim_prefs_set_bool(pref, active); |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
566 } |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
567 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
568 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
569 regex_popup_cb(GtkEntry *entry, GtkWidget *menu, DebugWindow *win) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
570 gaim_separator(menu); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
571 gaim_new_check_item(menu, _("Invert"), |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
572 G_CALLBACK(regex_menu_cb), |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
573 "/gaim/gtk/debug/invert", win->invert); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
574 gaim_new_check_item(menu, _("Highlight matches"), |
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/highlight", win->highlight); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
577 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
578 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
579 static void |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
580 regex_filter_toggled_cb(GtkToggleButton *button, DebugWindow *win) { |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
581 gboolean active; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
582 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
583 active = gtk_toggle_button_get_active(button); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
584 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
585 gaim_prefs_set_bool("/gaim/gtk/debug/filter", active); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
586 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
587 if(!GTK_IS_IMHTML(win->text)) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
588 return; |
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(active) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
591 regex_filter_all(win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
592 else |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
593 regex_show_all(win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
594 } |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
595 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
596 #endif /* HAVE_REGEX_H */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
597 |
5212 | 598 static DebugWindow * |
599 debug_window_new(void) | |
600 { | |
601 DebugWindow *win; | |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
602 GtkWidget *vbox; |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
603 GtkWidget *toolbar; |
10175 | 604 GtkWidget *frame; |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
605 GtkWidget *button; |
6094
538c522e36e1
[gaim-migrate @ 6553]
Christian Hammond <chipx86@chipx86.com>
parents:
6009
diff
changeset
|
606 GtkWidget *image; |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
607 gint width, height; |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
608 void *handle; |
5212 | 609 |
610 win = g_new0(DebugWindow, 1); | |
611 | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
612 width = gaim_prefs_get_int("/gaim/gtk/debug/width"); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
613 height = gaim_prefs_get_int("/gaim/gtk/debug/height"); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
614 |
5212 | 615 GAIM_DIALOG(win->window); |
10309 | 616 gaim_debug_info("gtkdebug", "Setting dimensions to %d, %d\n", |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
617 width, height); |
5642
1693a3027dc8
[gaim-migrate @ 6056]
Christian Hammond <chipx86@chipx86.com>
parents:
5636
diff
changeset
|
618 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
619 gtk_window_set_default_size(GTK_WINDOW(win->window), width, height); |
5212 | 620 gtk_window_set_role(GTK_WINDOW(win->window), "debug"); |
621 gtk_window_set_title(GTK_WINDOW(win->window), _("Debug Window")); | |
622 | |
623 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
624 G_CALLBACK(debug_window_destroy), NULL); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
625 g_signal_connect(G_OBJECT(win->window), "configure_event", |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
626 G_CALLBACK(configure_cb), win); |
5212 | 627 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
628 handle = gaim_gtk_debug_get_handle(); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
629 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
630 #ifdef HAVE_REGEX_H |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
631 /* the list store for all the messages */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
632 win->store = gtk_list_store_new(1, G_TYPE_STRING); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
633 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
634 /* 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
|
635 * gets called with gtk_list_store_append, which is a |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
636 * 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
|
637 * changed. -Gary |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
638 */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
639 g_signal_connect(G_OBJECT(win->store), "row-changed", |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
640 G_CALLBACK(regex_row_changed_cb), win); |
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 #endif /* HAVE_REGEX_H */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
643 |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
644 /* Setup the vbox */ |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
645 vbox = gtk_vbox_new(FALSE, 0); |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
646 gtk_container_add(GTK_CONTAINER(win->window), vbox); |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
647 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
648 if (gaim_prefs_get_bool("/gaim/gtk/debug/toolbar")) { |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
649 /* Setup our top button bar thingie. */ |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
650 toolbar = gtk_toolbar_new(); |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
651 gtk_toolbar_set_tooltips(GTK_TOOLBAR(toolbar), TRUE); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
652 |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
653 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
654 GTK_TOOLBAR_BOTH_HORIZ); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
655 gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar), |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
656 GTK_ICON_SIZE_SMALL_TOOLBAR); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
657 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
658 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
|
659 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
660 #ifndef HAVE_REGEX_H |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
661 /* Find button */ |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
662 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_FIND, |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
663 _("Find"), NULL, G_CALLBACK(find_cb), |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
664 win, -1); |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
665 #endif /* HAVE_REGEX_H */ |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
666 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
667 /* Save */ |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
668 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_SAVE, |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
669 _("Save"), NULL, G_CALLBACK(save_cb), |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
670 win, -1); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
671 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
672 /* Clear button */ |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
673 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_CLEAR, |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
674 _("Clear"), NULL, G_CALLBACK(clear_cb), |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
675 win, -1); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
676 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
677 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
678 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
679 /* Pause */ |
6094
538c522e36e1
[gaim-migrate @ 6553]
Christian Hammond <chipx86@chipx86.com>
parents:
6009
diff
changeset
|
680 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
|
681 button = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
682 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
683 NULL, _("Pause"), _("Pause"), |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
684 NULL, image, |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
685 G_CALLBACK(pause_cb), win); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
686 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
687 /* Timestamps */ |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
688 button = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
689 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
690 NULL, _("Timestamps"), |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
691 _("Timestamps"), NULL, NULL, |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
692 G_CALLBACK(timestamps_cb), |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
693 win); |
8953 | 694 |
695 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), | |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
696 gaim_prefs_get_bool("/core/debug/timestamps")); |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
697 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
698 gaim_prefs_connect_callback(handle, "/core/debug/timestamps", |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
699 timestamps_pref_cb, button); |
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 #ifdef HAVE_REGEX_H |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
702 /* regex stuff */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
703 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1); |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
704 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
705 /* regex toggle button */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
706 win->filter = |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
707 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
708 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
709 NULL, _("Filter"), _("Filter"), |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
710 NULL, NULL, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
711 G_CALLBACK(regex_filter_toggled_cb), |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
712 win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
713 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter), |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
714 gaim_prefs_get_bool("/gaim/gtk/debug/filter")); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
715 gaim_prefs_connect_callback(handle, "/gaim/gtk/debug/filter", |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
716 regex_pref_filter_cb, win); |
8953 | 717 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
718 /* regex entry */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
719 win->expression = gtk_entry_new(); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
720 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
721 GTK_TOOLBAR_CHILD_WIDGET, win->expression, |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
722 NULL, _("Right click for more options."), |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
723 NULL, NULL, NULL, NULL); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
724 /* 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
|
725 * to colorize a stored expression. |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
726 */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
727 g_signal_connect(G_OBJECT(win->expression), "changed", |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
728 G_CALLBACK(regex_changed_cb), win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
729 gtk_entry_set_text(GTK_ENTRY(win->expression), |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
730 gaim_prefs_get_string("/gaim/gtk/debug/regex")); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
731 g_signal_connect(G_OBJECT(win->expression), "populate-popup", |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
732 G_CALLBACK(regex_popup_cb), win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
733 gaim_prefs_connect_callback(handle, "/gaim/gtk/debug/regex", |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
734 regex_pref_expression_cb, win); |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
735 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
736 /* connect the rest of our pref callbacks */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
737 win->invert = gaim_prefs_get_bool("/gaim/gtk/debug/invert"); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
738 gaim_prefs_connect_callback(handle, "/gaim/gtk/debug/invert", |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
739 regex_pref_invert_cb, win); |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
740 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
741 win->highlight = gaim_prefs_get_bool("/gaim/gtk/debug/highlight"); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
742 gaim_prefs_connect_callback(handle, "/gaim/gtk/debug/highlight", |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
743 regex_pref_highlight_cb, win); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
744 |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
745 #endif /* HAVE_REGEX_H */ |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
746 } |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
747 |
10175 | 748 /* Add the gtkimhtml */ |
749 frame = gaim_gtk_create_imhtml(FALSE, &win->text, NULL); | |
10739 | 750 gtk_imhtml_set_format_functions(GTK_IMHTML(win->text), |
751 GTK_IMHTML_ALL ^ GTK_IMHTML_SMILEY ^ GTK_IMHTML_IMAGE); | |
10175 | 752 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
753 gtk_widget_show(frame); | |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
754 |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
755 #ifdef HAVE_REGEX_H |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
756 /* add the tag for regex highlighting */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
757 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
|
758 "background", "#FFAFAF", |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
759 "weight", "bold", |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
760 NULL); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
761 #endif /* HAVE_REGEX_H */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
762 |
5212 | 763 gtk_widget_show_all(win->window); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
764 |
5212 | 765 return win; |
766 } | |
767 | |
5625
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
768 static void |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
769 debug_enabled_cb(const char *name, GaimPrefType type, gpointer value, |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
770 gpointer data) |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
771 { |
5636 | 772 if (value) |
5625
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
773 gaim_gtk_debug_window_show(); |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
774 else |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
775 gaim_gtk_debug_window_hide(); |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
776 } |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
777 |
7150 | 778 static void |
779 gaim_glib_log_handler(const gchar *domain, GLogLevelFlags flags, | |
780 const gchar *msg, gpointer user_data) | |
781 { | |
782 GaimDebugLevel level; | |
783 char *new_msg = NULL; | |
784 char *new_domain = NULL; | |
785 | |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
786 if ((flags & G_LOG_LEVEL_ERROR) == G_LOG_LEVEL_ERROR) |
7150 | 787 level = GAIM_DEBUG_ERROR; |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
788 else if ((flags & G_LOG_LEVEL_CRITICAL) == G_LOG_LEVEL_CRITICAL) |
7150 | 789 level = GAIM_DEBUG_FATAL; |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
790 else if ((flags & G_LOG_LEVEL_WARNING) == G_LOG_LEVEL_WARNING) |
7150 | 791 level = GAIM_DEBUG_WARNING; |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
792 else if ((flags & G_LOG_LEVEL_MESSAGE) == G_LOG_LEVEL_MESSAGE) |
7150 | 793 level = GAIM_DEBUG_INFO; |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
794 else if ((flags & G_LOG_LEVEL_INFO) == G_LOG_LEVEL_INFO) |
7150 | 795 level = GAIM_DEBUG_INFO; |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
796 else if ((flags & G_LOG_LEVEL_DEBUG) == G_LOG_LEVEL_DEBUG) |
7150 | 797 level = GAIM_DEBUG_MISC; |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
798 else |
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
799 { |
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
800 gaim_debug_warning("gtkdebug", |
7150 | 801 "Unknown glib logging level in %d\n", flags); |
802 | |
803 level = GAIM_DEBUG_MISC; /* This will never happen. */ | |
804 } | |
805 | |
806 if (msg != NULL) | |
807 new_msg = gaim_utf8_try_convert(msg); | |
808 | |
809 if (domain != NULL) | |
810 new_domain = gaim_utf8_try_convert(domain); | |
811 | |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
812 if (new_msg != NULL) |
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
813 { |
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
814 gaim_debug(level, (new_domain != NULL ? new_domain : "g_log"), |
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
815 "%s\n", new_msg); |
7150 | 816 |
817 g_free(new_msg); | |
818 } | |
819 | |
820 if (new_domain != NULL) | |
821 g_free(new_domain); | |
822 } | |
823 | |
824 #ifdef _WIN32 | |
825 static void | |
826 gaim_glib_dummy_print_handler(const gchar *string) | |
827 { | |
828 } | |
829 #endif | |
830 | |
5625
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
831 void |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
832 gaim_gtk_debug_init(void) |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
833 { |
5684 | 834 /* Debug window preferences. */ |
835 /* | |
836 * NOTE: This must be set before prefs are loaded, and the callbacks | |
837 * set after they are loaded, since prefs sets the enabled | |
838 * preference here and that loads the window, which calls the | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
839 * configure event, which overrides the width and height! :P |
5684 | 840 */ |
841 | |
842 gaim_prefs_add_none("/gaim/gtk/debug"); | |
10307 | 843 |
844 /* Controls printing to the debug window */ | |
5684 | 845 gaim_prefs_add_bool("/gaim/gtk/debug/enabled", FALSE); |
10307 | 846 |
5684 | 847 gaim_prefs_add_bool("/gaim/gtk/debug/toolbar", TRUE); |
848 gaim_prefs_add_int("/gaim/gtk/debug/width", 450); | |
849 gaim_prefs_add_int("/gaim/gtk/debug/height", 250); | |
850 | |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
851 #ifdef HAVE_REGEX_H |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
852 gaim_prefs_add_string("/gaim/gtk/debug/regex", ""); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
853 gaim_prefs_add_bool("/gaim/gtk/debug/filter", FALSE); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
854 gaim_prefs_add_bool("/gaim/gtk/debug/invert", FALSE); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
855 gaim_prefs_add_bool("/gaim/gtk/debug/case_insensitive", FALSE); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
856 gaim_prefs_add_bool("/gaim/gtk/debug/highlight", FALSE); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
857 #endif /* HAVE_REGEX_H */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
858 |
10087 | 859 gaim_prefs_connect_callback(NULL, "/gaim/gtk/debug/enabled", |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5738
diff
changeset
|
860 debug_enabled_cb, NULL); |
7150 | 861 |
862 #define REGISTER_G_LOG_HANDLER(name) \ | |
863 g_log_set_handler((name), G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL \ | |
864 | G_LOG_FLAG_RECURSION, \ | |
865 gaim_glib_log_handler, NULL) | |
866 | |
867 /* Register the glib/gtk log handlers. */ | |
868 REGISTER_G_LOG_HANDLER(NULL); | |
869 REGISTER_G_LOG_HANDLER("Gdk"); | |
870 REGISTER_G_LOG_HANDLER("Gtk"); | |
7229
26fe5055e0b0
[gaim-migrate @ 7799]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7152
diff
changeset
|
871 REGISTER_G_LOG_HANDLER("GdkPixbuf"); |
7150 | 872 REGISTER_G_LOG_HANDLER("GLib"); |
873 REGISTER_G_LOG_HANDLER("GModule"); | |
874 REGISTER_G_LOG_HANDLER("GLib-GObject"); | |
875 REGISTER_G_LOG_HANDLER("GThread"); | |
876 | |
877 #ifdef _WIN32 | |
10314 | 878 if (!gaim_debug_is_enabled()) |
7150 | 879 g_set_print_handler(gaim_glib_dummy_print_handler); |
880 #endif | |
5625
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
881 } |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
882 |
5212 | 883 void |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
884 gaim_gtk_debug_uninit(void) |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
885 { |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
886 gaim_debug_set_ui_ops(NULL); |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
887 } |
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 void |
5212 | 890 gaim_gtk_debug_window_show(void) |
891 { | |
892 if (debug_win == NULL) | |
893 debug_win = debug_window_new(); | |
894 | |
895 gtk_widget_show(debug_win->window); | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
896 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
897 gaim_prefs_set_bool("/gaim/gtk/debug/enabled", TRUE); |
5212 | 898 } |
899 | |
900 void | |
901 gaim_gtk_debug_window_hide(void) | |
902 { | |
903 if (debug_win != NULL) { | |
904 gtk_widget_destroy(debug_win->window); | |
905 debug_window_destroy(NULL, NULL, NULL); | |
906 } | |
907 } | |
908 | |
909 static void | |
910 gaim_gtk_debug_print(GaimDebugLevel level, const char *category, | |
911 const char *format, va_list args) | |
912 { | |
11262 | 913 #ifdef HAVE_REGEX_H |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
914 GtkTreeIter iter; |
11262 | 915 #endif /* HAVE_REGEX_H */ |
10307 | 916 gboolean timestamps; |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
917 gchar *arg_s, *ts_s; |
10307 | 918 gchar *esc_s, *cat_s, *tmp, *s; |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
919 |
10307 | 920 if (!gaim_prefs_get_bool("/gaim/gtk/debug/enabled") || |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
921 (debug_win == NULL)) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
922 { |
10307 | 923 return; |
924 } | |
925 | |
926 timestamps = gaim_prefs_get_bool("/core/debug/timestamps"); | |
5212 | 927 |
928 arg_s = g_strdup_vprintf(format, args); | |
929 | |
10307 | 930 /* |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
931 * For some reason we only print the timestamp if category is |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
932 * not NULL. Why the hell do we do that? --Mark |
10307 | 933 */ |
934 if ((category != NULL) && (timestamps)) { | |
935 gchar mdate[64]; | |
936 | |
937 time_t mtime = time(NULL); | |
938 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | |
939 ts_s = g_strdup_printf("(%s) ", mdate); | |
940 } else { | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
941 ts_s = g_strdup(""); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
942 } |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
943 |
10307 | 944 if (category == NULL) |
945 cat_s = g_strdup(""); | |
946 else | |
947 cat_s = g_strdup_printf("<b>%s:</b> ", category); | |
5212 | 948 |
10307 | 949 esc_s = g_markup_escape_text(arg_s, -1); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
950 |
10307 | 951 g_free(arg_s); |
5212 | 952 |
10307 | 953 s = g_strdup_printf("<font color=\"%s\">%s%s%s</font>", |
954 debug_fg_colors[level], ts_s, cat_s, esc_s); | |
5212 | 955 |
10307 | 956 g_free(ts_s); |
957 g_free(cat_s); | |
958 g_free(esc_s); | |
5212 | 959 |
10307 | 960 tmp = gaim_utf8_try_convert(s); |
961 g_free(s); | |
962 s = tmp; | |
5212 | 963 |
10307 | 964 if (level == GAIM_DEBUG_FATAL) { |
965 tmp = g_strdup_printf("<b>%s</b>", s); | |
5212 | 966 g_free(s); |
10307 | 967 s = tmp; |
5212 | 968 } |
969 | |
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
970 #ifdef HAVE_REGEX_H |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
971 /* add the text to the list store */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
972 gtk_list_store_append(debug_win->store, &iter); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
973 gtk_list_store_set(debug_win->store, &iter, 0, s, -1); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
974 #else /* HAVE_REGEX_H */ |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
975 if(!debug_win->paused) |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
976 gtk_imhtml_append_text(GTK_IMHTML(debug_win->text), s, 0); |
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
977 #endif /* !HAVE_REGEX_H */ |
5212 | 978 |
10307 | 979 g_free(s); |
5212 | 980 } |
981 | |
982 static GaimDebugUiOps ops = | |
983 { | |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
984 gaim_gtk_debug_print, |
5212 | 985 }; |
986 | |
987 GaimDebugUiOps * | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
988 gaim_gtk_debug_get_ui_ops(void) |
5212 | 989 { |
990 return &ops; | |
991 } | |
10087 | 992 |
993 void * | |
994 gaim_gtk_debug_get_handle() { | |
995 static int handle; | |
996 | |
997 return &handle; | |
998 } |