annotate finch/gntdebug.c @ 27868:e4fa83bb82e0

propagate from branch 'im.pidgin.pidgin' (head c50c272054b5f756082d58737d15f1ab5e46be26) to branch 'im.pidgin.pidgin.yaz' (head 722923614311c50bbed8655320ee549b5ec3fb28)
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Sat, 16 Aug 2008 07:04:26 +0000
parents 39e07c9ae0d7
children 0320b4a33432 60f5abc6cf0c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * source distribution.
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * (at your option) any later version.
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * GNU General Public License for more details.
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include <gnt.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include <gntbox.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include <gntbutton.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #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
30 #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
31 #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
32 #include <gntlabel.h>
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #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
34 #include <gnttextview.h>
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 #include "gntdebug.h"
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
37 #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
38 #include "notify.h"
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 #include "util.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 #include <stdio.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 #include <string.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43
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
44 #define PREF_ROOT "/finch/debug"
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 static struct
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 GntWidget *window;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 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
50 GntWidget *search;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 gboolean paused;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 } debug;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53
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
54 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
55 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
56 {
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
57 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
58 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
59 return TRUE;
17026
47a9ba4f4373 Fix debug filtering.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17011
diff changeset
60 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
61 return TRUE;
17026
47a9ba4f4373 Fix debug filtering.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17011
diff changeset
62 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
63 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
64 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
65 }
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
66
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 static void
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
68 finch_debug_print(PurpleDebugLevel level, const char *category,
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 const char *args)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 {
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
71 if (debug.window && !debug.paused && match_string(category, args))
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 int pos = gnt_text_view_get_lines_below(GNT_TEXT_VIEW(debug.tview));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 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
75 const char *mdate;
87748f771638 The timestamp pref has been removed. Update finch accordingly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16677
diff changeset
76 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
77 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
78 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
79 mdate, flag);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 category, GNT_TEXT_FLAG_BOLD);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 ": ", GNT_TEXT_FLAG_BOLD);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 switch (level)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
88 case PURPLE_DEBUG_WARNING:
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 flag |= GNT_TEXT_FLAG_UNDERLINE;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
90 case PURPLE_DEBUG_ERROR:
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
91 case PURPLE_DEBUG_FATAL:
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 flag |= GNT_TEXT_FLAG_BOLD;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 break;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 default:
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 break;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), args, flag);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 if (pos <= 1)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 gnt_text_view_scroll(GNT_TEXT_VIEW(debug.tview), 0);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103
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
104 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
105 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
106 {
6dc5dc83a61b Add a whimpy ui op to the debug API that returns TRUE if debugging
Mark Doliner <mark@kingant.net>
parents: 15871
diff changeset
107 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
108 }
6dc5dc83a61b Add a whimpy ui op to the debug API that returns TRUE if debugging
Mark Doliner <mark@kingant.net>
parents: 15871
diff changeset
109
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
110 static PurpleDebugUiOps uiops =
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 finch_debug_print,
16677
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16427
diff changeset
113 finch_debug_is_enabled,
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16427
diff changeset
114
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16427
diff changeset
115 /* padding */
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16427
diff changeset
116 NULL,
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16427
diff changeset
117 NULL,
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16427
diff changeset
118 NULL,
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16427
diff changeset
119 NULL
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 };
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
122 PurpleDebugUiOps *finch_debug_get_ui_ops()
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 return &uiops;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 reset_debug_win(GntWidget *w, gpointer null)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 {
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
130 debug.window = debug.tview = debug.search = NULL;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 clear_debug_win(GntWidget *w, GntTextView *tv)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 gnt_text_view_clear(tv);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 print_stderr(const char *string)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 g_printerr("%s", string);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 suppress_error_messages(const char *message)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 {}
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 toggle_pause(GntWidget *w, gpointer n)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 debug.paused = !debug.paused;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 /* Xerox */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 static void
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
157 purple_glib_log_handler(const gchar *domain, GLogLevelFlags flags,
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 const gchar *msg, gpointer user_data)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
160 PurpleDebugLevel level;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 char *new_msg = NULL;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 char *new_domain = NULL;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 if ((flags & G_LOG_LEVEL_ERROR) == G_LOG_LEVEL_ERROR)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
165 level = PURPLE_DEBUG_ERROR;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 else if ((flags & G_LOG_LEVEL_CRITICAL) == G_LOG_LEVEL_CRITICAL)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
167 level = PURPLE_DEBUG_FATAL;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 else if ((flags & G_LOG_LEVEL_WARNING) == G_LOG_LEVEL_WARNING)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
169 level = PURPLE_DEBUG_WARNING;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 else if ((flags & G_LOG_LEVEL_MESSAGE) == G_LOG_LEVEL_MESSAGE)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
171 level = PURPLE_DEBUG_INFO;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 else if ((flags & G_LOG_LEVEL_INFO) == G_LOG_LEVEL_INFO)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
173 level = PURPLE_DEBUG_INFO;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 else if ((flags & G_LOG_LEVEL_DEBUG) == G_LOG_LEVEL_DEBUG)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
175 level = PURPLE_DEBUG_MISC;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 else
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
178 purple_debug_warning("gntdebug",
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 "Unknown glib logging level in %d\n", flags);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
181 level = PURPLE_DEBUG_MISC; /* This will never happen. */
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 if (msg != NULL)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
185 new_msg = purple_utf8_try_convert(msg);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 if (domain != NULL)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
188 new_domain = purple_utf8_try_convert(domain);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 if (new_msg != NULL)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
192 purple_debug(level, (new_domain != NULL ? new_domain : "g_log"),
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 "%s\n", new_msg);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 g_free(new_msg);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 g_free(new_domain);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 size_changed_cb(GntWidget *widget, int oldw, int oldh)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 int w, h;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 gnt_widget_get_size(widget, &w, &h);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
206 purple_prefs_set_int(PREF_ROOT "/size/width", w);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
207 purple_prefs_set_int(PREF_ROOT "/size/height", h);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209
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
210 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
211 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
212 {
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
213 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
214 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
215 }
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
216
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
217 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
218 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
219 {
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
220 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
221 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
222 (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
223 }
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
224
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
225 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
226 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
227 {
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
228 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
229
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
230 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
231 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
232 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
233 }
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
234
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
235 fprintf(fp, "Finch Debug Log : %s\n", purple_date_format_full(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
236 fprintf(fp, tv->string->str);
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
237 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
238 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
239 }
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
240
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
241 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
242 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
243 {
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
244 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
245 }
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
246
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
247 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
248 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
249 {
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
250 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
251 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
252 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
253 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
254 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
255 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
256 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
257 }
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
258
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 void finch_debug_window_show()
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 {
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
261 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
262
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 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
264 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
265 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
266 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
267 }
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268
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
269 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
270 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
271 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
272 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
273 gnt_box_set_alignment(GNT_BOX(debug.window), GNT_ALIGN_MID);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274
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
275 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
276 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
277 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
278 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
279 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
280 g_signal_connect(G_OBJECT(debug.tview), "size_changed", G_CALLBACK(size_changed_cb), NULL);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281
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
282 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
283
2d4df5ef0090 If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17026
diff changeset
284 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
285 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
286 gnt_box_set_fill(GNT_BOX(box), FALSE);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287
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
288 /* 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
289 * 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
290 * 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
291 */
2d4df5ef0090 If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17026
diff changeset
292 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
293 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
294 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
295 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
296
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
297 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
298 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
299 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
300 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
301
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
302 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
303 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
304 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
305 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
306 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
307 g_signal_connect(G_OBJECT(debug.search), "text_changed", G_CALLBACK(update_filter_string), NULL);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308
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
309 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
310 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
311 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
312 gnt_box_add_widget(GNT_BOX(box), wid);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313
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
314 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
315 GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_GROW_Y);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316
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
317 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
318
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 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
320 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
321 gnt_text_view_attach_pager_widget(GNT_TEXT_VIEW(debug.tview), debug.window);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323 gnt_widget_show(debug.window);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 static gboolean
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 start_with_debugwin(gpointer null)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329 finch_debug_window_show();
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 return FALSE;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 void finch_debug_init()
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335 /* Xerox */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336 #define REGISTER_G_LOG_HANDLER(name) \
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337 g_log_set_handler((name), G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL \
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 | G_LOG_FLAG_RECURSION, \
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
339 purple_glib_log_handler, NULL)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341 /* Register the glib log handlers. */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 REGISTER_G_LOG_HANDLER(NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 REGISTER_G_LOG_HANDLER("GLib");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344 REGISTER_G_LOG_HANDLER("GModule");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 REGISTER_G_LOG_HANDLER("GLib-GObject");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 REGISTER_G_LOG_HANDLER("GThread");
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
347 #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
348 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
349 #endif
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 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
352 if (!purple_debug_is_enabled())
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
353 g_set_printerr_handler(suppress_error_messages);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
355 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
356 purple_prefs_add_string(PREF_ROOT "/filter", "");
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
357 purple_prefs_add_none(PREF_ROOT "/size");
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
358 purple_prefs_add_int(PREF_ROOT "/size/width", 60);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
359 purple_prefs_add_int(PREF_ROOT "/size/height", 15);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
361 if (purple_debug_is_enabled())
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362 g_timeout_add(0, start_with_debugwin, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365 void finch_debug_uninit()
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368