summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael BOUCHAUD <michael.bouchaud@gmail.com>2011-05-25 19:08:38 +0000
committerMichael BOUCHAUD <michael.bouchaud@gmail.com>2011-05-25 19:08:38 +0000
commitbff85e95bd7463207c0f12150dd70772563aa0b7 (patch)
tree5167824a260819c0db888864f748a488e5449504
parentc89bde9986fa3a17bb4dc20c4937984ec1603971 (diff)
elementary: add eio test with a genlist
SVN revision: 59675
-rw-r--r--legacy/elementary/configure.ac5
-rw-r--r--legacy/elementary/src/bin/Makefile.am16
-rw-r--r--legacy/elementary/src/bin/test.c6
-rw-r--r--legacy/elementary/src/bin/test_eio.c171
4 files changed, 198 insertions, 0 deletions
diff --git a/legacy/elementary/configure.ac b/legacy/elementary/configure.ac
index 1bed7ebb7c..1f05909b93 100644
--- a/legacy/elementary/configure.ac
+++ b/legacy/elementary/configure.ac
@@ -212,6 +212,10 @@ PKG_CHECK_MODULES([ELEMENTARY],
212 ] 212 ]
213) 213)
214 214
215PKG_CHECK_MODULES([EIO],[eio], [have_eio="yes"], [have_eio="no"])
216
217AM_CONDITIONAL([HAVE_EIO], [test "x${have_eio}" = "xyes"])
218
215requirement_elm="edje >= 1.0.0 ecore-file >= 1.0.0 ecore-evas >= 1.0.0 ecore >= 1.0.0 evas >= 1.0.0 eet >= 1.4.0 eina >= 1.0.0 ${requirement_elm}" 219requirement_elm="edje >= 1.0.0 ecore-file >= 1.0.0 ecore-evas >= 1.0.0 ecore >= 1.0.0 evas >= 1.0.0 eet >= 1.4.0 eina >= 1.0.0 ${requirement_elm}"
216 220
217have_elementary_x="no" 221have_elementary_x="no"
@@ -551,6 +555,7 @@ echo " EFreet.................: ${have_elementary_efreet}"
551echo " EWeather...............: ${have_elementary_eweather}" 555echo " EWeather...............: ${have_elementary_eweather}"
552echo " Ethumb.................: ${have_elementary_ethumb}" 556echo " Ethumb.................: ${have_elementary_ethumb}"
553echo " Quick Launch...........: ${have_fork}" 557echo " Quick Launch...........: ${have_fork}"
558echo " eio....................: ${have_eio}"
554echo 559echo
555echo " eet......................: ${eet_eet}" 560echo " eet......................: ${eet_eet}"
556echo " edje_cc..................: ${edje_cc}" 561echo " edje_cc..................: ${edje_cc}"
diff --git a/legacy/elementary/src/bin/Makefile.am b/legacy/elementary/src/bin/Makefile.am
index b6cfd5e8bd..e72788c063 100644
--- a/legacy/elementary/src/bin/Makefile.am
+++ b/legacy/elementary/src/bin/Makefile.am
@@ -19,6 +19,10 @@ AM_CPPFLAGS = \
19@ELEMENTARY_EWEATHER_CFLAGS@ \ 19@ELEMENTARY_EWEATHER_CFLAGS@ \
20@ELEMENTARY_ETHUMB_CFLAGS@ 20@ELEMENTARY_ETHUMB_CFLAGS@
21 21
22if HAVE_EIO
23AM_CPPFLAGS += -DHAVE_EIO @EIO_CFLAGS@
24endif
25
22if ELEMENTARY_WINDOWS_BUILD 26if ELEMENTARY_WINDOWS_BUILD
23AM_CPPFLAGS += -DELEMENTARY_BUILD 27AM_CPPFLAGS += -DELEMENTARY_BUILD
24endif 28endif
@@ -101,12 +105,19 @@ test_win_state.c \
101test_grid.c \ 105test_grid.c \
102test_flip_page.c 106test_flip_page.c
103 107
108if HAVE_EIO
109elementary_test_SOURCES += test_eio.c
110endif
111
104elementary_test_LDADD = $(top_builddir)/src/lib/libelementary.la \ 112elementary_test_LDADD = $(top_builddir)/src/lib/libelementary.la \
105 @ELEMENTARY_EWEATHER_LIBS@ \ 113 @ELEMENTARY_EWEATHER_LIBS@ \
106 @ELEMENTARY_EDBUS_LIBS@ \ 114 @ELEMENTARY_EDBUS_LIBS@ \
107 @ELEMENTARY_EFREET_LIBS@ \ 115 @ELEMENTARY_EFREET_LIBS@ \
108 @ELEMENTARY_LIBS@ \ 116 @ELEMENTARY_LIBS@ \
109 @my_libs@ 117 @my_libs@
118if HAVE_EIO
119elementary_test_LDADD += @EIO_LIBS@
120endif
110elementary_test_LDFLAGS = 121elementary_test_LDFLAGS =
111 122
112elementary_config_SOURCES = \ 123elementary_config_SOURCES = \
@@ -155,6 +166,11 @@ elementary_testql_LDADD = $(top_builddir)/src/lib/libelementary.la \
155 @ELEMENTARY_EFREET_LIBS@ \ 166 @ELEMENTARY_EFREET_LIBS@ \
156 @ELEMENTARY_LIBS@ \ 167 @ELEMENTARY_LIBS@ \
157 @my_libs@ 168 @my_libs@
169
170if HAVE_EIO
171elementary_testql_LDADD += @EIO_LIBS@
172endif
173
158elementary_testql_CFLAGS = -DELM_LIB_QUICKLAUNCH=1 174elementary_testql_CFLAGS = -DELM_LIB_QUICKLAUNCH=1
159elementary_testql_LDFLAGS = 175elementary_testql_LDFLAGS =
160endif 176endif
diff --git a/legacy/elementary/src/bin/test.c b/legacy/elementary/src/bin/test.c
index ebeb2e0ec6..a352cbafdd 100644
--- a/legacy/elementary/src/bin/test.c
+++ b/legacy/elementary/src/bin/test.c
@@ -129,6 +129,9 @@ void test_segment_control(void *data, Evas_Object *obj, void *event_info);
129void test_store(void *data, Evas_Object *obj, void *event_info); 129void test_store(void *data, Evas_Object *obj, void *event_info);
130void test_win_inline(void *data, Evas_Object *obj, void *event_info); 130void test_win_inline(void *data, Evas_Object *obj, void *event_info);
131void test_grid(void *data, Evas_Object *obj, void *event_info); 131void test_grid(void *data, Evas_Object *obj, void *event_info);
132#ifdef HAVE_EIO
133void test_eio(void *data, Evas_Object *obj, void *event_info);
134#endif
132 135
133struct elm_test 136struct elm_test
134{ 137{
@@ -330,6 +333,9 @@ my_win_main(char *autorun)
330 ADD_TEST("Genlist Group", test_genlist8); 333 ADD_TEST("Genlist Group", test_genlist8);
331 ADD_TEST("Genlist Group Tree", test_genlist9); 334 ADD_TEST("Genlist Group Tree", test_genlist9);
332 ADD_TEST("Genlist Mode", test_genlist10); 335 ADD_TEST("Genlist Mode", test_genlist10);
336#ifdef HAVE_EIO
337 ADD_TEST("Genlist Eio", test_eio);
338#endif
333 ADD_TEST("GenGrid", test_gengrid); 339 ADD_TEST("GenGrid", test_gengrid);
334 ADD_TEST("GenGrid 2", test_gengrid2); 340 ADD_TEST("GenGrid 2", test_gengrid2);
335 ADD_TEST("Checks", test_check); 341 ADD_TEST("Checks", test_check);
diff --git a/legacy/elementary/src/bin/test_eio.c b/legacy/elementary/src/bin/test_eio.c
new file mode 100644
index 0000000000..89cd2bb129
--- /dev/null
+++ b/legacy/elementary/src/bin/test_eio.c
@@ -0,0 +1,171 @@
1#include <Elementary.h>
2#ifdef HAVE_CONFIG_H
3# include "elementary_config.h"
4#endif
5#include <Eio.h>
6#include <sys/times.h>
7
8#ifndef ELM_LIB_QUICKLAUNCH
9
10static Elm_Genlist_Item_Class it_eio;
11
12static clock_t st_time;
13static clock_t en_time;
14static struct tms st_cpu;
15static struct tms en_cpu;
16
17
18static void
19_sel_file(void *data, Evas_Object *obj, void *event_info)
20{
21}
22
23static Eina_Bool
24_ls_filter_cb(void *data, Eio_File *handler, const char *file)
25{
26 return EINA_TRUE;
27}
28
29static void
30_ls_main_cb(void *data, Eio_File *handler, const char *file)
31{
32 elm_genlist_item_sorted_insert(data,
33 &it_eio,
34 eina_stringshare_add(file),
35 NULL,
36 ELM_GENLIST_ITEM_NONE,
37 (Eina_Compare_Cb) strcmp,
38 _sel_file,
39 NULL);
40}
41
42void
43_ls_done_cb(void *data, Eio_File *handler)
44{
45 en_time = times(&en_cpu);
46 fprintf(stderr, "ls done\n");
47 fprintf(stderr, "Real Time: %.jd, User Time: %.jd, System Time: %.jd\n",
48 en_time - st_time,
49 en_cpu.tms_utime - st_cpu.tms_utime,
50 en_cpu.tms_stime - st_cpu.tms_stime);
51}
52
53void
54_ls_error_cb(void *data, Eio_File *handler, int error)
55{
56 fprintf(stderr, "error: [%s]\n", strerror(error));
57}
58
59static void
60_file_chosen(void *data,
61 Evas_Object *obj __UNUSED__,
62 void *event_info)
63{
64 const char *file = event_info;
65 if (file)
66 {
67 st_time = times(&st_cpu);
68 eio_file_ls(file,
69 _ls_filter_cb,
70 _ls_main_cb,
71 _ls_done_cb,
72 _ls_error_cb,
73 data);
74 }
75}
76
77static char *
78_gl_label_get(void *data, Evas_Object *obj, const char *part)
79{
80 char buf[PATH_MAX];
81 snprintf(buf, sizeof(buf), "Item # %s", (char*)data);
82 return strdup(buf);
83}
84
85static Evas_Object *
86_gl_icon_get(void *data, Evas_Object *obj, const char *part)
87{
88}
89
90static Eina_Bool
91_gl_state_get(void *data , Evas_Object *obj, const char *part)
92{
93 return EINA_FALSE;
94}
95
96static void
97_gl_del(void *data, Evas_Object *obj)
98{
99}
100
101static void
102_test_eio_clear(void *data, Evas_Object *obj, void *event)
103{
104 elm_genlist_clear(data);
105}
106
107void
108test_eio(void *data __UNUSED__,
109 Evas_Object *obj __UNUSED__,
110 void *event_info __UNUSED__)
111{
112 Evas_Object *win, *bg, *vbox, *hbox, *ic, *bt, *fs_bt, *en, *lb, *gl;
113
114 it_eio.item_style = "default";
115 it_eio.func.label_get = _gl_label_get;
116 it_eio.func.icon_get = _gl_icon_get;
117 it_eio.func.state_get = _gl_state_get;
118 it_eio.func.del = _gl_del;
119
120 win = elm_win_add(NULL, "fileselector-button", ELM_WIN_BASIC);
121 elm_win_title_set(win, "File Selector Button");
122 elm_win_autodel_set(win, 1);
123
124 bg = elm_bg_add(win);
125 elm_win_resize_object_add(win, bg);
126 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
127 evas_object_show(bg);
128
129 vbox = elm_box_add(win);
130 elm_win_resize_object_add(win, vbox);
131 evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
132 evas_object_show(vbox);
133
134 gl = elm_genlist_add(win);
135 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
136 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
137 elm_box_pack_end(vbox, gl);
138 evas_object_show(gl);
139
140 /* file selector button */
141 hbox = elm_box_add(win);
142 elm_box_horizontal_set(hbox, EINA_TRUE);
143 ic = elm_icon_add(win);
144 elm_icon_standard_set(ic, "file");
145 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
146 fs_bt = elm_fileselector_button_add(win);
147 elm_fileselector_button_label_set(fs_bt, "Select a dir");
148 elm_fileselector_button_icon_set(fs_bt, ic);
149 elm_fileselector_button_inwin_mode_set(fs_bt, EINA_TRUE);
150 elm_fileselector_button_folder_only_set(fs_bt, EINA_TRUE);
151
152 elm_box_pack_end(hbox, fs_bt);
153 elm_box_pack_end(vbox, hbox);
154 evas_object_show(fs_bt);
155 evas_object_show(ic);
156
157 /* attribute setting buttons */
158 bt = elm_button_add(win);
159 elm_button_label_set(bt, "clear");
160 evas_object_smart_callback_add(bt, "clicked", _test_eio_clear, gl);
161 elm_box_pack_end(hbox, bt);
162 evas_object_show(bt);
163 evas_object_show(hbox);
164
165 evas_object_smart_callback_add(fs_bt, "file,chosen", _file_chosen, gl);
166
167 evas_object_resize(win, 300, 500);
168 evas_object_show(win);
169}
170
171#endif