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