annotate console/libgnt/test/combo.c @ 14881:5228f8cf2a6a

[gaim-migrate @ 17650] Print a debug message if someone tries to specify a binding for some non-existent action. Make sure the conversation windows aren't too large to cause a crash. raise(SIGABRT) instead of exit() to force a coredump if something goes wrong with stdin. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 01 Nov 2006 20:59:23 +0000
parents 2d1b41e3cf0d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1 #include <gnt.h>
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
2 #include <gntbox.h>
13939
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
3 #include <gntbutton.h>
13979
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13960
diff changeset
4 #include <gntcheckbox.h>
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
5 #include <gntcombobox.h>
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
6 #include <gntlabel.h>
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
7
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
8 static void
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
9 button_activated(GntWidget *b, GntComboBox *combo)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
10 {
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
11 GntWidget *w = b->parent;
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
12
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
13 gnt_box_add_widget(GNT_BOX(w),
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
14 gnt_label_new(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo))));
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
15 fprintf(stderr, "%s\n", gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo)));
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
16 gnt_box_readjust(GNT_BOX(w->parent));
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
17 }
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
18
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
19 int main()
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
20 {
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
21 GntWidget *box, *combo, *button;
13939
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
22 GntWidget *hbox;
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
23
13960
a06f7495af6f [gaim-migrate @ 16513]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
24 #ifdef STANDALONE
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
25 freopen(".error", "w", stderr);
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26 gnt_init();
13960
a06f7495af6f [gaim-migrate @ 16513]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
27 #endif
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
28
13939
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
29 box = gnt_box_new(FALSE, TRUE);
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
30 gnt_widget_set_name(box, "box");
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
31 gnt_box_set_alignment(GNT_BOX(box), GNT_ALIGN_MID);
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
32 gnt_box_set_pad(GNT_BOX(box), 0);
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
33
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
34 gnt_box_set_toplevel(GNT_BOX(box), TRUE);
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
35 gnt_box_set_title(GNT_BOX(box), "Checkbox");
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36
13939
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
37 hbox = gnt_box_new(FALSE, FALSE);
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
38 gnt_box_set_pad(GNT_BOX(hbox), 0);
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
39 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID);
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
40 gnt_widget_set_name(hbox, "upper");
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
41
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
42 combo = gnt_combo_box_new();
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
43 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "1", "1");
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "2", "2");
13936
669898e6aa11 [gaim-migrate @ 16467]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13935
diff changeset
45 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "3", "3abcdefghijklmnopqrstuvwxyz");
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
46 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "4", "4");
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
47 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "5", "5");
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "6", "6");
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
49 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "7", "7");
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
50 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "8", "8");
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13979
diff changeset
51 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "9", "9");
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
53 GntWidget *l = gnt_label_new("Select");
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
54 gnt_box_add_widget(GNT_BOX(hbox), l);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
55 gnt_widget_set_size(l, 0, 1);
13939
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
56 gnt_box_add_widget(GNT_BOX(hbox), combo);
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
57
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
58 gnt_box_add_widget(GNT_BOX(box), hbox);
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
59
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
60 hbox = gnt_box_new(TRUE, FALSE);
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
61 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID);
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
62 gnt_widget_set_name(hbox, "lower");
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
63
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
64 button = gnt_button_new("OK");
13939
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
65 gnt_box_add_widget(GNT_BOX(hbox), button);
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13939
diff changeset
66 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(button_activated), combo);
13939
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
67
5d5c84239eea [gaim-migrate @ 16470]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13936
diff changeset
68 gnt_box_add_widget(GNT_BOX(box), hbox);
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
69
13979
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13960
diff changeset
70 gnt_box_add_widget(GNT_BOX(box), gnt_check_box_new("check box"));
a71678d2da16 [gaim-migrate @ 16540]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13960
diff changeset
71
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
72 gnt_widget_show(box);
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
73
13960
a06f7495af6f [gaim-migrate @ 16513]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
74 #ifdef STANDALONE
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
75 gnt_main();
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
76
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
77 gnt_quit();
13960
a06f7495af6f [gaim-migrate @ 16513]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
78 #endif
13935
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
79
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
80 return 0;
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
81 }
cd2da4b079cf [gaim-migrate @ 16466]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
82