Mercurial > pidgin.yaz
annotate src/gtkdebug.c @ 5411:2c4188300aba
[gaim-migrate @ 5787]
This fixes an i18n thing, I think.
I changed some stuff in oscar.c to use _() instead of calling gettext
directly. That's ok, right? I like the macro better.
I also fixed a compile warning or two. If that function declaration
isn't supposed to be there, feel free to move it, or remove it, or
lemme know and I'll do it.
Viva 0.63!
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 17 May 2003 05:41:18 +0000 |
parents | 1f901484599d |
children | 96bde36bb76b |
rev | line source |
---|---|
5212 | 1 /** |
2 * @file gtkdebug.c GTK+ Debug API | |
3 * @ingroup gtkui | |
4 * | |
5 * gaim | |
6 * | |
7 * Copyright (C) 2002-2003, Christian Hammond <chipx86@gnupdate.org> | |
8 * | |
9 * This program is free software; you can redistribute it and/or modify | |
10 * it under the terms of the GNU General Public License as published by | |
11 * the Free Software Foundation; either version 2 of the License, or | |
12 * (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program; if not, write to the Free Software | |
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 */ | |
23 #include "gtkdebug.h" | |
24 #include "gaim.h" | |
25 #include "gtkimhtml.h" | |
26 #include <gtk/gtk.h> | |
27 | |
28 typedef struct | |
29 { | |
30 GtkWidget *window; | |
31 GtkWidget *entry; | |
32 | |
33 } DebugWindow; | |
34 | |
35 static char debug_fg_colors[][8] = { | |
36 "#000000", /**< All debug levels. */ | |
37 "#666666", /**< Blather. */ | |
38 "#000000", /**< Information. */ | |
39 "#660000", /**< Warnings. */ | |
40 "#FF0000", /**< Errors. */ | |
41 "#FF0000", /**< Fatal errors. */ | |
42 }; | |
43 | |
44 static DebugWindow *debug_win = NULL; | |
45 | |
46 static gint | |
47 debug_window_destroy(GtkWidget *w, GdkEvent *event, void *unused) | |
48 { | |
49 g_free(debug_win); | |
50 debug_win = NULL; | |
51 | |
52 if (misc_options & OPT_MISC_DEBUG) | |
53 misc_options ^= OPT_MISC_DEBUG; | |
54 | |
55 save_prefs(); | |
56 | |
57 return FALSE; | |
58 } | |
59 | |
60 static DebugWindow * | |
61 debug_window_new(void) | |
62 { | |
63 DebugWindow *win; | |
64 GtkWidget *sw; | |
65 | |
66 win = g_new0(DebugWindow, 1); | |
67 | |
68 GAIM_DIALOG(win->window); | |
69 gtk_window_set_default_size(GTK_WINDOW(win->window), 500, 200); | |
70 gtk_window_set_role(GTK_WINDOW(win->window), "debug"); | |
71 gtk_window_set_title(GTK_WINDOW(win->window), _("Debug Window")); | |
72 | |
73 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
74 G_CALLBACK(debug_window_destroy), NULL); | |
75 | |
76 sw = gtk_scrolled_window_new(NULL, NULL); | |
77 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
78 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); | |
79 | |
80 win->entry = gtk_imhtml_new(NULL, NULL); | |
81 | |
82 gtk_container_add(GTK_CONTAINER(sw), win->entry); | |
83 gtk_container_add(GTK_CONTAINER(win->window), sw); | |
84 gtk_widget_show_all(win->window); | |
85 | |
86 return win; | |
87 } | |
88 | |
89 void | |
90 gaim_gtk_debug_window_show(void) | |
91 { | |
92 if (debug_win == NULL) | |
93 debug_win = debug_window_new(); | |
94 | |
95 gtk_widget_show(debug_win->window); | |
96 } | |
97 | |
98 void | |
99 gaim_gtk_debug_window_hide(void) | |
100 { | |
101 if (debug_win != NULL) { | |
102 gtk_widget_destroy(debug_win->window); | |
103 debug_window_destroy(NULL, NULL, NULL); | |
104 } | |
105 } | |
106 | |
107 static void | |
108 gaim_gtk_debug_print(GaimDebugLevel level, const char *category, | |
109 const char *format, va_list args) | |
110 { | |
111 gchar *esc_s, *arg_s, *cat_s, *s; | |
112 | |
113 arg_s = g_strdup_vprintf(format, args); | |
114 | |
115 if ((misc_options & OPT_MISC_DEBUG) && debug_win != NULL) { | |
116 if (category == NULL) | |
117 cat_s = g_strdup(""); | |
118 else | |
119 cat_s = g_strdup_printf("<b>%s:</b> ", category); | |
120 | |
121 esc_s = g_markup_escape_text(arg_s, -1); | |
122 | |
123 s = g_strdup_printf("<font color=\"%s\">%s%s</font>", | |
124 debug_fg_colors[level], cat_s, esc_s); | |
125 | |
126 g_free(esc_s); | |
127 | |
128 if (level == GAIM_DEBUG_FATAL) { | |
129 gchar *temp = s; | |
130 | |
131 s = g_strdup_printf("<b>%s</b>", temp); | |
132 g_free(temp); | |
133 } | |
134 | |
135 g_free(cat_s); | |
136 | |
137 gtk_imhtml_append_text(GTK_IMHTML(debug_win->entry), s, -1, 0); | |
138 | |
139 g_free(s); | |
140 } | |
141 | |
5214
7ea282e1f615
[gaim-migrate @ 5584]
Christian Hammond <chipx86@chipx86.com>
parents:
5212
diff
changeset
|
142 if (opt_debug) { |
7ea282e1f615
[gaim-migrate @ 5584]
Christian Hammond <chipx86@chipx86.com>
parents:
5212
diff
changeset
|
143 if (category == NULL) |
7ea282e1f615
[gaim-migrate @ 5584]
Christian Hammond <chipx86@chipx86.com>
parents:
5212
diff
changeset
|
144 g_print("%s", arg_s); |
7ea282e1f615
[gaim-migrate @ 5584]
Christian Hammond <chipx86@chipx86.com>
parents:
5212
diff
changeset
|
145 else |
5217
6afeab1955b2
[gaim-migrate @ 5587]
Christian Hammond <chipx86@chipx86.com>
parents:
5215
diff
changeset
|
146 g_print("%s: %s", category, arg_s); |
5214
7ea282e1f615
[gaim-migrate @ 5584]
Christian Hammond <chipx86@chipx86.com>
parents:
5212
diff
changeset
|
147 } |
5212 | 148 |
149 g_free(arg_s); | |
150 } | |
151 | |
152 static GaimDebugUiOps ops = | |
153 { | |
154 gaim_gtk_debug_print | |
155 }; | |
156 | |
157 GaimDebugUiOps * | |
158 gaim_get_gtk_debug_ui_ops(void) | |
159 { | |
160 return &ops; | |
161 } | |
162 |