1 #include <Elementary.h>
3 # include "elementary_config.h"
8 #ifndef ELM_LIB_QUICKLAUNCH
10 static Elm_Genlist_Item_Class it_eio;
12 static clock_t st_time;
13 static clock_t en_time;
14 static struct tms st_cpu;
15 static struct tms en_cpu;
17 static void _sel_file(void *data, Evas_Object *obj, void *event_info);
18 static Eina_Bool _ls_filter_cb(void *data, Eio_File *handler, const char *file);
19 static void _ls_main_cb(void *data, Eio_File *handler, const char *file);
20 static void _ls_done_cb(void *data, Eio_File *handler);
21 static void _ls_error_cb(void *data, Eio_File *handler, int error);
22 static void _file_chosen(void *data, Evas_Object *obj, void *event_info);
23 static char *_gl_text_get(void *data, Evas_Object *obj, const char *part);
24 static Evas_Object *_gl_content_get(void *data, Evas_Object *obj, const char *part);
25 static Eina_Bool _gl_state_get(void *data, Evas_Object *obj, const char *part);
26 static void _gl_del(void *data, Evas_Object *obj);
27 static void _test_eio_clear(void *data, Evas_Object *obj, void *event);
30 _sel_file(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
35 _ls_filter_cb(void *data __UNUSED__, Eio_File *handler __UNUSED__, const char *file __UNUSED__)
41 _ls_main_cb(void *data, Eio_File *handler __UNUSED__, const char *file)
43 elm_genlist_item_sorted_insert(data,
45 eina_stringshare_add(file),
47 ELM_GENLIST_ITEM_NONE,
48 (Eina_Compare_Cb) strcoll,
54 _ls_done_cb(void *data __UNUSED__, Eio_File *handler __UNUSED__)
56 en_time = times(&en_cpu);
57 fprintf(stderr, "ls done\n");
58 fprintf(stderr, "Real Time: %.jd, User Time: %.jd, System Time: %.jd\n",
59 (intmax_t)(en_time - st_time),
60 (intmax_t)(en_cpu.tms_utime - st_cpu.tms_utime),
61 (intmax_t)(en_cpu.tms_stime - st_cpu.tms_stime));
65 _ls_error_cb(void *data __UNUSED__, Eio_File *handler __UNUSED__, int error)
67 fprintf(stderr, "error: [%s]\n", strerror(error));
71 _file_chosen(void *data, Evas_Object *obj __UNUSED__, void *event_info)
73 const char *file = event_info;
76 st_time = times(&st_cpu);
87 _gl_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
90 snprintf(buf, sizeof(buf), "Item # %s", (char*)data);
95 _gl_content_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
101 _gl_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
107 _gl_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
112 _test_eio_clear(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
114 elm_genlist_clear(data);
118 test_eio(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
120 Evas_Object *win, *bg, *vbox, *hbox, *ic, *bt, *fs_bt, *gl;
122 it_eio.item_style = "default";
123 it_eio.func.text_get = _gl_text_get;
124 it_eio.func.content_get = _gl_content_get;
125 it_eio.func.state_get = _gl_state_get;
126 it_eio.func.del = _gl_del;
128 win = elm_win_add(NULL, "fileselector-button", ELM_WIN_BASIC);
129 elm_win_title_set(win, "File Selector Button");
130 elm_win_autodel_set(win, EINA_TRUE);
132 bg = elm_bg_add(win);
133 elm_win_resize_object_add(win, bg);
134 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
135 evas_object_show(bg);
137 vbox = elm_box_add(win);
138 elm_win_resize_object_add(win, vbox);
139 evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
140 evas_object_show(vbox);
142 gl = elm_genlist_add(win);
143 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
144 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
145 elm_box_pack_end(vbox, gl);
146 evas_object_show(gl);
148 /* file selector button */
149 hbox = elm_box_add(win);
150 elm_box_horizontal_set(hbox, EINA_TRUE);
151 ic = elm_icon_add(win);
152 elm_icon_standard_set(ic, "file");
153 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
154 fs_bt = elm_fileselector_button_add(win);
155 elm_object_text_set(fs_bt, "Select a dir");
156 elm_fileselector_button_icon_set(fs_bt, ic);
157 elm_fileselector_button_inwin_mode_set(fs_bt, EINA_TRUE);
158 elm_fileselector_button_folder_only_set(fs_bt, EINA_TRUE);
160 elm_box_pack_end(hbox, fs_bt);
161 elm_box_pack_end(vbox, hbox);
162 evas_object_show(fs_bt);
163 evas_object_show(ic);
165 /* attribute setting buttons */
166 bt = elm_button_add(win);
167 elm_object_text_set(bt, "clear");
168 evas_object_smart_callback_add(bt, "clicked", _test_eio_clear, gl);
169 elm_box_pack_end(hbox, bt);
170 evas_object_show(bt);
171 evas_object_show(hbox);
173 evas_object_smart_callback_add(fs_bt, "file,chosen", _file_chosen, gl);
175 evas_object_resize(win, 300, 500);
176 evas_object_show(win);