15817
|
1 #include <gnt.h>
|
|
2 #include <gntbox.h>
|
|
3 #include <gntbutton.h>
|
|
4 #include <gntcheckbox.h>
|
|
5 #include <gntcombobox.h>
|
|
6 #include <gntlabel.h>
|
|
7
|
|
8 static void
|
|
9 button_activated(GntWidget *b, GntComboBox *combo)
|
|
10 {
|
|
11 GntWidget *w = b->parent;
|
|
12
|
|
13 gnt_box_add_widget(GNT_BOX(w),
|
|
14 gnt_label_new(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo))));
|
|
15 fprintf(stderr, "%s\n", gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo)));
|
|
16 gnt_box_readjust(GNT_BOX(w->parent));
|
|
17 }
|
|
18
|
|
19 int main()
|
|
20 {
|
|
21 GntWidget *box, *combo, *button;
|
|
22 GntWidget *hbox;
|
|
23
|
|
24 #ifdef STANDALONE
|
|
25 freopen(".error", "w", stderr);
|
|
26 gnt_init();
|
|
27 #endif
|
|
28
|
|
29 box = gnt_box_new(FALSE, TRUE);
|
|
30 gnt_widget_set_name(box, "box");
|
|
31 gnt_box_set_alignment(GNT_BOX(box), GNT_ALIGN_MID);
|
|
32 gnt_box_set_pad(GNT_BOX(box), 0);
|
|
33
|
|
34 gnt_box_set_toplevel(GNT_BOX(box), TRUE);
|
|
35 gnt_box_set_title(GNT_BOX(box), "Checkbox");
|
|
36
|
|
37 hbox = gnt_box_new(FALSE, FALSE);
|
|
38 gnt_box_set_pad(GNT_BOX(hbox), 0);
|
|
39 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID);
|
|
40 gnt_widget_set_name(hbox, "upper");
|
|
41
|
|
42 combo = gnt_combo_box_new();
|
|
43 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "1", "1");
|
|
44 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "2", "2");
|
|
45 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "3", "3abcdefghijklmnopqrstuvwxyz");
|
|
46 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "4", "4");
|
|
47 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "5", "5");
|
|
48 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "6", "6");
|
|
49 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "7", "7");
|
|
50 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "8", "8");
|
|
51 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "9", "9");
|
|
52
|
|
53 GntWidget *l = gnt_label_new("Select");
|
|
54 gnt_box_add_widget(GNT_BOX(hbox), l);
|
|
55 gnt_widget_set_size(l, 0, 1);
|
|
56 gnt_box_add_widget(GNT_BOX(hbox), combo);
|
|
57
|
|
58 gnt_box_add_widget(GNT_BOX(box), hbox);
|
|
59
|
|
60 hbox = gnt_box_new(TRUE, FALSE);
|
|
61 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID);
|
|
62 gnt_widget_set_name(hbox, "lower");
|
|
63
|
|
64 button = gnt_button_new("OK");
|
|
65 gnt_box_add_widget(GNT_BOX(hbox), button);
|
|
66 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(button_activated), combo);
|
|
67
|
|
68 gnt_box_add_widget(GNT_BOX(box), hbox);
|
|
69
|
|
70 gnt_box_add_widget(GNT_BOX(box), gnt_check_box_new("check box"));
|
|
71
|
|
72 gnt_widget_show(box);
|
|
73
|
|
74 #ifdef STANDALONE
|
|
75 gnt_main();
|
|
76
|
|
77 gnt_quit();
|
|
78 #endif
|
|
79
|
|
80 return 0;
|
|
81 }
|
|
82
|