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