Mercurial > pidgin.yaz
annotate console/libgnt/test/tv.c @ 13960:a06f7495af6f
[gaim-migrate @ 16513]
It is possible to have multiple gnt-applications sharing the same screen.
To try this, 'make WM' in console/libgnt/test. It will have a small
'Command' entry. You can give a command like './focus.so' (or one of the
other examples). The applications can also be executed standalone. This
required some tinkering to the Makefile. I am not sure whether there is
an easier way of doing it.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Mon, 17 Jul 2006 22:27:26 +0000 |
parents | 8b2306c64efa |
children | 27182f83b79b |
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); |
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13883
diff
changeset
|
17 gnt_text_view_next_line(GNT_TEXT_VIEW(view)); |
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
18 gnt_entry_clear(GNT_ENTRY(w)); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
19 gnt_text_view_scroll(GNT_TEXT_VIEW(view), 0); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
20 |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
21 return TRUE; |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
22 } |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
23 else if (key[0] == 27) |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
24 { |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
25 if (strcmp(key+1, GNT_KEY_UP)) |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
26 gnt_text_view_scroll(GNT_TEXT_VIEW(view), 1); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
27 else if (strcmp(key+1, GNT_KEY_DOWN)) |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
28 gnt_text_view_scroll(GNT_TEXT_VIEW(view), -1); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
29 } |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
30 |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
31 return FALSE; |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
32 } |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
33 |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
34 int main() |
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 GntWidget *hbox, *entry, *view; |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
37 |
13960
a06f7495af6f
[gaim-migrate @ 16513]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13953
diff
changeset
|
38 #ifdef STANDALONE |
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
39 freopen(".error", "w", stderr); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
40 |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
41 gnt_init(); |
13960
a06f7495af6f
[gaim-migrate @ 16513]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13953
diff
changeset
|
42 #endif |
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
43 |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
44 hbox = gnt_box_new(FALSE, TRUE); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
45 gnt_widget_set_name(hbox, "hbox"); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
46 gnt_box_set_toplevel(GNT_BOX(hbox), TRUE); |
13953
8b2306c64efa
[gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
47 gnt_box_set_fill(GNT_BOX(hbox), FALSE); |
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
48 gnt_box_set_title(GNT_BOX(hbox), "Textview test"); |
13953
8b2306c64efa
[gaim-migrate @ 16501]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13952
diff
changeset
|
49 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID); |
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
50 |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
51 entry = gnt_entry_new(NULL); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
52 gnt_widget_set_name(entry, "entry"); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
53 GNT_WIDGET_SET_FLAGS(entry, GNT_WIDGET_CAN_TAKE_FOCUS); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
54 |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
55 view = gnt_text_view_new(); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
56 gnt_widget_set_name(view, "view"); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
57 |
13896
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13883
diff
changeset
|
58 gnt_widget_set_size(view, 20, 15); |
a621329e8c85
[gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13883
diff
changeset
|
59 gnt_widget_set_size(entry, 20, 1); |
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
60 |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
61 gnt_box_add_widget(GNT_BOX(hbox), view); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
62 gnt_box_add_widget(GNT_BOX(hbox), entry); |
13952
841a5ffbfee4
[gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13907
diff
changeset
|
63 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
|
64 |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
65 gnt_widget_show(hbox); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
66 |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
67 g_signal_connect(G_OBJECT(entry), "key_pressed", G_CALLBACK(key_pressed), view); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
68 |
13960
a06f7495af6f
[gaim-migrate @ 16513]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13953
diff
changeset
|
69 #ifdef STANDALONE |
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
70 gnt_main(); |
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
71 |
13907
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
72 gnt_quit(); |
13960
a06f7495af6f
[gaim-migrate @ 16513]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13953
diff
changeset
|
73 #endif |
13907
cc60d0861337
[gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13896
diff
changeset
|
74 |
13883
ab6376814e73
[gaim-migrate @ 16363]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
75 return 0; |
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 |