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__)
43 _compare_cb(const void *data1, const void *data2)
45 Elm_Object_Item *it = (Elm_Object_Item *)data1;
46 Elm_Object_Item *it2 = (Elm_Object_Item *)data2;
47 return strcoll(elm_object_item_data_get(it),
48 elm_object_item_data_get(it2));
51 >>>>>>> remotes/origin/upstream
53 _ls_main_cb(void *data, Eio_File *handler __UNUSED__, const char *file)
55 elm_genlist_item_sorted_insert(data,
57 eina_stringshare_add(file),
59 ELM_GENLIST_ITEM_NONE,
61 (Eina_Compare_Cb) strcoll,
64 >>>>>>> remotes/origin/upstream
70 _ls_done_cb(void *data __UNUSED__, Eio_File *handler __UNUSED__)
72 en_time = times(&en_cpu);
73 fprintf(stderr, "ls done\n");
74 fprintf(stderr, "Real Time: %.jd, User Time: %.jd, System Time: %.jd\n",
75 (intmax_t)(en_time - st_time),
76 (intmax_t)(en_cpu.tms_utime - st_cpu.tms_utime),
77 (intmax_t)(en_cpu.tms_stime - st_cpu.tms_stime));
81 _ls_error_cb(void *data __UNUSED__, Eio_File *handler __UNUSED__, int error)
83 fprintf(stderr, "error: [%s]\n", strerror(error));
87 _file_chosen(void *data, Evas_Object *obj __UNUSED__, void *event_info)
89 const char *file = event_info;
92 st_time = times(&st_cpu);
103 _gl_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
106 snprintf(buf, sizeof(buf), "Item # %s", (char*)data);
111 _gl_content_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
117 _gl_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
123 _gl_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__)
128 _test_eio_clear(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
130 elm_genlist_clear(data);
134 test_eio(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
136 Evas_Object *win, *bg, *vbox, *hbox, *ic, *bt, *fs_bt, *gl;
138 it_eio.item_style = "default";
139 it_eio.func.text_get = _gl_text_get;
140 it_eio.func.content_get = _gl_content_get;
141 it_eio.func.state_get = _gl_state_get;
142 it_eio.func.del = _gl_del;
144 win = elm_win_add(NULL, "fileselector-button", ELM_WIN_BASIC);
145 elm_win_title_set(win, "File Selector Button");
146 elm_win_autodel_set(win, EINA_TRUE);
148 bg = elm_bg_add(win);
149 elm_win_resize_object_add(win, bg);
150 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
151 evas_object_show(bg);
153 vbox = elm_box_add(win);
154 elm_win_resize_object_add(win, vbox);
155 evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
156 evas_object_show(vbox);
158 gl = elm_genlist_add(win);
159 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
160 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
161 elm_box_pack_end(vbox, gl);
162 evas_object_show(gl);
164 /* file selector button */
165 hbox = elm_box_add(win);
166 elm_box_horizontal_set(hbox, EINA_TRUE);
167 ic = elm_icon_add(win);
168 elm_icon_standard_set(ic, "file");
169 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
170 fs_bt = elm_fileselector_button_add(win);
171 elm_object_text_set(fs_bt, "Select a dir");
172 elm_object_part_content_set(fs_bt, "icon", ic);
173 elm_fileselector_button_inwin_mode_set(fs_bt, EINA_TRUE);
174 elm_fileselector_button_folder_only_set(fs_bt, EINA_TRUE);
176 elm_box_pack_end(hbox, fs_bt);
177 elm_box_pack_end(vbox, hbox);
178 evas_object_show(fs_bt);
179 evas_object_show(ic);
181 /* attribute setting buttons */
182 bt = elm_button_add(win);
183 elm_object_text_set(bt, "clear");
184 evas_object_smart_callback_add(bt, "clicked", _test_eio_clear, gl);
185 elm_box_pack_end(hbox, bt);
186 evas_object_show(bt);
187 evas_object_show(hbox);
189 evas_object_smart_callback_add(fs_bt, "file,chosen", _file_chosen, gl);
191 evas_object_resize(win, 300, 500);
192 evas_object_show(win);