Mercurial > pidgin
annotate src/gtkdebug.c @ 9518:6c24a6f07256
[gaim-migrate @ 10345]
" Updates irc and silc to pass the topic setter to
gaim_conv_chat_set_topic. Theres more code duplication
in here than I would like, but it's better than adding
another var and adding more conditionals.." --Gary Kramlich
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Mon, 12 Jul 2004 19:38:05 +0000 |
parents | 2d4301c90aed |
children | 4d05b6e9e9cd |
rev | line source |
---|---|
5212 | 1 /** |
2 * @file gtkdebug.c GTK+ Debug API | |
3 * @ingroup gtkui | |
4 * | |
5 * gaim | |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
10 * |
5212 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6280
diff
changeset
|
25 #include "gtkinternal.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5818
diff
changeset
|
26 |
9480 | 27 #include "notify.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5818
diff
changeset
|
28 #include "prefs.h" |
8953 | 29 #include "request.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5818
diff
changeset
|
30 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5818
diff
changeset
|
31 |
5212 | 32 #include "gtkdebug.h" |
33 #include "gtkimhtml.h" | |
8953 | 34 #include "gtkutils.h" |
6009
5cd7a10c6ade
[gaim-migrate @ 6457]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
35 #include "stock.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5818
diff
changeset
|
36 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5818
diff
changeset
|
37 #include "ui.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5818
diff
changeset
|
38 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5818
diff
changeset
|
39 extern int opt_debug; |
5212 | 40 |
41 typedef struct | |
42 { | |
43 GtkWidget *window; | |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
44 GtkWidget *text; |
8953 | 45 GtkWidget *find; |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
46 |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
47 gboolean timestamps; |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
48 gboolean paused; |
5212 | 49 |
5704
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
50 guint timestamps_handle; |
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
51 |
5212 | 52 } DebugWindow; |
53 | |
54 static char debug_fg_colors[][8] = { | |
55 "#000000", /**< All debug levels. */ | |
7150 | 56 "#666666", /**< Misc. */ |
5212 | 57 "#000000", /**< Information. */ |
58 "#660000", /**< Warnings. */ | |
59 "#FF0000", /**< Errors. */ | |
60 "#FF0000", /**< Fatal errors. */ | |
61 }; | |
62 | |
63 static DebugWindow *debug_win = NULL; | |
64 | |
8953 | 65 struct _find { |
66 DebugWindow *window; | |
67 GtkWidget *entry; | |
68 }; | |
69 | |
5212 | 70 static gint |
71 debug_window_destroy(GtkWidget *w, GdkEvent *event, void *unused) | |
72 { | |
5704
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
73 if (debug_win->timestamps_handle != 0) |
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
74 gaim_prefs_disconnect_callback(debug_win->timestamps_handle); |
9502 | 75 |
76 /* If the "Save Log" dialog is open then close it */ | |
77 gaim_request_close_with_handle(debug_win); | |
5704
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
78 |
5212 | 79 g_free(debug_win); |
80 debug_win = NULL; | |
81 | |
9480 | 82 gaim_prefs_set_bool("/gaim/gtk/debug/enabled", FALSE); |
83 | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
84 return FALSE; |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
85 } |
5212 | 86 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
87 static gboolean |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5738
diff
changeset
|
88 configure_cb(GtkWidget *w, GdkEventConfigure *event, DebugWindow *win) |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
89 { |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
90 if (GTK_WIDGET_VISIBLE(w)) { |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
91 gaim_prefs_set_int("/gaim/gtk/debug/width", event->width); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
92 gaim_prefs_set_int("/gaim/gtk/debug/height", event->height); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
93 } |
5212 | 94 |
95 return FALSE; | |
96 } | |
97 | |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
98 static void |
9482 | 99 do_find_cb(GtkWidget *widget, gint response, struct _find *f) |
8953 | 100 { |
9482 | 101 switch (response) { |
8953 | 102 case GTK_RESPONSE_OK: |
103 gtk_imhtml_search_find(GTK_IMHTML(f->window->text), | |
104 gtk_entry_get_text(GTK_ENTRY(f->entry))); | |
105 break; | |
106 | |
107 case GTK_RESPONSE_DELETE_EVENT: | |
108 case GTK_RESPONSE_CLOSE: | |
109 gtk_imhtml_search_clear(GTK_IMHTML(f->window->text)); | |
110 gtk_widget_destroy(f->window->find); | |
111 f->window->find = NULL; | |
112 g_free(f); | |
113 break; | |
114 } | |
115 } | |
116 | |
117 static void | |
118 find_cb(GtkWidget *w, DebugWindow *win) | |
119 { | |
120 GtkWidget *hbox, *img, *label; | |
121 struct _find *f; | |
122 | |
123 if(win->find) | |
124 { | |
125 gtk_window_present(GTK_WINDOW(win->find)); | |
126 return; | |
127 } | |
128 | |
129 f = g_malloc(sizeof(struct _find)); | |
130 f->window = win; | |
131 win->find = gtk_dialog_new_with_buttons(_("Find"), | |
132 GTK_WINDOW(win->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
133 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
134 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
135 gtk_dialog_set_default_response(GTK_DIALOG(win->find), | |
136 GTK_RESPONSE_OK); | |
137 g_signal_connect(G_OBJECT(win->find), "response", | |
138 G_CALLBACK(do_find_cb), f); | |
139 | |
140 gtk_container_set_border_width(GTK_CONTAINER(win->find), 6); | |
141 gtk_window_set_resizable(GTK_WINDOW(win->find), FALSE); | |
142 gtk_dialog_set_has_separator(GTK_DIALOG(win->find), FALSE); | |
143 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(win->find)->vbox), 12); | |
144 gtk_container_set_border_width( | |
145 GTK_CONTAINER(GTK_DIALOG(win->find)->vbox), 6); | |
146 | |
147 hbox = gtk_hbox_new(FALSE, 12); | |
148 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(win->find)->vbox), | |
149 hbox); | |
150 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, | |
151 GTK_ICON_SIZE_DIALOG); | |
152 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
153 | |
154 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
155 gtk_dialog_set_response_sensitive(GTK_DIALOG(win->find), | |
156 GTK_RESPONSE_OK, FALSE); | |
157 | |
158 label = gtk_label_new(NULL); | |
159 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); | |
160 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
161 | |
162 f->entry = gtk_entry_new(); | |
163 gtk_entry_set_activates_default(GTK_ENTRY(f->entry), TRUE); | |
164 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(f->entry)); | |
165 g_signal_connect(G_OBJECT(f->entry), "changed", | |
166 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
167 win->find); | |
168 gtk_box_pack_start(GTK_BOX(hbox), f->entry, FALSE, FALSE, 0); | |
169 | |
170 gtk_widget_show_all(win->find); | |
171 gtk_widget_grab_focus(f->entry); | |
172 } | |
173 | |
174 static void | |
9502 | 175 save_writefile_cb(void *user_data, const char *filename) |
8953 | 176 { |
9502 | 177 DebugWindow *win = (DebugWindow *)user_data; |
9489 | 178 FILE *fp; |
8953 | 179 char *tmp; |
180 | |
9480 | 181 if ((fp = fopen(filename, "w+")) == NULL) { |
9502 | 182 gaim_notify_error(win, NULL, _("Unable to open file."), NULL); |
8953 | 183 return; |
9480 | 184 } |
8953 | 185 |
9489 | 186 tmp = gtk_imhtml_get_text(GTK_IMHTML(win->text), NULL, NULL); |
8953 | 187 fprintf(fp, "Gaim Debug log : %s\n", gaim_date_full()); |
188 fprintf(fp, "%s", tmp); | |
189 g_free(tmp); | |
190 | |
191 fclose(fp); | |
192 } | |
193 | |
194 static void | |
195 save_cb(GtkWidget *w, DebugWindow *win) | |
196 { | |
9502 | 197 gaim_request_file(win, _("Save Debug Log"), "gaim-debug.log", TRUE, |
198 G_CALLBACK(save_writefile_cb), NULL, win); | |
8953 | 199 } |
200 | |
201 static void | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5738
diff
changeset
|
202 clear_cb(GtkWidget *w, DebugWindow *win) |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
203 { |
6280
d330afe3ccf0
[gaim-migrate @ 6779]
Christian Hammond <chipx86@chipx86.com>
parents:
6094
diff
changeset
|
204 gtk_imhtml_clear(GTK_IMHTML(win->text)); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
205 } |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
206 |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
207 static void |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5738
diff
changeset
|
208 pause_cb(GtkWidget *w, DebugWindow *win) |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
209 { |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
210 win->paused = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)); |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
211 } |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
212 |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
213 static void |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5738
diff
changeset
|
214 timestamps_cb(GtkWidget *w, DebugWindow *win) |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
215 { |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
216 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
|
217 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
218 gaim_prefs_set_bool("/gaim/gtk/debug/timestamps", win->timestamps); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
219 } |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
220 |
5704
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
221 static void |
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
222 timestamps_pref_cb(const char *name, GaimPrefType type, gpointer value, |
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
223 gpointer data) |
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
224 { |
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
225 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
|
226 } |
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
227 |
5212 | 228 static DebugWindow * |
229 debug_window_new(void) | |
230 { | |
231 DebugWindow *win; | |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
232 GtkWidget *vbox; |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
233 GtkWidget *toolbar; |
5212 | 234 GtkWidget *sw; |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
235 GtkWidget *button; |
6094
538c522e36e1
[gaim-migrate @ 6553]
Christian Hammond <chipx86@chipx86.com>
parents:
6009
diff
changeset
|
236 GtkWidget *image; |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
237 int width, height; |
5212 | 238 |
239 win = g_new0(DebugWindow, 1); | |
240 | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
241 width = gaim_prefs_get_int("/gaim/gtk/debug/width"); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
242 height = gaim_prefs_get_int("/gaim/gtk/debug/height"); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
243 |
5212 | 244 GAIM_DIALOG(win->window); |
5642
1693a3027dc8
[gaim-migrate @ 6056]
Christian Hammond <chipx86@chipx86.com>
parents:
5636
diff
changeset
|
245 gaim_debug(GAIM_DEBUG_INFO, "gtkdebug", "Setting dimensions to %d, %d\n", |
1693a3027dc8
[gaim-migrate @ 6056]
Christian Hammond <chipx86@chipx86.com>
parents:
5636
diff
changeset
|
246 width, height); |
1693a3027dc8
[gaim-migrate @ 6056]
Christian Hammond <chipx86@chipx86.com>
parents:
5636
diff
changeset
|
247 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
248 gtk_window_set_default_size(GTK_WINDOW(win->window), width, height); |
5212 | 249 gtk_window_set_role(GTK_WINDOW(win->window), "debug"); |
250 gtk_window_set_title(GTK_WINDOW(win->window), _("Debug Window")); | |
251 | |
252 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
253 G_CALLBACK(debug_window_destroy), NULL); | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
254 g_signal_connect(G_OBJECT(win->window), "configure_event", |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5738
diff
changeset
|
255 G_CALLBACK(configure_cb), win); |
5212 | 256 |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
257 /* Setup the vbox */ |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
258 vbox = gtk_vbox_new(FALSE, 0); |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
259 gtk_container_add(GTK_CONTAINER(win->window), vbox); |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
260 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
261 if (gaim_prefs_get_bool("/gaim/gtk/debug/toolbar")) { |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
262 /* Setup our top button bar thingie. */ |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
263 toolbar = gtk_toolbar_new(); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
264 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH_HORIZ); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
265 gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar), |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
266 GTK_ICON_SIZE_SMALL_TOOLBAR); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
267 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
268 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
|
269 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
270 /* Find button */ |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
271 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_FIND, |
8953 | 272 NULL, NULL, G_CALLBACK(find_cb), win, -1); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
273 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
274 /* Save */ |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
275 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_SAVE, |
8953 | 276 NULL, NULL, G_CALLBACK(save_cb), win, -1); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
277 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
278 /* Clear button */ |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
279 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_CLEAR, |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5738
diff
changeset
|
280 NULL, NULL, G_CALLBACK(clear_cb), win, -1); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
281 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
282 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
283 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
284 /* Pause */ |
6094
538c522e36e1
[gaim-migrate @ 6553]
Christian Hammond <chipx86@chipx86.com>
parents:
6009
diff
changeset
|
285 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
|
286 button = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
538c522e36e1
[gaim-migrate @ 6553]
Christian Hammond <chipx86@chipx86.com>
parents:
6009
diff
changeset
|
287 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, |
538c522e36e1
[gaim-migrate @ 6553]
Christian Hammond <chipx86@chipx86.com>
parents:
6009
diff
changeset
|
288 NULL, _("Pause"), NULL, NULL, |
538c522e36e1
[gaim-migrate @ 6553]
Christian Hammond <chipx86@chipx86.com>
parents:
6009
diff
changeset
|
289 image, G_CALLBACK(pause_cb), win); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
290 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
291 /* Timestamps */ |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
292 button = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
293 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
294 NULL, _("Timestamps"), NULL, NULL, |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5738
diff
changeset
|
295 NULL, G_CALLBACK(timestamps_cb), |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
296 win); |
8953 | 297 |
298 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), | |
8002
c94f2dad3b73
[gaim-migrate @ 8679]
Christian Hammond <chipx86@chipx86.com>
parents:
7229
diff
changeset
|
299 gaim_prefs_get_bool("/gaim/gtk/debug/timestamps")); |
8953 | 300 |
5704
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
301 win->timestamps_handle = |
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
302 gaim_prefs_connect_callback("/gaim/gtk/debug/timestamps", |
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
303 timestamps_pref_cb, button); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
304 } |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
305 |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
306 /* Now our scrolled window... */ |
5212 | 307 sw = gtk_scrolled_window_new(NULL, NULL); |
308 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
309 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
310 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
311 GTK_SHADOW_IN); |
5212 | 312 |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
313 /* ... which has a gtkimhtml in it. */ |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
314 win->text = gtk_imhtml_new(NULL, NULL); |
5212 | 315 |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
316 gtk_container_add(GTK_CONTAINER(sw), win->text); |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
317 |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
318 /* Pack it in... Not like that, sicko. */ |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
319 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
320 |
5212 | 321 gtk_widget_show_all(win->window); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
322 |
5212 | 323 return win; |
324 } | |
325 | |
5625
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
326 static void |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
327 debug_enabled_cb(const char *name, GaimPrefType type, gpointer value, |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
328 gpointer data) |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
329 { |
5636 | 330 if (value) |
5625
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
331 gaim_gtk_debug_window_show(); |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
332 else |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
333 gaim_gtk_debug_window_hide(); |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
334 } |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
335 |
7150 | 336 static void |
337 gaim_glib_log_handler(const gchar *domain, GLogLevelFlags flags, | |
338 const gchar *msg, gpointer user_data) | |
339 { | |
340 GaimDebugLevel level; | |
341 char *new_msg = NULL; | |
342 char *new_domain = NULL; | |
343 | |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
344 if ((flags & G_LOG_LEVEL_ERROR) == G_LOG_LEVEL_ERROR) |
7150 | 345 level = GAIM_DEBUG_ERROR; |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
346 else if ((flags & G_LOG_LEVEL_CRITICAL) == G_LOG_LEVEL_CRITICAL) |
7150 | 347 level = GAIM_DEBUG_FATAL; |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
348 else if ((flags & G_LOG_LEVEL_WARNING) == G_LOG_LEVEL_WARNING) |
7150 | 349 level = GAIM_DEBUG_WARNING; |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
350 else if ((flags & G_LOG_LEVEL_MESSAGE) == G_LOG_LEVEL_MESSAGE) |
7150 | 351 level = GAIM_DEBUG_INFO; |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
352 else if ((flags & G_LOG_LEVEL_INFO) == G_LOG_LEVEL_INFO) |
7150 | 353 level = GAIM_DEBUG_INFO; |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
354 else if ((flags & G_LOG_LEVEL_DEBUG) == G_LOG_LEVEL_DEBUG) |
7150 | 355 level = GAIM_DEBUG_MISC; |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
356 else |
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
357 { |
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
358 gaim_debug_warning("gtkdebug", |
7150 | 359 "Unknown glib logging level in %d\n", flags); |
360 | |
361 level = GAIM_DEBUG_MISC; /* This will never happen. */ | |
362 } | |
363 | |
364 if (msg != NULL) | |
365 new_msg = gaim_utf8_try_convert(msg); | |
366 | |
367 if (domain != NULL) | |
368 new_domain = gaim_utf8_try_convert(domain); | |
369 | |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
370 if (new_msg != NULL) |
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
371 { |
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
372 gaim_debug(level, (new_domain != NULL ? new_domain : "g_log"), |
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
373 "%s\n", new_msg); |
7150 | 374 |
375 g_free(new_msg); | |
376 } | |
377 | |
378 if (new_domain != NULL) | |
379 g_free(new_domain); | |
380 } | |
381 | |
382 #ifdef _WIN32 | |
383 static void | |
384 gaim_glib_dummy_print_handler(const gchar *string) | |
385 { | |
386 } | |
387 #endif | |
388 | |
5625
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
389 void |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
390 gaim_gtk_debug_init(void) |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
391 { |
5684 | 392 /* Debug window preferences. */ |
393 /* | |
394 * NOTE: This must be set before prefs are loaded, and the callbacks | |
395 * set after they are loaded, since prefs sets the enabled | |
396 * preference here and that loads the window, which calls the | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
397 * configure event, which overrides the width and height! :P |
5684 | 398 */ |
399 | |
400 gaim_prefs_add_none("/gaim/gtk/debug"); | |
401 gaim_prefs_add_bool("/gaim/gtk/debug/enabled", FALSE); | |
402 gaim_prefs_add_bool("/gaim/gtk/debug/timestamps", FALSE); | |
403 gaim_prefs_add_bool("/gaim/gtk/debug/toolbar", TRUE); | |
404 gaim_prefs_add_int("/gaim/gtk/debug/width", 450); | |
405 gaim_prefs_add_int("/gaim/gtk/debug/height", 250); | |
406 | |
5625
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
407 gaim_prefs_connect_callback("/gaim/gtk/debug/enabled", |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5738
diff
changeset
|
408 debug_enabled_cb, NULL); |
7150 | 409 |
410 #define REGISTER_G_LOG_HANDLER(name) \ | |
411 g_log_set_handler((name), G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL \ | |
412 | G_LOG_FLAG_RECURSION, \ | |
413 gaim_glib_log_handler, NULL) | |
414 | |
415 /* Register the glib/gtk log handlers. */ | |
416 REGISTER_G_LOG_HANDLER(NULL); | |
417 REGISTER_G_LOG_HANDLER("Gdk"); | |
418 REGISTER_G_LOG_HANDLER("Gtk"); | |
7229
26fe5055e0b0
[gaim-migrate @ 7799]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7152
diff
changeset
|
419 REGISTER_G_LOG_HANDLER("GdkPixbuf"); |
7150 | 420 REGISTER_G_LOG_HANDLER("GLib"); |
421 REGISTER_G_LOG_HANDLER("GModule"); | |
422 REGISTER_G_LOG_HANDLER("GLib-GObject"); | |
423 REGISTER_G_LOG_HANDLER("GThread"); | |
424 | |
425 #ifdef _WIN32 | |
426 if (!opt_debug) | |
427 g_set_print_handler(gaim_glib_dummy_print_handler); | |
428 #endif | |
5625
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
429 } |
73c9dc20e41a
[gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents:
5535
diff
changeset
|
430 |
5212 | 431 void |
432 gaim_gtk_debug_window_show(void) | |
433 { | |
434 if (debug_win == NULL) | |
435 debug_win = debug_window_new(); | |
436 | |
437 gtk_widget_show(debug_win->window); | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
438 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
439 gaim_prefs_set_bool("/gaim/gtk/debug/enabled", TRUE); |
5212 | 440 } |
441 | |
442 void | |
443 gaim_gtk_debug_window_hide(void) | |
444 { | |
445 if (debug_win != NULL) { | |
446 gtk_widget_destroy(debug_win->window); | |
447 debug_window_destroy(NULL, NULL, NULL); | |
448 } | |
449 } | |
450 | |
451 static void | |
452 gaim_gtk_debug_print(GaimDebugLevel level, const char *category, | |
453 const char *format, va_list args) | |
454 { | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
455 gchar *arg_s, *ts_s; |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
456 gboolean timestamps; |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
457 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
458 timestamps = gaim_prefs_get_bool("/gaim/gtk/debug/timestamps"); |
5212 | 459 |
460 arg_s = g_strdup_vprintf(format, args); | |
461 | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
462 if (category == NULL) { |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
463 ts_s = g_strdup(""); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
464 } |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
465 else { |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
466 /* |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
467 * If the category is not NULL, then do timestamps. |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
468 * This IS right. :) |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
469 */ |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
470 if (timestamps) { |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
471 gchar mdate[64]; |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
472 time_t mtime = time(NULL); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
473 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
474 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
475 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
476 ts_s = g_strdup_printf("(%s) ", mdate); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
477 } |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
478 else |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
479 ts_s = g_strdup(""); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
480 } |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
481 |
5535 | 482 if (gaim_prefs_get_bool("/gaim/gtk/debug/enabled") && |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
483 debug_win != NULL && !debug_win->paused) { |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
484 |
5738
ec032cb2f9ec
[gaim-migrate @ 6162]
Christian Hammond <chipx86@chipx86.com>
parents:
5704
diff
changeset
|
485 gchar *esc_s, *cat_s, *utf8_s, *s; |
5212 | 486 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
487 if (category == NULL) |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
488 cat_s = g_strdup(""); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
489 else |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
490 cat_s = g_strdup_printf("<b>%s:</b> ", category); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
491 |
5212 | 492 esc_s = g_markup_escape_text(arg_s, -1); |
493 | |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
494 s = g_strdup_printf("<font color=\"%s\">%s%s%s</font>", |
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
495 debug_fg_colors[level], ts_s, cat_s, esc_s); |
5212 | 496 |
497 g_free(esc_s); | |
498 | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
499 utf8_s = gaim_utf8_try_convert(s); |
5738
ec032cb2f9ec
[gaim-migrate @ 6162]
Christian Hammond <chipx86@chipx86.com>
parents:
5704
diff
changeset
|
500 g_free(s); |
ec032cb2f9ec
[gaim-migrate @ 6162]
Christian Hammond <chipx86@chipx86.com>
parents:
5704
diff
changeset
|
501 s = utf8_s; |
ec032cb2f9ec
[gaim-migrate @ 6162]
Christian Hammond <chipx86@chipx86.com>
parents:
5704
diff
changeset
|
502 |
5212 | 503 if (level == GAIM_DEBUG_FATAL) { |
504 gchar *temp = s; | |
505 | |
506 s = g_strdup_printf("<b>%s</b>", temp); | |
507 g_free(temp); | |
508 } | |
509 | |
510 g_free(cat_s); | |
511 | |
6982 | 512 gtk_imhtml_append_text(GTK_IMHTML(debug_win->text), s, 0); |
5212 | 513 |
514 g_free(s); | |
515 } | |
516 | |
5214
7ea282e1f615
[gaim-migrate @ 5584]
Christian Hammond <chipx86@chipx86.com>
parents:
5212
diff
changeset
|
517 if (opt_debug) { |
7ea282e1f615
[gaim-migrate @ 5584]
Christian Hammond <chipx86@chipx86.com>
parents:
5212
diff
changeset
|
518 if (category == NULL) |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
519 g_print("%s%s", ts_s, arg_s); |
5214
7ea282e1f615
[gaim-migrate @ 5584]
Christian Hammond <chipx86@chipx86.com>
parents:
5212
diff
changeset
|
520 else |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
521 g_print("%s%s: %s", ts_s, category, arg_s); |
5214
7ea282e1f615
[gaim-migrate @ 5584]
Christian Hammond <chipx86@chipx86.com>
parents:
5212
diff
changeset
|
522 } |
5212 | 523 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
524 g_free(ts_s); |
5212 | 525 g_free(arg_s); |
526 } | |
527 | |
528 static GaimDebugUiOps ops = | |
529 { | |
530 gaim_gtk_debug_print | |
531 }; | |
532 | |
533 GaimDebugUiOps * | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
534 gaim_gtk_debug_get_ui_ops(void) |
5212 | 535 { |
536 return &ops; | |
537 } |