Mercurial > pidgin
annotate finch/gntdebug.c @ 20625:54ff514fdd04
Pressing INSERT in the buddy list brings up the 'Add Buddy' dialog.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sun, 23 Sep 2007 01:25:56 +0000 |
parents | 6bf32c9e15a7 |
children | c8d4fe2cd0d7 |
rev | line source |
---|---|
15817 | 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:
19681
diff
changeset
|
4 */ |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
5 |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
6 /* finch |
15817 | 7 * |
15870
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
8 * Finch is the legal property of its developers, whose names are too numerous |
15817 | 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 | |
19681
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 |
15817 | 25 */ |
26 #include <gnt.h> | |
27 #include <gntbox.h> | |
28 #include <gntbutton.h> | |
29 #include <gntcheckbox.h> | |
17000
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
30 #include <gntentry.h> |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
31 #include <gntlabel.h> |
15817 | 32 #include <gntline.h> |
17000
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
33 #include <gnttextview.h> |
15817 | 34 |
35 #include "gntdebug.h" | |
15822 | 36 #include "finch.h" |
15817 | 37 #include "util.h" |
38 | |
39 #include <stdio.h> | |
40 #include <string.h> | |
41 | |
16424
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
|
42 #define PREF_ROOT "/finch/debug" |
15817 | 43 |
44 static struct | |
45 { | |
46 GntWidget *window; | |
47 GntWidget *tview; | |
17000
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
48 GntWidget *search; |
15817 | 49 gboolean paused; |
50 } debug; | |
51 | |
17000
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
52 static gboolean |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
53 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:
16988
diff
changeset
|
54 { |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
55 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:
16988
diff
changeset
|
56 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:
16988
diff
changeset
|
57 return TRUE; |
17015
47a9ba4f4373
Fix debug filtering.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17000
diff
changeset
|
58 if (g_strrstr(category, str) != NULL) |
17000
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
59 return TRUE; |
17015
47a9ba4f4373
Fix debug filtering.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17000
diff
changeset
|
60 if (g_strrstr(args, str) != NULL) |
17000
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
61 return TRUE; |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
62 return FALSE; |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
63 } |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
64 |
15817 | 65 static void |
15822 | 66 finch_debug_print(PurpleDebugLevel level, const char *category, |
15817 | 67 const char *args) |
68 { | |
17000
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
69 if (debug.window && !debug.paused && match_string(category, args)) |
15817 | 70 { |
71 int pos = gnt_text_view_get_lines_below(GNT_TEXT_VIEW(debug.tview)); | |
72 GntTextFormatFlags flag = GNT_TEXT_FLAG_NORMAL; | |
16988
87748f771638
The timestamp pref has been removed. Update finch accordingly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16669
diff
changeset
|
73 const char *mdate; |
87748f771638
The timestamp pref has been removed. Update finch accordingly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16669
diff
changeset
|
74 time_t mtime = time(NULL); |
87748f771638
The timestamp pref has been removed. Update finch accordingly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16669
diff
changeset
|
75 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:
16669
diff
changeset
|
76 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:
16669
diff
changeset
|
77 mdate, flag); |
15817 | 78 |
79 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), | |
80 category, GNT_TEXT_FLAG_BOLD); | |
81 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), | |
82 ": ", GNT_TEXT_FLAG_BOLD); | |
83 | |
84 switch (level) | |
85 { | |
15822 | 86 case PURPLE_DEBUG_WARNING: |
15817 | 87 flag |= GNT_TEXT_FLAG_UNDERLINE; |
15822 | 88 case PURPLE_DEBUG_ERROR: |
89 case PURPLE_DEBUG_FATAL: | |
15817 | 90 flag |= GNT_TEXT_FLAG_BOLD; |
91 break; | |
92 default: | |
93 break; | |
94 } | |
95 | |
96 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), args, flag); | |
97 if (pos <= 1) | |
98 gnt_text_view_scroll(GNT_TEXT_VIEW(debug.tview), 0); | |
99 } | |
100 } | |
101 | |
15985
6dc5dc83a61b
Add a whimpy ui op to the debug API that returns TRUE if debugging
Mark Doliner <mark@kingant.net>
parents:
15870
diff
changeset
|
102 static gboolean |
6dc5dc83a61b
Add a whimpy ui op to the debug API that returns TRUE if debugging
Mark Doliner <mark@kingant.net>
parents:
15870
diff
changeset
|
103 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:
15870
diff
changeset
|
104 { |
6dc5dc83a61b
Add a whimpy ui op to the debug API that returns TRUE if debugging
Mark Doliner <mark@kingant.net>
parents:
15870
diff
changeset
|
105 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:
15870
diff
changeset
|
106 } |
6dc5dc83a61b
Add a whimpy ui op to the debug API that returns TRUE if debugging
Mark Doliner <mark@kingant.net>
parents:
15870
diff
changeset
|
107 |
15822 | 108 static PurpleDebugUiOps uiops = |
15817 | 109 { |
110 finch_debug_print, | |
16669
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16424
diff
changeset
|
111 finch_debug_is_enabled, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16424
diff
changeset
|
112 |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16424
diff
changeset
|
113 /* padding */ |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16424
diff
changeset
|
114 NULL, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16424
diff
changeset
|
115 NULL, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16424
diff
changeset
|
116 NULL, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16424
diff
changeset
|
117 NULL |
15817 | 118 }; |
119 | |
15822 | 120 PurpleDebugUiOps *finch_debug_get_ui_ops() |
15817 | 121 { |
122 return &uiops; | |
123 } | |
124 | |
125 static void | |
126 reset_debug_win(GntWidget *w, gpointer null) | |
127 { | |
17000
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
128 debug.window = debug.tview = debug.search = NULL; |
15817 | 129 } |
130 | |
131 static void | |
132 clear_debug_win(GntWidget *w, GntTextView *tv) | |
133 { | |
134 gnt_text_view_clear(tv); | |
135 } | |
136 | |
137 static void | |
138 print_stderr(const char *string) | |
139 { | |
140 g_printerr("%s", string); | |
141 } | |
142 | |
143 static void | |
144 suppress_error_messages(const char *message) | |
145 {} | |
146 | |
147 static void | |
148 toggle_pause(GntWidget *w, gpointer n) | |
149 { | |
150 debug.paused = !debug.paused; | |
151 } | |
152 | |
153 /* Xerox */ | |
154 static void | |
15822 | 155 purple_glib_log_handler(const gchar *domain, GLogLevelFlags flags, |
15817 | 156 const gchar *msg, gpointer user_data) |
157 { | |
15822 | 158 PurpleDebugLevel level; |
15817 | 159 char *new_msg = NULL; |
160 char *new_domain = NULL; | |
161 | |
162 if ((flags & G_LOG_LEVEL_ERROR) == G_LOG_LEVEL_ERROR) | |
15822 | 163 level = PURPLE_DEBUG_ERROR; |
15817 | 164 else if ((flags & G_LOG_LEVEL_CRITICAL) == G_LOG_LEVEL_CRITICAL) |
15822 | 165 level = PURPLE_DEBUG_FATAL; |
15817 | 166 else if ((flags & G_LOG_LEVEL_WARNING) == G_LOG_LEVEL_WARNING) |
15822 | 167 level = PURPLE_DEBUG_WARNING; |
15817 | 168 else if ((flags & G_LOG_LEVEL_MESSAGE) == G_LOG_LEVEL_MESSAGE) |
15822 | 169 level = PURPLE_DEBUG_INFO; |
15817 | 170 else if ((flags & G_LOG_LEVEL_INFO) == G_LOG_LEVEL_INFO) |
15822 | 171 level = PURPLE_DEBUG_INFO; |
15817 | 172 else if ((flags & G_LOG_LEVEL_DEBUG) == G_LOG_LEVEL_DEBUG) |
15822 | 173 level = PURPLE_DEBUG_MISC; |
15817 | 174 else |
175 { | |
15822 | 176 purple_debug_warning("gntdebug", |
15817 | 177 "Unknown glib logging level in %d\n", flags); |
178 | |
15822 | 179 level = PURPLE_DEBUG_MISC; /* This will never happen. */ |
15817 | 180 } |
181 | |
182 if (msg != NULL) | |
15822 | 183 new_msg = purple_utf8_try_convert(msg); |
15817 | 184 |
185 if (domain != NULL) | |
15822 | 186 new_domain = purple_utf8_try_convert(domain); |
15817 | 187 |
188 if (new_msg != NULL) | |
189 { | |
15822 | 190 purple_debug(level, (new_domain != NULL ? new_domain : "g_log"), |
15817 | 191 "%s\n", new_msg); |
192 | |
193 g_free(new_msg); | |
194 } | |
195 | |
196 g_free(new_domain); | |
197 } | |
198 | |
199 static void | |
200 size_changed_cb(GntWidget *widget, int oldw, int oldh) | |
201 { | |
202 int w, h; | |
203 gnt_widget_get_size(widget, &w, &h); | |
15822 | 204 purple_prefs_set_int(PREF_ROOT "/size/width", w); |
205 purple_prefs_set_int(PREF_ROOT "/size/height", h); | |
15817 | 206 } |
207 | |
17000
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
208 static gboolean |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
209 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:
16988
diff
changeset
|
210 { |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
211 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:
16988
diff
changeset
|
212 return FALSE; |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
213 } |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
214 |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
215 static void |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
216 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:
16988
diff
changeset
|
217 { |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
218 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:
16988
diff
changeset
|
219 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:
16988
diff
changeset
|
220 (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:
16988
diff
changeset
|
221 } |
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
222 |
15817 | 223 void finch_debug_window_show() |
224 { | |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17015
diff
changeset
|
225 GntWidget *wid, *box; |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17015
diff
changeset
|
226 |
15817 | 227 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:
17015
diff
changeset
|
228 if (debug.window) { |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17015
diff
changeset
|
229 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:
17015
diff
changeset
|
230 return; |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17015
diff
changeset
|
231 } |
15817 | 232 |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17015
diff
changeset
|
233 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:
17015
diff
changeset
|
234 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:
17015
diff
changeset
|
235 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:
17015
diff
changeset
|
236 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:
17015
diff
changeset
|
237 gnt_box_set_alignment(GNT_BOX(debug.window), GNT_ALIGN_MID); |
15817 | 238 |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17015
diff
changeset
|
239 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:
17015
diff
changeset
|
240 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:
17015
diff
changeset
|
241 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:
17015
diff
changeset
|
242 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:
17015
diff
changeset
|
243 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:
17015
diff
changeset
|
244 g_signal_connect(G_OBJECT(debug.tview), "size_changed", G_CALLBACK(size_changed_cb), NULL); |
15817 | 245 |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17015
diff
changeset
|
246 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:
17015
diff
changeset
|
247 |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17015
diff
changeset
|
248 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:
17015
diff
changeset
|
249 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:
17015
diff
changeset
|
250 gnt_box_set_fill(GNT_BOX(box), FALSE); |
15817 | 251 |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17015
diff
changeset
|
252 /* 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:
17015
diff
changeset
|
253 * 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:
17015
diff
changeset
|
254 * 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:
17015
diff
changeset
|
255 */ |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17015
diff
changeset
|
256 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:
17015
diff
changeset
|
257 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:
17015
diff
changeset
|
258 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:
17015
diff
changeset
|
259 gnt_box_add_widget(GNT_BOX(box), wid); |
17000
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
260 |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17015
diff
changeset
|
261 debug.search = gnt_entry_new(purple_prefs_get_string(PREF_ROOT "/filter")); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17015
diff
changeset
|
262 gnt_box_add_widget(GNT_BOX(box), gnt_label_new(_("Filter: "))); |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17015
diff
changeset
|
263 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:
17015
diff
changeset
|
264 g_signal_connect(G_OBJECT(debug.search), "text_changed", G_CALLBACK(update_filter_string), NULL); |
15817 | 265 |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17015
diff
changeset
|
266 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:
17015
diff
changeset
|
267 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:
17015
diff
changeset
|
268 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:
17015
diff
changeset
|
269 gnt_box_add_widget(GNT_BOX(box), wid); |
15817 | 270 |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17015
diff
changeset
|
271 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:
17015
diff
changeset
|
272 GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_GROW_Y); |
15817 | 273 |
18345
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17015
diff
changeset
|
274 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:
17015
diff
changeset
|
275 |
2d4df5ef0090
If the action-windows are already there, then bring them to front when
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17015
diff
changeset
|
276 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:
17015
diff
changeset
|
277 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
|
278 gnt_text_view_attach_pager_widget(GNT_TEXT_VIEW(debug.tview), debug.window); |
15817 | 279 |
280 gnt_widget_show(debug.window); | |
281 } | |
282 | |
283 static gboolean | |
284 start_with_debugwin(gpointer null) | |
285 { | |
286 finch_debug_window_show(); | |
287 return FALSE; | |
288 } | |
289 | |
290 void finch_debug_init() | |
291 { | |
292 /* Xerox */ | |
293 #define REGISTER_G_LOG_HANDLER(name) \ | |
294 g_log_set_handler((name), G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL \ | |
295 | G_LOG_FLAG_RECURSION, \ | |
15822 | 296 purple_glib_log_handler, NULL) |
15817 | 297 |
298 /* Register the glib log handlers. */ | |
299 REGISTER_G_LOG_HANDLER(NULL); | |
300 REGISTER_G_LOG_HANDLER("GLib"); | |
301 REGISTER_G_LOG_HANDLER("GModule"); | |
302 REGISTER_G_LOG_HANDLER("GLib-GObject"); | |
303 REGISTER_G_LOG_HANDLER("GThread"); | |
304 | |
305 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
|
306 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
|
307 g_set_printerr_handler(suppress_error_messages); |
15817 | 308 |
15822 | 309 purple_prefs_add_none(PREF_ROOT); |
17000
531a4585d437
Now that timestamps are gone, let's allow filter strings in the debug window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16988
diff
changeset
|
310 purple_prefs_add_string(PREF_ROOT "/filter", ""); |
15822 | 311 purple_prefs_add_none(PREF_ROOT "/size"); |
312 purple_prefs_add_int(PREF_ROOT "/size/width", 60); | |
313 purple_prefs_add_int(PREF_ROOT "/size/height", 15); | |
15817 | 314 |
15822 | 315 if (purple_debug_is_enabled()) |
15817 | 316 g_timeout_add(0, start_with_debugwin, NULL); |
317 } | |
318 | |
319 void finch_debug_uninit() | |
320 { | |
321 } | |
322 |