forked from enlightenment/edi
filelist: Actually update on file add/rm
This is pretty much working except some genlist bugs :(
This commit is contained in:
parent
539953bc72
commit
5abd439e3e
|
@ -323,15 +323,63 @@ _on_list_contracted(void *data EINA_UNUSED,
|
||||||
_file_listing_empty(sd, it);
|
_file_listing_empty(sd, it);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static Elm_Object_Item *_file_listing_item_find(const char *path, Elm_Object_Item *root)
|
||||||
_ls_main_cb(void *data,
|
{
|
||||||
Eio_File *handler,
|
Elm_Object_Item *item;
|
||||||
const Eina_File_Direct_Info *info)
|
Edi_Dir_Data *sd;
|
||||||
|
const Eina_List *itemlist, *l;
|
||||||
|
|
||||||
|
if (root)
|
||||||
|
itemlist = elm_genlist_item_subitems_get(root);
|
||||||
|
else
|
||||||
|
itemlist = elm_genlist_realized_items_get(list);
|
||||||
|
EINA_LIST_FOREACH(itemlist, l, item)
|
||||||
|
{
|
||||||
|
sd = elm_object_item_data_get(item);
|
||||||
|
|
||||||
|
if (!strcmp(path, sd->path))
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_file_listing_item_insert(const char *path, Eina_Bool isdir, Elm_Object_Item *parent_it)
|
||||||
{
|
{
|
||||||
Listing_Request *lreq = data;
|
|
||||||
Elm_Genlist_Item_Class *clas = &itc;
|
Elm_Genlist_Item_Class *clas = &itc;
|
||||||
Edi_Dir_Data *sd;
|
Edi_Dir_Data *sd;
|
||||||
|
|
||||||
|
sd = calloc(1, sizeof(Edi_Dir_Data));
|
||||||
|
if (isdir)
|
||||||
|
{
|
||||||
|
clas = &itc2;
|
||||||
|
sd->isdir = EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
sd->path = eina_stringshare_add(path);
|
||||||
|
(void)!elm_genlist_item_sorted_insert(list, clas, sd, parent_it,
|
||||||
|
isdir ? ELM_GENLIST_ITEM_TREE : ELM_GENLIST_ITEM_NONE,
|
||||||
|
_file_list_cmp, _item_sel, sd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_file_listing_item_delete(const char *path, Elm_Object_Item *parent_it)
|
||||||
|
{
|
||||||
|
Elm_Object_Item *item;
|
||||||
|
|
||||||
|
item = _file_listing_item_find(path, parent_it);
|
||||||
|
if (!item)
|
||||||
|
return;
|
||||||
|
|
||||||
|
elm_object_item_del(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_ls_main_cb(void *data, Eio_File *handler, const Eina_File_Direct_Info *info)
|
||||||
|
{
|
||||||
|
Listing_Request *lreq = data;
|
||||||
|
|
||||||
if (eio_file_check(handler)) return;
|
if (eio_file_check(handler)) return;
|
||||||
|
|
||||||
//if (!lreq->sd->files_view || lreq->sd->current != handler)
|
//if (!lreq->sd->files_view || lreq->sd->current != handler)
|
||||||
|
@ -342,17 +390,7 @@ _ls_main_cb(void *data,
|
||||||
|
|
||||||
// _signal_first(lreq);
|
// _signal_first(lreq);
|
||||||
|
|
||||||
sd = calloc(1, sizeof(Edi_Dir_Data));
|
_file_listing_item_insert(info->path, info->type == EINA_FILE_DIR, lreq->parent_it);
|
||||||
if (info->type == EINA_FILE_DIR)
|
|
||||||
{
|
|
||||||
clas = &itc2;
|
|
||||||
sd->isdir = EINA_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
sd->path = eina_stringshare_add(info->path);
|
|
||||||
(void)!elm_genlist_item_sorted_insert(list, clas, sd, lreq->parent_it,
|
|
||||||
(clas == &itc2) ? ELM_GENLIST_ITEM_TREE : ELM_GENLIST_ITEM_NONE,
|
|
||||||
_file_list_cmp, _item_sel, sd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -404,9 +442,21 @@ _file_listing_updated(void *data EINA_UNUSED, int type EINA_UNUSED,
|
||||||
{
|
{
|
||||||
const char *dir;
|
const char *dir;
|
||||||
Eio_Monitor_Event *ev = event;
|
Eio_Monitor_Event *ev = event;
|
||||||
|
Elm_Object_Item *parent_it;
|
||||||
|
|
||||||
dir = ecore_file_dir_get(ev->filename);
|
dir = ecore_file_dir_get(ev->filename);
|
||||||
|
parent_it = _file_listing_item_find(dir, NULL);
|
||||||
|
|
||||||
|
if (type == EIO_MONITOR_FILE_CREATED)
|
||||||
|
_file_listing_item_insert(ev->filename, EINA_FALSE, parent_it);
|
||||||
|
else if (type == EIO_MONITOR_FILE_DELETED)
|
||||||
|
_file_listing_item_delete(ev->filename, parent_it);
|
||||||
|
if (type == EIO_MONITOR_DIRECTORY_CREATED)
|
||||||
|
_file_listing_item_insert(ev->filename, EINA_TRUE, parent_it);
|
||||||
|
else if (type == EIO_MONITOR_DIRECTORY_DELETED)
|
||||||
|
_file_listing_item_delete(ev->filename, parent_it);
|
||||||
|
else
|
||||||
|
DBG("Ignoring file update event for %s", ev->filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Panel filtering */
|
/* Panel filtering */
|
||||||
|
|
Loading…
Reference in New Issue