Mercurial > pidgin
annotate src/gtkdebug.c @ 11135:f2755f58a7da
[gaim-migrate @ 13196]
Straighten out some comments and get rid of a warning in gtkutils.c
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 20 Jul 2005 23:10:33 +0000 |
parents | 9be8ac00f27f |
children | a511b77a368b |
rev | line source |
---|---|
5212 | 1 /** |
2 * @file gtkdebug.c GTK+ Debug API | |
3 * @ingroup gtkui | |
4 * | |
5 * gaim | |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
7152
cada5ddc21f5
[gaim-migrate @ 7719]
Christian Hammond <chipx86@chipx86.com>
parents:
7150
diff
changeset
|
10 * |
5212 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
9791 | 25 #include "internal.h" |
26 #include "gtkgaim.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5818
diff
changeset
|
27 |
9480 | 28 #include "notify.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5818
diff
changeset
|
29 #include "prefs.h" |
8953 | 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 | 33 #include "gtkdebug.h" |
9709 | 34 #include "gtkdialogs.h" |
5212 | 35 #include "gtkimhtml.h" |
8953 | 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 | 39 typedef struct |
40 { | |
41 GtkWidget *window; | |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
42 GtkWidget *text; |
8953 | 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 | 50 |
51 } DebugWindow; | |
52 | |
53 static char debug_fg_colors[][8] = { | |
54 "#000000", /**< All debug levels. */ | |
7150 | 55 "#666666", /**< Misc. */ |
5212 | 56 "#000000", /**< Information. */ |
57 "#660000", /**< Warnings. */ | |
58 "#FF0000", /**< Errors. */ | |
59 "#FF0000", /**< Fatal errors. */ | |
60 }; | |
61 | |
62 static DebugWindow *debug_win = NULL; | |
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 | 67 struct _find { |
68 DebugWindow *window; | |
69 GtkWidget *entry; | |
70 }; | |
71 | |
5212 | 72 static gint |
73 debug_window_destroy(GtkWidget *w, GdkEvent *event, void *unused) | |
74 { | |
10087 | 75 gaim_prefs_disconnect_by_handle(gaim_gtk_debug_get_handle()); |
9502 | 76 |
77 /* If the "Save Log" dialog is open then close it */ | |
78 gaim_request_close_with_handle(debug_win); | |
5704
aa8dbb7e0a4d
[gaim-migrate @ 6125]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
79 |
5212 | 80 g_free(debug_win); |
81 debug_win = NULL; | |
82 | |
9480 | 83 gaim_prefs_set_bool("/gaim/gtk/debug/enabled", FALSE); |
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 | 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 | 95 |
96 return FALSE; | |
97 } | |
98 | |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
99 static void |
9482 | 100 do_find_cb(GtkWidget *widget, gint response, struct _find *f) |
8953 | 101 { |
9482 | 102 switch (response) { |
8953 | 103 case GTK_RESPONSE_OK: |
104 gtk_imhtml_search_find(GTK_IMHTML(f->window->text), | |
105 gtk_entry_get_text(GTK_ENTRY(f->entry))); | |
106 break; | |
107 | |
108 case GTK_RESPONSE_DELETE_EVENT: | |
109 case GTK_RESPONSE_CLOSE: | |
110 gtk_imhtml_search_clear(GTK_IMHTML(f->window->text)); | |
111 gtk_widget_destroy(f->window->find); | |
112 f->window->find = NULL; | |
113 g_free(f); | |
114 break; | |
115 } | |
116 } | |
117 | |
118 static void | |
119 find_cb(GtkWidget *w, DebugWindow *win) | |
120 { | |
121 GtkWidget *hbox, *img, *label; | |
122 struct _find *f; | |
123 | |
124 if(win->find) | |
125 { | |
126 gtk_window_present(GTK_WINDOW(win->find)); | |
127 return; | |
128 } | |
129 | |
130 f = g_malloc(sizeof(struct _find)); | |
131 f->window = win; | |
132 win->find = gtk_dialog_new_with_buttons(_("Find"), | |
133 GTK_WINDOW(win->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
134 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
135 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
136 gtk_dialog_set_default_response(GTK_DIALOG(win->find), | |
137 GTK_RESPONSE_OK); | |
138 g_signal_connect(G_OBJECT(win->find), "response", | |
139 G_CALLBACK(do_find_cb), f); | |
140 | |
141 gtk_container_set_border_width(GTK_CONTAINER(win->find), 6); | |
142 gtk_window_set_resizable(GTK_WINDOW(win->find), FALSE); | |
143 gtk_dialog_set_has_separator(GTK_DIALOG(win->find), FALSE); | |
144 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(win->find)->vbox), 12); | |
145 gtk_container_set_border_width( | |
146 GTK_CONTAINER(GTK_DIALOG(win->find)->vbox), 6); | |
147 | |
148 hbox = gtk_hbox_new(FALSE, 12); | |
149 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(win->find)->vbox), | |
150 hbox); | |
151 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, | |
152 GTK_ICON_SIZE_DIALOG); | |
153 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
154 | |
155 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
156 gtk_dialog_set_response_sensitive(GTK_DIALOG(win->find), | |
157 GTK_RESPONSE_OK, FALSE); | |
158 | |
159 label = gtk_label_new(NULL); | |
160 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); | |
161 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
162 | |
163 f->entry = gtk_entry_new(); | |
164 gtk_entry_set_activates_default(GTK_ENTRY(f->entry), TRUE); | |
165 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(f->entry)); | |
166 g_signal_connect(G_OBJECT(f->entry), "changed", | |
167 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
168 win->find); | |
169 gtk_box_pack_start(GTK_BOX(hbox), f->entry, FALSE, FALSE, 0); | |
170 | |
171 gtk_widget_show_all(win->find); | |
172 gtk_widget_grab_focus(f->entry); | |
173 } | |
174 | |
175 static void | |
9502 | 176 save_writefile_cb(void *user_data, const char *filename) |
8953 | 177 { |
9502 | 178 DebugWindow *win = (DebugWindow *)user_data; |
9489 | 179 FILE *fp; |
8953 | 180 char *tmp; |
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 | 183 gaim_notify_error(win, NULL, _("Unable to open file."), NULL); |
8953 | 184 return; |
9480 | 185 } |
8953 | 186 |
9489 | 187 tmp = gtk_imhtml_get_text(GTK_IMHTML(win->text), NULL, NULL); |
8953 | 188 fprintf(fp, "Gaim Debug log : %s\n", gaim_date_full()); |
189 fprintf(fp, "%s", tmp); | |
190 g_free(tmp); | |
191 | |
192 fclose(fp); | |
193 } | |
194 | |
195 static void | |
196 save_cb(GtkWidget *w, DebugWindow *win) | |
197 { | |
9502 | 198 gaim_request_file(win, _("Save Debug Log"), "gaim-debug.log", TRUE, |
199 G_CALLBACK(save_writefile_cb), NULL, win); | |
8953 | 200 } |
201 | |
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 | 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 | 249 static DebugWindow * |
250 debug_window_new(void) | |
251 { | |
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 | 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 | 263 |
264 win = g_new0(DebugWindow, 1); | |
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 | 269 GAIM_DIALOG(win->window); |
10309 | 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 | 274 gtk_window_set_role(GTK_WINDOW(win->window), "debug"); |
275 gtk_window_set_title(GTK_WINDOW(win->window), _("Debug Window")); | |
276 | |
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 | 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 | 328 |
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 | 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 | 369 /* Add the gtkimhtml */ |
370 frame = gaim_gtk_create_imhtml(FALSE, &win->text, NULL); | |
10739 | 371 gtk_imhtml_set_format_functions(GTK_IMHTML(win->text), |
372 GTK_IMHTML_ALL ^ GTK_IMHTML_SMILEY ^ GTK_IMHTML_IMAGE); | |
10175 | 373 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
374 gtk_widget_show(frame); | |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
375 |
5212 | 376 gtk_widget_show_all(win->window); |
5428
96bde36bb76b
[gaim-migrate @ 5808]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
377 |
5212 | 378 return win; |
379 } | |
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 | 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 | 391 static void |
392 gaim_glib_log_handler(const gchar *domain, GLogLevelFlags flags, | |
393 const gchar *msg, gpointer user_data) | |
394 { | |
395 GaimDebugLevel level; | |
396 char *new_msg = NULL; | |
397 char *new_domain = NULL; | |
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 | 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 | 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 | 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 | 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 | 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 | 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 | 414 "Unknown glib logging level in %d\n", flags); |
415 | |
416 level = GAIM_DEBUG_MISC; /* This will never happen. */ | |
417 } | |
418 | |
419 if (msg != NULL) | |
420 new_msg = gaim_utf8_try_convert(msg); | |
421 | |
422 if (domain != NULL) | |
423 new_domain = gaim_utf8_try_convert(domain); | |
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 | 429 |
430 g_free(new_msg); | |
431 } | |
432 | |
433 if (new_domain != NULL) | |
434 g_free(new_domain); | |
435 } | |
436 | |
437 #ifdef _WIN32 | |
438 static void | |
439 gaim_glib_dummy_print_handler(const gchar *string) | |
440 { | |
441 } | |
442 #endif | |
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 | 449 /* Debug window preferences. */ |
450 /* | |
451 * NOTE: This must be set before prefs are loaded, and the callbacks | |
452 * set after they are loaded, since prefs sets the enabled | |
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 | 455 */ |
456 | |
457 gaim_prefs_add_none("/gaim/gtk/debug"); | |
10307 | 458 |
459 /* Controls printing to the debug window */ | |
5684 | 460 gaim_prefs_add_bool("/gaim/gtk/debug/enabled", FALSE); |
10307 | 461 |
5684 | 462 gaim_prefs_add_bool("/gaim/gtk/debug/toolbar", TRUE); |
463 gaim_prefs_add_int("/gaim/gtk/debug/width", 450); | |
464 gaim_prefs_add_int("/gaim/gtk/debug/height", 250); | |
465 | |
10087 | 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 | 468 |
469 #define REGISTER_G_LOG_HANDLER(name) \ | |
470 g_log_set_handler((name), G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL \ | |
471 | G_LOG_FLAG_RECURSION, \ | |
472 gaim_glib_log_handler, NULL) | |
473 | |
474 /* Register the glib/gtk log handlers. */ | |
475 REGISTER_G_LOG_HANDLER(NULL); | |
476 REGISTER_G_LOG_HANDLER("Gdk"); | |
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 | 479 REGISTER_G_LOG_HANDLER("GLib"); |
480 REGISTER_G_LOG_HANDLER("GModule"); | |
481 REGISTER_G_LOG_HANDLER("GLib-GObject"); | |
482 REGISTER_G_LOG_HANDLER("GThread"); | |
483 | |
484 #ifdef _WIN32 | |
10314 | 485 if (!gaim_debug_is_enabled()) |
7150 | 486 g_set_print_handler(gaim_glib_dummy_print_handler); |
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 | 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 | 499 gaim_gtk_debug_window_show(void) |
500 { | |
501 if (debug_win == NULL) | |
502 debug_win = debug_window_new(); | |
503 | |
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 | 507 } |
508 | |
509 void | |
510 gaim_gtk_debug_window_hide(void) | |
511 { | |
512 if (debug_win != NULL) { | |
513 gtk_widget_destroy(debug_win->window); | |
514 debug_window_destroy(NULL, NULL, NULL); | |
515 } | |
516 } | |
517 | |
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 | 560 gaim_gtk_debug_print(GaimDebugLevel level, const char *category, |
561 const char *format, va_list args) | |
562 { | |
10307 | 563 gboolean timestamps; |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
564 gchar *arg_s, *ts_s; |
10307 | 565 gchar *esc_s, *cat_s, *tmp, *s; |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5430
diff
changeset
|
566 |
10307 | 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 | 570 return; |
571 } | |
572 | |
573 timestamps = gaim_prefs_get_bool("/core/debug/timestamps"); | |
5212 | 574 |
575 arg_s = g_strdup_vprintf(format, args); | |
576 | |
10307 | 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 | 580 */ |
581 if ((category != NULL) && (timestamps)) { | |
582 gchar mdate[64]; | |
583 | |
584 time_t mtime = time(NULL); | |
585 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | |
586 ts_s = g_strdup_printf("(%s) ", mdate); | |
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 | 591 if (category == NULL) |
592 cat_s = g_strdup(""); | |
593 else | |
594 cat_s = g_strdup_printf("<b>%s:</b> ", category); | |
5212 | 595 |
10307 | 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 | 598 g_free(arg_s); |
5212 | 599 |
10307 | 600 s = g_strdup_printf("<font color=\"%s\">%s%s%s</font>", |
601 debug_fg_colors[level], ts_s, cat_s, esc_s); | |
5212 | 602 |
10307 | 603 g_free(ts_s); |
604 g_free(cat_s); | |
605 g_free(esc_s); | |
5212 | 606 |
10307 | 607 tmp = gaim_utf8_try_convert(s); |
608 g_free(s); | |
609 s = tmp; | |
5212 | 610 |
10307 | 611 if (level == GAIM_DEBUG_FATAL) { |
612 tmp = g_strdup_printf("<b>%s</b>", s); | |
5212 | 613 g_free(s); |
10307 | 614 s = tmp; |
5212 | 615 } |
616 | |
10307 | 617 gtk_imhtml_append_text(GTK_IMHTML(debug_win->text), s, 0); |
5212 | 618 |
10307 | 619 g_free(s); |
5212 | 620 } |
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 | 672 if (debug_win == NULL) |
673 return; | |
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 | 684 static GaimDebugUiOps ops = |
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 | 689 }; |
690 | |
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 | 693 { |
694 return &ops; | |
695 } | |
10087 | 696 |
697 void * | |
698 gaim_gtk_debug_get_handle() { | |
699 static int handle; | |
700 | |
701 return &handle; | |
702 } |