Mercurial > pidgin.yaz
annotate finch/gntdebug.c @ 31484:0d5e038911a7
Correct the ref counts on the SlpMsgParts. When it's removed from the
list in the slpmsg, it should be unref'd, and when it's queued, it
should be ref'd. That should fix the leaks HanzZ saw.
Refs #13084.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Thu, 16 Dec 2010 00:14:49 +0000 |
parents | 6a3aaa4e5e56 |
children |
rev | line source |
---|---|
15818 | 1 /** |
2 * @file gntdebug.c GNT Debug API | |
16194
0f0832c13fcb
Rename the Doxygen group from gntui to finch and define the finch group
Richard Laager <rlaager@wiktel.com>
parents:
16124
diff
changeset
|
3 * @ingroup finch |
20074
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19680
diff
changeset
|
4 */ |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19680
diff
changeset
|
5 |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19680
diff
changeset
|
6 /* finch |
15818 | 7 * |
15871
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
8 * Finch is the legal property of its developers, whose names are too numerous |
15818 | 9 * to list here. Please refer to the COPYRIGHT file distributed with this |
10 * source distribution. | |
11 * | |
12 * This program is free software; you can redistribute it and/or modify | |
13 * it under the terms of the GNU General Public License as published by | |
14 * the Free Software Foundation; either version 2 of the License, or | |
15 * (at your option) any later version. | |
16 * | |
17 * This program is distributed in the hope that it will be useful, | |
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 * GNU General Public License for more details. | |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
23 * along with this program; if not, write to the Free Software | |
19680
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18454
diff
changeset
|
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15818 | 25 */ |
29152
259bbfb423d4
Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <paul@darkrain42.org>
parents:
27663
diff
changeset
|
26 |
259bbfb423d4
Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <paul@darkrain42.org>
parents:
27663
diff
changeset
|
27 #include <internal.h> |
259bbfb423d4
Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <paul@darkrain42.org>
parents:
27663
diff
changeset
|
28 |
15818 | 29 #include <gnt.h> |
30 #include <gntbox.h> | |
31 #include <gntbutton.h> | |
32 #include <gntcheckbox.h> | |
17011
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
33 #include <gntentry.h> |
20672
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
34 #include <gntfilesel.h> |
17011
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
35 #include <gntlabel.h> |
15818 | 36 #include <gntline.h> |
17011
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
37 #include <gnttextview.h> |
15818 | 38 |
39 #include "gntdebug.h" | |
15823 | 40 #include "finch.h" |
20672
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
41 #include "notify.h" |
26429
1c73d2ef9ddc
Remove some extra edits that snuck into Finch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26062
diff
changeset
|
42 #include "util.h" |
15818 | 43 |
44 #include <stdio.h> | |
45 #include <string.h> | |
46 | |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
16194
diff
changeset
|
47 #define PREF_ROOT "/finch/debug" |
15818 | 48 |
24851
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
49 static gboolean |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
50 handle_fprintf_stderr_cb(GIOChannel *source, GIOCondition cond, gpointer null) |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
51 { |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
52 gssize size; |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
53 char message[1024]; |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
54 |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
55 size = read(g_io_channel_unix_get_fd(source), message, sizeof(message) - 1); |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
56 if (size <= 0) { |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
57 /* Something bad probably happened elsewhere ... let's ignore */ |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
58 } else { |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
59 message[size] = '\0'; |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
60 g_log("stderr", G_LOG_LEVEL_WARNING, "%s", message); |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
61 } |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
62 |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
63 return TRUE; |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
64 } |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
65 |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
66 static void |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
67 handle_fprintf_stderr(gboolean stop) |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
68 { |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
69 GIOChannel *stderrch; |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
70 static int readhandle = -1; |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
71 int pipes[2]; |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
72 |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
73 if (stop) { |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
74 if (readhandle >= 0) { |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
75 g_source_remove(readhandle); |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
76 readhandle = -1; |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
77 } |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
78 return; |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
79 } |
30649
6a3aaa4e5e56
Get rid of this warning:
Stu Tomlinson <stu@nosnilmot.com>
parents:
29152
diff
changeset
|
80 if (pipe(pipes)) { |
6a3aaa4e5e56
Get rid of this warning:
Stu Tomlinson <stu@nosnilmot.com>
parents:
29152
diff
changeset
|
81 readhandle = -1; |
6a3aaa4e5e56
Get rid of this warning:
Stu Tomlinson <stu@nosnilmot.com>
parents:
29152
diff
changeset
|
82 return; |
6a3aaa4e5e56
Get rid of this warning:
Stu Tomlinson <stu@nosnilmot.com>
parents:
29152
diff
changeset
|
83 }; |
24851
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
84 dup2(pipes[1], STDERR_FILENO); |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
85 |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
86 stderrch = g_io_channel_unix_new(pipes[0]); |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
87 g_io_channel_set_close_on_unref(stderrch, TRUE); |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
88 readhandle = g_io_add_watch_full(stderrch, G_PRIORITY_HIGH, |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
89 G_IO_IN | G_IO_ERR | G_IO_PRI, |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
90 handle_fprintf_stderr_cb, NULL, NULL); |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
91 g_io_channel_unref(stderrch); |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
92 } |
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
93 |
15818 | 94 static struct |
95 { | |
96 GntWidget *window; | |
97 GntWidget *tview; | |
17011
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
98 GntWidget *search; |
15818 | 99 gboolean paused; |
100 } debug; | |
101 | |
17011
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
102 static gboolean |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
103 match_string(const char *category, const char *args) |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
104 { |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
105 const char *str = gnt_entry_get_text(GNT_ENTRY(debug.search)); |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
106 if (!str || !*str) |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
107 return TRUE; |
17026
47a9ba4f4373
Fix debug filtering.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17011
diff
changeset
|
108 if (g_strrstr(category, str) != NULL) |
17011
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
109 return TRUE; |
17026
47a9ba4f4373
Fix debug filtering.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17011
diff
changeset
|
110 if (g_strrstr(args, str) != NULL) |
17011
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
111 return TRUE; |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
112 return FALSE; |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
113 } |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
114 |
15818 | 115 static void |
15823 | 116 finch_debug_print(PurpleDebugLevel level, const char *category, |
15818 | 117 const char *args) |
118 { | |
17011
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
119 if (debug.window && !debug.paused && match_string(category, args)) |
15818 | 120 { |
121 int pos = gnt_text_view_get_lines_below(GNT_TEXT_VIEW(debug.tview)); | |
122 GntTextFormatFlags flag = GNT_TEXT_FLAG_NORMAL; | |
16999
87748f771638
The timestamp pref has been removed. Update finch accordingly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16677
diff
changeset
|
123 const char *mdate; |
87748f771638
The timestamp pref has been removed. Update finch accordingly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16677
diff
changeset
|
124 time_t mtime = time(NULL); |
87748f771638
The timestamp pref has been removed. Update finch accordingly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16677
diff
changeset
|
125 mdate = purple_utf8_strftime("%H:%M:%S ", localtime(&mtime)); |
87748f771638
The timestamp pref has been removed. Update finch accordingly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16677
diff
changeset
|
126 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), |
87748f771638
The timestamp pref has been removed. Update finch accordingly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16677
diff
changeset
|
127 mdate, flag); |
15818 | 128 |
129 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), | |
130 category, GNT_TEXT_FLAG_BOLD); | |
131 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), | |
132 ": ", GNT_TEXT_FLAG_BOLD); | |
133 | |
134 switch (level) | |
135 { | |
15823 | 136 case PURPLE_DEBUG_WARNING: |
15818 | 137 flag |= GNT_TEXT_FLAG_UNDERLINE; |
15823 | 138 case PURPLE_DEBUG_ERROR: |
139 case PURPLE_DEBUG_FATAL: | |
15818 | 140 flag |= GNT_TEXT_FLAG_BOLD; |
141 break; | |
142 default: | |
143 break; | |
144 } | |
145 | |
146 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), args, flag); | |
147 if (pos <= 1) | |
148 gnt_text_view_scroll(GNT_TEXT_VIEW(debug.tview), 0); | |
149 } | |
150 } | |
151 | |
15985
6dc5dc83a61b
Add a whimpy ui op to the debug API that returns TRUE if debugging
Mark Doliner <mark@kingant.net>
parents:
15871
diff
changeset
|
152 static gboolean |
6dc5dc83a61b
Add a whimpy ui op to the debug API that returns TRUE if debugging
Mark Doliner <mark@kingant.net>
parents:
15871
diff
changeset
|
153 finch_debug_is_enabled(PurpleDebugLevel level, const char *category) |
6dc5dc83a61b
Add a whimpy ui op to the debug API that returns TRUE if debugging
Mark Doliner <mark@kingant.net>
parents:
15871
diff
changeset
|
154 { |
6dc5dc83a61b
Add a whimpy ui op to the debug API that returns TRUE if debugging
Mark Doliner <mark@kingant.net>
parents:
15871
diff
changeset
|
155 return debug.window && !debug.paused; |
6dc5dc83a61b
Add a whimpy ui op to the debug API that returns TRUE if debugging
Mark Doliner <mark@kingant.net>
parents:
15871
diff
changeset
|
156 } |
6dc5dc83a61b
Add a whimpy ui op to the debug API that returns TRUE if debugging
Mark Doliner <mark@kingant.net>
parents:
15871
diff
changeset
|
157 |
15823 | 158 static PurpleDebugUiOps uiops = |
15818 | 159 { |
160 finch_debug_print, | |
16677
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16427
diff
changeset
|
161 finch_debug_is_enabled, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16427
diff
changeset
|
162 |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16427
diff
changeset
|
163 /* padding */ |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16427
diff
changeset
|
164 NULL, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16427
diff
changeset
|
165 NULL, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16427
diff
changeset
|
166 NULL, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16427
diff
changeset
|
167 NULL |
15818 | 168 }; |
169 | |
15823 | 170 PurpleDebugUiOps *finch_debug_get_ui_ops() |
15818 | 171 { |
172 return &uiops; | |
173 } | |
174 | |
175 static void | |
176 reset_debug_win(GntWidget *w, gpointer null) | |
177 { | |
17011
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
178 debug.window = debug.tview = debug.search = NULL; |
15818 | 179 } |
180 | |
181 static void | |
182 clear_debug_win(GntWidget *w, GntTextView *tv) | |
183 { | |
184 gnt_text_view_clear(tv); | |
185 } | |
186 | |
187 static void | |
188 print_stderr(const char *string) | |
189 { | |
190 g_printerr("%s", string); | |
191 } | |
192 | |
193 static void | |
194 toggle_pause(GntWidget *w, gpointer n) | |
195 { | |
196 debug.paused = !debug.paused; | |
197 } | |
198 | |
199 /* Xerox */ | |
200 static void | |
15823 | 201 purple_glib_log_handler(const gchar *domain, GLogLevelFlags flags, |
15818 | 202 const gchar *msg, gpointer user_data) |
203 { | |
15823 | 204 PurpleDebugLevel level; |
15818 | 205 char *new_msg = NULL; |
206 char *new_domain = NULL; | |
207 | |
208 if ((flags & G_LOG_LEVEL_ERROR) == G_LOG_LEVEL_ERROR) | |
15823 | 209 level = PURPLE_DEBUG_ERROR; |
15818 | 210 else if ((flags & G_LOG_LEVEL_CRITICAL) == G_LOG_LEVEL_CRITICAL) |
15823 | 211 level = PURPLE_DEBUG_FATAL; |
15818 | 212 else if ((flags & G_LOG_LEVEL_WARNING) == G_LOG_LEVEL_WARNING) |
15823 | 213 level = PURPLE_DEBUG_WARNING; |
15818 | 214 else if ((flags & G_LOG_LEVEL_MESSAGE) == G_LOG_LEVEL_MESSAGE) |
15823 | 215 level = PURPLE_DEBUG_INFO; |
15818 | 216 else if ((flags & G_LOG_LEVEL_INFO) == G_LOG_LEVEL_INFO) |
15823 | 217 level = PURPLE_DEBUG_INFO; |
15818 | 218 else if ((flags & G_LOG_LEVEL_DEBUG) == G_LOG_LEVEL_DEBUG) |
15823 | 219 level = PURPLE_DEBUG_MISC; |
15818 | 220 else |
221 { | |
15823 | 222 purple_debug_warning("gntdebug", |
15818 | 223 "Unknown glib logging level in %d\n", flags); |
224 | |
15823 | 225 level = PURPLE_DEBUG_MISC; /* This will never happen. */ |
15818 | 226 } |
227 | |
228 if (msg != NULL) | |
15823 | 229 new_msg = purple_utf8_try_convert(msg); |
15818 | 230 |
231 if (domain != NULL) | |
15823 | 232 new_domain = purple_utf8_try_convert(domain); |
15818 | 233 |
234 if (new_msg != NULL) | |
235 { | |
15823 | 236 purple_debug(level, (new_domain != NULL ? new_domain : "g_log"), |
15818 | 237 "%s\n", new_msg); |
238 | |
239 g_free(new_msg); | |
240 } | |
241 | |
242 g_free(new_domain); | |
243 } | |
244 | |
245 static void | |
246 size_changed_cb(GntWidget *widget, int oldw, int oldh) | |
247 { | |
248 int w, h; | |
249 gnt_widget_get_size(widget, &w, &h); | |
15823 | 250 purple_prefs_set_int(PREF_ROOT "/size/width", w); |
251 purple_prefs_set_int(PREF_ROOT "/size/height", h); | |
15818 | 252 } |
253 | |
17011
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
254 static gboolean |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
255 for_real(gpointer entry) |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
256 { |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
257 purple_prefs_set_string(PREF_ROOT "/filter", gnt_entry_get_text(entry)); |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
258 return FALSE; |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
259 } |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
260 |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
261 static void |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
262 update_filter_string(GntEntry *entry, gpointer null) |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
263 { |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
264 int id = g_timeout_add(1000, for_real, entry); |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
265 g_object_set_data_full(G_OBJECT(entry), "update-filter", GINT_TO_POINTER(id), |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
266 (GDestroyNotify)g_source_remove); |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
267 } |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
268 |
20672
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
269 static void |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
270 file_save(GntFileSel *fs, const char *path, const char *file, GntTextView *tv) |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
271 { |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
272 FILE *fp; |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
273 |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
274 if ((fp = g_fopen(path, "w+")) == NULL) { |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
275 purple_notify_error(NULL, NULL, _("Unable to open file."), NULL); |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
276 return; |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
277 } |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
278 |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
279 fprintf(fp, "Finch Debug Log : %s\n", purple_date_format_full(NULL)); |
24398
0320b4a33432
Backport the 'purple_debug_*(msg)' -> 'purple_debug_*("%s", msg);' fixes.
Richard Laager <rlaager@wiktel.com>
parents:
21796
diff
changeset
|
280 fprintf(fp, "%s", tv->string->str); |
20672
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
281 fclose(fp); |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
282 gnt_widget_destroy(GNT_WIDGET(fs)); |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
283 } |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
284 |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
285 static void |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
286 file_cancel(GntWidget *w, GntFileSel *fs) |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
287 { |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
288 gnt_widget_destroy(GNT_WIDGET(fs)); |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
289 } |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
290 |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
291 static void |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
292 save_debug_win(GntWidget *w, GntTextView *tv) |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
293 { |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
294 GntWidget *window = gnt_file_sel_new(); |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
295 GntFileSel *sel = GNT_FILE_SEL(window); |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
296 gnt_file_sel_set_current_location(sel, purple_home_dir()); |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
297 gnt_file_sel_set_suggested_filename(sel, "debug.txt"); |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
298 g_signal_connect(G_OBJECT(sel), "file_selected", G_CALLBACK(file_save), tv); |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
299 g_signal_connect(G_OBJECT(sel->cancel), "activate", G_CALLBACK(file_cancel), sel); |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
300 gnt_widget_show(window); |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
301 } |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
302 |
15818 | 303 void finch_debug_window_show() |
304 { | |
20672
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
305 GntWidget *wid, *box, *label; |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
306 |
15818 | 307 debug.paused = FALSE; |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
308 if (debug.window) { |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
309 gnt_window_present(debug.window); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
310 return; |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
311 } |
15818 | 312 |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
313 debug.window = gnt_vbox_new(FALSE); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
314 gnt_box_set_toplevel(GNT_BOX(debug.window), TRUE); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
315 gnt_box_set_title(GNT_BOX(debug.window), _("Debug Window")); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
316 gnt_box_set_pad(GNT_BOX(debug.window), 0); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
317 gnt_box_set_alignment(GNT_BOX(debug.window), GNT_ALIGN_MID); |
15818 | 318 |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
319 debug.tview = gnt_text_view_new(); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
320 gnt_box_add_widget(GNT_BOX(debug.window), debug.tview); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
321 gnt_widget_set_size(debug.tview, |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
322 purple_prefs_get_int(PREF_ROOT "/size/width"), |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
323 purple_prefs_get_int(PREF_ROOT "/size/height")); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
324 g_signal_connect(G_OBJECT(debug.tview), "size_changed", G_CALLBACK(size_changed_cb), NULL); |
15818 | 325 |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
326 gnt_box_add_widget(GNT_BOX(debug.window), gnt_line_new(FALSE)); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
327 |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
328 box = gnt_hbox_new(FALSE); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
329 gnt_box_set_alignment(GNT_BOX(box), GNT_ALIGN_MID); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
330 gnt_box_set_fill(GNT_BOX(box), FALSE); |
15818 | 331 |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
332 /* XXX: Setting the GROW_Y for the following widgets don't make sense. But right now |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
333 * it's necessary to make the width of the debug window resizable ... like I said, |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
334 * it doesn't make sense. The bug is likely in the packing in gntbox.c. |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
335 */ |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
336 wid = gnt_button_new(_("Clear")); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
337 g_signal_connect(G_OBJECT(wid), "activate", G_CALLBACK(clear_debug_win), debug.tview); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
338 GNT_WIDGET_SET_FLAGS(wid, GNT_WIDGET_GROW_Y); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
339 gnt_box_add_widget(GNT_BOX(box), wid); |
17011
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
340 |
20672
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
341 wid = gnt_button_new(_("Save")); |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
342 g_signal_connect(G_OBJECT(wid), "activate", G_CALLBACK(save_debug_win), debug.tview); |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
343 GNT_WIDGET_SET_FLAGS(wid, GNT_WIDGET_GROW_Y); |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
344 gnt_box_add_widget(GNT_BOX(box), wid); |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
345 |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
346 debug.search = gnt_entry_new(purple_prefs_get_string(PREF_ROOT "/filter")); |
20672
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
347 label = gnt_label_new(_("Filter:")); |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
348 GNT_WIDGET_UNSET_FLAGS(label, GNT_WIDGET_GROW_X); |
c8d4fe2cd0d7
Add save button to the debug window and alter some GROW_X for visual appeal
Richard Nelson <wabz@pidgin.im>
parents:
20074
diff
changeset
|
349 gnt_box_add_widget(GNT_BOX(box), label); |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
350 gnt_box_add_widget(GNT_BOX(box), debug.search); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
351 g_signal_connect(G_OBJECT(debug.search), "text_changed", G_CALLBACK(update_filter_string), NULL); |
15818 | 352 |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
353 wid = gnt_check_box_new(_("Pause")); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
354 g_signal_connect(G_OBJECT(wid), "toggled", G_CALLBACK(toggle_pause), NULL); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
355 GNT_WIDGET_SET_FLAGS(wid, GNT_WIDGET_GROW_Y); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
356 gnt_box_add_widget(GNT_BOX(box), wid); |
15818 | 357 |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
358 gnt_box_add_widget(GNT_BOX(debug.window), box); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
359 GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_GROW_Y); |
15818 | 360 |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
361 gnt_widget_set_name(debug.window, "debug-window"); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
362 |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
363 g_signal_connect(G_OBJECT(debug.window), "destroy", G_CALLBACK(reset_debug_win), NULL); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17026
diff
changeset
|
364 gnt_text_view_attach_scroll_widget(GNT_TEXT_VIEW(debug.tview), debug.window); |
18427
be8c4eba38f6
Use the utility function for the conversation and debug windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18345
diff
changeset
|
365 gnt_text_view_attach_pager_widget(GNT_TEXT_VIEW(debug.tview), debug.window); |
15818 | 366 |
367 gnt_widget_show(debug.window); | |
368 } | |
369 | |
370 static gboolean | |
371 start_with_debugwin(gpointer null) | |
372 { | |
373 finch_debug_window_show(); | |
374 return FALSE; | |
375 } | |
376 | |
377 void finch_debug_init() | |
378 { | |
379 /* Xerox */ | |
380 #define REGISTER_G_LOG_HANDLER(name) \ | |
381 g_log_set_handler((name), G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL \ | |
382 | G_LOG_FLAG_RECURSION, \ | |
15823 | 383 purple_glib_log_handler, NULL) |
15818 | 384 |
385 /* Register the glib log handlers. */ | |
386 REGISTER_G_LOG_HANDLER(NULL); | |
387 REGISTER_G_LOG_HANDLER("GLib"); | |
388 REGISTER_G_LOG_HANDLER("GModule"); | |
389 REGISTER_G_LOG_HANDLER("GLib-GObject"); | |
390 REGISTER_G_LOG_HANDLER("GThread"); | |
24503
e2e57d3c0578
Use glib log functions to show error messages.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24398
diff
changeset
|
391 REGISTER_G_LOG_HANDLER("Gnt"); |
21796
39e07c9ae0d7
Trap gstreamer error messages with our debug stuff so they don't get spewed
Stu Tomlinson <stu@nosnilmot.com>
parents:
20672
diff
changeset
|
392 #ifdef USE_GSTREAMER |
39e07c9ae0d7
Trap gstreamer error messages with our debug stuff so they don't get spewed
Stu Tomlinson <stu@nosnilmot.com>
parents:
20672
diff
changeset
|
393 REGISTER_G_LOG_HANDLER("GStreamer"); |
39e07c9ae0d7
Trap gstreamer error messages with our debug stuff so they don't get spewed
Stu Tomlinson <stu@nosnilmot.com>
parents:
20672
diff
changeset
|
394 #endif |
24851
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
395 REGISTER_G_LOG_HANDLER("stderr"); |
15818 | 396 |
397 g_set_print_handler(print_stderr); /* Redirect the debug messages to stderr */ | |
18454
6b623a59cec6
If debug is enabled using the -d argument, then do not suppress the outputs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18427
diff
changeset
|
398 if (!purple_debug_is_enabled()) |
24851
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
399 handle_fprintf_stderr(FALSE); |
15818 | 400 |
15823 | 401 purple_prefs_add_none(PREF_ROOT); |
17011
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16999
diff
changeset
|
402 purple_prefs_add_string(PREF_ROOT "/filter", ""); |
15823 | 403 purple_prefs_add_none(PREF_ROOT "/size"); |
404 purple_prefs_add_int(PREF_ROOT "/size/width", 60); | |
405 purple_prefs_add_int(PREF_ROOT "/size/height", 15); | |
15818 | 406 |
15823 | 407 if (purple_debug_is_enabled()) |
15818 | 408 g_timeout_add(0, start_with_debugwin, NULL); |
409 } | |
410 | |
411 void finch_debug_uninit() | |
412 { | |
24851
bbcdb1786eda
Redirect stderr to the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24503
diff
changeset
|
413 handle_fprintf_stderr(TRUE); |
15818 | 414 } |
415 |