Mercurial > pidgin
annotate src/gtkdebug.c @ 13035:7da470b0c424
[gaim-migrate @ 15393]
Everyone says plugins shouldn't include internal.h. So, why do we install it? In keeping with my theory that diffs are the easiest way to explain what I'm thinking, I'm committing this. If it's bogus, feel free to revert or make me do so.
committer: Tailor Script <tailor@pidgin.im>
| author | Richard Laager <rlaager@wiktel.com> |
|---|---|
| date | Wed, 25 Jan 2006 06:39:02 +0000 |
| parents | 69b3d5cbd2b1 |
| children | e1e5462b7d81 |
| 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; |
|
13033
69b3d5cbd2b1
[gaim-migrate @ 15389]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
215 time_t now = time(NULL); |
|
69b3d5cbd2b1
[gaim-migrate @ 15389]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
216 char date[64]; |
| 8953 | 217 |
|
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10448
diff
changeset
|
218 if ((fp = g_fopen(filename, "w+")) == NULL) { |
| 9502 | 219 gaim_notify_error(win, NULL, _("Unable to open file."), NULL); |
| 8953 | 220 return; |
| 9480 | 221 } |
| 8953 | 222 |
| 9489 | 223 tmp = gtk_imhtml_get_text(GTK_IMHTML(win->text), NULL, NULL); |
|
13033
69b3d5cbd2b1
[gaim-migrate @ 15389]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
224 strftime(date, sizeof(date), "%c", localtime(&now)); |
|
69b3d5cbd2b1
[gaim-migrate @ 15389]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
225 fprintf(fp, "Gaim Debug Log : %s\n", date); |
| 8953 | 226 fprintf(fp, "%s", tmp); |
| 227 g_free(tmp); | |
| 228 | |
| 229 fclose(fp); | |
| 230 } | |
| 231 | |
| 232 static void | |
| 233 save_cb(GtkWidget *w, DebugWindow *win) | |
| 234 { | |
| 9502 | 235 gaim_request_file(win, _("Save Debug Log"), "gaim-debug.log", TRUE, |
| 236 G_CALLBACK(save_writefile_cb), NULL, win); | |
| 8953 | 237 } |
| 238 | |
| 239 static void | |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5738
diff
changeset
|
240 clear_cb(GtkWidget *w, DebugWindow *win) |
|
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
241 { |
|
6280
d330afe3ccf0
[gaim-migrate @ 6779]
Christian Hammond <chipx86@chipx86.com>
parents:
6094
diff
changeset
|
242 gtk_imhtml_clear(GTK_IMHTML(win->text)); |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
243 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
244 #ifdef HAVE_REGEX_H |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
245 gtk_list_store_clear(win->store); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
246 #endif /* HAVE_REGEX_H */ |
|
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
247 } |
|
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 static void |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5738
diff
changeset
|
250 pause_cb(GtkWidget *w, DebugWindow *win) |
|
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
251 { |
|
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
252 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
|
253 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
254 #ifdef HAVE_REGEX_H |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
255 if(!win->paused) { |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
256 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
257 regex_filter_all(win); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
258 else |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
259 regex_show_all(win); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
260 } |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
261 #endif /* HAVE_REGEX_H */ |
|
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
262 } |
|
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 static void |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5738
diff
changeset
|
265 timestamps_cb(GtkWidget *w, DebugWindow *win) |
|
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
266 { |
|
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
267 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
|
268 |
| 10307 | 269 gaim_prefs_set_bool("/core/debug/timestamps", win->timestamps); |
|
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
270 } |
|
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
271 |
|
5704
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
272 static void |
| 12816 | 273 timestamps_pref_cb(const char *name, GaimPrefType type, |
| 274 gconstpointer value, gpointer data) | |
|
5704
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
275 { |
|
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
276 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
|
277 } |
|
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
278 |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
279 /****************************************************************************** |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
280 * regex stuff |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
281 *****************************************************************************/ |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
282 #ifdef HAVE_REGEX_H |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
283 static void |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
284 regex_clear_color(GtkWidget *w) { |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
285 gtk_widget_modify_base(w, GTK_STATE_NORMAL, NULL); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
286 } |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
287 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
288 static void |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
289 regex_change_color(GtkWidget *w, guint16 r, guint16 g, guint16 b) { |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
290 GdkColor color; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
291 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
292 color.red = r; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
293 color.green = g; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
294 color.blue = b; |
|
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 gtk_widget_modify_base(w, GTK_STATE_NORMAL, &color); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
297 } |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
298 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
299 static void |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
300 regex_highlight_clear(DebugWindow *win) { |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
301 GtkIMHtml *imhtml = GTK_IMHTML(win->text); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
302 GtkTextIter s, e; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
303 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
304 gtk_text_buffer_get_start_iter(imhtml->text_buffer, &s); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
305 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &e); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
306 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
|
307 } |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
308 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
309 static void |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
310 regex_match(DebugWindow *win, const gchar *text) { |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
311 GtkIMHtml *imhtml = GTK_IMHTML(win->text); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
312 regmatch_t matches[4]; /* adjust if necessary */ |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
313 size_t n_matches = sizeof(matches) / sizeof(matches[0]); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
314 gchar *plaintext; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
315 gint inverted; |
|
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 if(!text) |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
318 return; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
319 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
320 inverted = (win->invert) ? REG_NOMATCH : 0; |
|
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 /* 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
|
323 * it makes the ^ and $ operators work :) |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
324 */ |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
325 plaintext = gaim_markup_strip_html(text); |
|
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 /* 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
|
328 * it, and work out the offsets to highlight. |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
329 */ |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
330 if(regexec(&win->regex, plaintext, n_matches, matches, 0) == inverted) { |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
331 GtkTextIter ins; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
332 gchar *p = plaintext; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
333 gint i, offset = 0; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
334 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
335 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &ins, |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
336 gtk_text_buffer_get_insert(imhtml->text_buffer)); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
337 i = gtk_text_iter_get_offset(&ins); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
338 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
339 gtk_imhtml_append_text(imhtml, text, 0); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
340 |
|
11312
a546498f7adc
[gaim-migrate @ 13512]
Gary Kramlich <grim@reaperworld.com>
parents:
11311
diff
changeset
|
341 /* 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
|
342 * done and move on. |
|
11310
0058b0737e76
[gaim-migrate @ 13510]
Gary Kramlich <grim@reaperworld.com>
parents:
11262
diff
changeset
|
343 */ |
|
0058b0737e76
[gaim-migrate @ 13510]
Gary Kramlich <grim@reaperworld.com>
parents:
11262
diff
changeset
|
344 if(!win->highlight || inverted == REG_NOMATCH) { |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
345 g_free(plaintext); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
346 return; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
347 } |
|
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 /* 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
|
350 * if necessary... |
|
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 do { |
|
12231
c342eb6e8cd3
[gaim-migrate @ 14533]
Richard Laager <rlaager@wiktel.com>
parents:
11473
diff
changeset
|
353 size_t m; |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
354 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
355 for(m = 0; m < n_matches; m++) { |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
356 GtkTextIter ms, me; |
|
11310
0058b0737e76
[gaim-migrate @ 13510]
Gary Kramlich <grim@reaperworld.com>
parents:
11262
diff
changeset
|
357 |
|
0058b0737e76
[gaim-migrate @ 13510]
Gary Kramlich <grim@reaperworld.com>
parents:
11262
diff
changeset
|
358 if(matches[m].rm_eo == -1) |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
359 break; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
360 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
361 i += offset; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
362 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
363 gtk_text_buffer_get_iter_at_offset(imhtml->text_buffer, &ms, |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
364 i + matches[m].rm_so); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
365 gtk_text_buffer_get_iter_at_offset(imhtml->text_buffer, &me, |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
366 i + matches[m].rm_eo); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
367 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "regex", |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
368 &ms, &me); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
369 offset = matches[m].rm_eo; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
370 } |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
371 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
372 p += offset; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
373 } while(regexec(&win->regex, p, n_matches, matches, REG_NOTBOL) == inverted); |
|
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 g_free(plaintext); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
377 } |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
378 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
379 static gboolean |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
380 regex_filter_all_cb(GtkTreeModel *m, GtkTreePath *p, GtkTreeIter *iter, |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
381 gpointer data) |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
382 { |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
383 DebugWindow *win = (DebugWindow *)data; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
384 gchar *text; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
385 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
386 gtk_tree_model_get(m, iter, 0, &text, -1); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
387 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
388 regex_match(win, text); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
389 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
390 g_free(text); |
|
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 return FALSE; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
393 } |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
394 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
395 static void |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
396 regex_filter_all(DebugWindow *win) { |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
397 gtk_imhtml_clear(GTK_IMHTML(win->text)); |
|
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 if(win->highlight) |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
400 regex_highlight_clear(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 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
|
403 win); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
404 } |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
405 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
406 static gboolean |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
407 regex_show_all_cb(GtkTreeModel *m, GtkTreePath *p, GtkTreeIter *iter, |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
408 gpointer data) |
|
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 DebugWindow *win = (DebugWindow *)data; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
411 gchar *text; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
412 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
413 gtk_tree_model_get(m, iter, 0, &text, -1); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
414 gtk_imhtml_append_text(GTK_IMHTML(win->text), text, 0); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
415 g_free(text); |
|
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 return FALSE; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
418 } |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
419 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
420 static void |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
421 regex_show_all(DebugWindow *win) { |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
422 gtk_imhtml_clear(GTK_IMHTML(win->text)); |
|
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 if(win->highlight) |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
425 regex_highlight_clear(win); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
426 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
427 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
|
428 win); |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
429 } |
|
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
430 |
|
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
431 static void |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
432 regex_compile(DebugWindow *win) { |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
433 const gchar *text; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
434 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
435 text = gtk_entry_get_text(GTK_ENTRY(win->expression)); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
436 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
437 if(text == NULL || *text == '\0') { |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
438 regex_clear_color(win->expression); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
439 gtk_widget_set_sensitive(win->filter, FALSE); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
440 return; |
|
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 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
443 regfree(&win->regex); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
444 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
445 if(regcomp(&win->regex, text, REG_EXTENDED | REG_ICASE) != 0) { |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
446 /* failed to compile */ |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
447 regex_change_color(win->expression, 0xFFFF, 0xAFFF, 0xAFFF); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
448 gtk_widget_set_sensitive(win->filter, FALSE); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
449 } else { |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
450 /* compiled successfully */ |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
451 regex_change_color(win->expression, 0xAFFF, 0xFFFF, 0xAFFF); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
452 gtk_widget_set_sensitive(win->filter, TRUE); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
453 } |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
454 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
455 /* 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
|
456 * got changed, and not the expression. |
|
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 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
459 regex_filter_all(win); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
460 } |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
461 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
462 static void |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
463 regex_pref_filter_cb(const gchar *name, GaimPrefType type, |
| 12816 | 464 gconstpointer val, gpointer data) |
|
11256
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 DebugWindow *win = (DebugWindow *)data; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
467 gboolean active = GPOINTER_TO_INT(val), current; |
|
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 if(!win || !win->window) |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
470 return; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
471 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
472 current = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter)); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
473 if(active != current) |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
474 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter), active); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
475 } |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
476 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
477 static void |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
478 regex_pref_expression_cb(const gchar *name, GaimPrefType type, |
| 12816 | 479 gconstpointer val, gpointer data) |
|
11256
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 DebugWindow *win = (DebugWindow *)data; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
482 const gchar *exp = (const gchar *)val; |
|
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 gtk_entry_set_text(GTK_ENTRY(win->expression), exp); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
485 } |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
486 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
487 static void |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
488 regex_pref_invert_cb(const gchar *name, GaimPrefType type, |
| 12816 | 489 gconstpointer val, gpointer data) |
|
11256
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 DebugWindow *win = (DebugWindow *)data; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
492 gboolean active = GPOINTER_TO_INT(val); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
493 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
494 win->invert = active; |
|
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 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
497 regex_filter_all(win); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
498 } |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
499 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
500 static void |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
501 regex_pref_highlight_cb(const gchar *name, GaimPrefType type, |
| 12816 | 502 gconstpointer val, gpointer data) |
|
11256
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 DebugWindow *win = (DebugWindow *)data; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
505 gboolean active = GPOINTER_TO_INT(val); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
506 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
507 win->highlight = active; |
|
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 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
510 regex_filter_all(win); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
511 } |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
512 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
513 static void |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
514 regex_row_changed_cb(GtkTreeModel *model, GtkTreePath *path, |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
515 GtkTreeIter *iter, DebugWindow *win) |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
516 { |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
517 gchar *text; |
|
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(!win || !win->window) |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
520 return; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
521 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
522 /* 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
|
523 * 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
|
524 * 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
|
525 * reiterate over the store to handle matches that were outputted when |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
526 * we were paused. |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
527 */ |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
528 if(win->paused) |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
529 return; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
530 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
531 gtk_tree_model_get(model, iter, 0, &text, -1); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
532 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
533 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) { |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
534 regex_match(win, text); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
535 } else { |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
536 gtk_imhtml_append_text(GTK_IMHTML(win->text), text, 0); |
|
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 g_free(text); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
540 } |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
541 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
542 static gboolean |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
543 regex_timer_cb(DebugWindow *win) { |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
544 const gchar *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 text = gtk_entry_get_text(GTK_ENTRY(win->expression)); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
547 gaim_prefs_set_string("/gaim/gtk/debug/regex", text); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
548 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
549 win->timer = 0; |
|
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 return FALSE; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
552 } |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
553 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
554 static void |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
555 regex_changed_cb(GtkWidget *w, DebugWindow *win) { |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
556 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) { |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
557 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter), |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
558 FALSE); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
559 } |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
560 |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
561 if(win->timer == 0) |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
562 win->timer = gaim_timeout_add(5000, (GSourceFunc)regex_timer_cb, win); |
|
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 regex_compile(win); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
565 } |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
566 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
567 static void |
|
11450
b7978afe81d0
[gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents:
11312
diff
changeset
|
568 regex_key_release_cb(GtkWidget *w, GdkEventKey *e, DebugWindow *win) { |
|
11473
171c34a04a9f
[gaim-migrate @ 13714]
Gary Kramlich <grim@reaperworld.com>
parents:
11450
diff
changeset
|
569 if(e->keyval == GDK_Return && |
|
11450
b7978afe81d0
[gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents:
11312
diff
changeset
|
570 GTK_WIDGET_IS_SENSITIVE(win->filter) && |
|
b7978afe81d0
[gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents:
11312
diff
changeset
|
571 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) |
|
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 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter), TRUE); |
|
b7978afe81d0
[gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents:
11312
diff
changeset
|
574 } |
|
b7978afe81d0
[gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents:
11312
diff
changeset
|
575 } |
|
b7978afe81d0
[gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents:
11312
diff
changeset
|
576 |
|
b7978afe81d0
[gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents:
11312
diff
changeset
|
577 static void |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
578 regex_menu_cb(GtkWidget *item, const gchar *pref) { |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
579 gboolean active; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
580 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
581 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
|
582 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
583 gaim_prefs_set_bool(pref, active); |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
584 } |
|
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
585 |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
586 static void |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
587 regex_popup_cb(GtkEntry *entry, GtkWidget *menu, DebugWindow *win) { |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
588 gaim_separator(menu); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
589 gaim_new_check_item(menu, _("Invert"), |
|
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/invert", win->invert); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
592 gaim_new_check_item(menu, _("Highlight matches"), |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
593 G_CALLBACK(regex_menu_cb), |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
594 "/gaim/gtk/debug/highlight", win->highlight); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
595 } |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
596 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
597 static void |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
598 regex_filter_toggled_cb(GtkToggleButton *button, DebugWindow *win) { |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
599 gboolean active; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
600 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
601 active = gtk_toggle_button_get_active(button); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
602 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
603 gaim_prefs_set_bool("/gaim/gtk/debug/filter", active); |
|
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(!GTK_IS_IMHTML(win->text)) |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
606 return; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
607 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
608 if(active) |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
609 regex_filter_all(win); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
610 else |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
611 regex_show_all(win); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
612 } |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
613 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
614 #endif /* HAVE_REGEX_H */ |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
615 |
| 5212 | 616 static DebugWindow * |
| 617 debug_window_new(void) | |
| 618 { | |
| 619 DebugWindow *win; | |
|
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
620 GtkWidget *vbox; |
|
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
621 GtkWidget *toolbar; |
| 10175 | 622 GtkWidget *frame; |
|
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
623 GtkWidget *button; |
|
6094
538c522e36e1
[gaim-migrate @ 6553]
Christian Hammond <chipx86@chipx86.com>
parents:
6009
diff
changeset
|
624 GtkWidget *image; |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
625 gint width, height; |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
626 void *handle; |
| 5212 | 627 |
| 628 win = g_new0(DebugWindow, 1); | |
| 629 | |
|
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
630 width = gaim_prefs_get_int("/gaim/gtk/debug/width"); |
|
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
631 height = gaim_prefs_get_int("/gaim/gtk/debug/height"); |
|
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
632 |
| 5212 | 633 GAIM_DIALOG(win->window); |
| 10309 | 634 gaim_debug_info("gtkdebug", "Setting dimensions to %d, %d\n", |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
635 width, height); |
|
5642
1693a3027dc8
[gaim-migrate @ 6056]
Christian Hammond <chipx86@chipx86.com>
parents:
5636
diff
changeset
|
636 |
|
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
637 gtk_window_set_default_size(GTK_WINDOW(win->window), width, height); |
| 5212 | 638 gtk_window_set_role(GTK_WINDOW(win->window), "debug"); |
| 639 gtk_window_set_title(GTK_WINDOW(win->window), _("Debug Window")); | |
| 640 | |
| 641 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
642 G_CALLBACK(debug_window_destroy), NULL); |
|
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
643 g_signal_connect(G_OBJECT(win->window), "configure_event", |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
644 G_CALLBACK(configure_cb), win); |
| 5212 | 645 |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
646 handle = gaim_gtk_debug_get_handle(); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
647 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
648 #ifdef HAVE_REGEX_H |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
649 /* the list store for all the messages */ |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
650 win->store = gtk_list_store_new(1, G_TYPE_STRING); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
651 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
652 /* 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
|
653 * gets called with gtk_list_store_append, which is a |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
654 * 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
|
655 * changed. -Gary |
|
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 g_signal_connect(G_OBJECT(win->store), "row-changed", |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
658 G_CALLBACK(regex_row_changed_cb), win); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
659 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
660 #endif /* HAVE_REGEX_H */ |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
661 |
|
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
662 /* Setup the vbox */ |
|
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
663 vbox = gtk_vbox_new(FALSE, 0); |
|
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
664 gtk_container_add(GTK_CONTAINER(win->window), vbox); |
|
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
665 |
|
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
666 if (gaim_prefs_get_bool("/gaim/gtk/debug/toolbar")) { |
|
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
667 /* Setup our top button bar thingie. */ |
|
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
668 toolbar = gtk_toolbar_new(); |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
669 gtk_toolbar_set_tooltips(GTK_TOOLBAR(toolbar), TRUE); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
670 |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
671 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), |
|
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
672 GTK_TOOLBAR_BOTH_HORIZ); |
|
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
673 gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar), |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
674 GTK_ICON_SIZE_SMALL_TOOLBAR); |
|
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
675 |
|
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
676 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
|
677 |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
678 #ifndef HAVE_REGEX_H |
|
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
679 /* Find button */ |
|
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
680 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_FIND, |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
681 _("Find"), NULL, G_CALLBACK(find_cb), |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
682 win, -1); |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
683 #endif /* HAVE_REGEX_H */ |
|
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
684 |
|
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
685 /* Save */ |
|
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
686 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_SAVE, |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
687 _("Save"), NULL, G_CALLBACK(save_cb), |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
688 win, -1); |
|
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
689 |
|
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
690 /* Clear button */ |
|
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
691 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_CLEAR, |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
692 _("Clear"), NULL, G_CALLBACK(clear_cb), |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
693 win, -1); |
|
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
694 |
|
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
695 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1); |
|
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
696 |
|
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
697 /* Pause */ |
|
6094
538c522e36e1
[gaim-migrate @ 6553]
Christian Hammond <chipx86@chipx86.com>
parents:
6009
diff
changeset
|
698 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
|
699 button = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
700 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
701 NULL, _("Pause"), _("Pause"), |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
702 NULL, image, |
|
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
703 G_CALLBACK(pause_cb), win); |
|
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
704 |
|
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
705 /* Timestamps */ |
|
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
706 button = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
707 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, |
|
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
708 NULL, _("Timestamps"), |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
709 _("Timestamps"), NULL, NULL, |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
710 G_CALLBACK(timestamps_cb), |
|
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
711 win); |
| 8953 | 712 |
| 713 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), | |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
714 gaim_prefs_get_bool("/core/debug/timestamps")); |
|
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 gaim_prefs_connect_callback(handle, "/core/debug/timestamps", |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
717 timestamps_pref_cb, button); |
|
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
718 |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
719 #ifdef HAVE_REGEX_H |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
720 /* regex stuff */ |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
721 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1); |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
722 |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
723 /* regex toggle button */ |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
724 win->filter = |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
725 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
726 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
727 NULL, _("Filter"), _("Filter"), |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
728 NULL, NULL, |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
729 G_CALLBACK(regex_filter_toggled_cb), |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
730 win); |
|
11450
b7978afe81d0
[gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents:
11312
diff
changeset
|
731 /* we purposely disable the toggle button here in case |
|
b7978afe81d0
[gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents:
11312
diff
changeset
|
732 * /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
|
733 * 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
|
734 * toggle button sensitive. |
|
b7978afe81d0
[gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents:
11312
diff
changeset
|
735 */ |
|
b7978afe81d0
[gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents:
11312
diff
changeset
|
736 gtk_widget_set_sensitive(win->filter, FALSE); |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
737 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter), |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
738 gaim_prefs_get_bool("/gaim/gtk/debug/filter")); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
739 gaim_prefs_connect_callback(handle, "/gaim/gtk/debug/filter", |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
740 regex_pref_filter_cb, win); |
| 8953 | 741 |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
742 /* regex entry */ |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
743 win->expression = gtk_entry_new(); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
744 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
745 GTK_TOOLBAR_CHILD_WIDGET, win->expression, |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
746 NULL, _("Right click for more options."), |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
747 NULL, NULL, NULL, NULL); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
748 /* 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
|
749 * to colorize a stored expression. |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
750 */ |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
751 g_signal_connect(G_OBJECT(win->expression), "changed", |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
752 G_CALLBACK(regex_changed_cb), win); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
753 gtk_entry_set_text(GTK_ENTRY(win->expression), |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
754 gaim_prefs_get_string("/gaim/gtk/debug/regex")); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
755 g_signal_connect(G_OBJECT(win->expression), "populate-popup", |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
756 G_CALLBACK(regex_popup_cb), win); |
|
11450
b7978afe81d0
[gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents:
11312
diff
changeset
|
757 g_signal_connect(G_OBJECT(win->expression), "key-release-event", |
|
b7978afe81d0
[gaim-migrate @ 13689]
Gary Kramlich <grim@reaperworld.com>
parents:
11312
diff
changeset
|
758 G_CALLBACK(regex_key_release_cb), win); |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
759 gaim_prefs_connect_callback(handle, "/gaim/gtk/debug/regex", |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
760 regex_pref_expression_cb, win); |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
761 |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
762 /* connect the rest of our pref callbacks */ |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
763 win->invert = gaim_prefs_get_bool("/gaim/gtk/debug/invert"); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
764 gaim_prefs_connect_callback(handle, "/gaim/gtk/debug/invert", |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
765 regex_pref_invert_cb, win); |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
766 |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
767 win->highlight = gaim_prefs_get_bool("/gaim/gtk/debug/highlight"); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
768 gaim_prefs_connect_callback(handle, "/gaim/gtk/debug/highlight", |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
769 regex_pref_highlight_cb, win); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
770 |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
771 #endif /* HAVE_REGEX_H */ |
|
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
772 } |
|
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
773 |
| 10175 | 774 /* Add the gtkimhtml */ |
| 775 frame = gaim_gtk_create_imhtml(FALSE, &win->text, NULL); | |
| 10739 | 776 gtk_imhtml_set_format_functions(GTK_IMHTML(win->text), |
| 777 GTK_IMHTML_ALL ^ GTK_IMHTML_SMILEY ^ GTK_IMHTML_IMAGE); | |
| 10175 | 778 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
| 779 gtk_widget_show(frame); | |
|
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
780 |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
781 #ifdef HAVE_REGEX_H |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
782 /* add the tag for regex highlighting */ |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
783 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
|
784 "background", "#FFAFAF", |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
785 "weight", "bold", |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
786 NULL); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
787 #endif /* HAVE_REGEX_H */ |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
788 |
| 5212 | 789 gtk_widget_show_all(win->window); |
|
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
790 |
| 5212 | 791 return win; |
| 792 } | |
| 793 | |
|
5625
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
794 static void |
| 12816 | 795 debug_enabled_cb(const char *name, GaimPrefType type, |
| 796 gconstpointer value, gpointer data) | |
|
5625
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
797 { |
| 5636 | 798 if (value) |
|
5625
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
799 gaim_gtk_debug_window_show(); |
|
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
800 else |
|
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
801 gaim_gtk_debug_window_hide(); |
|
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
802 } |
|
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
803 |
| 7150 | 804 static void |
| 805 gaim_glib_log_handler(const gchar *domain, GLogLevelFlags flags, | |
| 806 const gchar *msg, gpointer user_data) | |
| 807 { | |
| 808 GaimDebugLevel level; | |
| 809 char *new_msg = NULL; | |
| 810 char *new_domain = NULL; | |
| 811 | |
|
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
812 if ((flags & G_LOG_LEVEL_ERROR) == G_LOG_LEVEL_ERROR) |
| 7150 | 813 level = GAIM_DEBUG_ERROR; |
|
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
814 else if ((flags & G_LOG_LEVEL_CRITICAL) == G_LOG_LEVEL_CRITICAL) |
| 7150 | 815 level = GAIM_DEBUG_FATAL; |
|
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
816 else if ((flags & G_LOG_LEVEL_WARNING) == G_LOG_LEVEL_WARNING) |
| 7150 | 817 level = GAIM_DEBUG_WARNING; |
|
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
818 else if ((flags & G_LOG_LEVEL_MESSAGE) == G_LOG_LEVEL_MESSAGE) |
| 7150 | 819 level = GAIM_DEBUG_INFO; |
|
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
820 else if ((flags & G_LOG_LEVEL_INFO) == G_LOG_LEVEL_INFO) |
| 7150 | 821 level = GAIM_DEBUG_INFO; |
|
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
822 else if ((flags & G_LOG_LEVEL_DEBUG) == G_LOG_LEVEL_DEBUG) |
| 7150 | 823 level = GAIM_DEBUG_MISC; |
|
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
824 else |
|
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
825 { |
|
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
826 gaim_debug_warning("gtkdebug", |
| 7150 | 827 "Unknown glib logging level in %d\n", flags); |
| 828 | |
| 829 level = GAIM_DEBUG_MISC; /* This will never happen. */ | |
| 830 } | |
| 831 | |
| 832 if (msg != NULL) | |
| 833 new_msg = gaim_utf8_try_convert(msg); | |
| 834 | |
| 835 if (domain != NULL) | |
| 836 new_domain = gaim_utf8_try_convert(domain); | |
| 837 | |
|
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
838 if (new_msg != NULL) |
|
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
839 { |
|
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
840 gaim_debug(level, (new_domain != NULL ? new_domain : "g_log"), |
|
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
841 "%s\n", new_msg); |
| 7150 | 842 |
| 843 g_free(new_msg); | |
| 844 } | |
| 845 | |
| 846 if (new_domain != NULL) | |
| 847 g_free(new_domain); | |
| 848 } | |
| 849 | |
| 850 #ifdef _WIN32 | |
| 851 static void | |
| 852 gaim_glib_dummy_print_handler(const gchar *string) | |
| 853 { | |
| 854 } | |
| 855 #endif | |
| 856 | |
|
5625
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
857 void |
|
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
858 gaim_gtk_debug_init(void) |
|
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
859 { |
| 5684 | 860 /* Debug window preferences. */ |
| 861 /* | |
| 862 * NOTE: This must be set before prefs are loaded, and the callbacks | |
| 863 * set after they are loaded, since prefs sets the enabled | |
| 864 * preference here and that loads the window, which calls the | |
|
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
865 * configure event, which overrides the width and height! :P |
| 5684 | 866 */ |
| 867 | |
| 868 gaim_prefs_add_none("/gaim/gtk/debug"); | |
| 10307 | 869 |
| 870 /* Controls printing to the debug window */ | |
| 5684 | 871 gaim_prefs_add_bool("/gaim/gtk/debug/enabled", FALSE); |
| 10307 | 872 |
| 5684 | 873 gaim_prefs_add_bool("/gaim/gtk/debug/toolbar", TRUE); |
| 874 gaim_prefs_add_int("/gaim/gtk/debug/width", 450); | |
| 875 gaim_prefs_add_int("/gaim/gtk/debug/height", 250); | |
| 876 | |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
877 #ifdef HAVE_REGEX_H |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
878 gaim_prefs_add_string("/gaim/gtk/debug/regex", ""); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
879 gaim_prefs_add_bool("/gaim/gtk/debug/filter", FALSE); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
880 gaim_prefs_add_bool("/gaim/gtk/debug/invert", FALSE); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
881 gaim_prefs_add_bool("/gaim/gtk/debug/case_insensitive", FALSE); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
882 gaim_prefs_add_bool("/gaim/gtk/debug/highlight", FALSE); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
883 #endif /* HAVE_REGEX_H */ |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
884 |
| 10087 | 885 gaim_prefs_connect_callback(NULL, "/gaim/gtk/debug/enabled", |
|
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5738
diff
changeset
|
886 debug_enabled_cb, NULL); |
| 7150 | 887 |
| 888 #define REGISTER_G_LOG_HANDLER(name) \ | |
| 889 g_log_set_handler((name), G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL \ | |
| 890 | G_LOG_FLAG_RECURSION, \ | |
| 891 gaim_glib_log_handler, NULL) | |
| 892 | |
| 893 /* Register the glib/gtk log handlers. */ | |
| 894 REGISTER_G_LOG_HANDLER(NULL); | |
| 895 REGISTER_G_LOG_HANDLER("Gdk"); | |
| 896 REGISTER_G_LOG_HANDLER("Gtk"); | |
|
7229
26fe5055e0b0
[gaim-migrate @ 7799]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7152
diff
changeset
|
897 REGISTER_G_LOG_HANDLER("GdkPixbuf"); |
| 7150 | 898 REGISTER_G_LOG_HANDLER("GLib"); |
| 899 REGISTER_G_LOG_HANDLER("GModule"); | |
| 900 REGISTER_G_LOG_HANDLER("GLib-GObject"); | |
| 901 REGISTER_G_LOG_HANDLER("GThread"); | |
| 902 | |
| 903 #ifdef _WIN32 | |
| 10314 | 904 if (!gaim_debug_is_enabled()) |
| 7150 | 905 g_set_print_handler(gaim_glib_dummy_print_handler); |
| 906 #endif | |
|
5625
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
907 } |
|
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
908 |
| 5212 | 909 void |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
910 gaim_gtk_debug_uninit(void) |
|
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 gaim_debug_set_ui_ops(NULL); |
|
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
913 } |
|
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
914 |
|
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
915 void |
| 5212 | 916 gaim_gtk_debug_window_show(void) |
| 917 { | |
| 918 if (debug_win == NULL) | |
| 919 debug_win = debug_window_new(); | |
| 920 | |
| 921 gtk_widget_show(debug_win->window); | |
|
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
922 |
|
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
923 gaim_prefs_set_bool("/gaim/gtk/debug/enabled", TRUE); |
| 5212 | 924 } |
| 925 | |
| 926 void | |
| 927 gaim_gtk_debug_window_hide(void) | |
| 928 { | |
| 929 if (debug_win != NULL) { | |
| 930 gtk_widget_destroy(debug_win->window); | |
| 931 debug_window_destroy(NULL, NULL, NULL); | |
| 932 } | |
| 933 } | |
| 934 | |
| 935 static void | |
| 936 gaim_gtk_debug_print(GaimDebugLevel level, const char *category, | |
| 937 const char *format, va_list args) | |
| 938 { | |
| 11262 | 939 #ifdef HAVE_REGEX_H |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
940 GtkTreeIter iter; |
| 11262 | 941 #endif /* HAVE_REGEX_H */ |
| 10307 | 942 gboolean timestamps; |
|
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
943 gchar *arg_s, *ts_s; |
| 10307 | 944 gchar *esc_s, *cat_s, *tmp, *s; |
|
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
945 |
| 10307 | 946 if (!gaim_prefs_get_bool("/gaim/gtk/debug/enabled") || |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
947 (debug_win == NULL)) |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
948 { |
| 10307 | 949 return; |
| 950 } | |
| 951 | |
| 952 timestamps = gaim_prefs_get_bool("/core/debug/timestamps"); | |
| 5212 | 953 |
| 954 arg_s = g_strdup_vprintf(format, args); | |
| 955 | |
| 10307 | 956 /* |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
957 * For some reason we only print the timestamp if category is |
|
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
958 * not NULL. Why the hell do we do that? --Mark |
| 10307 | 959 */ |
| 960 if ((category != NULL) && (timestamps)) { | |
| 961 gchar mdate[64]; | |
| 962 | |
| 963 time_t mtime = time(NULL); | |
| 964 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | |
| 965 ts_s = g_strdup_printf("(%s) ", mdate); | |
| 966 } else { | |
|
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
967 ts_s = g_strdup(""); |
|
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
968 } |
|
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
969 |
| 10307 | 970 if (category == NULL) |
| 971 cat_s = g_strdup(""); | |
| 972 else | |
| 973 cat_s = g_strdup_printf("<b>%s:</b> ", category); | |
| 5212 | 974 |
| 10307 | 975 esc_s = g_markup_escape_text(arg_s, -1); |
|
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
976 |
| 10307 | 977 g_free(arg_s); |
| 5212 | 978 |
| 10307 | 979 s = g_strdup_printf("<font color=\"%s\">%s%s%s</font>", |
| 980 debug_fg_colors[level], ts_s, cat_s, esc_s); | |
| 5212 | 981 |
| 10307 | 982 g_free(ts_s); |
| 983 g_free(cat_s); | |
| 984 g_free(esc_s); | |
| 5212 | 985 |
| 10307 | 986 tmp = gaim_utf8_try_convert(s); |
| 987 g_free(s); | |
| 988 s = tmp; | |
| 5212 | 989 |
| 10307 | 990 if (level == GAIM_DEBUG_FATAL) { |
| 991 tmp = g_strdup_printf("<b>%s</b>", s); | |
| 5212 | 992 g_free(s); |
| 10307 | 993 s = tmp; |
| 5212 | 994 } |
| 995 | |
|
11256
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
996 #ifdef HAVE_REGEX_H |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
997 /* add the text to the list store */ |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
998 gtk_list_store_append(debug_win->store, &iter); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
999 gtk_list_store_set(debug_win->store, &iter, 0, s, -1); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
1000 #else /* HAVE_REGEX_H */ |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
1001 if(!debug_win->paused) |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
1002 gtk_imhtml_append_text(GTK_IMHTML(debug_win->text), s, 0); |
|
bb0d7b719af2
[gaim-migrate @ 13430]
Gary Kramlich <grim@reaperworld.com>
parents:
11243
diff
changeset
|
1003 #endif /* !HAVE_REGEX_H */ |
| 5212 | 1004 |
| 10307 | 1005 g_free(s); |
| 5212 | 1006 } |
| 1007 | |
| 1008 static GaimDebugUiOps ops = | |
| 1009 { | |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10739
diff
changeset
|
1010 gaim_gtk_debug_print, |
| 5212 | 1011 }; |
| 1012 | |
| 1013 GaimDebugUiOps * | |
|
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1014 gaim_gtk_debug_get_ui_ops(void) |
| 5212 | 1015 { |
| 1016 return &ops; | |
| 1017 } | |
| 10087 | 1018 |
| 1019 void * | |
| 1020 gaim_gtk_debug_get_handle() { | |
| 1021 static int handle; | |
| 1022 | |
| 1023 return &handle; | |
| 1024 } |
