annotate src/gtkdebug.c @ 11158:2c930d591492

[gaim-migrate @ 13245] This is what the command actually does, I'm not sure if jabber should allow for invi tes to other rooms than the one the command is run from. committer: Tailor Script <tailor@pidgin.im>
author Etan Reisner <pidgin@unreliablesource.net>
date Mon, 25 Jul 2005 23:46:34 +0000
parents 9be8ac00f27f
children a511b77a368b
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 */
9791
4a15962c344a [gaim-migrate @ 10659]
Mark Doliner <mark@kingant.net>
parents: 9709
diff changeset
25 #include "internal.h"
4a15962c344a [gaim-migrate @ 10659]
Mark Doliner <mark@kingant.net>
parents: 9709
diff changeset
26 #include "gtkgaim.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5818
diff changeset
27
9480
91856b52a391 [gaim-migrate @ 10305]
Mark Doliner <mark@kingant.net>
parents: 8953
diff changeset
28 #include "notify.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5818
diff changeset
29 #include "prefs.h"
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
30 #include "request.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5818
diff changeset
31 #include "util.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5818
diff changeset
32
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33 #include "gtkdebug.h"
9709
4d05b6e9e9cd [gaim-migrate @ 10570]
Mark Doliner <mark@kingant.net>
parents: 9504
diff changeset
34 #include "gtkdialogs.h"
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 #include "gtkimhtml.h"
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
36 #include "gtkutils.h"
10297
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 10175
diff changeset
37 #include "gtkstock.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5818
diff changeset
38
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 typedef struct
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 GtkWidget *window;
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
42 GtkWidget *text;
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
43 GtkWidget *find;
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
44
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
45 /* The category filter tree view. */
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
46 GtkWidget *treeview;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
47
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
48 gboolean timestamps;
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
49 gboolean paused;
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50
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
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
64 static GHashTable *debug_categories = NULL;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
65 static gboolean filter_enabled = FALSE;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
66
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
67 struct _find {
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
68 DebugWindow *window;
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
69 GtkWidget *entry;
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
70 };
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
71
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 static gint
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73 debug_window_destroy(GtkWidget *w, GdkEvent *event, void *unused)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 {
10087
9fdbfe832fac [gaim-migrate @ 11098]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
75 gaim_prefs_disconnect_by_handle(gaim_gtk_debug_get_handle());
9502
578986136bac [gaim-migrate @ 10329]
Mark Doliner <mark@kingant.net>
parents: 9501
diff changeset
76
578986136bac [gaim-migrate @ 10329]
Mark Doliner <mark@kingant.net>
parents: 9501
diff changeset
77 /* If the "Save Log" dialog is open then close it */
578986136bac [gaim-migrate @ 10329]
Mark Doliner <mark@kingant.net>
parents: 9501
diff changeset
78 gaim_request_close_with_handle(debug_win);
5704
aa8dbb7e0a4d [gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
79
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 g_free(debug_win);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 debug_win = NULL;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82
9480
91856b52a391 [gaim-migrate @ 10305]
Mark Doliner <mark@kingant.net>
parents: 8953
diff changeset
83 gaim_prefs_set_bool("/gaim/gtk/debug/enabled", FALSE);
91856b52a391 [gaim-migrate @ 10305]
Mark Doliner <mark@kingant.net>
parents: 8953
diff changeset
84
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
85 return FALSE;
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
86 }
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
88 static gboolean
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5738
diff changeset
89 configure_cb(GtkWidget *w, GdkEventConfigure *event, DebugWindow *win)
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
90 {
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
91 if (GTK_WIDGET_VISIBLE(w)) {
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
92 gaim_prefs_set_int("/gaim/gtk/debug/width", event->width);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
93 gaim_prefs_set_int("/gaim/gtk/debug/height", event->height);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
94 }
5212
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 return FALSE;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
99 static void
9482
b917acdc982f [gaim-migrate @ 10307]
Mark Doliner <mark@kingant.net>
parents: 9480
diff changeset
100 do_find_cb(GtkWidget *widget, gint response, struct _find *f)
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
101 {
9482
b917acdc982f [gaim-migrate @ 10307]
Mark Doliner <mark@kingant.net>
parents: 9480
diff changeset
102 switch (response) {
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
103 case GTK_RESPONSE_OK:
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
104 gtk_imhtml_search_find(GTK_IMHTML(f->window->text),
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
105 gtk_entry_get_text(GTK_ENTRY(f->entry)));
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
106 break;
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
107
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
108 case GTK_RESPONSE_DELETE_EVENT:
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
109 case GTK_RESPONSE_CLOSE:
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
110 gtk_imhtml_search_clear(GTK_IMHTML(f->window->text));
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
111 gtk_widget_destroy(f->window->find);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
112 f->window->find = NULL;
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
113 g_free(f);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
114 break;
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 }
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
117
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
118 static void
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
119 find_cb(GtkWidget *w, DebugWindow *win)
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
120 {
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
121 GtkWidget *hbox, *img, *label;
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
122 struct _find *f;
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 if(win->find)
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
125 {
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
126 gtk_window_present(GTK_WINDOW(win->find));
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
127 return;
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
128 }
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
129
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
130 f = g_malloc(sizeof(struct _find));
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
131 f->window = win;
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
132 win->find = gtk_dialog_new_with_buttons(_("Find"),
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
133 GTK_WINDOW(win->window), GTK_DIALOG_DESTROY_WITH_PARENT,
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
134 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
135 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
136 gtk_dialog_set_default_response(GTK_DIALOG(win->find),
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
137 GTK_RESPONSE_OK);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
138 g_signal_connect(G_OBJECT(win->find), "response",
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
139 G_CALLBACK(do_find_cb), f);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
140
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
141 gtk_container_set_border_width(GTK_CONTAINER(win->find), 6);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
142 gtk_window_set_resizable(GTK_WINDOW(win->find), FALSE);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
143 gtk_dialog_set_has_separator(GTK_DIALOG(win->find), FALSE);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
144 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
145 gtk_container_set_border_width(
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
146 GTK_CONTAINER(GTK_DIALOG(win->find)->vbox), 6);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
147
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
148 hbox = gtk_hbox_new(FALSE, 12);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
149 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(win->find)->vbox),
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
150 hbox);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
151 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION,
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
152 GTK_ICON_SIZE_DIALOG);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
153 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
154
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
155 gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
156 gtk_dialog_set_response_sensitive(GTK_DIALOG(win->find),
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
157 GTK_RESPONSE_OK, FALSE);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
158
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
159 label = gtk_label_new(NULL);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
160 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:"));
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
161 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
162
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
163 f->entry = gtk_entry_new();
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
164 gtk_entry_set_activates_default(GTK_ENTRY(f->entry), TRUE);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
165 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
166 g_signal_connect(G_OBJECT(f->entry), "changed",
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
167 G_CALLBACK(gaim_gtk_set_sensitive_if_input),
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
168 win->find);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
169 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
170
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
171 gtk_widget_show_all(win->find);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
172 gtk_widget_grab_focus(f->entry);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
173 }
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
174
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
175 static void
9502
578986136bac [gaim-migrate @ 10329]
Mark Doliner <mark@kingant.net>
parents: 9501
diff changeset
176 save_writefile_cb(void *user_data, const char *filename)
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
177 {
9502
578986136bac [gaim-migrate @ 10329]
Mark Doliner <mark@kingant.net>
parents: 9501
diff changeset
178 DebugWindow *win = (DebugWindow *)user_data;
9489
85caa0722dfc [gaim-migrate @ 10314]
Mark Doliner <mark@kingant.net>
parents: 9486
diff changeset
179 FILE *fp;
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
180 char *tmp;
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
181
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10448
diff changeset
182 if ((fp = g_fopen(filename, "w+")) == NULL) {
9502
578986136bac [gaim-migrate @ 10329]
Mark Doliner <mark@kingant.net>
parents: 9501
diff changeset
183 gaim_notify_error(win, NULL, _("Unable to open file."), NULL);
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
184 return;
9480
91856b52a391 [gaim-migrate @ 10305]
Mark Doliner <mark@kingant.net>
parents: 8953
diff changeset
185 }
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
186
9489
85caa0722dfc [gaim-migrate @ 10314]
Mark Doliner <mark@kingant.net>
parents: 9486
diff changeset
187 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
188 fprintf(fp, "Gaim Debug log : %s\n", gaim_date_full());
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
189 fprintf(fp, "%s", tmp);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
190 g_free(tmp);
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 fclose(fp);
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
193 }
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
194
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
195 static void
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
196 save_cb(GtkWidget *w, DebugWindow *win)
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
197 {
9502
578986136bac [gaim-migrate @ 10329]
Mark Doliner <mark@kingant.net>
parents: 9501
diff changeset
198 gaim_request_file(win, _("Save Debug Log"), "gaim-debug.log", TRUE,
578986136bac [gaim-migrate @ 10329]
Mark Doliner <mark@kingant.net>
parents: 9501
diff changeset
199 G_CALLBACK(save_writefile_cb), NULL, win);
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
200 }
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
201
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
202 static void
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5738
diff changeset
203 clear_cb(GtkWidget *w, DebugWindow *win)
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
204 {
6280
d330afe3ccf0 [gaim-migrate @ 6779]
Christian Hammond <chipx86@chipx86.com>
parents: 6094
diff changeset
205 gtk_imhtml_clear(GTK_IMHTML(win->text));
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
206 }
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
207
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
208 static void
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5738
diff changeset
209 pause_cb(GtkWidget *w, DebugWindow *win)
5428
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 win->paused = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
212 }
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
213
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
214 static void
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5738
diff changeset
215 timestamps_cb(GtkWidget *w, DebugWindow *win)
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
216 {
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
217 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
218
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
219 gaim_prefs_set_bool("/core/debug/timestamps", win->timestamps);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
220 }
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
221
5704
aa8dbb7e0a4d [gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
222 static void
aa8dbb7e0a4d [gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
223 timestamps_pref_cb(const char *name, GaimPrefType type, gpointer value,
aa8dbb7e0a4d [gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
224 gpointer data)
aa8dbb7e0a4d [gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
225 {
6478
338147ea6896 [gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
226 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
227 }
aa8dbb7e0a4d [gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
228
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
229 static void
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
230 filter_cb(GtkToggleButton *button, DebugWindow *win)
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
231 {
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
232 if (gtk_toggle_button_get_active(button)) {
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
233 filter_enabled = TRUE;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
234 } else {
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
235 filter_enabled = FALSE;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
236 }
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
237 }
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
238
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
239 static void
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
240 debug_liststore_append(gpointer key, gpointer value, gpointer user_data)
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
241 {
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
242 GtkTreeIter iter;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
243 GtkListStore **liststore = (GtkListStore **)user_data;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
244
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
245 gtk_list_store_append(*liststore, &iter);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
246 gtk_list_store_set(*liststore, &iter, 0, key, -1);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
247 }
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
248
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249 static DebugWindow *
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250 debug_window_new(void)
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 DebugWindow *win;
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
253 GtkWidget *vbox;
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
254 GtkWidget *toolbar;
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10087
diff changeset
255 GtkWidget *frame;
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
256 GtkWidget *button;
6094
538c522e36e1 [gaim-migrate @ 6553]
Christian Hammond <chipx86@chipx86.com>
parents: 6009
diff changeset
257 GtkWidget *image;
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
258 GtkListStore *liststore = NULL;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
259 GtkCellRenderer *renderer = NULL;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
260 GtkTreeSelection *selection = NULL;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
261 GtkTreeViewColumn *column = NULL;
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
262 int width, height;
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
263
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
264 win = g_new0(DebugWindow, 1);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
265
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
266 width = gaim_prefs_get_int("/gaim/gtk/debug/width");
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
267 height = gaim_prefs_get_int("/gaim/gtk/debug/height");
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
268
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
269 GAIM_DIALOG(win->window);
10309
19974fd2d61d [gaim-migrate @ 11501]
Mark Doliner <mark@kingant.net>
parents: 10307
diff changeset
270 gaim_debug_info("gtkdebug", "Setting dimensions to %d, %d\n",
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
271 width, height);
5642
1693a3027dc8 [gaim-migrate @ 6056]
Christian Hammond <chipx86@chipx86.com>
parents: 5636
diff changeset
272
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
273 gtk_window_set_default_size(GTK_WINDOW(win->window), width, height);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
274 gtk_window_set_role(GTK_WINDOW(win->window), "debug");
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
275 gtk_window_set_title(GTK_WINDOW(win->window), _("Debug Window"));
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 g_signal_connect(G_OBJECT(win->window), "delete_event",
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
278 G_CALLBACK(debug_window_destroy), NULL);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
279 g_signal_connect(G_OBJECT(win->window), "configure_event",
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
280 G_CALLBACK(configure_cb), win);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
281
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
282 /* Setup the vbox */
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
283 vbox = gtk_vbox_new(FALSE, 0);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
284 gtk_container_add(GTK_CONTAINER(win->window), vbox);
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
285
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
286 if (gaim_prefs_get_bool("/gaim/gtk/debug/toolbar")) {
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
287 /* Setup our top button bar thingie. */
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
288 toolbar = gtk_toolbar_new();
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
289 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar),
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
290 GTK_TOOLBAR_BOTH_HORIZ);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
291 gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar),
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
292 GTK_ICON_SIZE_SMALL_TOOLBAR);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
293
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
294 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
295
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
296 /* Find button */
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
297 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_FIND,
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
298 NULL, NULL, G_CALLBACK(find_cb),
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
299 win, -1);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
300
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
301 /* Save */
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
302 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_SAVE,
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
303 NULL, NULL, G_CALLBACK(save_cb),
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
304 win, -1);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
305
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
306 /* Clear button */
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
307 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_CLEAR,
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
308 NULL, NULL, G_CALLBACK(clear_cb),
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
309 win, -1);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
310
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
311 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
312
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
313 /* Pause */
6094
538c522e36e1 [gaim-migrate @ 6553]
Christian Hammond <chipx86@chipx86.com>
parents: 6009
diff changeset
314 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
315 button = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
316 GTK_TOOLBAR_CHILD_TOGGLEBUTTON,
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
317 NULL, _("Pause"), NULL,
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
318 NULL, image,
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
319 G_CALLBACK(pause_cb), win);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
320
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
321 /* Timestamps */
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
322 button = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
323 GTK_TOOLBAR_CHILD_TOGGLEBUTTON,
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
324 NULL, _("Timestamps"),
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
325 NULL, NULL, NULL,
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
326 G_CALLBACK(timestamps_cb),
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
327 win);
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
328
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
329 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
330 gaim_prefs_get_bool("/core/debug/timestamps"));
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
331
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
332 gaim_prefs_connect_callback(gaim_gtk_debug_get_handle(),
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
333 "/core/debug/timestamps",
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
334 timestamps_pref_cb, button);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
335
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
336 button = gtk_check_button_new_with_label(_("Filter"));
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
337 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(filter_cb), win);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
338 button = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
339 GTK_TOOLBAR_CHILD_WIDGET,
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
340 button, NULL, NULL, NULL,
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
341 NULL, NULL, NULL);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
342
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
343 button = gtk_scrolled_window_new(NULL, NULL);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
344 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(button),
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
345 GTK_POLICY_NEVER,
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
346 GTK_POLICY_AUTOMATIC);
8953
0277908e367d [gaim-migrate @ 9726]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
347
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
348 liststore = gtk_list_store_new(1, G_TYPE_STRING);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
349 win->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(liststore));
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
350 renderer = gtk_cell_renderer_text_new();
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
351 column = gtk_tree_view_column_new_with_attributes(_("Filter"), renderer, "text", 0, NULL);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
352
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
353 gtk_tree_view_append_column(GTK_TREE_VIEW(win->treeview), column);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
354 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(win->treeview), FALSE);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
355 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(liststore), 0, GTK_SORT_ASCENDING);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
356
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
357 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(win->treeview));
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
358 gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
359
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
360 g_hash_table_foreach(debug_categories, (GHFunc)debug_liststore_append, &liststore);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
361
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
362 gtk_container_add(GTK_CONTAINER(button), win->treeview);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
363 button = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
364 GTK_TOOLBAR_CHILD_WIDGET,
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
365 button, NULL, NULL,
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
366 NULL, NULL, NULL, NULL);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
367 }
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
368
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10087
diff changeset
369 /* Add the gtkimhtml */
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10087
diff changeset
370 frame = gaim_gtk_create_imhtml(FALSE, &win->text, NULL);
10739
42dbc4ba1325 [gaim-migrate @ 12341]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
371 gtk_imhtml_set_format_functions(GTK_IMHTML(win->text),
42dbc4ba1325 [gaim-migrate @ 12341]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
372 GTK_IMHTML_ALL ^ GTK_IMHTML_SMILEY ^ GTK_IMHTML_IMAGE);
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10087
diff changeset
373 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10087
diff changeset
374 gtk_widget_show(frame);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
375
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
376 gtk_widget_show_all(win->window);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
377
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
378 return win;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
379 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
380
5625
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
381 static void
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
382 debug_enabled_cb(const char *name, GaimPrefType type, gpointer value,
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
383 gpointer data)
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
384 {
5636
11233ca9f533 [gaim-migrate @ 6043]
Nathan Walp <nwalp@pidgin.im>
parents: 5631
diff changeset
385 if (value)
5625
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
386 gaim_gtk_debug_window_show();
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
387 else
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
388 gaim_gtk_debug_window_hide();
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
389 }
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
390
7150
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
391 static void
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
392 gaim_glib_log_handler(const gchar *domain, GLogLevelFlags flags,
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
393 const gchar *msg, gpointer user_data)
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
394 {
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
395 GaimDebugLevel level;
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
396 char *new_msg = NULL;
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
397 char *new_domain = NULL;
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
398
7152
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
399 if ((flags & G_LOG_LEVEL_ERROR) == G_LOG_LEVEL_ERROR)
7150
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
400 level = GAIM_DEBUG_ERROR;
7152
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
401 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
402 level = GAIM_DEBUG_FATAL;
7152
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
403 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
404 level = GAIM_DEBUG_WARNING;
7152
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
405 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
406 level = GAIM_DEBUG_INFO;
7152
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
407 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
408 level = GAIM_DEBUG_INFO;
7152
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
409 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
410 level = GAIM_DEBUG_MISC;
7152
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
411 else
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
412 {
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
413 gaim_debug_warning("gtkdebug",
7150
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
414 "Unknown glib logging level in %d\n", flags);
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
415
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
416 level = GAIM_DEBUG_MISC; /* This will never happen. */
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
417 }
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
418
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
419 if (msg != NULL)
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
420 new_msg = gaim_utf8_try_convert(msg);
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
421
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
422 if (domain != NULL)
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
423 new_domain = gaim_utf8_try_convert(domain);
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
424
7152
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
425 if (new_msg != NULL)
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
426 {
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
427 gaim_debug(level, (new_domain != NULL ? new_domain : "g_log"),
cada5ddc21f5 [gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents: 7150
diff changeset
428 "%s\n", new_msg);
7150
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
429
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
430 g_free(new_msg);
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
431 }
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
432
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
433 if (new_domain != NULL)
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
434 g_free(new_domain);
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
435 }
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
436
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
437 #ifdef _WIN32
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
438 static void
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
439 gaim_glib_dummy_print_handler(const gchar *string)
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
440 {
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
441 }
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
442 #endif
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
443
5625
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
444 void
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
445 gaim_gtk_debug_init(void)
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
446 {
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
447 gaim_debug_register_category("gtkdebug");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
448
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
449 /* Debug window preferences. */
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
450 /*
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
451 * 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
452 * set after they are loaded, since prefs sets the enabled
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
453 * preference here and that loads the window, which calls the
8735
92cbf9713795 [gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
454 * configure event, which overrides the width and height! :P
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
455 */
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
456
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
457 gaim_prefs_add_none("/gaim/gtk/debug");
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
458
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
459 /* Controls printing to the debug window */
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
460 gaim_prefs_add_bool("/gaim/gtk/debug/enabled", FALSE);
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
461
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
462 gaim_prefs_add_bool("/gaim/gtk/debug/toolbar", TRUE);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
463 gaim_prefs_add_int("/gaim/gtk/debug/width", 450);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
464 gaim_prefs_add_int("/gaim/gtk/debug/height", 250);
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5642
diff changeset
465
10087
9fdbfe832fac [gaim-migrate @ 11098]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
466 gaim_prefs_connect_callback(NULL, "/gaim/gtk/debug/enabled",
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5738
diff changeset
467 debug_enabled_cb, NULL);
7150
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
468
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
469 #define REGISTER_G_LOG_HANDLER(name) \
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
470 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
471 | G_LOG_FLAG_RECURSION, \
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
472 gaim_glib_log_handler, NULL)
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
473
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
474 /* Register the glib/gtk log handlers. */
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
475 REGISTER_G_LOG_HANDLER(NULL);
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
476 REGISTER_G_LOG_HANDLER("Gdk");
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
477 REGISTER_G_LOG_HANDLER("Gtk");
7229
26fe5055e0b0 [gaim-migrate @ 7799]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7152
diff changeset
478 REGISTER_G_LOG_HANDLER("GdkPixbuf");
7150
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
479 REGISTER_G_LOG_HANDLER("GLib");
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
480 REGISTER_G_LOG_HANDLER("GModule");
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
481 REGISTER_G_LOG_HANDLER("GLib-GObject");
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
482 REGISTER_G_LOG_HANDLER("GThread");
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
483
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
484 #ifdef _WIN32
10314
0a561b6ef7ec [gaim-migrate @ 11512]
Mark Doliner <mark@kingant.net>
parents: 10309
diff changeset
485 if (!gaim_debug_is_enabled())
7150
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
486 g_set_print_handler(gaim_glib_dummy_print_handler);
e09020153d85 [gaim-migrate @ 7717]
Sean Egan <seanegan@gmail.com>
parents: 7108
diff changeset
487 #endif
5625
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
488 }
73c9dc20e41a [gaim-migrate @ 6032]
Christian Hammond <chipx86@chipx86.com>
parents: 5535
diff changeset
489
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
490 void
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
491 gaim_gtk_debug_uninit(void)
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
492 {
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
493 gaim_debug_unregister_category("gtkdebug");
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
494
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
495 gaim_debug_set_ui_ops(NULL);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
496 }
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
497
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
498 void
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
499 gaim_gtk_debug_window_show(void)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
500 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
501 if (debug_win == NULL)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
502 debug_win = debug_window_new();
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
503
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
504 gtk_widget_show(debug_win->window);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
505
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
506 gaim_prefs_set_bool("/gaim/gtk/debug/enabled", TRUE);
5212
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 void
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
510 gaim_gtk_debug_window_hide(void)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
511 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
512 if (debug_win != NULL) {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
513 gtk_widget_destroy(debug_win->window);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
514 debug_window_destroy(NULL, NULL, NULL);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
515 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
516 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
517
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
518 static void
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
519 create_debug_selected_categories(GtkTreeModel *model, GtkTreePath *path,
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
520 GtkTreeIter *iter, gpointer data)
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
521 {
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
522 GHashTable **hashtable = (GHashTable **)data;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
523 char *text = NULL;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
524
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
525 gtk_tree_model_get(model, iter, 0, &text, -1);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
526
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
527 g_hash_table_insert(*hashtable, text, NULL);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
528 }
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
529
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
530 static gboolean
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
531 debug_is_filtered_out(const char *category)
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
532 {
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
533 GtkTreeSelection *selection = NULL;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
534 GHashTable *hashtable = NULL;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
535 gboolean found = FALSE;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
536
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
537 if (category == NULL)
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
538 return FALSE;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
539
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
540 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(debug_win->treeview));
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
541 hashtable = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
542 NULL);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
543
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
544 gtk_tree_selection_selected_foreach(selection,
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
545 create_debug_selected_categories,
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
546 &hashtable);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
547
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
548 if (filter_enabled) {
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
549 if (g_hash_table_lookup_extended(hashtable, category, NULL, NULL))
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
550 found = FALSE;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
551 else
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
552 found = TRUE;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
553 }
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
554
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
555 g_hash_table_destroy(hashtable);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
556 return found;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
557 }
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
558
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
559 static void
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
560 gaim_gtk_debug_print(GaimDebugLevel level, const char *category,
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
561 const char *format, va_list args)
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
562 {
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
563 gboolean timestamps;
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
564 gchar *arg_s, *ts_s;
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
565 gchar *esc_s, *cat_s, *tmp, *s;
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
566
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
567 if (!gaim_prefs_get_bool("/gaim/gtk/debug/enabled") ||
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
568 (debug_win == NULL) || debug_win->paused ||
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
569 debug_is_filtered_out(category)) {
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
570 return;
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
571 }
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
572
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
573 timestamps = gaim_prefs_get_bool("/core/debug/timestamps");
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
574
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
575 arg_s = g_strdup_vprintf(format, args);
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
576
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
577 /*
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
578 * For some reason we only print the timestamp if category is
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
579 * not NULL. Why the hell do we do that? --Mark
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
580 */
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
581 if ((category != NULL) && (timestamps)) {
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
582 gchar mdate[64];
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
583
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
584 time_t mtime = time(NULL);
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
585 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime));
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
586 ts_s = g_strdup_printf("(%s) ", mdate);
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
587 } else {
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
588 ts_s = g_strdup("");
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
589 }
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5430
diff changeset
590
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
591 if (category == NULL)
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
592 cat_s = g_strdup("");
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
593 else
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
594 cat_s = g_strdup_printf("<b>%s:</b> ", category);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
595
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
596 esc_s = g_markup_escape_text(arg_s, -1);
5428
96bde36bb76b [gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
597
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
598 g_free(arg_s);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
599
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
600 s = g_strdup_printf("<font color=\"%s\">%s%s%s</font>",
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
601 debug_fg_colors[level], ts_s, cat_s, esc_s);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
602
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
603 g_free(ts_s);
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
604 g_free(cat_s);
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
605 g_free(esc_s);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
606
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
607 tmp = gaim_utf8_try_convert(s);
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
608 g_free(s);
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
609 s = tmp;
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
610
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
611 if (level == GAIM_DEBUG_FATAL) {
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
612 tmp = g_strdup_printf("<b>%s</b>", s);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
613 g_free(s);
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
614 s = tmp;
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
615 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
616
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
617 gtk_imhtml_append_text(GTK_IMHTML(debug_win->text), s, 0);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
618
10307
2ac21bf20e04 [gaim-migrate @ 11497]
Mark Doliner <mark@kingant.net>
parents: 10297
diff changeset
619 g_free(s);
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
620 }
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
621
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
622 static void
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
623 gaim_gtk_debug_register_category(const char *category)
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
624 {
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
625 /* XXX I'd like to be able to put this creation in _init, but that
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
626 * would require that this be init:ed before anything that wants to
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
627 * register a category, and I'm not sure I can count on this coming
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
628 * first */
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
629 if (debug_categories == NULL)
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
630 debug_categories = g_hash_table_new_full(g_str_hash,
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
631 g_str_equal,
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
632 g_free, NULL);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
633
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
634 if (!g_hash_table_lookup_extended(debug_categories, category, NULL, NULL)) {
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
635 g_hash_table_insert(debug_categories, g_strdup(category), NULL);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
636
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
637 if (debug_win != NULL && debug_win->treeview != NULL) {
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
638 GtkTreeModel *model = NULL;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
639 GtkTreeIter iter;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
640
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
641 model = gtk_tree_view_get_model(GTK_TREE_VIEW(debug_win->treeview));
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
642
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
643 gtk_list_store_append(GTK_LIST_STORE(model), &iter);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
644 gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0,
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
645 category, -1);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
646 }
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
647 }
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
648 }
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
649
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
650 static gboolean
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
651 find_and_remove_category(GtkTreeModel *model, GtkTreePath *path,
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
652 GtkTreeIter *iter, gpointer data)
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
653 {
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
654 GValue value = {0};
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
655
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
656 gtk_tree_model_get_value(model, iter, 0, &value);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
657
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
658 if (strcmp(g_value_get_string(&value), data) == 0) {
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
659 gtk_list_store_remove(GTK_LIST_STORE(model), iter);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
660
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
661 return TRUE;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
662 }
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
663
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
664 return FALSE;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
665 }
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
666
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
667 static void
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
668 gaim_gtk_debug_unregister_category(const char *category)
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
669 {
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
670 GtkTreeModel *model = NULL;
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
671
11056
9be8ac00f27f [gaim-migrate @ 13007]
Mark Doliner <mark@kingant.net>
parents: 11034
diff changeset
672 if (debug_win == NULL)
9be8ac00f27f [gaim-migrate @ 13007]
Mark Doliner <mark@kingant.net>
parents: 11034
diff changeset
673 return;
9be8ac00f27f [gaim-migrate @ 13007]
Mark Doliner <mark@kingant.net>
parents: 11034
diff changeset
674
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
675 model = gtk_tree_view_get_model(GTK_TREE_VIEW(debug_win->treeview));
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
676
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
677 gtk_tree_model_foreach(model,
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
678 (GtkTreeModelForeachFunc)find_and_remove_category,
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
679 (char *)category);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
680
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
681 g_hash_table_remove(debug_categories, category);
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
682 }
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
683
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
684 static GaimDebugUiOps ops =
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
685 {
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
686 gaim_gtk_debug_print,
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
687 gaim_gtk_debug_register_category,
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10739
diff changeset
688 gaim_gtk_debug_unregister_category
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
689 };
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
690
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
691 GaimDebugUiOps *
7035
feb3d21a7794 [gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
692 gaim_gtk_debug_get_ui_ops(void)
5212
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
693 {
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
694 return &ops;
740303e8425b [gaim-migrate @ 5582]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
695 }
10087
9fdbfe832fac [gaim-migrate @ 11098]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
696
9fdbfe832fac [gaim-migrate @ 11098]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
697 void *
9fdbfe832fac [gaim-migrate @ 11098]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
698 gaim_gtk_debug_get_handle() {
9fdbfe832fac [gaim-migrate @ 11098]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
699 static int handle;
9fdbfe832fac [gaim-migrate @ 11098]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
700
9fdbfe832fac [gaim-migrate @ 11098]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
701 return &handle;
9fdbfe832fac [gaim-migrate @ 11098]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9791
diff changeset
702 }