comparison finch/gntdebug.c @ 15822:32c366eeeb99

sed -ie 's/gaim/purple/g'
author Sean Egan <seanegan@gmail.com>
date Mon, 19 Mar 2007 07:01:17 +0000
parents 0e3a8505ebbe
children 66dff3dfdea6
comparison
equal deleted inserted replaced
15821:84b0f9b23ede 15822:32c366eeeb99
1 /** 1 /**
2 * @file gntdebug.c GNT Debug API 2 * @file gntdebug.c GNT Debug API
3 * @ingroup gntui 3 * @ingroup gntui
4 * 4 *
5 * gaim 5 * purple
6 * 6 *
7 * Gaim is the legal property of its developers, whose names are too numerous 7 * Purple 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 8 * to list here. Please refer to the COPYRIGHT file distributed with this
9 * source distribution. 9 * source distribution.
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 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 12 * it under the terms of the GNU General Public License as published by
28 #include <gntbutton.h> 28 #include <gntbutton.h>
29 #include <gntcheckbox.h> 29 #include <gntcheckbox.h>
30 #include <gntline.h> 30 #include <gntline.h>
31 31
32 #include "gntdebug.h" 32 #include "gntdebug.h"
33 #include "gntgaim.h" 33 #include "finch.h"
34 #include "util.h" 34 #include "util.h"
35 35
36 #include <stdio.h> 36 #include <stdio.h>
37 #include <string.h> 37 #include <string.h>
38 38
39 #define PREF_ROOT "/gaim/gnt/debug" 39 #define PREF_ROOT "/purple/gnt/debug"
40 40
41 static struct 41 static struct
42 { 42 {
43 GntWidget *window; 43 GntWidget *window;
44 GntWidget *tview; 44 GntWidget *tview;
65 } 65 }
66 return FALSE; 66 return FALSE;
67 } 67 }
68 68
69 static void 69 static void
70 finch_debug_print(GaimDebugLevel level, const char *category, 70 finch_debug_print(PurpleDebugLevel level, const char *category,
71 const char *args) 71 const char *args)
72 { 72 {
73 if (debug.window && !debug.paused) 73 if (debug.window && !debug.paused)
74 { 74 {
75 int pos = gnt_text_view_get_lines_below(GNT_TEXT_VIEW(debug.tview)); 75 int pos = gnt_text_view_get_lines_below(GNT_TEXT_VIEW(debug.tview));
76 GntTextFormatFlags flag = GNT_TEXT_FLAG_NORMAL; 76 GntTextFormatFlags flag = GNT_TEXT_FLAG_NORMAL;
77 77
78 if (debug.timestamps) { 78 if (debug.timestamps) {
79 const char *mdate; 79 const char *mdate;
80 time_t mtime = time(NULL); 80 time_t mtime = time(NULL);
81 mdate = gaim_utf8_strftime("%H:%M:%S ", localtime(&mtime)); 81 mdate = purple_utf8_strftime("%H:%M:%S ", localtime(&mtime));
82 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), 82 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview),
83 mdate, flag); 83 mdate, flag);
84 } 84 }
85 85
86 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), 86 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview),
88 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), 88 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview),
89 ": ", GNT_TEXT_FLAG_BOLD); 89 ": ", GNT_TEXT_FLAG_BOLD);
90 90
91 switch (level) 91 switch (level)
92 { 92 {
93 case GAIM_DEBUG_WARNING: 93 case PURPLE_DEBUG_WARNING:
94 flag |= GNT_TEXT_FLAG_UNDERLINE; 94 flag |= GNT_TEXT_FLAG_UNDERLINE;
95 case GAIM_DEBUG_ERROR: 95 case PURPLE_DEBUG_ERROR:
96 case GAIM_DEBUG_FATAL: 96 case PURPLE_DEBUG_FATAL:
97 flag |= GNT_TEXT_FLAG_BOLD; 97 flag |= GNT_TEXT_FLAG_BOLD;
98 break; 98 break;
99 default: 99 default:
100 break; 100 break;
101 } 101 }
104 if (pos <= 1) 104 if (pos <= 1)
105 gnt_text_view_scroll(GNT_TEXT_VIEW(debug.tview), 0); 105 gnt_text_view_scroll(GNT_TEXT_VIEW(debug.tview), 0);
106 } 106 }
107 } 107 }
108 108
109 static GaimDebugUiOps uiops = 109 static PurpleDebugUiOps uiops =
110 { 110 {
111 finch_debug_print, 111 finch_debug_print,
112 }; 112 };
113 113
114 GaimDebugUiOps *finch_debug_get_ui_ops() 114 PurpleDebugUiOps *finch_debug_get_ui_ops()
115 { 115 {
116 return &uiops; 116 return &uiops;
117 } 117 }
118 118
119 static void 119 static void
146 146
147 static void 147 static void
148 toggle_timestamps(GntWidget *w, gpointer n) 148 toggle_timestamps(GntWidget *w, gpointer n)
149 { 149 {
150 debug.timestamps = !debug.timestamps; 150 debug.timestamps = !debug.timestamps;
151 gaim_prefs_set_bool("/core/debug/timestamps", debug.timestamps); 151 purple_prefs_set_bool("/core/debug/timestamps", debug.timestamps);
152 } 152 }
153 153
154 /* Xerox */ 154 /* Xerox */
155 static void 155 static void
156 gaim_glib_log_handler(const gchar *domain, GLogLevelFlags flags, 156 purple_glib_log_handler(const gchar *domain, GLogLevelFlags flags,
157 const gchar *msg, gpointer user_data) 157 const gchar *msg, gpointer user_data)
158 { 158 {
159 GaimDebugLevel level; 159 PurpleDebugLevel level;
160 char *new_msg = NULL; 160 char *new_msg = NULL;
161 char *new_domain = NULL; 161 char *new_domain = NULL;
162 162
163 if ((flags & G_LOG_LEVEL_ERROR) == G_LOG_LEVEL_ERROR) 163 if ((flags & G_LOG_LEVEL_ERROR) == G_LOG_LEVEL_ERROR)
164 level = GAIM_DEBUG_ERROR; 164 level = PURPLE_DEBUG_ERROR;
165 else if ((flags & G_LOG_LEVEL_CRITICAL) == G_LOG_LEVEL_CRITICAL) 165 else if ((flags & G_LOG_LEVEL_CRITICAL) == G_LOG_LEVEL_CRITICAL)
166 level = GAIM_DEBUG_FATAL; 166 level = PURPLE_DEBUG_FATAL;
167 else if ((flags & G_LOG_LEVEL_WARNING) == G_LOG_LEVEL_WARNING) 167 else if ((flags & G_LOG_LEVEL_WARNING) == G_LOG_LEVEL_WARNING)
168 level = GAIM_DEBUG_WARNING; 168 level = PURPLE_DEBUG_WARNING;
169 else if ((flags & G_LOG_LEVEL_MESSAGE) == G_LOG_LEVEL_MESSAGE) 169 else if ((flags & G_LOG_LEVEL_MESSAGE) == G_LOG_LEVEL_MESSAGE)
170 level = GAIM_DEBUG_INFO; 170 level = PURPLE_DEBUG_INFO;
171 else if ((flags & G_LOG_LEVEL_INFO) == G_LOG_LEVEL_INFO) 171 else if ((flags & G_LOG_LEVEL_INFO) == G_LOG_LEVEL_INFO)
172 level = GAIM_DEBUG_INFO; 172 level = PURPLE_DEBUG_INFO;
173 else if ((flags & G_LOG_LEVEL_DEBUG) == G_LOG_LEVEL_DEBUG) 173 else if ((flags & G_LOG_LEVEL_DEBUG) == G_LOG_LEVEL_DEBUG)
174 level = GAIM_DEBUG_MISC; 174 level = PURPLE_DEBUG_MISC;
175 else 175 else
176 { 176 {
177 gaim_debug_warning("gntdebug", 177 purple_debug_warning("gntdebug",
178 "Unknown glib logging level in %d\n", flags); 178 "Unknown glib logging level in %d\n", flags);
179 179
180 level = GAIM_DEBUG_MISC; /* This will never happen. */ 180 level = PURPLE_DEBUG_MISC; /* This will never happen. */
181 } 181 }
182 182
183 if (msg != NULL) 183 if (msg != NULL)
184 new_msg = gaim_utf8_try_convert(msg); 184 new_msg = purple_utf8_try_convert(msg);
185 185
186 if (domain != NULL) 186 if (domain != NULL)
187 new_domain = gaim_utf8_try_convert(domain); 187 new_domain = purple_utf8_try_convert(domain);
188 188
189 if (new_msg != NULL) 189 if (new_msg != NULL)
190 { 190 {
191 gaim_debug(level, (new_domain != NULL ? new_domain : "g_log"), 191 purple_debug(level, (new_domain != NULL ? new_domain : "g_log"),
192 "%s\n", new_msg); 192 "%s\n", new_msg);
193 193
194 g_free(new_msg); 194 g_free(new_msg);
195 } 195 }
196 196
200 static void 200 static void
201 size_changed_cb(GntWidget *widget, int oldw, int oldh) 201 size_changed_cb(GntWidget *widget, int oldw, int oldh)
202 { 202 {
203 int w, h; 203 int w, h;
204 gnt_widget_get_size(widget, &w, &h); 204 gnt_widget_get_size(widget, &w, &h);
205 gaim_prefs_set_int(PREF_ROOT "/size/width", w); 205 purple_prefs_set_int(PREF_ROOT "/size/width", w);
206 gaim_prefs_set_int(PREF_ROOT "/size/height", h); 206 purple_prefs_set_int(PREF_ROOT "/size/height", h);
207 } 207 }
208 208
209 void finch_debug_window_show() 209 void finch_debug_window_show()
210 { 210 {
211 debug.paused = FALSE; 211 debug.paused = FALSE;
212 debug.timestamps = gaim_prefs_get_bool("/core/debug/timestamps"); 212 debug.timestamps = purple_prefs_get_bool("/core/debug/timestamps");
213 if (debug.window == NULL) 213 if (debug.window == NULL)
214 { 214 {
215 GntWidget *wid, *box; 215 GntWidget *wid, *box;
216 debug.window = gnt_vbox_new(FALSE); 216 debug.window = gnt_vbox_new(FALSE);
217 gnt_box_set_toplevel(GNT_BOX(debug.window), TRUE); 217 gnt_box_set_toplevel(GNT_BOX(debug.window), TRUE);
220 gnt_box_set_alignment(GNT_BOX(debug.window), GNT_ALIGN_MID); 220 gnt_box_set_alignment(GNT_BOX(debug.window), GNT_ALIGN_MID);
221 221
222 debug.tview = gnt_text_view_new(); 222 debug.tview = gnt_text_view_new();
223 gnt_box_add_widget(GNT_BOX(debug.window), debug.tview); 223 gnt_box_add_widget(GNT_BOX(debug.window), debug.tview);
224 gnt_widget_set_size(debug.tview, 224 gnt_widget_set_size(debug.tview,
225 gaim_prefs_get_int(PREF_ROOT "/size/width"), 225 purple_prefs_get_int(PREF_ROOT "/size/width"),
226 gaim_prefs_get_int(PREF_ROOT "/size/height")); 226 purple_prefs_get_int(PREF_ROOT "/size/height"));
227 g_signal_connect(G_OBJECT(debug.tview), "size_changed", G_CALLBACK(size_changed_cb), NULL); 227 g_signal_connect(G_OBJECT(debug.tview), "size_changed", G_CALLBACK(size_changed_cb), NULL);
228 228
229 gnt_box_add_widget(GNT_BOX(debug.window), gnt_line_new(FALSE)); 229 gnt_box_add_widget(GNT_BOX(debug.window), gnt_line_new(FALSE));
230 230
231 box = gnt_hbox_new(FALSE); 231 box = gnt_hbox_new(FALSE);
275 { 275 {
276 /* Xerox */ 276 /* Xerox */
277 #define REGISTER_G_LOG_HANDLER(name) \ 277 #define REGISTER_G_LOG_HANDLER(name) \
278 g_log_set_handler((name), G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL \ 278 g_log_set_handler((name), G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL \
279 | G_LOG_FLAG_RECURSION, \ 279 | G_LOG_FLAG_RECURSION, \
280 gaim_glib_log_handler, NULL) 280 purple_glib_log_handler, NULL)
281 281
282 /* Register the glib log handlers. */ 282 /* Register the glib log handlers. */
283 REGISTER_G_LOG_HANDLER(NULL); 283 REGISTER_G_LOG_HANDLER(NULL);
284 REGISTER_G_LOG_HANDLER("GLib"); 284 REGISTER_G_LOG_HANDLER("GLib");
285 REGISTER_G_LOG_HANDLER("GModule"); 285 REGISTER_G_LOG_HANDLER("GModule");
287 REGISTER_G_LOG_HANDLER("GThread"); 287 REGISTER_G_LOG_HANDLER("GThread");
288 288
289 g_set_print_handler(print_stderr); /* Redirect the debug messages to stderr */ 289 g_set_print_handler(print_stderr); /* Redirect the debug messages to stderr */
290 g_set_printerr_handler(suppress_error_messages); 290 g_set_printerr_handler(suppress_error_messages);
291 291
292 gaim_prefs_add_none(PREF_ROOT); 292 purple_prefs_add_none(PREF_ROOT);
293 gaim_prefs_add_none(PREF_ROOT "/size"); 293 purple_prefs_add_none(PREF_ROOT "/size");
294 gaim_prefs_add_int(PREF_ROOT "/size/width", 60); 294 purple_prefs_add_int(PREF_ROOT "/size/width", 60);
295 gaim_prefs_add_int(PREF_ROOT "/size/height", 15); 295 purple_prefs_add_int(PREF_ROOT "/size/height", 15);
296 296
297 if (gaim_debug_is_enabled()) 297 if (purple_debug_is_enabled())
298 g_timeout_add(0, start_with_debugwin, NULL); 298 g_timeout_add(0, start_with_debugwin, NULL);
299 } 299 }
300 300
301 void finch_debug_uninit() 301 void finch_debug_uninit()
302 { 302 {