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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 #include <gnt.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 #include <gntbox.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 #include <gntbutton.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 #include <gntcheckbox.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 button_activated(GntWidget *b, GntComboBox *combo)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 GntWidget *w = b->parent;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 gnt_box_add_widget(GNT_BOX(w),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 gnt_label_new(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo))));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 fprintf(stderr, "%s\n", gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo)));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 gnt_box_readjust(GNT_BOX(w->parent));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 int main()
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 GntWidget *box, *combo, *button;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 GntWidget *hbox;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 #ifdef STANDALONE
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 freopen(".error", "w", stderr);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 gnt_init();
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 #endif
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 box = gnt_box_new(FALSE, TRUE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 gnt_widget_set_name(box, "box");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 gnt_box_set_alignment(GNT_BOX(box), GNT_ALIGN_MID);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 gnt_box_set_pad(GNT_BOX(box), 0);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 gnt_box_set_toplevel(GNT_BOX(box), TRUE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 gnt_box_set_title(GNT_BOX(box), "Checkbox");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 hbox = gnt_box_new(FALSE, FALSE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 gnt_box_set_pad(GNT_BOX(hbox), 0);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 gnt_widget_set_name(hbox, "upper");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 combo = gnt_combo_box_new();
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "1", "1");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "2", "2");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "3", "3abcdefghijklmnopqrstuvwxyz");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "4", "4");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "5", "5");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "6", "6");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "7", "7");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "8", "8");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), "9", "9");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 GntWidget *l = gnt_label_new("Select");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 gnt_box_add_widget(GNT_BOX(hbox), l);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 gnt_widget_set_size(l, 0, 1);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 gnt_box_add_widget(GNT_BOX(hbox), combo);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 gnt_box_add_widget(GNT_BOX(box), hbox);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 hbox = gnt_box_new(TRUE, FALSE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 gnt_widget_set_name(hbox, "lower");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 button = gnt_button_new("OK");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 gnt_box_add_widget(GNT_BOX(hbox), button);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(button_activated), combo);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 gnt_box_add_widget(GNT_BOX(box), hbox);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 gnt_box_add_widget(GNT_BOX(box), gnt_check_box_new("check box"));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 gnt_widget_show(box);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 #ifdef STANDALONE
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 gnt_main();
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 gnt_quit();
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 #endif
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 return 0;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105