Mercurial > pidgin.yaz
comparison console/libgnt/test/keys.c @ 14200:5300e2f1fed3
[gaim-migrate @ 16872]
Test program to detect keycodes.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 19 Aug 2006 05:44:40 +0000 |
parents | |
children | a766441af5ea |
comparison
equal
deleted
inserted
replaced
14199:2c71c9ecf394 | 14200:5300e2f1fed3 |
---|---|
1 #include <gnt.h> | |
2 #include <gntbox.h> | |
3 #include <gntentry.h> | |
4 #include <gntlabel.h> | |
5 | |
6 static gboolean | |
7 print_keycode(GntEntry *entry, const char *text, gpointer null) | |
8 { | |
9 char *s = g_strdup_printf("%s ", text); | |
10 gnt_entry_set_text(entry, s); | |
11 g_free(s); | |
12 if (text[0] == 27) | |
13 return FALSE; | |
14 else | |
15 return TRUE; | |
16 } | |
17 | |
18 int main() | |
19 { | |
20 GntWidget *window, *entry; | |
21 | |
22 gnt_init(); | |
23 | |
24 freopen(".error", "w", stderr); | |
25 | |
26 window = gnt_hbox_new(FALSE); | |
27 gnt_box_set_toplevel(GNT_BOX(window), TRUE); | |
28 | |
29 gnt_box_add_widget(GNT_BOX(window), gnt_label_new("Press any key: ")); | |
30 | |
31 entry = gnt_entry_new(NULL); | |
32 gnt_box_add_widget(GNT_BOX(window), entry); | |
33 g_signal_connect(G_OBJECT(entry), "key_pressed", G_CALLBACK(print_keycode), NULL); | |
34 | |
35 gnt_widget_set_position(window, getmaxx(stdscr) / 2 - 12, getmaxy(stdscr) / 2 - 3); | |
36 gnt_widget_show(window); | |
37 | |
38 gnt_main(); | |
39 gnt_quit(); | |
40 return 0; | |
41 } | |
42 |