fix disk selector to handle intl trext properly. was bad to begin with.
[framework/uifw/elementary.git] / src / bin / test_diskselector.c
1 #include <Elementary.h>
2 #ifdef HAVE_CONFIG_H
3 # include "elementary_config.h"
4 #endif
5 #ifndef ELM_LIB_QUICKLAUNCH
6
7 static void
8 _disk_sel(void *data __UNUSED__, Evas_Object * obj __UNUSED__, void *event_info)
9 {
10    Elm_Diskselector_Item *it = event_info;
11    printf("Equinox: %s\n", elm_diskselector_item_label_get(it));
12 }
13
14 static void
15 _disk_next(void *data __UNUSED__, Evas_Object * obj __UNUSED__, void *event_info)
16 {
17    Elm_Diskselector_Item *next, *prev, *it = event_info;
18    prev = elm_diskselector_item_prev_get(it);
19    next = elm_diskselector_item_next_get(it);
20    printf("Prev: %s, Next: %s\n", elm_diskselector_item_label_get(prev),
21           elm_diskselector_item_label_get(next));
22 }
23
24 static void
25 _print_disk_info_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
26 {
27    Elm_Diskselector_Item *it = event_info;
28    printf("Selected label: %s\n", elm_diskselector_item_label_get(it));
29 }
30
31 static Evas_Object *
32 _disk_create(Evas_Object *win, Eina_Bool round)
33 {
34    Elm_Diskselector_Item *it;
35    Evas_Object *di;
36
37    di = elm_diskselector_add(win);
38
39    elm_diskselector_item_append(di, "January", NULL, NULL, NULL);
40    elm_diskselector_item_append(di, "February", NULL, _disk_next, NULL);
41    elm_diskselector_item_append(di, "March", NULL, _disk_sel, NULL);
42    elm_diskselector_item_append(di, "April", NULL, NULL, NULL);
43    elm_diskselector_item_append(di, "May", NULL, NULL, NULL);
44    elm_diskselector_item_append(di, "June", NULL, NULL, NULL);
45    elm_diskselector_item_append(di, "July", NULL, NULL, NULL);
46    it = elm_diskselector_item_append(di, "August", NULL, NULL, NULL);
47    elm_diskselector_item_append(di, "September", NULL, _disk_sel, NULL);
48    elm_diskselector_item_append(di, "October", NULL, NULL, NULL);
49    elm_diskselector_item_append(di, "November", NULL, NULL, NULL);
50    elm_diskselector_item_append(di, "December", NULL, NULL, NULL);
51
52    elm_diskselector_item_selected_set(it, EINA_TRUE);
53    elm_diskselector_round_set(di, round);
54
55    return di;
56 }
57
58 void
59 test_diskselector(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
60 {
61    Evas_Object *win, *bg, *bx, *disk, *ic;
62    Elm_Diskselector_Item *it;
63    char buf[PATH_MAX];
64    int idx = 0;
65
66    char *month_list[] = {
67       "Jan", "Feb", "Mar",
68       "Apr", "May", "Jun",
69       "Jul", "Aug", "Sep",
70       "Oct", "Nov", "Dec"
71    };
72    char date[3];
73
74    win = elm_win_add(NULL, "diskselector", ELM_WIN_BASIC);
75    elm_win_title_set(win, "Disk Selector");
76    elm_win_autodel_set(win, 1);
77
78    bg = elm_bg_add(win);
79    elm_win_resize_object_add(win, bg);
80    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
81    evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
82    evas_object_show(bg);
83
84    bx = elm_box_add(win);
85    elm_win_resize_object_add(win, bx);
86    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
87    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
88    evas_object_show(bx);
89
90    disk = _disk_create(win, EINA_TRUE);
91    evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
92    evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
93    elm_box_pack_end(bx, disk);
94    evas_object_show(disk);
95    evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
96    it = elm_diskselector_selected_item_get(disk);
97    elm_diskselector_item_selected_set(it, EINA_FALSE);
98
99    disk = _disk_create(win, EINA_FALSE);
100    evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
101    evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
102    elm_box_pack_end(bx, disk);
103    evas_object_show(disk);
104    evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
105    it = elm_diskselector_first_item_get(disk);
106    it = elm_diskselector_item_next_get(it);
107    elm_diskselector_item_selected_set(it, EINA_TRUE);
108
109    disk = _disk_create(win, EINA_FALSE);
110    evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
111    evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
112    elm_box_pack_end(bx, disk);
113    evas_object_show(disk);
114    evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
115    elm_diskselector_side_label_lenght_set(disk, 4);
116
117    disk = elm_diskselector_add(win);
118    ic = elm_icon_add(win);
119    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
120    elm_icon_file_set(ic, buf, NULL);
121    elm_icon_scale_set(ic, 1, 1);
122    elm_diskselector_item_append(disk, "Sunday", ic, NULL, NULL);
123    elm_diskselector_item_append(disk, "Monday", NULL, NULL, NULL);
124    elm_diskselector_item_append(disk, "Tuesday", NULL, NULL, NULL);
125    elm_diskselector_item_append(disk, "Wednesday", NULL, NULL, NULL);
126    elm_diskselector_item_append(disk, "Thursday", NULL, NULL, NULL);
127    elm_diskselector_item_append(disk, "Friday", NULL, NULL, NULL);
128    elm_diskselector_item_append(disk, "Saturday", NULL, NULL, NULL);
129    elm_diskselector_round_set(disk, EINA_TRUE);
130    evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
131    evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
132    elm_box_pack_end(bx, disk);
133    evas_object_show(disk);
134    evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
135
136    disk = elm_diskselector_add(win);
137    ic = elm_icon_add(win);
138    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
139    elm_icon_file_set(ic, buf, NULL);
140    elm_icon_scale_set(ic, 1, 1);
141    elm_diskselector_item_append(disk, "머리스타일", ic, NULL, NULL);
142    elm_diskselector_item_append(disk, "プロが伝授する", NULL, NULL, NULL);
143    elm_diskselector_item_append(disk, "生上访要求政府", NULL, NULL, NULL);
144    elm_diskselector_item_append(disk, "English", NULL, NULL, NULL);
145    elm_diskselector_item_append(disk, "والشريعة", NULL, NULL, NULL);
146    elm_diskselector_item_append(disk, "עִבְרִית", NULL, NULL, NULL);
147    elm_diskselector_item_append(disk, "Grüßen", NULL, NULL, NULL);
148    elm_diskselector_round_set(disk, EINA_TRUE);
149    evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
150    evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
151    elm_box_pack_end(bx, disk);
152    evas_object_show(disk);
153    evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
154    
155    // displayed item number setting example
156    disk = elm_diskselector_add(win);
157    elm_diskselector_display_item_num_set(disk, 5);
158
159    for (idx = 0; idx < (int)(sizeof(month_list) / sizeof(month_list[0])); idx++)
160      {
161         it = elm_diskselector_item_append(disk, month_list[idx], NULL, NULL, NULL);
162      }
163
164    elm_diskselector_item_selected_set(it, EINA_TRUE);
165    elm_diskselector_round_set(disk, EINA_TRUE);
166    evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
167    evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
168    elm_box_pack_end(bx, disk);
169    evas_object_show(disk);
170    evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
171
172    // displayed item number setting example
173    disk = elm_diskselector_add(win);
174    elm_diskselector_display_item_num_set(disk, 7);
175
176    for (idx = 1; idx < 31; idx++)
177      {
178         snprintf(date, sizeof(date), "%d", idx);
179         it = elm_diskselector_item_append(disk, date, NULL, NULL, NULL);
180      }
181
182    elm_diskselector_item_selected_set(it, EINA_TRUE);
183    elm_diskselector_round_set(disk, EINA_TRUE);
184    evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
185    evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
186    elm_box_pack_end(bx, disk);
187    evas_object_show(disk);
188    evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
189
190
191    evas_object_resize(win, 320, 480);
192    evas_object_show(win);
193 }
194
195 #endif