Mercurial > pidgin
annotate finch/libgnt/test/combo.c @ 27033:2ab648c328cc
Consistently emit conversation-updated for typing state changes.
Also reformatted ChangeLog.API a bit (I noticed there's a Changed section)
and added a comment to the psychic plugin (since I had to look up why it
was doing that).
Patch from Florian Quze. Closes #7605.
committer: Paul Aurich <paul@darkrain42.org>
author | Florian Quèze <florian@instantbird.org> |
---|---|
date | Fri, 05 Jun 2009 02:30:31 +0000 |
parents | f104e1d45d85 |
children | a8cc50c2279f |
rev | line source |
---|---|
15817 | 1 #include <gnt.h> |
2 #include <gntbox.h> | |
3 #include <gntbutton.h> | |
4 #include <gntcheckbox.h> | |
5 #include <gntcombobox.h> | |
18510
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
6 #include <gntentry.h> |
15817 | 7 #include <gntlabel.h> |
18510
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
8 #include <gntslider.h> |
15817 | 9 |
10 static void | |
11 button_activated(GntWidget *b, GntComboBox *combo) | |
12 { | |
13 GntWidget *w = b->parent; | |
14 | |
15 gnt_box_add_widget(GNT_BOX(w), | |
16 gnt_label_new(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo)))); | |
17 fprintf(stderr, "%s\n", gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo))); | |
18 gnt_box_readjust(GNT_BOX(w->parent)); | |
19 } | |
20 | |
18510
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
21 static void |
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
22 update_label(GntSlider *slider, int current_value, GntEntry *entry) |
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
23 { |
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
24 char value[256]; |
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
25 g_snprintf(value, sizeof(value), "%d/%d", current_value, slider->max); |
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
26 /*gnt_label_set_text(label, value);*/ |
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
27 /*gnt_widget_draw(GNT_WIDGET(label));*/ |
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
28 gnt_entry_set_text(entry, value); |
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
29 } |
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
30 |
15817 | 31 int main() |
32 { | |
33 GntWidget *box, *combo, *button; | |
34 GntWidget *hbox; | |
35 | |
36 #ifdef STANDALONE | |
37 freopen(".error", "w", stderr); | |
38 gnt_init(); | |
39 #endif | |
40 | |
41 box = gnt_box_new(FALSE, TRUE); | |
42 gnt_widget_set_name(box, "box"); | |
43 gnt_box_set_alignment(GNT_BOX(box), GNT_ALIGN_MID); | |
44 gnt_box_set_pad(GNT_BOX(box), 0); | |
45 | |
46 gnt_box_set_toplevel(GNT_BOX(box), TRUE); | |
47 gnt_box_set_title(GNT_BOX(box), "Checkbox"); | |
48 | |
49 hbox = gnt_box_new(FALSE, FALSE); | |
50 gnt_box_set_pad(GNT_BOX(hbox), 0); | |
51 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID); | |
52 gnt_widget_set_name(hbox, "upper"); | |
53 | |
54 combo = gnt_combo_box_new(); | |
55 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "1", "1"); | |
56 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "2", "2"); | |
57 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "3", "3abcdefghijklmnopqrstuvwxyz"); | |
58 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "4", "4"); | |
59 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "5", "5"); | |
60 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "6", "6"); | |
61 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "7", "7"); | |
62 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "8", "8"); | |
63 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "9", "9"); | |
64 | |
65 GntWidget *l = gnt_label_new("Select"); | |
66 gnt_box_add_widget(GNT_BOX(hbox), l); | |
67 gnt_widget_set_size(l, 0, 1); | |
68 gnt_box_add_widget(GNT_BOX(hbox), combo); | |
69 | |
70 gnt_box_add_widget(GNT_BOX(box), hbox); | |
71 | |
72 hbox = gnt_box_new(TRUE, FALSE); | |
73 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID); | |
74 gnt_widget_set_name(hbox, "lower"); | |
75 | |
76 button = gnt_button_new("OK"); | |
77 gnt_box_add_widget(GNT_BOX(hbox), button); | |
78 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(button_activated), combo); | |
79 | |
80 gnt_box_add_widget(GNT_BOX(box), hbox); | |
81 | |
82 gnt_box_add_widget(GNT_BOX(box), gnt_check_box_new("check box")); | |
83 | |
18510
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
84 GntWidget *e = gnt_entry_new(NULL); |
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
85 gnt_box_add_widget(GNT_BOX(box), e); |
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
86 |
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
87 GntWidget *slider = gnt_slider_new(TRUE, 0, 100); |
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
88 gnt_slider_set_value(GNT_SLIDER(slider), 50); |
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
89 gnt_box_add_widget(GNT_BOX(box), slider); |
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
90 g_signal_connect(G_OBJECT(slider), "changed", G_CALLBACK(update_label), e); |
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
91 gnt_slider_reflect_label(GNT_SLIDER(slider), GNT_LABEL(l)); |
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
92 |
15817 | 93 gnt_widget_show(box); |
94 | |
18510
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
95 gnt_widget_show(gnt_file_sel_new()); |
f104e1d45d85
Changes to the test apps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15817
diff
changeset
|
96 |
15817 | 97 #ifdef STANDALONE |
98 gnt_main(); | |
99 | |
100 gnt_quit(); | |
101 #endif | |
102 | |
103 return 0; | |
104 } | |
105 |