annotate src/gtkdebug.c @ 5607:eeba9205dd0f

[gaim-migrate @ 6011] that win32 stuff has gotten really old committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Sat, 31 May 2003 15:49:46 +0000
parents 933739f789f9
children 73c9dc20e41a
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"
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
26 #include "prefs.h"
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 #include <gtk/gtk.h>
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29 typedef struct
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 GtkWidget *window;
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
32 GtkWidget *text;
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
33
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
34 gboolean timestamps;
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
35 gboolean paused;
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37 } DebugWindow;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 static char debug_fg_colors[][8] = {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40 "#000000", /**< All debug levels. */
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 "#666666", /**< Blather. */
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42 "#000000", /**< Information. */
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43 "#660000", /**< Warnings. */
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44 "#FF0000", /**< Errors. */
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45 "#FF0000", /**< Fatal errors. */
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
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 static DebugWindow *debug_win = NULL;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 static gint
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 debug_window_destroy(GtkWidget *w, GdkEvent *event, void *unused)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 g_free(debug_win);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 debug_win = NULL;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
56 gaim_prefs_set_bool("/gaim/gtk/debug/enabled", FALSE);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
57
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
58 return FALSE;
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
59 }
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
61 static gboolean
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
62 __configure_cb(GtkWidget *w, GdkEventConfigure *event, DebugWindow *win)
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
63 {
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
64 if (GTK_WIDGET_VISIBLE(w)) {
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
65 gaim_prefs_set_int("/gaim/gtk/debug/width", event->width);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
66 gaim_prefs_set_int("/gaim/gtk/debug/height", event->height);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
67 }
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 return FALSE;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
72 static void
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
73 __clear_cb(GtkWidget *w, DebugWindow *win)
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 gtk_imhtml_clear(GTK_IMHTML(win->text));
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
76 }
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 static void
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
79 __pause_cb(GtkWidget *w, DebugWindow *win)
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
80 {
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
81 win->paused = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
82 }
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
83
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
84 static void
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
85 __timestamps_cb(GtkWidget *w, DebugWindow *win)
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
86 {
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
87 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
88
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
89 gaim_prefs_set_bool("/gaim/gtk/debug/timestamps", win->timestamps);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
90
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
91 }
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
92
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93 static DebugWindow *
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 debug_window_new(void)
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 DebugWindow *win;
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
97 GtkWidget *vbox;
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
98 GtkWidget *toolbar;
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 GtkWidget *sw;
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
100 GtkWidget *button;
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
101 int width, height;
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103 win = g_new0(DebugWindow, 1);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
105 width = gaim_prefs_get_int("/gaim/gtk/debug/width");
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
106 height = gaim_prefs_get_int("/gaim/gtk/debug/height");
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
107
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108 GAIM_DIALOG(win->window);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
109 gtk_window_set_default_size(GTK_WINDOW(win->window), width, height);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 gtk_window_set_role(GTK_WINDOW(win->window), "debug");
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 gtk_window_set_title(GTK_WINDOW(win->window), _("Debug Window"));
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 g_signal_connect(G_OBJECT(win->window), "delete_event",
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 G_CALLBACK(debug_window_destroy), NULL);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
115 g_signal_connect(G_OBJECT(win->window), "configure_event",
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
116 G_CALLBACK(__configure_cb), win);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
118 /* Setup the vbox */
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
119 vbox = gtk_vbox_new(FALSE, 0);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
120 gtk_container_add(GTK_CONTAINER(win->window), vbox);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
121
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
122 if (gaim_prefs_get_bool("/gaim/gtk/debug/toolbar")) {
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
123 /* Setup our top button bar thingie. */
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
124 toolbar = gtk_toolbar_new();
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
125 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH_HORIZ);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
126 gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar),
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
127 GTK_ICON_SIZE_SMALL_TOOLBAR);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
128
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
129 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
130
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
131 #if 0
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
132 /* Find button */
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
133 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_FIND,
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
134 NULL, NULL, NULL, NULL, -1);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
135
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
136 /* Save */
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
137 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_SAVE,
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
138 NULL, NULL, NULL, NULL, -1);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
139 #endif
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
140
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
141 /* Clear button */
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
142 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_CLEAR,
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
143 NULL, NULL, G_CALLBACK(__clear_cb), win, -1);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
144
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
145 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
146
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
147 /* Pause */
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
148 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
149 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL,
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
150 _("Pause"), NULL, NULL,
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
151 NULL, G_CALLBACK(__pause_cb), win);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
152
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
153 /* Timestamps */
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
154 button = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
155 GTK_TOOLBAR_CHILD_TOGGLEBUTTON,
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
156 NULL, _("Timestamps"), NULL, NULL,
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
157 NULL, G_CALLBACK(__timestamps_cb),
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
158 win);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
159
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
160 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
161 gaim_prefs_get_bool("/gaim/gtk/debug/timestamps"));
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
162 }
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
163
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
164 /* Now our scrolled window... */
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165 sw = gtk_scrolled_window_new(NULL, NULL);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
167 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
168 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
169 GTK_SHADOW_IN);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
171 /* ... which has a gtkimhtml in it. */
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
172 win->text = gtk_imhtml_new(NULL, NULL);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
174 gtk_container_add(GTK_CONTAINER(sw), win->text);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
175
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
176 /* Pack it in... Not like that, sicko. */
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
177 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
178
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179 gtk_widget_show_all(win->window);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
180
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181 return win;
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
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184 void
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
185 gaim_gtk_debug_window_show(void)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
186 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
187 if (debug_win == NULL)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
188 debug_win = debug_window_new();
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190 gtk_widget_show(debug_win->window);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
191
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
192 gaim_prefs_set_bool("/gaim/gtk/debug/enabled", TRUE);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
194
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195 void
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196 gaim_gtk_debug_window_hide(void)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198 if (debug_win != NULL) {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199 gtk_widget_destroy(debug_win->window);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
200 debug_window_destroy(NULL, NULL, NULL);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
202 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204 static void
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205 gaim_gtk_debug_print(GaimDebugLevel level, const char *category,
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206 const char *format, va_list args)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207 {
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
208 gchar *arg_s, *ts_s;
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
209 gboolean timestamps;
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
210
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
211 timestamps = gaim_prefs_get_bool("/gaim/gtk/debug/timestamps");
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213 arg_s = g_strdup_vprintf(format, args);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
215 if (category == NULL) {
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
216 ts_s = g_strdup("");
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 else {
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
219 /*
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
220 * If the category is not NULL, then do timestamps.
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
221 * This IS right. :)
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
222 */
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
223 if (timestamps) {
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
224 gchar mdate[64];
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
225 time_t mtime = time(NULL);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
226
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
227 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime));
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
228
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
229 ts_s = g_strdup_printf("(%s) ", mdate);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
230 }
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
231 else
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
232 ts_s = g_strdup("");
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
233 }
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
234
5535
933739f789f9 [gaim-migrate @ 5935]
Nathan Walp <nwalp@pidgin.im>
parents: 5530
diff changeset
235 if (gaim_prefs_get_bool("/gaim/gtk/debug/enabled") &&
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
236 debug_win != NULL && !debug_win->paused) {
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
237
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
238 gchar *esc_s, *cat_s, *s;
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
239
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
240 if (category == NULL)
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
241 cat_s = g_strdup("");
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
242 else
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
243 cat_s = g_strdup_printf("<b>%s:</b> ", category);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
244
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245 esc_s = g_markup_escape_text(arg_s, -1);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
247 s = g_strdup_printf("<font color=\"%s\">%s%s%s</font>",
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
248 debug_fg_colors[level], ts_s, cat_s, esc_s);
5212
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 g_free(esc_s);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252 if (level == GAIM_DEBUG_FATAL) {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
253 gchar *temp = s;
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 s = g_strdup_printf("<b>%s</b>", temp);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
256 g_free(temp);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
257 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
259 g_free(cat_s);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
260
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
261 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
262
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
263 g_free(s);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
264 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
265
5214
7ea282e1f615 [gaim-migrate @ 5584]
Christian Hammond <chipx86@chipx86.com>
parents: 5212
diff changeset
266 if (opt_debug) {
7ea282e1f615 [gaim-migrate @ 5584]
Christian Hammond <chipx86@chipx86.com>
parents: 5212
diff changeset
267 if (category == NULL)
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
268 g_print("%s%s", ts_s, arg_s);
5214
7ea282e1f615 [gaim-migrate @ 5584]
Christian Hammond <chipx86@chipx86.com>
parents: 5212
diff changeset
269 else
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
270 g_print("%s%s: %s", ts_s, category, arg_s);
5214
7ea282e1f615 [gaim-migrate @ 5584]
Christian Hammond <chipx86@chipx86.com>
parents: 5212
diff changeset
271 }
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
272
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
273 g_free(ts_s);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
274 g_free(arg_s);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
275 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
276
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
277 static GaimDebugUiOps ops =
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
278 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
279 gaim_gtk_debug_print
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
280 };
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
281
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
282 GaimDebugUiOps *
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
283 gaim_get_gtk_debug_ui_ops(void)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
284 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
285 return &ops;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
286 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
287