Mercurial > pidgin.yaz
annotate console/gntdebug.c @ 14693:ae0136b0a3ae
[gaim-migrate @ 17445]
Patch #1569730 from Richard Nelson (wabz):
"This patch adds a "Clear" button, timestamp and pause
options, and stops it scrolling down if it's scrolled up."
and
"Also gives the debug window a name, so window managers
can more easily have their way with it."
These changes make the debug window a whole lot more usable.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sun, 08 Oct 2006 03:56:06 +0000 |
parents | 81650a27f253 |
children | 3b5c732458ec |
rev | line source |
---|---|
14558
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
1 /** |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
2 * @file gntdebug.c GNT Debug API |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
3 * @ingroup gntui |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
4 * |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
5 * gaim |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
6 * |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
7 * Gaim is the legal property of its developers, whose names are too numerous |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
8 * to list here. Please refer to the COPYRIGHT file distributed with this |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
9 * source distribution. |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
10 * |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
11 * This program is free software; you can redistribute it and/or modify |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
12 * it under the terms of the GNU General Public License as published by |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
13 * the Free Software Foundation; either version 2 of the License, or |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
14 * (at your option) any later version. |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
15 * |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
16 * This program is distributed in the hope that it will be useful, |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
19 * GNU General Public License for more details. |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
20 * |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
21 * You should have received a copy of the GNU General Public License |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
22 * along with this program; if not, write to the Free Software |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
81650a27f253
[gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14274
diff
changeset
|
24 */ |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
25 #include <gnt.h> |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
26 #include <gntbox.h> |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
27 #include <gnttextview.h> |
14693
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
28 #include <gntbutton.h> |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
29 #include <gntcheckbox.h> |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
30 #include <gntline.h> |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
31 |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
32 #include "gntdebug.h" |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
33 #include "gntgaim.h" |
14693
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
34 #include "util.h" |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
35 |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
36 #include <stdio.h> |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
37 #include <string.h> |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
38 |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
39 static struct |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
40 { |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
41 GntWidget *window; |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
42 GntWidget *tview; |
14693
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
43 gboolean paused; |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
44 gboolean timestamps; |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
45 } debug; |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
46 |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
47 static gboolean |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
48 debug_window_kpress_cb(GntWidget *wid, const char *key, GntTextView *view) |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
49 { |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
50 if (key[0] == 27) |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
51 { |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
52 if (strcmp(key+1, GNT_KEY_DOWN) == 0) |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
53 gnt_text_view_scroll(view, 1); |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
54 else if (strcmp(key+1, GNT_KEY_UP) == 0) |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
55 gnt_text_view_scroll(view, -1); |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
56 else if (strcmp(key+1, GNT_KEY_PGDOWN) == 0) |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
57 gnt_text_view_scroll(view, wid->priv.height - 2); |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
58 else if (strcmp(key+1, GNT_KEY_PGUP) == 0) |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
59 gnt_text_view_scroll(view, -(wid->priv.height - 2)); |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
60 else |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
61 return FALSE; |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
62 return TRUE; |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
63 } |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
64 return FALSE; |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
65 } |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
66 |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
67 static void |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
68 gg_debug_print(GaimDebugLevel level, const char *category, |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
69 const char *args) |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
70 { |
14693
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
71 if (debug.window && !debug.paused) |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
72 { |
14693
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
73 int pos = gnt_text_view_get_lines_below(GNT_TEXT_VIEW(debug.tview)); |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
74 GntTextFormatFlags flag = GNT_TEXT_FLAG_NORMAL; |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
75 |
14693
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
76 if (debug.timestamps) { |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
77 const char *mdate; |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
78 time_t mtime = time(NULL); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
79 mdate = gaim_utf8_strftime("%H:%M:%S ", localtime(&mtime)); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
80 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
81 mdate, flag); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
82 } |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
83 |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
84 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
85 category, GNT_TEXT_FLAG_BOLD); |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
86 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
87 ": ", GNT_TEXT_FLAG_BOLD); |
14693
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
88 |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
89 switch (level) |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
90 { |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
91 case GAIM_DEBUG_WARNING: |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
92 flag |= GNT_TEXT_FLAG_UNDERLINE; |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
93 case GAIM_DEBUG_ERROR: |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
94 case GAIM_DEBUG_FATAL: |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
95 flag |= GNT_TEXT_FLAG_BOLD; |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
96 break; |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
97 default: |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
98 break; |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
99 } |
14693
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
100 |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
101 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), args, flag); |
14693
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
102 if (pos <= 1) |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
103 gnt_text_view_scroll(GNT_TEXT_VIEW(debug.tview), 0); |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
104 } |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
105 } |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
106 |
14693
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
107 static GaimDebugUiOps uiops = |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
108 { |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
109 gg_debug_print, |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
110 }; |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
111 |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
112 GaimDebugUiOps *gg_debug_get_ui_ops() |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
113 { |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
114 return &uiops; |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
115 } |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
116 |
13985
a7b1d2ab9cb0
[gaim-migrate @ 16555]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13983
diff
changeset
|
117 static void |
a7b1d2ab9cb0
[gaim-migrate @ 16555]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13983
diff
changeset
|
118 reset_debug_win(GntWidget *w, gpointer null) |
a7b1d2ab9cb0
[gaim-migrate @ 16555]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13983
diff
changeset
|
119 { |
a7b1d2ab9cb0
[gaim-migrate @ 16555]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13983
diff
changeset
|
120 debug.window = debug.tview = NULL; |
a7b1d2ab9cb0
[gaim-migrate @ 16555]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13983
diff
changeset
|
121 } |
a7b1d2ab9cb0
[gaim-migrate @ 16555]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13983
diff
changeset
|
122 |
14125
7dfa024c1a4a
[gaim-migrate @ 16763]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14059
diff
changeset
|
123 static void |
14693
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
124 clear_debug_win(GntWidget *w, GntTextView *tv) |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
125 { |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
126 gnt_text_view_clear(tv); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
127 } |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
128 |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
129 static void |
14125
7dfa024c1a4a
[gaim-migrate @ 16763]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14059
diff
changeset
|
130 print_stderr(const char *string) |
7dfa024c1a4a
[gaim-migrate @ 16763]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14059
diff
changeset
|
131 { |
7dfa024c1a4a
[gaim-migrate @ 16763]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14059
diff
changeset
|
132 g_printerr("%s", string); |
7dfa024c1a4a
[gaim-migrate @ 16763]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14059
diff
changeset
|
133 } |
7dfa024c1a4a
[gaim-migrate @ 16763]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14059
diff
changeset
|
134 |
14693
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
135 static void |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
136 toggle_pause(GntWidget *w, gpointer n) |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
137 { |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
138 debug.paused = !debug.paused; |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
139 } |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
140 |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
141 static void |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
142 toggle_timestamps(GntWidget *w, gpointer n) |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
143 { |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
144 debug.timestamps = !debug.timestamps; |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
145 gaim_prefs_set_bool("/core/debug/timestamps", debug.timestamps); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
146 } |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
147 |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
148 void gg_debug_window_show() |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
149 { |
14693
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
150 debug.paused = false; |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
151 debug.timestamps = gaim_prefs_get_bool("/core/debug/timestamps"); |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
152 if (debug.window == NULL) |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
153 { |
14693
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
154 GntWidget *wid, *box; |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
155 debug.window = gnt_vbox_new(FALSE); |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
156 gnt_box_set_toplevel(GNT_BOX(debug.window), TRUE); |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
157 gnt_box_set_title(GNT_BOX(debug.window), _("Debug Window")); |
14693
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
158 gnt_box_set_pad(GNT_BOX(debug.window), 0); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
159 gnt_box_set_alignment(GNT_BOX(debug.window), GNT_ALIGN_MID); |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
160 |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
161 debug.tview = gnt_text_view_new(); |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
162 gnt_box_add_widget(GNT_BOX(debug.window), debug.tview); |
13985
a7b1d2ab9cb0
[gaim-migrate @ 16555]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13983
diff
changeset
|
163 |
14693
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
164 gnt_box_add_widget(GNT_BOX(debug.window), gnt_line_new(FALSE)); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
165 |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
166 box = gnt_hbox_new(FALSE); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
167 gnt_box_set_alignment(GNT_BOX(box), GNT_ALIGN_MID); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
168 |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
169 /* XXX: Setting the GROW_Y for the following widgets don't make sense. But right now |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
170 * it's necessary to make the width of the debug window resizable ... like I said, |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
171 * it doesn't make sense. The bug is likely in the packing in gntbox.c. |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
172 */ |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
173 wid = gnt_button_new(_("Clear")); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
174 g_signal_connect(G_OBJECT(wid), "activate", G_CALLBACK(clear_debug_win), debug.tview); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
175 GNT_WIDGET_SET_FLAGS(wid, GNT_WIDGET_GROW_Y); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
176 gnt_box_add_widget(GNT_BOX(box), wid); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
177 |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
178 wid = gnt_check_box_new(_("Pause")); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
179 g_signal_connect(G_OBJECT(wid), "toggled", G_CALLBACK(toggle_pause), NULL); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
180 GNT_WIDGET_SET_FLAGS(wid, GNT_WIDGET_GROW_Y); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
181 gnt_box_add_widget(GNT_BOX(box), wid); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
182 |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
183 wid = gnt_check_box_new(_("Timestamps")); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
184 gnt_check_box_set_checked(GNT_CHECK_BOX(wid), debug.timestamps); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
185 g_signal_connect(G_OBJECT(wid), "toggled", G_CALLBACK(toggle_timestamps), NULL); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
186 GNT_WIDGET_SET_FLAGS(wid, GNT_WIDGET_GROW_Y); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
187 gnt_box_add_widget(GNT_BOX(box), wid); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
188 |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
189 gnt_box_add_widget(GNT_BOX(debug.window), box); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
190 GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_GROW_Y); |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
191 |
ae0136b0a3ae
[gaim-migrate @ 17445]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14558
diff
changeset
|
192 gnt_widget_set_name(debug.window, "debug-window"); |
14059
2d1b41e3cf0d
[gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14010
diff
changeset
|
193 |
13985
a7b1d2ab9cb0
[gaim-migrate @ 16555]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13983
diff
changeset
|
194 g_signal_connect(G_OBJECT(debug.window), "destroy", G_CALLBACK(reset_debug_win), NULL); |
14059
2d1b41e3cf0d
[gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14010
diff
changeset
|
195 g_signal_connect(G_OBJECT(debug.window), "key_pressed", G_CALLBACK(debug_window_kpress_cb), debug.tview); |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
196 } |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
197 |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
198 gnt_widget_show(debug.window); |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
199 } |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
200 |
14274
43d9afee9c3c
[gaim-migrate @ 16959]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14125
diff
changeset
|
201 static gboolean |
43d9afee9c3c
[gaim-migrate @ 16959]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14125
diff
changeset
|
202 start_with_debugwin(gpointer null) |
43d9afee9c3c
[gaim-migrate @ 16959]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14125
diff
changeset
|
203 { |
43d9afee9c3c
[gaim-migrate @ 16959]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14125
diff
changeset
|
204 gg_debug_window_show(); |
43d9afee9c3c
[gaim-migrate @ 16959]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14125
diff
changeset
|
205 return FALSE; |
43d9afee9c3c
[gaim-migrate @ 16959]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14125
diff
changeset
|
206 } |
43d9afee9c3c
[gaim-migrate @ 16959]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14125
diff
changeset
|
207 |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
208 void gg_debug_init() |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
209 { |
14125
7dfa024c1a4a
[gaim-migrate @ 16763]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14059
diff
changeset
|
210 g_set_print_handler(print_stderr); /* Redirect the debug messages to stderr */ |
14010
7573bd40a190
[gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13985
diff
changeset
|
211 if (gaim_debug_is_enabled()) |
14274
43d9afee9c3c
[gaim-migrate @ 16959]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14125
diff
changeset
|
212 g_timeout_add(0, start_with_debugwin, NULL); |
13983
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
213 } |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
214 |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
215 void gg_debug_uninit() |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
216 { |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
217 } |
b7a99d54a5a9
[gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
218 |