2 # include "elementary_config.h"
5 #ifdef HAVE_SYS_TIMES_H
6 # include <sys/times.h>
10 # ifndef WIN32_LEAN_AND_MEAN
11 # define WIN32_LEAN_AND_MEAN
14 # undef WIN32_LEAN_AND_MEAN
19 #include <Elementary.h>
20 #ifndef ELM_LIB_QUICKLAUNCH
22 static Elm_Genlist_Item_Class it_eio;
25 ULONGLONG st_time_kernel;
26 ULONGLONG st_time_user;
27 ULONGLONG en_time_kernel;
28 ULONGLONG en_time_user;
30 static clock_t st_time;
31 static clock_t en_time;
32 static struct tms st_cpu;
33 static struct tms en_cpu;
36 static void _sel_file(void *data, Evas_Object *obj, void *event_info);
37 static Eina_Bool _ls_filter_cb(void *data, Eio_File *handler, const char *file);
38 static void _ls_main_cb(void *data, Eio_File *handler, const char *file);
39 static void _ls_done_cb(void *data, Eio_File *handler);
40 static void _ls_error_cb(void *data, Eio_File *handler, int error);
41 static void _file_chosen(void *data, Evas_Object *obj, void *event_info);
42 static char *_gl_text_get(void *data, Evas_Object *obj, const char *part);
43 static Evas_Object *_gl_content_get(void *data, Evas_Object *obj, const char *part);
44 static Eina_Bool _gl_state_get(void *data, Evas_Object *obj, const char *part);
45 static void _gl_del(void *data, Evas_Object *obj);
46 static void _test_eio_clear(void *data, Evas_Object *obj, void *event);
49 _sel_file(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
54 _ls_filter_cb(void *data __UNUSED__, Eio_File *handler __UNUSED__, const char *file __UNUSED__)
60 _compare_cb(const void *data1, const void *data2)
62 Elm_Object_Item *it = (Elm_Object_Item *)data1;
63 Elm_Object_Item *it2 = (Elm_Object_Item *)data2;
64 return strcoll(elm_object_item_data_get(it),
65 elm_object_item_data_get(it2));
69 _ls_main_cb(void *data, Eio_File *handler __UNUSED__, const char *file)
71 elm_genlist_item_sorted_insert(data,
73 eina_stringshare_add(file),
75 ELM_GENLIST_ITEM_NONE,
82 _ls_done_cb(void *data __UNUSED__, Eio_File *handler __UNUSED__)
89 ULARGE_INTEGER time_kernel;
90 ULARGE_INTEGER time_user;
92 if (!GetProcessTimes(GetCurrentProcess(),
96 time_kernel.u.LowPart = tk.dwLowDateTime;
97 time_kernel.u.HighPart = tk.dwHighDateTime;
98 en_time_kernel = time_kernel.QuadPart;
100 time_user.u.LowPart = tu.dwLowDateTime;
101 time_user.u.HighPart = tu.dwHighDateTime;
102 en_time_user = time_user.QuadPart;
104 fprintf(stderr, "ls done\n");
105 fprintf(stderr, "Kernel Time: %lld, User Time: %lld",
106 (en_time_kernel - st_time_kernel),
107 (en_time_user - st_time_user));
109 en_time = times(&en_cpu);
110 fprintf(stderr, "ls done\n");
111 fprintf(stderr, "Real Time: %.jd, User Time: %.jd, System Time: %.jd\n",
112 (intmax_t)(en_time - st_time),
113 (intmax_t)(en_cpu.tms_utime - st_cpu.tms_utime),
114 (intmax_t)(en_cpu.tms_stime - st_cpu.tms_stime));
119 _ls_error_cb(void *data __UNUSED__, Eio_File *handler __UNUSED__, int error)
121 fprintf(stderr, "error: [%s]\n", strerror(error));
125 _file_chosen(void *data, Evas_Object *obj __UNUSED__, void *event_info)
127 const char *file = event_info;
135 ULARGE_INTEGER time_kernel;
136 ULARGE_INTEGER time_user;
138 if (!GetProcessTimes(GetCurrentProcess(),
142 time_kernel.u.LowPart = tk.dwLowDateTime;
143 time_kernel.u.HighPart = tk.dwHighDateTime;
144 st_time_kernel = time_kernel.QuadPart;
146 time_user.u.LowPart = tu.dwLowDateTime;
147 time_user.u.HighPart = tu.dwHighDateTime;
148 st_time_user = time_user.QuadPart;
150 st_time = times(&st_cpu);
162 _gl_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
165 snprintf(buf, sizeof(buf), "Item # %s", (char*)data);
170 _gl_content_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
176 _gl_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
182 _gl_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
187 _test_eio_clear(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
189 elm_genlist_clear(data);
193 test_eio(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
195 Evas_Object *win, *vbox, *hbox, *ic, *bt, *fs_bt, *gl;
197 it_eio.item_style = "default";
198 it_eio.func.text_get = _gl_text_get;
199 it_eio.func.content_get = _gl_content_get;
200 it_eio.func.state_get = _gl_state_get;
201 it_eio.func.del = _gl_del;
203 win = elm_win_util_standard_add("fileselector-button", "File Selector Button");
204 elm_win_autodel_set(win, EINA_TRUE);
206 vbox = elm_box_add(win);
207 elm_win_resize_object_add(win, vbox);
208 evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
209 evas_object_show(vbox);
211 gl = elm_genlist_add(win);
212 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
213 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
214 elm_box_pack_end(vbox, gl);
215 evas_object_show(gl);
217 /* file selector button */
218 hbox = elm_box_add(win);
219 elm_box_horizontal_set(hbox, EINA_TRUE);
220 ic = elm_icon_add(win);
221 elm_icon_standard_set(ic, "file");
222 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
223 fs_bt = elm_fileselector_button_add(win);
224 elm_object_text_set(fs_bt, "Select a dir");
225 elm_object_part_content_set(fs_bt, "icon", ic);
226 elm_fileselector_button_inwin_mode_set(fs_bt, EINA_TRUE);
227 elm_fileselector_button_folder_only_set(fs_bt, EINA_TRUE);
229 elm_box_pack_end(hbox, fs_bt);
230 elm_box_pack_end(vbox, hbox);
231 evas_object_show(fs_bt);
232 evas_object_show(ic);
234 /* attribute setting buttons */
235 bt = elm_button_add(win);
236 elm_object_text_set(bt, "clear");
237 evas_object_smart_callback_add(bt, "clicked", _test_eio_clear, gl);
238 elm_box_pack_end(hbox, bt);
239 evas_object_show(bt);
240 evas_object_show(hbox);
242 evas_object_smart_callback_add(fs_bt, "file,chosen", _file_chosen, gl);
244 evas_object_resize(win, 300, 500);
245 evas_object_show(win);