Mercurial > pidgin.yaz
annotate console/libgnt/test/tv.c @ 14693:ae0136b0a3ae
[gaim-migrate @ 17445]
Patch #1569730 from Richard Nelson (wabz):
"This patch adds a "Clear" button, timestamp and pause
options, and stops it scrolling down if it's scrolled up."
and
"Also gives the debug window a name, so window managers
can more easily have their way with it."
These changes make the debug window a whole lot more usable.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sun, 08 Oct 2006 03:56:06 +0000 |
parents | 70f52ff1caec |
children | 8a0cfee11af8 |
rev | line source |
---|---|
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1 #include "gntbutton.h" |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
2 #include "gnt.h" |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
3 #include "gntkeys.h" |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
4 #include "gnttree.h" |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
5 #include "gntbox.h" |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
6 #include "gntentry.h" |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
7 #include "gnttextview.h" |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
8 |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
9 static gboolean |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
10 key_pressed(GntWidget *w, const char *key, GntWidget *view) |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
11 { |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
12 if (key[0] == '\r' && key[1] == 0) |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
13 { |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
14 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(view), |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
15 gnt_entry_get_text(GNT_ENTRY(w)), |
13896
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13883
diff
changeset
|
16 GNT_TEXT_FLAG_HIGHLIGHT); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
17 gnt_entry_add_to_history(GNT_ENTRY(w), gnt_entry_get_text(GNT_ENTRY(w))); |
13896
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13883
diff
changeset
|
18 gnt_text_view_next_line(GNT_TEXT_VIEW(view)); |
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
19 gnt_entry_clear(GNT_ENTRY(w)); |
14041
27182f83b79b
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13960
diff
changeset
|
20 if (gnt_text_view_get_lines_below(GNT_TEXT_VIEW(view)) <= 1) |
27182f83b79b
[gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13960
diff
changeset
|
21 gnt_text_view_scroll(GNT_TEXT_VIEW(view), 0); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
22 gnt_entry_remove_suggest(GNT_ENTRY(w), "acb"); |
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
23 |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
24 return TRUE; |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
25 } |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
26 else if (key[0] == 27) |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
27 { |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
28 if (strcmp(key+1, GNT_KEY_UP) == 0) |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
29 gnt_text_view_scroll(GNT_TEXT_VIEW(view), -1); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
30 else if (strcmp(key+1, GNT_KEY_DOWN) == 0) |
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
31 gnt_text_view_scroll(GNT_TEXT_VIEW(view), 1); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
32 else |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
33 return FALSE; |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
34 return TRUE; |
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
35 } |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
36 |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
37 return FALSE; |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
38 } |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
39 |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
40 int main() |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
41 { |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
42 GntWidget *hbox, *entry, *view; |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
43 |
13960
a06f7495af6f
[gaim-migrate @ 16513]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13953
diff
changeset
|
44 #ifdef STANDALONE |
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
45 freopen(".error", "w", stderr); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
46 |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
47 gnt_init(); |
13960
a06f7495af6f
[gaim-migrate @ 16513]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13953
diff
changeset
|
48 #endif |
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
49 |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
50 hbox = gnt_box_new(FALSE, TRUE); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
51 gnt_widget_set_name(hbox, "hbox"); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
52 gnt_box_set_toplevel(GNT_BOX(hbox), TRUE); |
13953
8b2306c64efa
[gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
53 gnt_box_set_fill(GNT_BOX(hbox), FALSE); |
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
54 gnt_box_set_title(GNT_BOX(hbox), "Textview test"); |
13953
8b2306c64efa
[gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
55 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID); |
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
56 |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
57 entry = gnt_entry_new(NULL); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
58 gnt_widget_set_name(entry, "entry"); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
59 GNT_WIDGET_SET_FLAGS(entry, GNT_WIDGET_CAN_TAKE_FOCUS); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
60 |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
61 gnt_entry_set_word_suggest(GNT_ENTRY(entry), TRUE); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
62 gnt_entry_set_always_suggest(GNT_ENTRY(entry), FALSE); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
63 gnt_entry_add_suggest(GNT_ENTRY(entry), "a"); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
64 gnt_entry_add_suggest(GNT_ENTRY(entry), "ab"); |
14105
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
65 gnt_entry_add_suggest(GNT_ENTRY(entry), "abe"); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
66 gnt_entry_add_suggest(GNT_ENTRY(entry), "abc"); |
14105
eaf7f35635bc
[gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14091
diff
changeset
|
67 gnt_entry_add_suggest(GNT_ENTRY(entry), "abcde"); |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
68 gnt_entry_add_suggest(GNT_ENTRY(entry), "abcd"); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
69 gnt_entry_add_suggest(GNT_ENTRY(entry), "acb"); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
70 |
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
71 view = gnt_text_view_new(); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
72 gnt_widget_set_name(view, "view"); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
73 |
13896
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13883
diff
changeset
|
74 gnt_widget_set_size(view, 20, 15); |
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13883
diff
changeset
|
75 gnt_widget_set_size(entry, 20, 1); |
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
76 |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
77 gnt_box_add_widget(GNT_BOX(hbox), view); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
78 gnt_box_add_widget(GNT_BOX(hbox), entry); |
13952
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
79 gnt_box_add_widget(GNT_BOX(hbox), gnt_button_new("OK")); |
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
80 |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
81 gnt_widget_show(hbox); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
82 |
14091
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
83 gnt_entry_set_history_length(GNT_ENTRY(entry), -1); |
ae4cbed1b309
[gaim-migrate @ 16715]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14041
diff
changeset
|
84 g_signal_connect_after(G_OBJECT(entry), "key_pressed", G_CALLBACK(key_pressed), view); |
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
85 |
14397
70f52ff1caec
[gaim-migrate @ 17105]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
86 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(view), "plugins: ", GNT_TEXT_FLAG_BOLD); |
70f52ff1caec
[gaim-migrate @ 17105]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
87 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(view), "this is the 1st line\n", GNT_TEXT_FLAG_NORMAL); |
70f52ff1caec
[gaim-migrate @ 17105]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
88 |
70f52ff1caec
[gaim-migrate @ 17105]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
89 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(view), "plugins: ", GNT_TEXT_FLAG_BOLD); |
70f52ff1caec
[gaim-migrate @ 17105]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
90 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(view), "this is the 2nd line\n", GNT_TEXT_FLAG_NORMAL); |
70f52ff1caec
[gaim-migrate @ 17105]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
91 |
70f52ff1caec
[gaim-migrate @ 17105]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
92 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(view), "plugins: ", GNT_TEXT_FLAG_BOLD); |
70f52ff1caec
[gaim-migrate @ 17105]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
93 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(view), "this is the 3rd line\n", GNT_TEXT_FLAG_NORMAL); |
70f52ff1caec
[gaim-migrate @ 17105]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
94 |
70f52ff1caec
[gaim-migrate @ 17105]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
95 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(view), "plugins: ", GNT_TEXT_FLAG_BOLD); |
70f52ff1caec
[gaim-migrate @ 17105]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
96 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(view), "this is the 4th line\n", GNT_TEXT_FLAG_NORMAL); |
70f52ff1caec
[gaim-migrate @ 17105]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14105
diff
changeset
|
97 |
13960
a06f7495af6f
[gaim-migrate @ 16513]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13953
diff
changeset
|
98 #ifdef STANDALONE |
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
99 gnt_main(); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
100 |
13907
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
101 gnt_quit(); |
13960
a06f7495af6f
[gaim-migrate @ 16513]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13953
diff
changeset
|
102 #endif |
13907
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
103 |
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
104 return 0; |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
105 } |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
106 |