Mercurial > pidgin
comparison console/gntdebug.c @ 13983:b7a99d54a5a9
[gaim-migrate @ 16552]
Add a debug window. The scrolling doesn't seem to work properly. I
will try to figure out what's wrong with it.
Start the request-ui. The ui for request input, choice and action are
mostly done. I am not handling multiline input requests yet. It's not
too high in my todo-list either.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sun, 23 Jul 2006 20:38:07 +0000 |
parents | |
children | a7b1d2ab9cb0 |
comparison
equal
deleted
inserted
replaced
13982:052aee037835 | 13983:b7a99d54a5a9 |
---|---|
1 #include <gnt.h> | |
2 #include <gntbox.h> | |
3 #include <gnttextview.h> | |
4 | |
5 #include "gntdebug.h" | |
6 #include "gntgaim.h" | |
7 | |
8 #include <stdio.h> | |
9 #include <string.h> | |
10 | |
11 static struct | |
12 { | |
13 GntWidget *window; | |
14 GntWidget *tview; | |
15 } debug; | |
16 | |
17 static gboolean | |
18 debug_window_kpress_cb(GntWidget *wid, const char *key, GntTextView *view) | |
19 { | |
20 if (key[0] == 27) | |
21 { | |
22 /* XXX: This doesn't seem to always work */ | |
23 if (strcmp(key+1, GNT_KEY_DOWN) == 0) | |
24 gnt_text_view_scroll(view, 1); | |
25 else if (strcmp(key+1, GNT_KEY_UP) == 0) | |
26 gnt_text_view_scroll(view, -1); | |
27 else if (strcmp(key+1, GNT_KEY_PGDOWN) == 0) | |
28 gnt_text_view_scroll(view, wid->priv.height - 2); | |
29 else if (strcmp(key+1, GNT_KEY_PGUP) == 0) | |
30 gnt_text_view_scroll(view, -(wid->priv.height - 2)); | |
31 else | |
32 return FALSE; | |
33 return TRUE; | |
34 } | |
35 return FALSE; | |
36 } | |
37 | |
38 static void | |
39 gg_debug_print(GaimDebugLevel level, const char *category, | |
40 const char *args) | |
41 { | |
42 if (debug.window == NULL) | |
43 fprintf(stderr, "%s: %s\n", category, args); | |
44 else | |
45 { | |
46 GntTextFormatFlags flag = GNT_TEXT_FLAG_NORMAL; | |
47 | |
48 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), | |
49 category, GNT_TEXT_FLAG_BOLD); | |
50 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), | |
51 ": ", GNT_TEXT_FLAG_BOLD); | |
52 | |
53 switch (level) | |
54 { | |
55 case GAIM_DEBUG_WARNING: | |
56 flag |= GNT_TEXT_FLAG_UNDERLINE; | |
57 case GAIM_DEBUG_ERROR: | |
58 case GAIM_DEBUG_FATAL: | |
59 flag |= GNT_TEXT_FLAG_BOLD; | |
60 break; | |
61 default: | |
62 break; | |
63 } | |
64 | |
65 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), args, flag); | |
66 gnt_text_view_next_line(GNT_TEXT_VIEW(debug.tview)); | |
67 gnt_text_view_scroll(GNT_TEXT_VIEW(debug.tview), 0); | |
68 | |
69 g_signal_connect(G_OBJECT(debug.window), "key_pressed", G_CALLBACK(debug_window_kpress_cb), debug.tview); | |
70 } | |
71 } | |
72 | |
73 static GaimDebugUiOps uiops = | |
74 { | |
75 gg_debug_print, | |
76 }; | |
77 | |
78 GaimDebugUiOps *gg_debug_get_ui_ops() | |
79 { | |
80 return &uiops; | |
81 } | |
82 | |
83 void gg_debug_window_show() | |
84 { | |
85 if (debug.window == NULL) | |
86 { | |
87 debug.window = gnt_vbox_new(FALSE); | |
88 gnt_box_set_toplevel(GNT_BOX(debug.window), TRUE); | |
89 gnt_box_set_title(GNT_BOX(debug.window), _("Debug Window")); | |
90 | |
91 debug.tview = gnt_text_view_new(); | |
92 gnt_box_add_widget(GNT_BOX(debug.window), debug.tview); | |
93 } | |
94 | |
95 gnt_widget_show(debug.window); | |
96 } | |
97 | |
98 void gg_debug_init() | |
99 { | |
100 gg_debug_window_show(); | |
101 } | |
102 | |
103 void gg_debug_uninit() | |
104 { | |
105 } | |
106 |