diff --git a/configure.ac b/configure.ac index 8f988be..0657283 100644 --- a/configure.ac +++ b/configure.ac @@ -21,6 +21,7 @@ requirements="\ elementary >= ${efl_version} \ edje >= ${efl_version} \ emotion >= ${efl_version} \ + eio >= ${efl_version} \ " PKG_CHECK_MODULES([RAGE], [${requirements}]) diff --git a/src/bin/dnd.c b/src/bin/dnd.c index f6b2eaf..541d1fe 100644 --- a/src/bin/dnd.c +++ b/src/bin/dnd.c @@ -1,4 +1,5 @@ #include +#include #include "main.h" #include "win.h" #include "winvid.h" @@ -60,37 +61,59 @@ _escape_parse(const char *str) return dest; } -static Eina_Bool -_recurse_dir(Evas_Object *win, const char *path) +struct _recurse_data { - Eina_Bool ret = EINA_FALSE; - Eina_List *ls, *l; - char *p, *escape; - const char *full; + Evas_Object *win; + Eina_Bool inserted; +}; - ls = ecore_file_ls(path); - EINA_LIST_FOREACH(ls, l, p) +static void +_cb_recurse_end(void *data, Eio_File *f EINA_UNUSED) +{ + struct _recurse_data *d = data; + if (d->inserted) { - escape = _escape_parse(p); - full = eina_stringshare_printf("%s/%s", path, escape); - free(escape); - if (ecore_file_is_dir(full)) - { - ret = _recurse_dir(win, full); - eina_stringshare_del(full); - continue; - } - - printf("inserting '%s'\n", full); - win_video_insert(win, full); - eina_stringshare_del(full); - ret = EINA_TRUE; + win_video_next(d->win); + win_list_content_update(d->win); } - EINA_LIST_FREE(ls, p) - free(p); + free(d); +} - return ret; +static void +_cb_recurse_error(void *data EINA_UNUSED, Eio_File *f EINA_UNUSED, int error) +{ + printf("error recursing: %d\n", error); +} + +static Eina_Bool +_cb_recurse_filter(void *data EINA_UNUSED, Eio_File *f EINA_UNUSED, const Eina_File_Direct_Info *info) +{ + return info->type == EINA_FILE_REG || info->type == EINA_FILE_DIR; +} + +static void +_cb_recurse(void *data, Eio_File *f EINA_UNUSED, const Eina_File_Direct_Info *info) +{ + struct _recurse_data *d = data; + char *path; + if (info->type == EINA_FILE_DIR) + return; + + path = _escape_parse(info->path); + printf("inserting '%s'\n", path); + win_video_insert(d->win, path); + d->inserted = EINA_TRUE; + free(path); +} + +static void +_recurse_dir(Evas_Object *win, const char *path) +{ + struct _recurse_data *data = calloc(1, sizeof(*data)); + data->win = win; + eio_dir_stat_ls(path, _cb_recurse_filter, _cb_recurse, _cb_recurse_end, + _cb_recurse_error, data); } Eina_Bool @@ -128,7 +151,7 @@ _cb_drop(void *data, Evas_Object *o EINA_UNUSED, Elm_Selection_Data *ev) { if (ecore_file_is_dir(tt)) { - inserted = _recurse_dir(win, tt); + _recurse_dir(win, tt); } else { @@ -149,7 +172,7 @@ _cb_drop(void *data, Evas_Object *o EINA_UNUSED, Elm_Selection_Data *ev) { if (ecore_file_is_dir(tt)) { - inserted = _recurse_dir(win, tt); + _recurse_dir(win, tt); } else { @@ -172,7 +195,7 @@ _cb_drop(void *data, Evas_Object *o EINA_UNUSED, Elm_Selection_Data *ev) { if (ecore_file_is_dir(tt)) { - inserted = _recurse_dir(win, tt); + _recurse_dir(win, tt); } else { @@ -193,6 +216,7 @@ _cb_drop(void *data, Evas_Object *o EINA_UNUSED, Elm_Selection_Data *ev) void dnd_init(Evas_Object *win, Evas_Object *tgt) { + eio_init(); elm_drop_target_add(tgt, ELM_SEL_FORMAT_TEXT | ELM_SEL_FORMAT_IMAGE, _cb_drag_enter, win, @@ -200,3 +224,9 @@ dnd_init(Evas_Object *win, Evas_Object *tgt) _cb_drag_pos, win, _cb_drop, win); } + +void +dnd_shutdown(void) +{ + eio_shutdown(); +} diff --git a/src/bin/dnd.h b/src/bin/dnd.h index 32d9b02..7cca372 100644 --- a/src/bin/dnd.h +++ b/src/bin/dnd.h @@ -2,5 +2,6 @@ #define _DND_H__ 1 void dnd_init(Evas_Object *win, Evas_Object *tgt); +void dnd_shutdown(void); #endif diff --git a/src/bin/win.c b/src/bin/win.c index 938c179..6a1e6d7 100644 --- a/src/bin/win.c +++ b/src/bin/win.c @@ -48,6 +48,7 @@ _cb_win_del(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void } evas_object_data_del(obj, "inf"); free(inf); + dnd_shutdown(); } static void