15817
|
1 #include "gntbutton.h"
|
|
2 #include "gnt.h"
|
|
3 #include "gntkeys.h"
|
|
4 #include "gnttree.h"
|
|
5 #include "gntbox.h"
|
|
6
|
|
7 static gboolean
|
|
8 key_pressed(GntWidget *widget, const char *text, gpointer null)
|
|
9 {
|
|
10 GntWidget *w = null;
|
|
11 GntWidget *box = gnt_box_new(FALSE, FALSE);
|
|
12 GntWidget *label = gnt_label_new("so wassup!!");
|
|
13
|
|
14 gnt_box_add_widget(GNT_BOX(box), label);
|
|
15 GNT_WIDGET_UNSET_FLAGS(box, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW);
|
|
16 gnt_box_set_title(GNT_BOX(box), "This is a test");
|
|
17
|
|
18 gnt_widget_show(box);
|
|
19 #if 0
|
|
20
|
|
21 gnt_widget_set_focus(w, TRUE);
|
|
22
|
|
23 /* XXX: This is to just test stuff */
|
|
24 if (text[0] == 27)
|
|
25 {
|
|
26 if (strcmp(text+1, GNT_KEY_LEFT) == 0 && w->priv.x)
|
|
27 (w->priv.x)--;
|
|
28 else if (strcmp(text+1, GNT_KEY_RIGHT) == 0)
|
|
29 (w->priv.x)++;
|
|
30 else if (strcmp(text+1, GNT_KEY_UP) == 0 && w->priv.y)
|
|
31 (w->priv.y)--;
|
|
32 else if (strcmp(text+1, GNT_KEY_DOWN) == 0)
|
|
33 (w->priv.y)++;
|
|
34 }
|
|
35
|
|
36 gnt_widget_draw(w);
|
|
37 #endif
|
|
38
|
|
39 return FALSE;
|
|
40 }
|
|
41
|
|
42 static void
|
|
43 button1(GntWidget *widget, gpointer null)
|
|
44 {
|
|
45 printf("OLAAA");
|
|
46 gnt_widget_destroy(null);
|
|
47 }
|
|
48
|
|
49 static void
|
|
50 button2(GntWidget *widget, gpointer null)
|
|
51 {
|
|
52 printf("BOOYAA");
|
|
53 }
|
|
54
|
|
55 static gboolean
|
|
56 w_scroll(GntWidget *tree)
|
|
57 {
|
|
58 g_return_val_if_fail(GNT_IS_TREE(tree), FALSE);
|
|
59 gnt_tree_scroll(GNT_TREE(tree), 1);
|
|
60 /*wscrl(tree->window, 1);*/
|
|
61 /*box(tree->window, ACS_VLINE, ACS_HLINE);*/
|
|
62 /*wrefresh(tree->window);*/
|
|
63 /*char *s = 0;*/
|
|
64 /**s = 'a';*/
|
|
65 return TRUE;
|
|
66 }
|
|
67
|
|
68 int main()
|
|
69 {
|
|
70 gnt_init();
|
|
71
|
|
72 GntWidget *widget = gnt_button_new("Button 1");
|
|
73 GntWidget *widget2 = gnt_button_new("Button 2 has a longish text with a UTF-8 thing …");
|
|
74 GntWidget *label = gnt_label_new("So wassup dudes and dudettes!!\nSo this is, like,\nthe third line!! \\o/");
|
|
75 GntWidget *vbox, *hbox, *tree;
|
|
76 WINDOW *test;
|
|
77
|
|
78 box(stdscr, 0, 0);
|
|
79 wrefresh(stdscr);
|
|
80
|
|
81 vbox = gnt_box_new(FALSE, FALSE);
|
|
82 hbox = gnt_box_new(FALSE, TRUE);
|
|
83
|
|
84 gnt_widget_set_name(vbox, "vbox");
|
|
85 gnt_widget_set_name(hbox, "hbox");
|
|
86 gnt_widget_set_name(widget, "widget");
|
|
87 gnt_widget_set_name(widget2, "widget2");
|
|
88
|
|
89 gnt_box_add_widget(GNT_BOX(vbox), widget);
|
|
90 gnt_box_add_widget(GNT_BOX(vbox), widget2);
|
|
91
|
|
92 gnt_box_add_widget(GNT_BOX(hbox), label);
|
|
93 /*gnt_box_add_widget(GNT_BOX(hbox), vbox);*/
|
|
94
|
|
95 gnt_box_add_widget(GNT_BOX(hbox), gnt_entry_new("a"));
|
|
96
|
|
97 tree = gnt_tree_new();
|
|
98 gnt_box_add_widget(GNT_BOX(hbox), tree);
|
|
99
|
|
100 gnt_tree_add_row_after(GNT_TREE(tree), "a", "a", NULL, NULL);
|
|
101 gnt_tree_add_row_after(GNT_TREE(tree), "c", "c", NULL, NULL);
|
|
102 gnt_tree_add_row_after(GNT_TREE(tree), "d", "d", NULL, NULL);
|
|
103 gnt_tree_add_row_after(GNT_TREE(tree), "e", "e", "a", NULL);
|
|
104 gnt_tree_add_row_after(GNT_TREE(tree), "b", "b", "d", NULL);
|
|
105
|
|
106 GNT_WIDGET_UNSET_FLAGS(hbox, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW);
|
|
107 gnt_box_set_title(GNT_BOX(hbox), "111111111111111111111111111111111111111111111111111111111111111This is the title …");
|
|
108
|
|
109 /*gnt_widget_set_take_focus(vbox, TRUE);*/
|
|
110 /*gnt_widget_set_take_focus(hbox, TRUE);*/
|
|
111 /*gnt_widget_set_position(hbox, 10, 10);*/
|
|
112
|
|
113 gnt_widget_show(hbox);
|
|
114
|
|
115 g_signal_connect(hbox, "key_pressed", G_CALLBACK(key_pressed), tree);
|
|
116 g_signal_connect(widget, "activate", G_CALLBACK(button1), hbox);
|
|
117 g_signal_connect(widget2, "activate", G_CALLBACK(button2), hbox);
|
|
118
|
|
119 /*g_timeout_add(1000, (GSourceFunc)w_scroll, tree);*/
|
|
120
|
|
121 gnt_main();
|
|
122
|
|
123 return 0;
|
|
124 }
|
|
125
|