annotate src/gtkdebug.c @ 5527:166ed121e555

[gaim-migrate @ 5927] Ambrose LI (acli) updated the traditional Chinese (zh_TW) translation committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Mon, 26 May 2003 04:26:24 +0000
parents 908f3d9ee660
children 2c4c975620f0
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 *
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 * Copyright (C) 2002-2003, Christian Hammond <chipx86@gnupdate.org>
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 *
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * 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
11 * the Free Software Foundation; either version 2 of the License, or
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * (at your option) any later version.
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 *
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * GNU General Public License for more details.
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 *
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 */
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 #include "gtkdebug.h"
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24 #include "gaim.h"
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 #include "gtkimhtml.h"
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26 #include <gtk/gtk.h>
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 typedef struct
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30 GtkWidget *window;
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
31 GtkWidget *text;
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
32
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
33 gboolean timestamps;
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
34 gboolean paused;
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36 } DebugWindow;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38 static char debug_fg_colors[][8] = {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 "#000000", /**< All debug levels. */
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40 "#666666", /**< Blather. */
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 "#000000", /**< Information. */
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42 "#660000", /**< Warnings. */
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43 "#FF0000", /**< Errors. */
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44 "#FF0000", /**< Fatal errors. */
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45 };
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 static DebugWindow *debug_win = NULL;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49 static gint
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 debug_window_destroy(GtkWidget *w, GdkEvent *event, void *unused)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 g_free(debug_win);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 debug_win = NULL;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 if (misc_options & OPT_MISC_DEBUG)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 misc_options ^= OPT_MISC_DEBUG;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 save_prefs();
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60 return FALSE;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
63 static void
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
64 __clear_cb(GtkWidget *w, DebugWindow *win)
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
65 {
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
66 gtk_imhtml_clear(GTK_IMHTML(win->text));
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
67 }
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
68
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
69 static void
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
70 __pause_cb(GtkWidget *w, DebugWindow *win)
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
71 {
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
72 win->paused = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
73 }
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
74
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
75 static void
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
76 __timestamps_cb(GtkWidget *w, DebugWindow *win)
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
77 {
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
78 win->timestamps = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
79 }
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
80
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 static DebugWindow *
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 debug_window_new(void)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84 DebugWindow *win;
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
85 GtkWidget *vbox;
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
86 GtkWidget *toolbar;
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 GtkWidget *sw;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 win = g_new0(DebugWindow, 1);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 GAIM_DIALOG(win->window);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 gtk_window_set_default_size(GTK_WINDOW(win->window), 500, 200);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93 gtk_window_set_role(GTK_WINDOW(win->window), "debug");
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 gtk_window_set_title(GTK_WINDOW(win->window), _("Debug Window"));
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 g_signal_connect(G_OBJECT(win->window), "delete_event",
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 G_CALLBACK(debug_window_destroy), NULL);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
99 /* Setup the vbox */
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
100 vbox = gtk_vbox_new(FALSE, 0);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
101 gtk_container_add(GTK_CONTAINER(win->window), vbox);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
102
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
103 /* Setup our top button bar thingie. */
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
104 toolbar = gtk_toolbar_new();
5429
7d1a44cbd347 [gaim-migrate @ 5809]
Christian Hammond <chipx86@chipx86.com>
parents: 5428
diff changeset
105 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH_HORIZ);
7d1a44cbd347 [gaim-migrate @ 5809]
Christian Hammond <chipx86@chipx86.com>
parents: 5428
diff changeset
106 gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar),
7d1a44cbd347 [gaim-migrate @ 5809]
Christian Hammond <chipx86@chipx86.com>
parents: 5428
diff changeset
107 GTK_ICON_SIZE_SMALL_TOOLBAR);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
108
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
109 gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
110
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
111 #if 0
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
112 /* Find button */
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
113 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_FIND,
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
114 NULL, NULL, NULL, NULL, -1);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
115
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
116 /* Save */
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
117 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_SAVE,
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
118 NULL, NULL, NULL, NULL, -1);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
119 #endif
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
120
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
121 /* Clear button */
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
122 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_CLEAR,
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
123 NULL, NULL, G_CALLBACK(__clear_cb), win, -1);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
124
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
125 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
126
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
127 /* Pause */
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
128 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
129 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL,
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
130 _("Pause"), NULL, NULL,
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
131 NULL, G_CALLBACK(__pause_cb), win);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
132
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
133 /* Timestamps */
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
134 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
135 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL,
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
136 _("Timestamps"), NULL, NULL,
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
137 NULL, G_CALLBACK(__timestamps_cb), win);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
138
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
139 /* Now our scrolled window... */
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 sw = gtk_scrolled_window_new(NULL, NULL);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
142 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
143 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
144 GTK_SHADOW_IN);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
146 /* ... which has a gtkimhtml in it. */
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
147 win->text = gtk_imhtml_new(NULL, NULL);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
149 gtk_container_add(GTK_CONTAINER(sw), win->text);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
150
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
151 /* Pack it in... Not like that, sicko. */
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
152 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
153
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 gtk_widget_show_all(win->window);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
155
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156 return win;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 void
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160 gaim_gtk_debug_window_show(void)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162 if (debug_win == NULL)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163 debug_win = debug_window_new();
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165 gtk_widget_show(debug_win->window);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168 void
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169 gaim_gtk_debug_window_hide(void)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
171 if (debug_win != NULL) {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172 gtk_widget_destroy(debug_win->window);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173 debug_window_destroy(NULL, NULL, NULL);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
175 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
177 static void
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178 gaim_gtk_debug_print(GaimDebugLevel level, const char *category,
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179 const char *format, va_list args)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180 {
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
181 gchar *arg_s;
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183 arg_s = g_strdup_vprintf(format, args);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
185 if ((misc_options & OPT_MISC_DEBUG) &&
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
186 debug_win != NULL && !debug_win->paused) {
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
187
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
188 gchar *esc_s, *cat_s, *ts_s, *s;
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
189
5430
908f3d9ee660 [gaim-migrate @ 5810]
Christian Hammond <chipx86@chipx86.com>
parents: 5429
diff changeset
190 if (category == NULL) {
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 cat_s = g_strdup("");
5430
908f3d9ee660 [gaim-migrate @ 5810]
Christian Hammond <chipx86@chipx86.com>
parents: 5429
diff changeset
192 ts_s = g_strdup("");
908f3d9ee660 [gaim-migrate @ 5810]
Christian Hammond <chipx86@chipx86.com>
parents: 5429
diff changeset
193 }
908f3d9ee660 [gaim-migrate @ 5810]
Christian Hammond <chipx86@chipx86.com>
parents: 5429
diff changeset
194 else {
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195 cat_s = g_strdup_printf("<b>%s:</b> ", category);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196
5430
908f3d9ee660 [gaim-migrate @ 5810]
Christian Hammond <chipx86@chipx86.com>
parents: 5429
diff changeset
197 /*
908f3d9ee660 [gaim-migrate @ 5810]
Christian Hammond <chipx86@chipx86.com>
parents: 5429
diff changeset
198 * If the category is not NULL, then do timestamps.
908f3d9ee660 [gaim-migrate @ 5810]
Christian Hammond <chipx86@chipx86.com>
parents: 5429
diff changeset
199 * This IS right. :)
908f3d9ee660 [gaim-migrate @ 5810]
Christian Hammond <chipx86@chipx86.com>
parents: 5429
diff changeset
200 */
908f3d9ee660 [gaim-migrate @ 5810]
Christian Hammond <chipx86@chipx86.com>
parents: 5429
diff changeset
201 if (debug_win->timestamps) {
908f3d9ee660 [gaim-migrate @ 5810]
Christian Hammond <chipx86@chipx86.com>
parents: 5429
diff changeset
202 gchar mdate[64];
908f3d9ee660 [gaim-migrate @ 5810]
Christian Hammond <chipx86@chipx86.com>
parents: 5429
diff changeset
203 time_t mtime = time(NULL);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
204
5430
908f3d9ee660 [gaim-migrate @ 5810]
Christian Hammond <chipx86@chipx86.com>
parents: 5429
diff changeset
205 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime));
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
206
5430
908f3d9ee660 [gaim-migrate @ 5810]
Christian Hammond <chipx86@chipx86.com>
parents: 5429
diff changeset
207 ts_s = g_strdup_printf("(%s) ", mdate);
908f3d9ee660 [gaim-migrate @ 5810]
Christian Hammond <chipx86@chipx86.com>
parents: 5429
diff changeset
208 }
908f3d9ee660 [gaim-migrate @ 5810]
Christian Hammond <chipx86@chipx86.com>
parents: 5429
diff changeset
209 else
908f3d9ee660 [gaim-migrate @ 5810]
Christian Hammond <chipx86@chipx86.com>
parents: 5429
diff changeset
210 ts_s = g_strdup("");
5428
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
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213 esc_s = g_markup_escape_text(arg_s, -1);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
215 s = g_strdup_printf("<font color=\"%s\">%s%s%s</font>",
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
216 debug_fg_colors[level], ts_s, cat_s, esc_s);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
218 g_free(ts_s);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219 g_free(esc_s);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221 if (level == GAIM_DEBUG_FATAL) {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 gchar *temp = s;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 s = g_strdup_printf("<b>%s</b>", temp);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 g_free(temp);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228 g_free(cat_s);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
230 gtk_imhtml_append_text(GTK_IMHTML(debug_win->text), s, -1, 0);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
232 g_free(s);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
233 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
234
5214
7ea282e1f615 [gaim-migrate @ 5584]
Christian Hammond <chipx86@chipx86.com>
parents: 5212
diff changeset
235 if (opt_debug) {
7ea282e1f615 [gaim-migrate @ 5584]
Christian Hammond <chipx86@chipx86.com>
parents: 5212
diff changeset
236 if (category == NULL)
7ea282e1f615 [gaim-migrate @ 5584]
Christian Hammond <chipx86@chipx86.com>
parents: 5212
diff changeset
237 g_print("%s", arg_s);
7ea282e1f615 [gaim-migrate @ 5584]
Christian Hammond <chipx86@chipx86.com>
parents: 5212
diff changeset
238 else
5217
6afeab1955b2 [gaim-migrate @ 5587]
Christian Hammond <chipx86@chipx86.com>
parents: 5215
diff changeset
239 g_print("%s: %s", category, arg_s);
5214
7ea282e1f615 [gaim-migrate @ 5584]
Christian Hammond <chipx86@chipx86.com>
parents: 5212
diff changeset
240 }
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
241
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
242 g_free(arg_s);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245 static GaimDebugUiOps ops =
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
247 gaim_gtk_debug_print
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
248 };
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250 GaimDebugUiOps *
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 gaim_get_gtk_debug_ui_ops(void)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
253 return &ops;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
254 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
255