summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2011-06-25 23:39:43 +0000
committerCedric BAIL <cedric.bail@free.fr>2011-06-25 23:39:43 +0000
commit452e2d379f47d3a7d9be6b741be5b5429036448e (patch)
treec134fafcfa04faf2df6ed053e546a162ae3f7551
parent74dd82cf60a2e11a1bd21188e8b33b5cdeb51673 (diff)
elementary: use Eio when available for fileselector.
SVN revision: 60692
-rw-r--r--legacy/elementary/configure.ac9
-rw-r--r--legacy/elementary/src/bin/Makefile.am23
-rw-r--r--legacy/elementary/src/lib/Elementary.h.in7
-rw-r--r--legacy/elementary/src/lib/Makefile.am2
-rw-r--r--legacy/elementary/src/lib/elc_fileselector.c335
5 files changed, 311 insertions, 65 deletions
diff --git a/legacy/elementary/configure.ac b/legacy/elementary/configure.ac
index 39f107872f..01ac4450d6 100644
--- a/legacy/elementary/configure.ac
+++ b/legacy/elementary/configure.ac
@@ -212,7 +212,14 @@ PKG_CHECK_MODULES([ELEMENTARY],
212 ] 212 ]
213) 213)
214 214
215PKG_CHECK_MODULES([EIO],[eio], [have_eio="yes"], [have_eio="no"]) 215PKG_CHECK_MODULES([EIO],
216 [eio],
217 [
218 have_eio="yes"
219 AC_DEFINE(HAVE_EIO, 1, [Use EIO for asynchronous file access])
220 requirement_elm="eio ${requirement_elm}"
221 ],
222 [have_eio="no"])
216 223
217AM_CONDITIONAL([HAVE_EIO], [test "x${have_eio}" = "xyes"]) 224AM_CONDITIONAL([HAVE_EIO], [test "x${have_eio}" = "xyes"])
218 225
diff --git a/legacy/elementary/src/bin/Makefile.am b/legacy/elementary/src/bin/Makefile.am
index 287e47083c..262e781ecb 100644
--- a/legacy/elementary/src/bin/Makefile.am
+++ b/legacy/elementary/src/bin/Makefile.am
@@ -17,11 +17,8 @@ AM_CPPFLAGS = \
17@ELEMENTARY_EDBUS_CFLAGS@ \ 17@ELEMENTARY_EDBUS_CFLAGS@ \
18@ELEMENTARY_EFREET_CFLAGS@ \ 18@ELEMENTARY_EFREET_CFLAGS@ \
19@ELEMENTARY_EWEATHER_CFLAGS@ \ 19@ELEMENTARY_EWEATHER_CFLAGS@ \
20@ELEMENTARY_ETHUMB_CFLAGS@ 20@ELEMENTARY_ETHUMB_CFLAGS@ \
21 21@EIO_CFLAGS@
22if HAVE_EIO
23AM_CPPFLAGS += -DHAVE_EIO @EIO_CFLAGS@
24endif
25 22
26if ELEMENTARY_WINDOWS_BUILD 23if ELEMENTARY_WINDOWS_BUILD
27AM_CPPFLAGS += -DELEMENTARY_BUILD 24AM_CPPFLAGS += -DELEMENTARY_BUILD
@@ -118,10 +115,8 @@ elementary_test_LDADD = $(top_builddir)/src/lib/libelementary.la \
118 @ELEMENTARY_EDBUS_LIBS@ \ 115 @ELEMENTARY_EDBUS_LIBS@ \
119 @ELEMENTARY_EFREET_LIBS@ \ 116 @ELEMENTARY_EFREET_LIBS@ \
120 @ELEMENTARY_LIBS@ \ 117 @ELEMENTARY_LIBS@ \
118 @EIO_LIBS@ \
121 @my_libs@ 119 @my_libs@
122if HAVE_EIO
123elementary_test_LDADD += @EIO_LIBS@
124endif
125elementary_test_LDFLAGS = 120elementary_test_LDFLAGS =
126 121
127elementary_config_SOURCES = \ 122elementary_config_SOURCES = \
@@ -160,11 +155,8 @@ elementary_testqldir = $(libdir)
160elementary_testql_LTLIBRARIES = elementary_testql.la 155elementary_testql_LTLIBRARIES = elementary_testql.la
161elementary_testql_la_SOURCES = $(elementary_test_SOURCES) 156elementary_testql_la_SOURCES = $(elementary_test_SOURCES)
162elementary_testql_la_LIBADD = $(top_builddir)/src/lib/libelementary.la \ 157elementary_testql_la_LIBADD = $(top_builddir)/src/lib/libelementary.la \
163 @ELEMENTARY_EWEATHER_LIBS@ 158 @ELEMENTARY_EWEATHER_LIBS@ \
164 159 @EIO_LIBS@
165if HAVE_EIO
166elementary_testql_la_LIBADD += @EIO_LIBS@
167endif
168 160
169elementary_testql_la_CFLAGS = 161elementary_testql_la_CFLAGS =
170elementary_testql_la_LDFLAGS = -module -avoid-version -no-undefined 162elementary_testql_la_LDFLAGS = -module -avoid-version -no-undefined
@@ -174,12 +166,9 @@ elementary_testql_LDADD = $(top_builddir)/src/lib/libelementary.la \
174 @ELEMENTARY_EDBUS_LIBS@ \ 166 @ELEMENTARY_EDBUS_LIBS@ \
175 @ELEMENTARY_EFREET_LIBS@ \ 167 @ELEMENTARY_EFREET_LIBS@ \
176 @ELEMENTARY_LIBS@ \ 168 @ELEMENTARY_LIBS@ \
169 @EIO_LIBS@
177 @my_libs@ 170 @my_libs@
178 171
179if HAVE_EIO
180elementary_testql_LDADD += @EIO_LIBS@
181endif
182
183elementary_testql_CFLAGS = -DELM_LIB_QUICKLAUNCH=1 172elementary_testql_CFLAGS = -DELM_LIB_QUICKLAUNCH=1
184elementary_testql_LDFLAGS = 173elementary_testql_LDFLAGS =
185endif 174endif
diff --git a/legacy/elementary/src/lib/Elementary.h.in b/legacy/elementary/src/lib/Elementary.h.in
index 283f7354a6..13cd437969 100644
--- a/legacy/elementary/src/lib/Elementary.h.in
+++ b/legacy/elementary/src/lib/Elementary.h.in
@@ -2191,6 +2191,8 @@ extern "C" {
2191 EAPI Evas_Object *elm_gengrid_item_gengrid_get(const Elm_Gengrid_Item *item) EINA_ARG_NONNULL(1); 2191 EAPI Evas_Object *elm_gengrid_item_gengrid_get(const Elm_Gengrid_Item *item) EINA_ARG_NONNULL(1);
2192 EAPI void elm_gengrid_item_del(Elm_Gengrid_Item *item) EINA_ARG_NONNULL(1); 2192 EAPI void elm_gengrid_item_del(Elm_Gengrid_Item *item) EINA_ARG_NONNULL(1);
2193 EAPI void elm_gengrid_item_update(Elm_Gengrid_Item *item) EINA_ARG_NONNULL(1); 2193 EAPI void elm_gengrid_item_update(Elm_Gengrid_Item *item) EINA_ARG_NONNULL(1);
2194 EAPI const Elm_Gengrid_Item_Class *elm_gengrid_item_item_class_get(const Elm_Gengrid_Item *item) EINA_ARG_NONNULL(1);
2195 EAPI void elm_gengrid_item_item_class_set(Elm_Gengrid_Item *item, const Elm_Gengrid_Item_Class *gic) EINA_ARG_NONNULL(1, 2);
2194 EAPI void *elm_gengrid_item_data_get(const Elm_Gengrid_Item *item) EINA_ARG_NONNULL(1); 2196 EAPI void *elm_gengrid_item_data_get(const Elm_Gengrid_Item *item) EINA_ARG_NONNULL(1);
2195 EAPI void elm_gengrid_item_data_set(Elm_Gengrid_Item *item, const void *data) EINA_ARG_NONNULL(1); 2197 EAPI void elm_gengrid_item_data_set(Elm_Gengrid_Item *item, const void *data) EINA_ARG_NONNULL(1);
2196 EAPI void elm_gengrid_item_pos_get(const Elm_Gengrid_Item *item, unsigned int *x, unsigned int *y) EINA_ARG_NONNULL(1); 2198 EAPI void elm_gengrid_item_pos_get(const Elm_Gengrid_Item *item, unsigned int *x, unsigned int *y) EINA_ARG_NONNULL(1);
@@ -2224,6 +2226,7 @@ extern "C" {
2224 EAPI Elm_Gengrid_Item *elm_gengrid_item_insert_before(Evas_Object *obj, const Elm_Gengrid_Item_Class *gic, const void *data, Elm_Gengrid_Item *relative, Evas_Smart_Cb func, const void *func_data) EINA_ARG_NONNULL(1); 2226 EAPI Elm_Gengrid_Item *elm_gengrid_item_insert_before(Evas_Object *obj, const Elm_Gengrid_Item_Class *gic, const void *data, Elm_Gengrid_Item *relative, Evas_Smart_Cb func, const void *func_data) EINA_ARG_NONNULL(1);
2225 EAPI Elm_Gengrid_Item *elm_gengrid_item_insert_after(Evas_Object *obj, const Elm_Gengrid_Item_Class *gic, const void *data, Elm_Gengrid_Item *relative, Evas_Smart_Cb func, const void *func_data) EINA_ARG_NONNULL(1); 2227 EAPI Elm_Gengrid_Item *elm_gengrid_item_insert_after(Evas_Object *obj, const Elm_Gengrid_Item_Class *gic, const void *data, Elm_Gengrid_Item *relative, Evas_Smart_Cb func, const void *func_data) EINA_ARG_NONNULL(1);
2226 EAPI Elm_Gengrid_Item *elm_gengrid_item_sorted_insert(Evas_Object *obj, const Elm_Gengrid_Item_Class *gic, const void *data, Eina_Compare_Cb comp, Evas_Smart_Cb func, const void *func_data) EINA_ARG_NONNULL(1); 2228 EAPI Elm_Gengrid_Item *elm_gengrid_item_sorted_insert(Evas_Object *obj, const Elm_Gengrid_Item_Class *gic, const void *data, Eina_Compare_Cb comp, Evas_Smart_Cb func, const void *func_data) EINA_ARG_NONNULL(1);
2229 EAPI Elm_Gengrid_Item *elm_gengrid_item_direct_sorted_insert(Evas_Object *obj, const Elm_Gengrid_Item_Class *gic, const void *data, Eina_Compare_Cb comp, Evas_Smart_Cb func, const void *func_data);
2227 /* smart callbacks called: 2230 /* smart callbacks called:
2228 * 2231 *
2229 * selected - User has selected an item. 2232 * selected - User has selected an item.
@@ -3638,7 +3641,8 @@ extern "C" {
3638 EAPI Elm_Genlist_Item *elm_genlist_item_prepend(Evas_Object *obj, const Elm_Genlist_Item_Class *itc, const void *data, Elm_Genlist_Item *parent, Elm_Genlist_Item_Flags flags, Evas_Smart_Cb func, const void *func_data) EINA_ARG_NONNULL(1); 3641 EAPI Elm_Genlist_Item *elm_genlist_item_prepend(Evas_Object *obj, const Elm_Genlist_Item_Class *itc, const void *data, Elm_Genlist_Item *parent, Elm_Genlist_Item_Flags flags, Evas_Smart_Cb func, const void *func_data) EINA_ARG_NONNULL(1);
3639 EAPI Elm_Genlist_Item *elm_genlist_item_insert_before(Evas_Object *obj, const Elm_Genlist_Item_Class *itc, const void *data, Elm_Genlist_Item *parent, Elm_Genlist_Item *before, Elm_Genlist_Item_Flags flags, Evas_Smart_Cb func, const void *func_data) EINA_ARG_NONNULL(1, 5); 3642 EAPI Elm_Genlist_Item *elm_genlist_item_insert_before(Evas_Object *obj, const Elm_Genlist_Item_Class *itc, const void *data, Elm_Genlist_Item *parent, Elm_Genlist_Item *before, Elm_Genlist_Item_Flags flags, Evas_Smart_Cb func, const void *func_data) EINA_ARG_NONNULL(1, 5);
3640 EAPI Elm_Genlist_Item *elm_genlist_item_insert_after(Evas_Object *obj, const Elm_Genlist_Item_Class *itc, const void *data, Elm_Genlist_Item *parent, Elm_Genlist_Item *after, Elm_Genlist_Item_Flags flags, Evas_Smart_Cb func, const void *func_data) EINA_ARG_NONNULL(1, 5); 3643 EAPI Elm_Genlist_Item *elm_genlist_item_insert_after(Evas_Object *obj, const Elm_Genlist_Item_Class *itc, const void *data, Elm_Genlist_Item *parent, Elm_Genlist_Item *after, Elm_Genlist_Item_Flags flags, Evas_Smart_Cb func, const void *func_data) EINA_ARG_NONNULL(1, 5);
3641EAPI Elm_Genlist_Item *elm_genlist_item_sorted_insert(Evas_Object *obj, const Elm_Genlist_Item_Class *itc, const void *data, Elm_Genlist_Item *parent, Elm_Genlist_Item_Flags flags, Eina_Compare_Cb comp, Evas_Smart_Cb func,const void *func_data); 3644 EAPI Elm_Genlist_Item *elm_genlist_item_sorted_insert(Evas_Object *obj, const Elm_Genlist_Item_Class *itc, const void *data, Elm_Genlist_Item *parent, Elm_Genlist_Item_Flags flags, Eina_Compare_Cb comp, Evas_Smart_Cb func,const void *func_data);
3645 EAPI Elm_Genlist_Item *elm_genlist_item_direct_sorted_insert(Evas_Object *obj, const Elm_Genlist_Item_Class *itc, const void *data, Elm_Genlist_Item *parent, Elm_Genlist_Item_Flags flags, Eina_Compare_Cb comp, Evas_Smart_Cb func, const void *func_data);
3642 /* operations to retrieve existing items */ 3646 /* operations to retrieve existing items */
3643 EAPI Elm_Genlist_Item *elm_genlist_selected_item_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); 3647 EAPI Elm_Genlist_Item *elm_genlist_selected_item_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
3644 EAPI const Eina_List *elm_genlist_selected_items_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); 3648 EAPI const Eina_List *elm_genlist_selected_items_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
@@ -3682,6 +3686,7 @@ EAPI Elm_Genlist_Item *elm_genlist_item_sorted_insert(Evas_Object *obj, const El
3682 EAPI const Evas_Object *elm_genlist_item_object_get(const Elm_Genlist_Item *it) EINA_ARG_NONNULL(1); 3686 EAPI const Evas_Object *elm_genlist_item_object_get(const Elm_Genlist_Item *it) EINA_ARG_NONNULL(1);
3683 EAPI void elm_genlist_item_update(Elm_Genlist_Item *item) EINA_ARG_NONNULL(1); 3687 EAPI void elm_genlist_item_update(Elm_Genlist_Item *item) EINA_ARG_NONNULL(1);
3684 EAPI void elm_genlist_item_item_class_update(Elm_Genlist_Item *it, const Elm_Genlist_Item_Class *itc) EINA_ARG_NONNULL(1, 2); 3688 EAPI void elm_genlist_item_item_class_update(Elm_Genlist_Item *it, const Elm_Genlist_Item_Class *itc) EINA_ARG_NONNULL(1, 2);
3689 EAPI const Elm_Genlist_Item_Class *elm_genlist_item_item_class_get(const Elm_Genlist_Item *it) EINA_ARG_NONNULL(1);
3685 EAPI void elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item, const char *text) EINA_ARG_NONNULL(1); 3690 EAPI void elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item, const char *text) EINA_ARG_NONNULL(1);
3686 EAPI void elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb) EINA_ARG_NONNULL(1); 3691 EAPI void elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb) EINA_ARG_NONNULL(1);
3687 EAPI void elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item) EINA_ARG_NONNULL(1); 3692 EAPI void elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item) EINA_ARG_NONNULL(1);
diff --git a/legacy/elementary/src/lib/Makefile.am b/legacy/elementary/src/lib/Makefile.am
index 879373131a..bbd2929df5 100644
--- a/legacy/elementary/src/lib/Makefile.am
+++ b/legacy/elementary/src/lib/Makefile.am
@@ -23,6 +23,7 @@ AM_CPPFLAGS = \
23@ELEMENTARY_ETHUMB_CFLAGS@ \ 23@ELEMENTARY_ETHUMB_CFLAGS@ \
24@ELEMENTARY_EMAP_CFLAGS@ \ 24@ELEMENTARY_EMAP_CFLAGS@ \
25@EVIL_CFLAGS@ \ 25@EVIL_CFLAGS@ \
26@EIO_CFLAGS@ \
26@EFL_PTHREAD_CFLAGS@ 27@EFL_PTHREAD_CFLAGS@
27 28
28if ELEMENTARY_WINDOWS_BUILD 29if ELEMENTARY_WINDOWS_BUILD
@@ -133,6 +134,7 @@ libelementary_la_LIBADD = \
133@ELEMENTARY_ETHUMB_LIBS@ \ 134@ELEMENTARY_ETHUMB_LIBS@ \
134@ELEMENTARY_EMAP_LIBS@ \ 135@ELEMENTARY_EMAP_LIBS@ \
135@EVIL_LIBS@ \ 136@EVIL_LIBS@ \
137@EIO_LIBS@ \
136@EFL_PTHREAD_LIBS@ 138@EFL_PTHREAD_LIBS@
137libelementary_la_LDFLAGS = \ 139libelementary_la_LDFLAGS = \
138-no-undefined @lt_enable_auto_import@ \ 140-no-undefined @lt_enable_auto_import@ \
diff --git a/legacy/elementary/src/lib/elc_fileselector.c b/legacy/elementary/src/lib/elc_fileselector.c
index 36a9709ed7..0f0d242fdc 100644
--- a/legacy/elementary/src/lib/elc_fileselector.c
+++ b/legacy/elementary/src/lib/elc_fileselector.c
@@ -27,10 +27,16 @@
27#include <Elementary.h> 27#include <Elementary.h>
28#include "elm_priv.h" 28#include "elm_priv.h"
29 29
30#ifdef HAVE_EIO
31# include <Eio.h>
32#endif
33
30typedef struct _Widget_Data Widget_Data; 34typedef struct _Widget_Data Widget_Data;
31 35
32struct _Widget_Data 36struct _Widget_Data
33{ 37{
38 EINA_REFCOUNT;
39
34 Evas_Object *edje; 40 Evas_Object *edje;
35 Evas_Object *filename_entry; 41 Evas_Object *filename_entry;
36 Evas_Object *path_entry; 42 Evas_Object *path_entry;
@@ -48,6 +54,10 @@ struct _Widget_Data
48 54
49 const char *path_separator; 55 const char *path_separator;
50 56
57#ifdef HAVE_EIO
58 Eio_File *current;
59#endif
60
51 Elm_Fileselector_Mode mode; 61 Elm_Fileselector_Mode mode;
52 62
53 Eina_Bool only_folder : 1; 63 Eina_Bool only_folder : 1;
@@ -60,8 +70,34 @@ struct sel_data
60 const char *path; 70 const char *path;
61}; 71};
62 72
63Elm_Genlist_Item_Class list_itc; 73typedef struct _Widget_Request Widget_Request;
64Elm_Gengrid_Item_Class grid_itc; 74struct _Widget_Request
75{
76 Widget_Data *wd;
77 Elm_Genlist_Item *parent;
78
79 Evas_Object *obj;
80 const char *path;
81 Eina_Bool first : 1;
82};
83
84typedef enum {
85 ELM_DIRECTORY = 0,
86 ELM_FILE_IMAGE = 1,
87 ELM_FILE_UNKNOW = 2,
88 ELM_FILE_LAST
89} Elm_Fileselector_Type;
90
91static Elm_Genlist_Item_Class list_itc[ELM_FILE_LAST] = {
92 { "default", { NULL, NULL, NULL, NULL, NULL }, NULL },
93 { "default", { NULL, NULL, NULL, NULL, NULL }, NULL },
94 { "default", { NULL, NULL, NULL, NULL, NULL }, NULL }
95};
96static Elm_Gengrid_Item_Class grid_itc[ELM_FILE_LAST] = {
97 { "default", { NULL, NULL, NULL, NULL } },
98 { "default", { NULL, NULL, NULL, NULL } },
99 { "default", { NULL, NULL, NULL, NULL } }
100};
65 101
66static const char *widtype = NULL; 102static const char *widtype = NULL;
67 103
@@ -83,18 +119,14 @@ static void _do_anchors(Evas_Object *obj,
83 119
84/*** ELEMENTARY WIDGET ***/ 120/*** ELEMENTARY WIDGET ***/
85static void 121static void
86_del_hook(Evas_Object *obj) 122_widget_data_free(Widget_Data *wd)
87{ 123{
88 Widget_Data *wd;
89 void *sd;
90
91 wd = elm_widget_data_get(obj);
92 if (!wd) return;
93
94 if (wd->path) eina_stringshare_del(wd->path); 124 if (wd->path) eina_stringshare_del(wd->path);
95 if (wd->selection) eina_stringshare_del(wd->selection); 125 if (wd->selection) eina_stringshare_del(wd->selection);
96 if (wd->sel_idler) 126 if (wd->sel_idler)
97 { 127 {
128 void *sd;
129
98 sd = ecore_idler_del(wd->sel_idler); 130 sd = ecore_idler_del(wd->sel_idler);
99 free(sd); 131 free(sd);
100 } 132 }
@@ -102,6 +134,23 @@ _del_hook(Evas_Object *obj)
102} 134}
103 135
104static void 136static void
137_del_hook(Evas_Object *obj)
138{
139 Widget_Data *wd;
140
141 wd = elm_widget_data_get(obj);
142 if (!wd) return;
143
144 eio_file_cancel(wd->current);
145
146 wd->files_list = NULL;
147 wd->files_grid = NULL;
148
149 EINA_REFCOUNT_UNREF(wd)
150 _widget_data_free(wd);
151}
152
153static void
105_sizing_eval(Evas_Object *obj) 154_sizing_eval(Evas_Object *obj)
106{ 155{
107 Widget_Data *wd = elm_widget_data_get(obj); 156 Widget_Data *wd = elm_widget_data_get(obj);
@@ -212,38 +261,56 @@ _itc_label_get(void *data,
212} 261}
213 262
214static Evas_Object * 263static Evas_Object *
215_itc_icon_get(void *data, 264_itc_icon_folder_get(void *data __UNUSED__,
216 Evas_Object *obj, 265 Evas_Object *obj,
217 const char *source) 266 const char *source)
218{ 267{
219 Evas_Object *ic; 268 Evas_Object *ic;
220 269
221 if (!strcmp(source, "elm.swallow.icon")) 270 if (strcmp(source, "elm.swallow.icon")) return NULL;
222 {
223 const char *filename = data;
224 271
225 ic = elm_icon_add(obj); 272 ic = elm_icon_add(obj);
226 if (ecore_file_is_dir((char *)data)) 273 elm_icon_standard_set(ic, "folder");
227 elm_icon_standard_set(ic, "folder");
228 else
229 {
230 if (evas_object_image_extension_can_load_fast_get(filename))
231 {
232 elm_icon_standard_set(ic, "image");
233 elm_icon_thumb_set(ic, filename, NULL);
234 }
235 else
236 {
237 elm_icon_standard_set(ic, "file");
238 }
239 }
240 274
241 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 275 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL,
242 1, 1); 276 1, 1);
243 evas_object_show(ic); 277 return ic;
244 return ic; 278}
245 } 279
246 return NULL; 280static Evas_Object *
281_itc_icon_image_get(void *data,
282 Evas_Object *obj,
283 const char *source)
284{
285 const char *filename = data;
286 Evas_Object *ic;
287
288 if (strcmp(source, "elm.swallow.icon")) return NULL;
289
290 ic = elm_icon_add(obj);
291 elm_icon_standard_set(ic, "image");
292 elm_icon_thumb_set(ic, filename, NULL);
293
294 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL,
295 1, 1);
296 return ic;
297}
298
299static Evas_Object *
300_itc_icon_file_get(void *data __UNUSED__,
301 Evas_Object *obj,
302 const char *source)
303{
304 Evas_Object *ic;
305
306 if (strcmp(source, "elm.swallow.icon")) return NULL;
307
308 ic = elm_icon_add(obj);
309 elm_icon_standard_set(ic, "file");
310
311 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL,
312 1, 1);
313 return ic;
247} 314}
248 315
249static Eina_Bool 316static Eina_Bool
@@ -487,18 +554,164 @@ _do_anchors(Evas_Object *obj,
487 elm_entry_entry_set(wd->path_entry, buf); 554 elm_entry_entry_set(wd->path_entry, buf);
488} 555}
489 556
557#ifdef HAVE_EIO
558static Eina_Bool
559_filter_cb(void *data __UNUSED__, Eio_File *handler, const Eina_File_Direct_Info *info)
560{
561 const char *filename;
562
563 if (info->path[info->name_start] == '.')
564 return EINA_FALSE;
565
566 filename = eina_stringshare_add(info->path);
567 eio_file_associate_direct_add(handler, "filename", filename, EINA_FREE_CB(eina_stringshare_del));
568
569 if (info->type == EINA_FILE_DIR)
570 {
571 eio_file_associate_direct_add(handler, "type/grid", &grid_itc[ELM_DIRECTORY], NULL);
572 eio_file_associate_direct_add(handler, "type/list", &list_itc[ELM_DIRECTORY], NULL);
573 }
574 else
575 {
576 if (evas_object_image_extension_can_load_get(info->path + info->name_start))
577 {
578 eio_file_associate_direct_add(handler, "type/grid", &grid_itc[ELM_FILE_IMAGE], NULL);
579 eio_file_associate_direct_add(handler, "type/list", &list_itc[ELM_FILE_IMAGE], NULL);
580 }
581 else
582 {
583 eio_file_associate_direct_add(handler, "type/grid", &grid_itc[ELM_FILE_UNKNOW], NULL);
584 eio_file_associate_direct_add(handler, "type/list", &list_itc[ELM_FILE_UNKNOW], NULL);
585 }
586 }
587
588 return EINA_TRUE;
589}
590
591static int
592_file_grid_cmp(const void *a, const void *b)
593{
594 const Elm_Gengrid_Item *ga = a;
595 const Elm_Gengrid_Item *gb = b;
596 const Elm_Gengrid_Item_Class *ca = elm_gengrid_item_item_class_get(ga);
597 const Elm_Gengrid_Item_Class *cb = elm_gengrid_item_item_class_get(gb);
598
599 if (ca == &grid_itc[ELM_DIRECTORY])
600 {
601 if (cb != &grid_itc[ELM_DIRECTORY])
602 return -1;
603 }
604
605 return strcoll(elm_gengrid_item_data_get(ga), elm_gengrid_item_data_get(gb));
606}
607
608static int
609_file_list_cmp(const void *a, const void *b)
610{
611 const Elm_Genlist_Item *la = a;
612 const Elm_Genlist_Item *lb = b;
613 const Elm_Genlist_Item_Class *ca = elm_genlist_item_item_class_get(la);
614 const Elm_Genlist_Item_Class *cb = elm_genlist_item_item_class_get(lb);
615
616 if (ca == &list_itc[ELM_DIRECTORY])
617 {
618 if (cb != &list_itc[ELM_DIRECTORY])
619 return -1;
620 }
621
622 return strcoll(elm_genlist_item_data_get(la), elm_genlist_item_data_get(lb));
623}
624
625static void
626_signal_first(Widget_Request *wr)
627{
628 if (!wr->first) return ;
629 evas_object_smart_callback_call(wr->obj, SIG_DIRECTORY_OPEN, (void *)wr->path);
630 if (!wr->parent)
631 {
632 elm_genlist_clear(wr->wd->files_list);
633 elm_gengrid_clear(wr->wd->files_grid);
634 eina_stringshare_replace(&wr->wd->path, wr->path);
635 _do_anchors(wr->obj, wr->path);
636 }
637
638 if (wr->wd->filename_entry) elm_entry_entry_set(wr->wd->filename_entry, "");
639
640 wr->first = EINA_FALSE;
641}
642
643static void
644_main_cb(void *data, Eio_File *handler, const Eina_File_Direct_Info *info __UNUSED__)
645{
646 Widget_Request *wr = data;
647
648 if (eio_file_check(handler))
649 return ;
650 if (!wr->wd->files_list || !wr->wd->files_grid) return ;
651
652 _signal_first(wr);
653
654 if (wr->wd->mode == ELM_FILESELECTOR_LIST)
655 elm_genlist_item_direct_sorted_insert(wr->wd->files_list, eio_file_associate_find(handler, "type/list"),
656 eina_stringshare_ref(eio_file_associate_find(handler, "filename")),
657 wr->parent, ELM_GENLIST_ITEM_NONE, _file_list_cmp, NULL, NULL);
658 else if (wr->wd->mode == ELM_FILESELECTOR_GRID)
659 elm_gengrid_item_direct_sorted_insert(wr->wd->files_grid, eio_file_associate_find(handler, "type/grid"),
660 eina_stringshare_ref(eio_file_associate_find(handler, "filename")),
661 _file_grid_cmp, NULL, NULL);
662}
663
664static void
665_widget_request_cleanup(Widget_Request *wr)
666{
667 EINA_REFCOUNT_UNREF(wr->wd)
668 _widget_data_free(wr->wd);
669
670 eina_stringshare_del(wr->path);
671 free(wr);
672}
673
674static void
675_done_cb(void *data, Eio_File *handler __UNUSED__)
676{
677 Widget_Request *wr = data;
678
679 _signal_first(wr);
680
681 wr->wd->current = NULL;
682 _widget_request_cleanup(wr);
683}
684
685static void
686_error_cb(void *data, Eio_File *handler, int error __UNUSED__)
687{
688 Widget_Request *wr = data;
689
690 if (wr->wd->current == handler)
691 wr->wd->current = NULL;
692 _widget_request_cleanup(wr);
693}
694
695#endif
696
490static void 697static void
491_populate(Evas_Object *obj, 698_populate(Evas_Object *obj,
492 const char *path, 699 const char *path,
493 Elm_Genlist_Item *parent) 700 Elm_Genlist_Item *parent)
494{ 701{
495 Widget_Data *wd = elm_widget_data_get(obj); 702 Widget_Data *wd = elm_widget_data_get(obj);
703#ifdef HAVE_EIO
704 Widget_Request *wr;
705#else
496 Eina_File_Direct_Info *file; 706 Eina_File_Direct_Info *file;
497 Eina_Iterator *it; 707 Eina_Iterator *it;
498 const char *real; 708 const char *real;
499 Eina_List *files = NULL, *dirs = NULL; 709 Eina_List *files = NULL, *dirs = NULL;
710#endif
500 711
501 if ((!wd) || (!ecore_file_is_dir(path))) return; 712 if (!wd) return;
713#ifndef HAVE_EIO
714 if (!ecore_file_is_dir(path)) return ;
502 it = eina_file_stat_ls(path); 715 it = eina_file_stat_ls(path);
503 if (!it) return ; 716 if (!it) return ;
504 evas_object_smart_callback_call(obj, SIG_DIRECTORY_OPEN, (void *)path); 717 evas_object_smart_callback_call(obj, SIG_DIRECTORY_OPEN, (void *)path);
@@ -532,30 +745,52 @@ _populate(Evas_Object *obj,
532 EINA_LIST_FREE(dirs, real) 745 EINA_LIST_FREE(dirs, real)
533 { 746 {
534 if (wd->mode == ELM_FILESELECTOR_LIST) 747 if (wd->mode == ELM_FILESELECTOR_LIST)
535 elm_genlist_item_append(wd->files_list, &list_itc, 748 elm_genlist_item_append(wd->files_list, &list_itc[ELM_DIRECTORY],
536 real, /* item data */ 749 real, /* item data */
537 parent, 750 parent,
538 wd->expand ? ELM_GENLIST_ITEM_SUBITEMS : 751 wd->expand ? ELM_GENLIST_ITEM_SUBITEMS :
539 ELM_GENLIST_ITEM_NONE, 752 ELM_GENLIST_ITEM_NONE,
540 NULL, NULL); 753 NULL, NULL);
541 else if (wd->mode == ELM_FILESELECTOR_GRID) 754 else if (wd->mode == ELM_FILESELECTOR_GRID)
542 elm_gengrid_item_append(wd->files_grid, &grid_itc, 755 elm_gengrid_item_append(wd->files_grid, &grid_itc[ELM_DIRECTORY],
543 real, /* item data */ 756 real, /* item data */
544 NULL, NULL); 757 NULL, NULL);
545 } 758 }
546 759
547 EINA_LIST_FREE(files, real) 760 EINA_LIST_FREE(files, real)
548 { 761 {
762 Elm_Fileselector_Type type = evas_object_image_extension_can_load_fast_get(real) ?
763 ELM_FILE_IMAGE : ELM_FILE_UNKNOW;
764
549 if (wd->mode == ELM_FILESELECTOR_LIST) 765 if (wd->mode == ELM_FILESELECTOR_LIST)
550 elm_genlist_item_append(wd->files_list, &list_itc, 766 elm_genlist_item_append(wd->files_list, &list_itc[type],
551 real, /* item data */ 767 real, /* item data */
552 parent, ELM_GENLIST_ITEM_NONE, 768 parent, ELM_GENLIST_ITEM_NONE,
553 NULL, NULL); 769 NULL, NULL);
554 else if (wd->mode == ELM_FILESELECTOR_GRID) 770 else if (wd->mode == ELM_FILESELECTOR_GRID)
555 elm_gengrid_item_append(wd->files_grid, &grid_itc, 771 elm_gengrid_item_append(wd->files_grid, &grid_itc[type],
556 real, /* item data */ 772 real, /* item data */
557 NULL, NULL); 773 NULL, NULL);
558 } 774 }
775#else
776 if (wd->current)
777 eio_file_cancel(wd->current);
778 wr = malloc(sizeof (Widget_Request));
779 if (!wr) return ;
780 wr->wd = wd;
781 EINA_REFCOUNT_REF(wr->wd);
782 wr->parent = parent; /* FIXME: should we refcount the parent ? */
783 wr->obj = obj;
784 wr->path = eina_stringshare_add(path);
785 wr->first = EINA_TRUE;
786
787 wd->current = eio_file_stat_ls(path,
788 _filter_cb,
789 _main_cb,
790 _done_cb,
791 _error_cb,
792 wr);
793#endif
559} 794}
560 795
561/*** API ***/ 796/*** API ***/
@@ -574,10 +809,13 @@ elm_fileselector_add(Evas_Object *parent)
574 Evas *e; 809 Evas *e;
575 Evas_Object *obj, *ic, *bt, *li, *en, *grid; 810 Evas_Object *obj, *ic, *bt, *li, *en, *grid;
576 Widget_Data *wd; 811 Widget_Data *wd;
812 unsigned int i;
577 int s; 813 int s;
578 814
579 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL); 815 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
580 816
817 EINA_REFCOUNT_INIT(wd);
818
581 ELM_SET_WIDTYPE(widtype, "fileselector"); 819 ELM_SET_WIDTYPE(widtype, "fileselector");
582 elm_widget_type_set(obj, "fileselector"); 820 elm_widget_type_set(obj, "fileselector");
583 elm_widget_sub_object_add(parent, obj); 821 elm_widget_sub_object_add(parent, obj);
@@ -622,11 +860,16 @@ elm_fileselector_add(Evas_Object *parent)
622 elm_widget_sub_object_add(obj, bt); 860 elm_widget_sub_object_add(obj, bt);
623 wd->home_button = bt; 861 wd->home_button = bt;
624 862
625 list_itc.item_style = grid_itc.item_style = "default"; 863 list_itc[ELM_DIRECTORY].func.icon_get = grid_itc[ELM_DIRECTORY].func.icon_get = _itc_icon_folder_get;
626 list_itc.func.label_get = grid_itc.func.label_get = _itc_label_get; 864 list_itc[ELM_FILE_IMAGE].func.icon_get = grid_itc[ELM_FILE_IMAGE].func.icon_get = _itc_icon_image_get;
627 list_itc.func.icon_get = grid_itc.func.icon_get = _itc_icon_get; 865 list_itc[ELM_FILE_UNKNOW].func.icon_get = grid_itc[ELM_FILE_UNKNOW].func.icon_get = _itc_icon_file_get;
628 list_itc.func.state_get = grid_itc.func.state_get = _itc_state_get; 866
629 list_itc.func.del = grid_itc.func.del = _itc_del; 867 for (i = 0; i < ELM_FILE_LAST; ++i)
868 {
869 list_itc[i].func.label_get = grid_itc[i].func.label_get = _itc_label_get;
870 list_itc[i].func.state_get = grid_itc[i].func.state_get = _itc_state_get;
871 list_itc[i].func.del = grid_itc[i].func.del = _itc_del;
872 }
630 873
631 li = elm_genlist_add(parent); 874 li = elm_genlist_add(parent);
632 elm_widget_mirrored_automatic_set(li, EINA_FALSE); 875 elm_widget_mirrored_automatic_set(li, EINA_FALSE);