Mercurial > pidgin
annotate finch/gntdebug.c @ 18637:3597903cf8ff
Just show an empty line, instead of bouncing the text down when the user
stops typing.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 25 Jul 2007 20:57:24 +0000 |
parents | 6b623a59cec6 |
children | 3432d37a4a77 44b4e8bd759b 315151da0dc6 |
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 |
15817 | 4 * |
15870
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
5 * finch |
15817 | 6 * |
15870
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
7 * Finch is the legal property of its developers, whose names are too numerous |
15817 | 8 * to list here. Please refer to the COPYRIGHT file distributed with this |
9 * source distribution. | |
10 * | |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
25 #include <gnt.h> | |
26 #include <gntbox.h> | |
27 #include <gntbutton.h> | |
28 #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
|
29 #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
|
30 #include <gntlabel.h> |
15817 | 31 #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
|
32 #include <gnttextview.h> |
15817 | 33 |
34 #include "gntdebug.h" | |
15822 | 35 #include "finch.h" |
15817 | 36 #include "util.h" |
37 | |
38 #include <stdio.h> | |
39 #include <string.h> | |
40 | |
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
|
41 #define PREF_ROOT "/finch/debug" |
15817 | 42 |
43 static struct | |
44 { | |
45 GntWidget *window; | |
46 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
|
47 GntWidget *search; |
15817 | 48 gboolean paused; |
49 } debug; | |
50 | |
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
|
51 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
|
52 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
|
53 { |
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 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
|
55 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
|
56 return TRUE; |
17015
47a9ba4f4373
Fix debug filtering.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17000
diff
changeset
|
57 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
|
58 return TRUE; |
17015
47a9ba4f4373
Fix debug filtering.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17000
diff
changeset
|
59 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
|
60 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
|
61 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
|
62 } |
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 |
15817 | 64 static void |
15822 | 65 finch_debug_print(PurpleDebugLevel level, const char *category, |
15817 | 66 const char *args) |
67 { | |
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
|
68 if (debug.window && !debug.paused && match_string(category, args)) |
15817 | 69 { |
70 int pos = gnt_text_view_get_lines_below(GNT_TEXT_VIEW(debug.tview)); | |
71 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
|
72 const char *mdate; |
87748f771638
The timestamp pref has been removed. Update finch accordingly.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16669
diff
changeset
|
73 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
|
74 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
|
75 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
|
76 mdate, flag); |
15817 | 77 |
78 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), | |
79 category, GNT_TEXT_FLAG_BOLD); | |
80 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), | |
81 ": ", GNT_TEXT_FLAG_BOLD); | |
82 | |
83 switch (level) | |
84 { | |
15822 | 85 case PURPLE_DEBUG_WARNING: |
15817 | 86 flag |= GNT_TEXT_FLAG_UNDERLINE; |
15822 | 87 case PURPLE_DEBUG_ERROR: |
88 case PURPLE_DEBUG_FATAL: | |
15817 | 89 flag |= GNT_TEXT_FLAG_BOLD; |
90 break; | |
91 default: | |
92 break; | |
93 } | |
94 | |
95 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), args, flag); | |
96 if (pos <= 1) | |
97 gnt_text_view_scroll(GNT_TEXT_VIEW(debug.tview), 0); | |
98 } | |
99 } | |
100 | |
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
|
101 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
|
102 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
|
103 { |
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 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
|
105 } |
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 |
15822 | 107 static PurpleDebugUiOps uiops = |
15817 | 108 { |
109 finch_debug_print, | |
16669
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16424
diff
changeset
|
110 finch_debug_is_enabled, |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16424
diff
changeset
|
111 |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16424
diff
changeset
|
112 /* padding */ |
30829e806dae
And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents:
16424
diff
changeset
|
113 NULL, |
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 |
15817 | 117 }; |
118 | |
15822 | 119 PurpleDebugUiOps *finch_debug_get_ui_ops() |
15817 | 120 { |
121 return &uiops; | |
122 } | |
123 | |
124 static void | |
125 reset_debug_win(GntWidget *w, gpointer null) | |
126 { | |
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
|
127 debug.window = debug.tview = debug.search = NULL; |
15817 | 128 } |
129 | |
130 static void | |
131 clear_debug_win(GntWidget *w, GntTextView *tv) | |
132 { | |
133 gnt_text_view_clear(tv); | |
134 } | |
135 | |
136 static void | |
137 print_stderr(const char *string) | |
138 { | |
139 g_printerr("%s", string); | |
140 } | |
141 | |
142 static void | |
143 suppress_error_messages(const char *message) | |
144 {} | |
145 | |
146 static void | |
147 toggle_pause(GntWidget *w, gpointer n) | |
148 { | |
149 debug.paused = !debug.paused; | |
150 } | |
151 | |
152 /* Xerox */ | |
153 static void | |
15822 | 154 purple_glib_log_handler(const gchar *domain, GLogLevelFlags flags, |
15817 | 155 const gchar *msg, gpointer user_data) |
156 { | |
15822 | 157 PurpleDebugLevel level; |
15817 | 158 char *new_msg = NULL; |
159 char *new_domain = NULL; | |
160 | |
161 if ((flags & G_LOG_LEVEL_ERROR) == G_LOG_LEVEL_ERROR) | |
15822 | 162 level = PURPLE_DEBUG_ERROR; |
15817 | 163 else if ((flags & G_LOG_LEVEL_CRITICAL) == G_LOG_LEVEL_CRITICAL) |
15822 | 164 level = PURPLE_DEBUG_FATAL; |
15817 | 165 else if ((flags & G_LOG_LEVEL_WARNING) == G_LOG_LEVEL_WARNING) |
15822 | 166 level = PURPLE_DEBUG_WARNING; |
15817 | 167 else if ((flags & G_LOG_LEVEL_MESSAGE) == G_LOG_LEVEL_MESSAGE) |
15822 | 168 level = PURPLE_DEBUG_INFO; |
15817 | 169 else if ((flags & G_LOG_LEVEL_INFO) == G_LOG_LEVEL_INFO) |
15822 | 170 level = PURPLE_DEBUG_INFO; |
15817 | 171 else if ((flags & G_LOG_LEVEL_DEBUG) == G_LOG_LEVEL_DEBUG) |
15822 | 172 level = PURPLE_DEBUG_MISC; |
15817 | 173 else |
174 { | |
15822 | 175 purple_debug_warning("gntdebug", |
15817 | 176 "Unknown glib logging level in %d\n", flags); |
177 | |
15822 | 178 level = PURPLE_DEBUG_MISC; /* This will never happen. */ |
15817 | 179 } |
180 | |
181 if (msg != NULL) | |
15822 | 182 new_msg = purple_utf8_try_convert(msg); |
15817 | 183 |
184 if (domain != NULL) | |
15822 | 185 new_domain = purple_utf8_try_convert(domain); |
15817 | 186 |
187 if (new_msg != NULL) | |
188 { | |
15822 | 189 purple_debug(level, (new_domain != NULL ? new_domain : "g_log"), |
15817 | 190 "%s\n", new_msg); |
191 | |
192 g_free(new_msg); | |
193 } | |
194 | |
195 g_free(new_domain); | |
196 } | |
197 | |
198 static void | |
199 size_changed_cb(GntWidget *widget, int oldw, int oldh) | |
200 { | |
201 int w, h; | |
202 gnt_widget_get_size(widget, &w, &h); | |
15822 | 203 purple_prefs_set_int(PREF_ROOT "/size/width", w); |
204 purple_prefs_set_int(PREF_ROOT "/size/height", h); | |
15817 | 205 } |
206 | |
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
|
207 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
|
208 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
|
209 { |
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 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
|
211 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
|
212 } |
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 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
|
215 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
|
216 { |
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 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
|
218 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
|
219 (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
|
220 } |
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 |
15817 | 222 void finch_debug_window_show() |
223 { | |
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
|
224 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
|
225 |
15817 | 226 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
|
227 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
|
228 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
|
229 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
|
230 } |
15817 | 231 |
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
|
232 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
|
233 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
|
234 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
|
235 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
|
236 gnt_box_set_alignment(GNT_BOX(debug.window), GNT_ALIGN_MID); |
15817 | 237 |
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
|
238 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
|
239 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
|
240 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
|
241 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
|
242 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
|
243 g_signal_connect(G_OBJECT(debug.tview), "size_changed", G_CALLBACK(size_changed_cb), NULL); |
15817 | 244 |
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
|
245 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
|
246 |
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 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
|
248 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
|
249 gnt_box_set_fill(GNT_BOX(box), FALSE); |
15817 | 250 |
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
|
251 /* 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
|
252 * 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
|
253 * 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
|
254 */ |
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 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
|
256 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
|
257 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
|
258 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
|
259 |
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
|
260 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
|
261 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
|
262 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
|
263 g_signal_connect(G_OBJECT(debug.search), "text_changed", G_CALLBACK(update_filter_string), NULL); |
15817 | 264 |
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
|
265 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
|
266 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
|
267 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
|
268 gnt_box_add_widget(GNT_BOX(box), wid); |
15817 | 269 |
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
|
270 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
|
271 GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_GROW_Y); |
15817 | 272 |
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
|
273 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
|
274 |
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 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
|
276 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
|
277 gnt_text_view_attach_pager_widget(GNT_TEXT_VIEW(debug.tview), debug.window); |
15817 | 278 |
279 gnt_widget_show(debug.window); | |
280 } | |
281 | |
282 static gboolean | |
283 start_with_debugwin(gpointer null) | |
284 { | |
285 finch_debug_window_show(); | |
286 return FALSE; | |
287 } | |
288 | |
289 void finch_debug_init() | |
290 { | |
291 /* Xerox */ | |
292 #define REGISTER_G_LOG_HANDLER(name) \ | |
293 g_log_set_handler((name), G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL \ | |
294 | G_LOG_FLAG_RECURSION, \ | |
15822 | 295 purple_glib_log_handler, NULL) |
15817 | 296 |
297 /* Register the glib log handlers. */ | |
298 REGISTER_G_LOG_HANDLER(NULL); | |
299 REGISTER_G_LOG_HANDLER("GLib"); | |
300 REGISTER_G_LOG_HANDLER("GModule"); | |
301 REGISTER_G_LOG_HANDLER("GLib-GObject"); | |
302 REGISTER_G_LOG_HANDLER("GThread"); | |
303 | |
304 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
|
305 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
|
306 g_set_printerr_handler(suppress_error_messages); |
15817 | 307 |
15822 | 308 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
|
309 purple_prefs_add_string(PREF_ROOT "/filter", ""); |
15822 | 310 purple_prefs_add_none(PREF_ROOT "/size"); |
311 purple_prefs_add_int(PREF_ROOT "/size/width", 60); | |
312 purple_prefs_add_int(PREF_ROOT "/size/height", 15); | |
15817 | 313 |
15822 | 314 if (purple_debug_is_enabled()) |
15817 | 315 g_timeout_add(0, start_with_debugwin, NULL); |
316 } | |
317 | |
318 void finch_debug_uninit() | |
319 { | |
320 } | |
321 |