dnd: Recurse into directories using eio
Signed-off-by: Eduardo Lima (Etrunko) <eduardo.lima@intel.com>
This commit is contained in:
parent
4b4be34131
commit
3813ef7c45
|
@ -21,6 +21,7 @@ requirements="\
|
||||||
elementary >= ${efl_version} \
|
elementary >= ${efl_version} \
|
||||||
edje >= ${efl_version} \
|
edje >= ${efl_version} \
|
||||||
emotion >= ${efl_version} \
|
emotion >= ${efl_version} \
|
||||||
|
eio >= ${efl_version} \
|
||||||
"
|
"
|
||||||
PKG_CHECK_MODULES([RAGE], [${requirements}])
|
PKG_CHECK_MODULES([RAGE], [${requirements}])
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <Elementary.h>
|
#include <Elementary.h>
|
||||||
|
#include <Eio.h>
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "win.h"
|
#include "win.h"
|
||||||
#include "winvid.h"
|
#include "winvid.h"
|
||||||
|
@ -60,37 +61,59 @@ _escape_parse(const char *str)
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
struct _recurse_data
|
||||||
_recurse_dir(Evas_Object *win, const char *path)
|
|
||||||
{
|
{
|
||||||
Eina_Bool ret = EINA_FALSE;
|
Evas_Object *win;
|
||||||
Eina_List *ls, *l;
|
Eina_Bool inserted;
|
||||||
char *p, *escape;
|
};
|
||||||
const char *full;
|
|
||||||
|
|
||||||
ls = ecore_file_ls(path);
|
static void
|
||||||
EINA_LIST_FOREACH(ls, l, p)
|
_cb_recurse_end(void *data, Eio_File *f EINA_UNUSED)
|
||||||
|
{
|
||||||
|
struct _recurse_data *d = data;
|
||||||
|
if (d->inserted)
|
||||||
{
|
{
|
||||||
escape = _escape_parse(p);
|
win_video_next(d->win);
|
||||||
full = eina_stringshare_printf("%s/%s", path, escape);
|
win_list_content_update(d->win);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EINA_LIST_FREE(ls, p)
|
free(d);
|
||||||
free(p);
|
}
|
||||||
|
|
||||||
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
|
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))
|
if (ecore_file_is_dir(tt))
|
||||||
{
|
{
|
||||||
inserted = _recurse_dir(win, tt);
|
_recurse_dir(win, tt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -149,7 +172,7 @@ _cb_drop(void *data, Evas_Object *o EINA_UNUSED, Elm_Selection_Data *ev)
|
||||||
{
|
{
|
||||||
if (ecore_file_is_dir(tt))
|
if (ecore_file_is_dir(tt))
|
||||||
{
|
{
|
||||||
inserted = _recurse_dir(win, tt);
|
_recurse_dir(win, tt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -172,7 +195,7 @@ _cb_drop(void *data, Evas_Object *o EINA_UNUSED, Elm_Selection_Data *ev)
|
||||||
{
|
{
|
||||||
if (ecore_file_is_dir(tt))
|
if (ecore_file_is_dir(tt))
|
||||||
{
|
{
|
||||||
inserted = _recurse_dir(win, tt);
|
_recurse_dir(win, tt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -193,6 +216,7 @@ _cb_drop(void *data, Evas_Object *o EINA_UNUSED, Elm_Selection_Data *ev)
|
||||||
void
|
void
|
||||||
dnd_init(Evas_Object *win, Evas_Object *tgt)
|
dnd_init(Evas_Object *win, Evas_Object *tgt)
|
||||||
{
|
{
|
||||||
|
eio_init();
|
||||||
elm_drop_target_add(tgt,
|
elm_drop_target_add(tgt,
|
||||||
ELM_SEL_FORMAT_TEXT | ELM_SEL_FORMAT_IMAGE,
|
ELM_SEL_FORMAT_TEXT | ELM_SEL_FORMAT_IMAGE,
|
||||||
_cb_drag_enter, win,
|
_cb_drag_enter, win,
|
||||||
|
@ -200,3 +224,9 @@ dnd_init(Evas_Object *win, Evas_Object *tgt)
|
||||||
_cb_drag_pos, win,
|
_cb_drag_pos, win,
|
||||||
_cb_drop, win);
|
_cb_drop, win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dnd_shutdown(void)
|
||||||
|
{
|
||||||
|
eio_shutdown();
|
||||||
|
}
|
||||||
|
|
|
@ -2,5 +2,6 @@
|
||||||
#define _DND_H__ 1
|
#define _DND_H__ 1
|
||||||
|
|
||||||
void dnd_init(Evas_Object *win, Evas_Object *tgt);
|
void dnd_init(Evas_Object *win, Evas_Object *tgt);
|
||||||
|
void dnd_shutdown(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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");
|
evas_object_data_del(obj, "inf");
|
||||||
free(inf);
|
free(inf);
|
||||||
|
dnd_shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue