annotate src/gtkdebug.c @ 9739:35f22ba01bd7

[gaim-migrate @ 10603] bug fix. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Wed, 11 Aug 2004 18:05:10 +0000
parents 4d05b6e9e9cd
children 4a15962c344a
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 *
8046
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 8002
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 8002
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 8002
diff changeset
9 * source distribution.
7152
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
10 *
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * 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
13 * the Free Software Foundation; either version 2 of the License, or
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * (at your option) any later version.
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 *
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * GNU General Public License for more details.
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 *
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
9480
91856b52a391 [gaim-migrate @ 10305]
Mark Doliner <mark@kingant.net>
parents: 8953
diff changeset
27 #include "notify.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5818
diff changeset
28 #include "prefs.h"
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
29 #include "request.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5818
diff changeset
30 #include "util.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5818
diff changeset
31
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32 #include "gtkdebug.h"
9709
4d05b6e9e9cd [gaim-migrate @ 10570]
Mark Doliner <mark@kingant.net>
parents: 9504
diff changeset
33 #include "gtkdialogs.h"
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34 #include "gtkimhtml.h"
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
35 #include "gtkutils.h"
6009
5cd7a10c6ade [gaim-migrate @ 6457]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
36 #include "stock.h"
5872
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
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40 typedef struct
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42 GtkWidget *window;
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
43 GtkWidget *text;
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
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
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 } DebugWindow;
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 static char debug_fg_colors[][8] = {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 "#000000", /**< All debug levels. */
7150
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
55 "#666666", /**< Misc. */
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 "#000000", /**< Information. */
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57 "#660000", /**< Warnings. */
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 "#FF0000", /**< Errors. */
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 "#FF0000", /**< Fatal errors. */
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60 };
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 static DebugWindow *debug_win = NULL;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
64 struct _find {
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
65 DebugWindow *window;
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
66 GtkWidget *entry;
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
67 };
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
68
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 static gint
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 debug_window_destroy(GtkWidget *w, GdkEvent *event, void *unused)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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);
9502
578986136bac [gaim-migrate @ 10329]
Mark Doliner <mark@kingant.net>
parents: 9501
diff changeset
74
578986136bac [gaim-migrate @ 10329]
Mark Doliner <mark@kingant.net>
parents: 9501
diff changeset
75 /* If the "Save Log" dialog is open then close it */
578986136bac [gaim-migrate @ 10329]
Mark Doliner <mark@kingant.net>
parents: 9501
diff changeset
76 gaim_request_close_with_handle(debug_win);
5704
aa8dbb7e0a4d [gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
77
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78 g_free(debug_win);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79 debug_win = NULL;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80
9480
91856b52a391 [gaim-migrate @ 10305]
Mark Doliner <mark@kingant.net>
parents: 8953
diff changeset
81 gaim_prefs_set_bool("/gaim/gtk/debug/enabled", FALSE);
91856b52a391 [gaim-migrate @ 10305]
Mark Doliner <mark@kingant.net>
parents: 8953
diff changeset
82
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
83 return FALSE;
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
84 }
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
86 static gboolean
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5738
diff changeset
87 configure_cb(GtkWidget *w, GdkEventConfigure *event, DebugWindow *win)
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 if (GTK_WIDGET_VISIBLE(w)) {
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
90 gaim_prefs_set_int("/gaim/gtk/debug/width", event->width);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
91 gaim_prefs_set_int("/gaim/gtk/debug/height", event->height);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
92 }
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 return FALSE;
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
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
97 static void
9482
b917acdc982f [gaim-migrate @ 10307]
Mark Doliner <mark@kingant.net>
parents: 9480
diff changeset
98 do_find_cb(GtkWidget *widget, gint response, struct _find *f)
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
99 {
9482
b917acdc982f [gaim-migrate @ 10307]
Mark Doliner <mark@kingant.net>
parents: 9480
diff changeset
100 switch (response) {
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
101 case GTK_RESPONSE_OK:
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
102 gtk_imhtml_search_find(GTK_IMHTML(f->window->text),
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
103 gtk_entry_get_text(GTK_ENTRY(f->entry)));
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
104 break;
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
105
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
106 case GTK_RESPONSE_DELETE_EVENT:
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
107 case GTK_RESPONSE_CLOSE:
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
108 gtk_imhtml_search_clear(GTK_IMHTML(f->window->text));
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
109 gtk_widget_destroy(f->window->find);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
110 f->window->find = NULL;
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
111 g_free(f);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
112 break;
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
113 }
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
114 }
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
115
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
116 static void
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
117 find_cb(GtkWidget *w, DebugWindow *win)
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
118 {
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
119 GtkWidget *hbox, *img, *label;
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
120 struct _find *f;
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
121
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
122 if(win->find)
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
123 {
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
124 gtk_window_present(GTK_WINDOW(win->find));
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
125 return;
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
126 }
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
127
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
128 f = g_malloc(sizeof(struct _find));
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
129 f->window = win;
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
130 win->find = gtk_dialog_new_with_buttons(_("Find"),
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
131 GTK_WINDOW(win->window), GTK_DIALOG_DESTROY_WITH_PARENT,
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
132 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
133 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
134 gtk_dialog_set_default_response(GTK_DIALOG(win->find),
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
135 GTK_RESPONSE_OK);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
136 g_signal_connect(G_OBJECT(win->find), "response",
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
137 G_CALLBACK(do_find_cb), f);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
138
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
139 gtk_container_set_border_width(GTK_CONTAINER(win->find), 6);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
140 gtk_window_set_resizable(GTK_WINDOW(win->find), FALSE);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
141 gtk_dialog_set_has_separator(GTK_DIALOG(win->find), FALSE);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
142 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(win->find)->vbox), 12);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
143 gtk_container_set_border_width(
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
144 GTK_CONTAINER(GTK_DIALOG(win->find)->vbox), 6);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
145
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
146 hbox = gtk_hbox_new(FALSE, 12);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
147 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(win->find)->vbox),
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
148 hbox);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
149 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION,
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
150 GTK_ICON_SIZE_DIALOG);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
151 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
152
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
153 gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
154 gtk_dialog_set_response_sensitive(GTK_DIALOG(win->find),
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
155 GTK_RESPONSE_OK, FALSE);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
156
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
157 label = gtk_label_new(NULL);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
158 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:"));
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
159 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
160
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
161 f->entry = gtk_entry_new();
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
162 gtk_entry_set_activates_default(GTK_ENTRY(f->entry), TRUE);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
163 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(f->entry));
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
164 g_signal_connect(G_OBJECT(f->entry), "changed",
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
165 G_CALLBACK(gaim_gtk_set_sensitive_if_input),
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
166 win->find);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
167 gtk_box_pack_start(GTK_BOX(hbox), f->entry, FALSE, FALSE, 0);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
168
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
169 gtk_widget_show_all(win->find);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
170 gtk_widget_grab_focus(f->entry);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
171 }
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
172
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
173 static void
9502
578986136bac [gaim-migrate @ 10329]
Mark Doliner <mark@kingant.net>
parents: 9501
diff changeset
174 save_writefile_cb(void *user_data, const char *filename)
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
175 {
9502
578986136bac [gaim-migrate @ 10329]
Mark Doliner <mark@kingant.net>
parents: 9501
diff changeset
176 DebugWindow *win = (DebugWindow *)user_data;
9489
85caa0722dfc [gaim-migrate @ 10314]
Mark Doliner <mark@kingant.net>
parents: 9486
diff changeset
177 FILE *fp;
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
178 char *tmp;
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
179
9480
91856b52a391 [gaim-migrate @ 10305]
Mark Doliner <mark@kingant.net>
parents: 8953
diff changeset
180 if ((fp = fopen(filename, "w+")) == NULL) {
9502
578986136bac [gaim-migrate @ 10329]
Mark Doliner <mark@kingant.net>
parents: 9501
diff changeset
181 gaim_notify_error(win, NULL, _("Unable to open file."), NULL);
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
182 return;
9480
91856b52a391 [gaim-migrate @ 10305]
Mark Doliner <mark@kingant.net>
parents: 8953
diff changeset
183 }
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
184
9489
85caa0722dfc [gaim-migrate @ 10314]
Mark Doliner <mark@kingant.net>
parents: 9486
diff changeset
185 tmp = gtk_imhtml_get_text(GTK_IMHTML(win->text), NULL, NULL);
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
186 fprintf(fp, "Gaim Debug log : %s\n", gaim_date_full());
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
187 fprintf(fp, "%s", tmp);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
188 g_free(tmp);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
189
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
190 fclose(fp);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
191 }
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
192
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
193 static void
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
194 save_cb(GtkWidget *w, DebugWindow *win)
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
195 {
9502
578986136bac [gaim-migrate @ 10329]
Mark Doliner <mark@kingant.net>
parents: 9501
diff changeset
196 gaim_request_file(win, _("Save Debug Log"), "gaim-debug.log", TRUE,
578986136bac [gaim-migrate @ 10329]
Mark Doliner <mark@kingant.net>
parents: 9501
diff changeset
197 G_CALLBACK(save_writefile_cb), NULL, win);
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
198 }
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
199
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
200 static void
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5738
diff changeset
201 clear_cb(GtkWidget *w, DebugWindow *win)
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
202 {
6280
d330afe3ccf0 [gaim-migrate @ 6779]
Christian Hammond <chipx86@chipx86.com>
parents: 6094
diff changeset
203 gtk_imhtml_clear(GTK_IMHTML(win->text));
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
204 }
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
205
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
206 static void
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5738
diff changeset
207 pause_cb(GtkWidget *w, DebugWindow *win)
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
208 {
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
209 win->paused = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
210 }
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 static void
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5738
diff changeset
213 timestamps_cb(GtkWidget *w, DebugWindow *win)
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
214 {
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
215 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
216
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
217 gaim_prefs_set_bool("/gaim/gtk/debug/timestamps", win->timestamps);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
218 }
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
219
5704
aa8dbb7e0a4d [gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
220 static void
aa8dbb7e0a4d [gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
221 timestamps_pref_cb(const char *name, GaimPrefType type, gpointer value,
aa8dbb7e0a4d [gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
222 gpointer data)
aa8dbb7e0a4d [gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
223 {
6478
338147ea6896 [gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
224 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
225 }
aa8dbb7e0a4d [gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
226
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227 static DebugWindow *
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228 debug_window_new(void)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230 DebugWindow *win;
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
231 GtkWidget *vbox;
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
232 GtkWidget *toolbar;
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
233 GtkWidget *sw;
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
234 GtkWidget *button;
6094
538c522e36e1 [gaim-migrate @ 6553]
Christian Hammond <chipx86@chipx86.com>
parents: 6009
diff changeset
235 GtkWidget *image;
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
236 int width, height;
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
237
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
238 win = g_new0(DebugWindow, 1);
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 width = gaim_prefs_get_int("/gaim/gtk/debug/width");
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
241 height = gaim_prefs_get_int("/gaim/gtk/debug/height");
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
242
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243 GAIM_DIALOG(win->window);
5642
1693a3027dc8 [gaim-migrate @ 6056]
Christian Hammond <chipx86@chipx86.com>
parents: 5636
diff changeset
244 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
245 width, height);
1693a3027dc8 [gaim-migrate @ 6056]
Christian Hammond <chipx86@chipx86.com>
parents: 5636
diff changeset
246
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
247 gtk_window_set_default_size(GTK_WINDOW(win->window), width, height);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
248 gtk_window_set_role(GTK_WINDOW(win->window), "debug");
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249 gtk_window_set_title(GTK_WINDOW(win->window), _("Debug Window"));
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 g_signal_connect(G_OBJECT(win->window), "delete_event",
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252 G_CALLBACK(debug_window_destroy), NULL);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
253 g_signal_connect(G_OBJECT(win->window), "configure_event",
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5738
diff changeset
254 G_CALLBACK(configure_cb), win);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
255
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
256 /* Setup the vbox */
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
257 vbox = gtk_vbox_new(FALSE, 0);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
258 gtk_container_add(GTK_CONTAINER(win->window), vbox);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
259
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
260 if (gaim_prefs_get_bool("/gaim/gtk/debug/toolbar")) {
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
261 /* Setup our top button bar thingie. */
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
262 toolbar = gtk_toolbar_new();
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
263 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH_HORIZ);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
264 gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar),
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
265 GTK_ICON_SIZE_SMALL_TOOLBAR);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
266
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
267 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
268
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
269 /* Find button */
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
270 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_FIND,
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
271 NULL, NULL, G_CALLBACK(find_cb), win, -1);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
272
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
273 /* Save */
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
274 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_SAVE,
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
275 NULL, NULL, G_CALLBACK(save_cb), win, -1);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
276
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
277 /* Clear button */
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
278 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_CLEAR,
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5738
diff changeset
279 NULL, NULL, G_CALLBACK(clear_cb), win, -1);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
280
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
281 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
282
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
283 /* Pause */
6094
538c522e36e1 [gaim-migrate @ 6553]
Christian Hammond <chipx86@chipx86.com>
parents: 6009
diff changeset
284 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
285 button = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
538c522e36e1 [gaim-migrate @ 6553]
Christian Hammond <chipx86@chipx86.com>
parents: 6009
diff changeset
286 GTK_TOOLBAR_CHILD_TOGGLEBUTTON,
538c522e36e1 [gaim-migrate @ 6553]
Christian Hammond <chipx86@chipx86.com>
parents: 6009
diff changeset
287 NULL, _("Pause"), NULL, NULL,
538c522e36e1 [gaim-migrate @ 6553]
Christian Hammond <chipx86@chipx86.com>
parents: 6009
diff changeset
288 image, G_CALLBACK(pause_cb), win);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
289
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
290 /* Timestamps */
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
291 button = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
292 GTK_TOOLBAR_CHILD_TOGGLEBUTTON,
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
293 NULL, _("Timestamps"), NULL, NULL,
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5738
diff changeset
294 NULL, G_CALLBACK(timestamps_cb),
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
295 win);
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
296
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
297 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
8002
c94f2dad3b73 [gaim-migrate @ 8679]
Christian Hammond <chipx86@chipx86.com>
parents: 7229
diff changeset
298 gaim_prefs_get_bool("/gaim/gtk/debug/timestamps"));
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
299
5704
aa8dbb7e0a4d [gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
300 win->timestamps_handle =
aa8dbb7e0a4d [gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
301 gaim_prefs_connect_callback("/gaim/gtk/debug/timestamps",
aa8dbb7e0a4d [gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
302 timestamps_pref_cb, button);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
303 }
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
304
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
305 /* Now our scrolled window... */
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
306 sw = gtk_scrolled_window_new(NULL, NULL);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
307 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
308 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
309 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
310 GTK_SHADOW_IN);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
311
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
312 /* ... which has a gtkimhtml in it. */
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
313 win->text = gtk_imhtml_new(NULL, NULL);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
314
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
315 gtk_container_add(GTK_CONTAINER(sw), win->text);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
316
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
317 /* Pack it in... Not like that, sicko. */
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
318 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
319
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
320 gtk_widget_show_all(win->window);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
321
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
322 return win;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
323 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
324
5625
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
325 static void
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
326 debug_enabled_cb(const char *name, GaimPrefType type, gpointer value,
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
327 gpointer data)
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
328 {
5636
11233ca9f533 [gaim-migrate @ 6043]
Nathan Walp <nwalp@pidgin.im>
parents: 5631
diff changeset
329 if (value)
5625
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
330 gaim_gtk_debug_window_show();
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
331 else
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
332 gaim_gtk_debug_window_hide();
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
333 }
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
334
7150
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
335 static void
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
336 gaim_glib_log_handler(const gchar *domain, GLogLevelFlags flags,
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
337 const gchar *msg, gpointer user_data)
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
338 {
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
339 GaimDebugLevel level;
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
340 char *new_msg = NULL;
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
341 char *new_domain = NULL;
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
342
7152
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
343 if ((flags & G_LOG_LEVEL_ERROR) == G_LOG_LEVEL_ERROR)
7150
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
344 level = GAIM_DEBUG_ERROR;
7152
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
345 else if ((flags & G_LOG_LEVEL_CRITICAL) == G_LOG_LEVEL_CRITICAL)
7150
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
346 level = GAIM_DEBUG_FATAL;
7152
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
347 else if ((flags & G_LOG_LEVEL_WARNING) == G_LOG_LEVEL_WARNING)
7150
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
348 level = GAIM_DEBUG_WARNING;
7152
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
349 else if ((flags & G_LOG_LEVEL_MESSAGE) == G_LOG_LEVEL_MESSAGE)
7150
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
350 level = GAIM_DEBUG_INFO;
7152
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
351 else if ((flags & G_LOG_LEVEL_INFO) == G_LOG_LEVEL_INFO)
7150
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
352 level = GAIM_DEBUG_INFO;
7152
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
353 else if ((flags & G_LOG_LEVEL_DEBUG) == G_LOG_LEVEL_DEBUG)
7150
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
354 level = GAIM_DEBUG_MISC;
7152
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
355 else
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
356 {
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
357 gaim_debug_warning("gtkdebug",
7150
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
358 "Unknown glib logging level in %d\n", flags);
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
359
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
360 level = GAIM_DEBUG_MISC; /* This will never happen. */
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
361 }
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
362
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
363 if (msg != NULL)
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
364 new_msg = gaim_utf8_try_convert(msg);
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
365
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
366 if (domain != NULL)
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
367 new_domain = gaim_utf8_try_convert(domain);
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
368
7152
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
369 if (new_msg != NULL)
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
370 {
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
371 gaim_debug(level, (new_domain != NULL ? new_domain : "g_log"),
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
372 "%s\n", new_msg);
7150
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
373
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
374 g_free(new_msg);
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
375 }
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
376
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
377 if (new_domain != NULL)
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
378 g_free(new_domain);
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
379 }
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
380
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
381 #ifdef _WIN32
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
382 static void
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
383 gaim_glib_dummy_print_handler(const gchar *string)
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
384 {
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
385 }
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
386 #endif
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
387
5625
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
388 void
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
389 gaim_gtk_debug_init(void)
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
390 {
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
391 /* Debug window preferences. */
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
392 /*
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
393 * NOTE: This must be set before prefs are loaded, and the callbacks
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
394 * set after they are loaded, since prefs sets the enabled
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
395 * preference here and that loads the window, which calls the
8735
92cbf9713795 [gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
396 * configure event, which overrides the width and height! :P
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
397 */
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
398
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
399 gaim_prefs_add_none("/gaim/gtk/debug");
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
400 gaim_prefs_add_bool("/gaim/gtk/debug/enabled", FALSE);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
401 gaim_prefs_add_bool("/gaim/gtk/debug/timestamps", FALSE);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
402 gaim_prefs_add_bool("/gaim/gtk/debug/toolbar", TRUE);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
403 gaim_prefs_add_int("/gaim/gtk/debug/width", 450);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
404 gaim_prefs_add_int("/gaim/gtk/debug/height", 250);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
405
5625
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
406 gaim_prefs_connect_callback("/gaim/gtk/debug/enabled",
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5738
diff changeset
407 debug_enabled_cb, NULL);
7150
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
408
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
409 #define REGISTER_G_LOG_HANDLER(name) \
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
410 g_log_set_handler((name), G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL \
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
411 | G_LOG_FLAG_RECURSION, \
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
412 gaim_glib_log_handler, NULL)
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
413
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
414 /* Register the glib/gtk log handlers. */
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
415 REGISTER_G_LOG_HANDLER(NULL);
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
416 REGISTER_G_LOG_HANDLER("Gdk");
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
417 REGISTER_G_LOG_HANDLER("Gtk");
7229
26fe5055e0b0 [gaim-migrate @ 7799]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7152
diff changeset
418 REGISTER_G_LOG_HANDLER("GdkPixbuf");
7150
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
419 REGISTER_G_LOG_HANDLER("GLib");
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
420 REGISTER_G_LOG_HANDLER("GModule");
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
421 REGISTER_G_LOG_HANDLER("GLib-GObject");
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
422 REGISTER_G_LOG_HANDLER("GThread");
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
423
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
424 #ifdef _WIN32
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
425 if (!opt_debug)
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
426 g_set_print_handler(gaim_glib_dummy_print_handler);
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
427 #endif
5625
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
428 }
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
429
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
430 void
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
431 gaim_gtk_debug_window_show(void)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
432 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
433 if (debug_win == NULL)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
434 debug_win = debug_window_new();
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
435
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
436 gtk_widget_show(debug_win->window);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
437
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
438 gaim_prefs_set_bool("/gaim/gtk/debug/enabled", TRUE);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
439 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
440
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
441 void
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
442 gaim_gtk_debug_window_hide(void)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
443 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
444 if (debug_win != NULL) {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
445 gtk_widget_destroy(debug_win->window);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
446 debug_window_destroy(NULL, NULL, NULL);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
447 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
448 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
449
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
450 static void
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
451 gaim_gtk_debug_print(GaimDebugLevel level, const char *category,
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
452 const char *format, va_list args)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
453 {
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
454 gchar *arg_s, *ts_s;
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
455 gboolean timestamps;
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
456
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
457 timestamps = gaim_prefs_get_bool("/gaim/gtk/debug/timestamps");
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
458
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
459 arg_s = g_strdup_vprintf(format, args);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
460
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
461 if (category == NULL) {
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
462 ts_s = g_strdup("");
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
463 }
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
464 else {
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
465 /*
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
466 * If the category is not NULL, then do timestamps.
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
467 * This IS right. :)
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
468 */
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
469 if (timestamps) {
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
470 gchar mdate[64];
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
471 time_t mtime = time(NULL);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
472
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
473 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime));
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
474
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
475 ts_s = g_strdup_printf("(%s) ", mdate);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
476 }
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
477 else
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
478 ts_s = g_strdup("");
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
479 }
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
480
5535
933739f789f9 [gaim-migrate @ 5935]
Nathan Walp <nwalp@pidgin.im>
parents: 5530
diff changeset
481 if (gaim_prefs_get_bool("/gaim/gtk/debug/enabled") &&
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
482 debug_win != NULL && !debug_win->paused) {
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
483
5738
ec032cb2f9ec [gaim-migrate @ 6162]
Christian Hammond <chipx86@chipx86.com>
parents: 5704
diff changeset
484 gchar *esc_s, *cat_s, *utf8_s, *s;
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
485
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
486 if (category == NULL)
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
487 cat_s = g_strdup("");
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
488 else
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
489 cat_s = g_strdup_printf("<b>%s:</b> ", category);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
490
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
491 esc_s = g_markup_escape_text(arg_s, -1);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
492
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
493 s = g_strdup_printf("<font color=\"%s\">%s%s%s</font>",
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
494 debug_fg_colors[level], ts_s, cat_s, esc_s);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
495
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
496 g_free(esc_s);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
497
7108
6faeeecab0dc [gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents: 7035
diff changeset
498 utf8_s = gaim_utf8_try_convert(s);
5738
ec032cb2f9ec [gaim-migrate @ 6162]
Christian Hammond <chipx86@chipx86.com>
parents: 5704
diff changeset
499 g_free(s);
ec032cb2f9ec [gaim-migrate @ 6162]
Christian Hammond <chipx86@chipx86.com>
parents: 5704
diff changeset
500 s = utf8_s;
ec032cb2f9ec [gaim-migrate @ 6162]
Christian Hammond <chipx86@chipx86.com>
parents: 5704
diff changeset
501
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
502 if (level == GAIM_DEBUG_FATAL) {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
503 gchar *temp = s;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
504
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
505 s = g_strdup_printf("<b>%s</b>", temp);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
506 g_free(temp);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
507 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
508
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
509 g_free(cat_s);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
510
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6478
diff changeset
511 gtk_imhtml_append_text(GTK_IMHTML(debug_win->text), s, 0);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
512
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
513 g_free(s);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
514 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
515
5214
7ea282e1f615 [gaim-migrate @ 5584]
Christian Hammond <chipx86@chipx86.com>
parents: 5212
diff changeset
516 if (opt_debug) {
7ea282e1f615 [gaim-migrate @ 5584]
Christian Hammond <chipx86@chipx86.com>
parents: 5212
diff changeset
517 if (category == NULL)
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
518 g_print("%s%s", ts_s, arg_s);
5214
7ea282e1f615 [gaim-migrate @ 5584]
Christian Hammond <chipx86@chipx86.com>
parents: 5212
diff changeset
519 else
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
520 g_print("%s%s: %s", ts_s, category, arg_s);
5214
7ea282e1f615 [gaim-migrate @ 5584]
Christian Hammond <chipx86@chipx86.com>
parents: 5212
diff changeset
521 }
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
522
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
523 g_free(ts_s);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
524 g_free(arg_s);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
525 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
526
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
527 static GaimDebugUiOps ops =
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
528 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
529 gaim_gtk_debug_print
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
530 };
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
531
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
532 GaimDebugUiOps *
7035
feb3d21a7794 [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
533 gaim_gtk_debug_get_ui_ops(void)
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
534 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
535 return &ops;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
536 }