annotate src/gtkdebug.c @ 12790:651972254c7a

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