Ephoto: Move back to using EIO for file system monitoring

This commit is contained in:
Stephen okra Houston 2016-08-02 13:27:01 -05:00
parent 7d663786a2
commit a8cd52c266
4 changed files with 231 additions and 92 deletions

View File

@ -263,7 +263,8 @@ struct _Ephoto
Eina_Bool folders_toggle; Eina_Bool folders_toggle;
Eina_Bool editor_blocking; Eina_Bool editor_blocking;
Ecore_File_Monitor *monitor; Eio_Monitor *monitor;
Eina_List *monitor_handlers;
Ecore_Thread *file_thread; Ecore_Thread *file_thread;
Eina_List *file_pos; Eina_List *file_pos;
Eina_List *upload_handlers; Eina_List *upload_handlers;
@ -301,7 +302,8 @@ struct _Ephoto_Entry
const char *label; const char *label;
double size; double size;
Ephoto *ephoto; Ephoto *ephoto;
Ecore_File_Monitor *monitor; Eio_Monitor *monitor;
Eina_List *monitor_handlers;
Elm_Object_Item *item; Elm_Object_Item *item;
Elm_Object_Item *parent; Elm_Object_Item *parent;
Eina_List *free_listeners; Eina_List *free_listeners;

View File

@ -21,7 +21,8 @@ struct _Ephoto_Directory_Browser
Eio_File *ls; Eio_File *ls;
Eina_Bool dirs_only; Eina_Bool dirs_only;
Eina_Bool thumbs_only; Eina_Bool thumbs_only;
Ecore_File_Monitor *monitor; Eio_Monitor *monitor;
Eina_List *monitor_handlers;
Eina_List *handlers; Eina_List *handlers;
Eina_List *todo_items; Eina_List *todo_items;
Ecore_Job *change_dir_job; Ecore_Job *change_dir_job;
@ -706,38 +707,40 @@ _todo_items_free(Ephoto_Directory_Browser *db)
db->todo_items = NULL; db->todo_items = NULL;
} }
static void static Eina_Bool
_monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED, _monitor_cb(void *data, int type,
Ecore_File_Event event, const char *path) void *event)
{ {
Elm_Object_Item *item; Elm_Object_Item *item;
Ephoto_Entry *entry = data; Ephoto_Entry *entry = data;
Ephoto_Entry *e; Ephoto_Entry *e;
Ecore_Event_Handler *handler;
Eio_Monitor_Event *ev = event;
char file[PATH_MAX], dir[PATH_MAX]; char file[PATH_MAX], dir[PATH_MAX];
const Elm_Genlist_Item_Class *ic; const Elm_Genlist_Item_Class *ic;
char buf[PATH_MAX]; char buf[PATH_MAX];
if (!entry) if (!entry)
return; return ECORE_CALLBACK_PASS_ON;
snprintf(file, PATH_MAX, "%s", path); snprintf(file, PATH_MAX, "%s", ev->filename);
snprintf(dir, PATH_MAX, "%s", ecore_file_dir_get(file)); snprintf(dir, PATH_MAX, "%s", ecore_file_dir_get(file));
if (strcmp(entry->path, dir)) if (strcmp(entry->path, dir))
return; return ECORE_CALLBACK_PASS_ON;
if (event == ECORE_FILE_EVENT_CREATED_DIRECTORY) if (type == EIO_MONITOR_DIRECTORY_CREATED)
{ {
if (!ecore_file_is_dir(path)) if (!ecore_file_is_dir(ev->filename))
return; return ECORE_CALLBACK_PASS_ON;
if (ephoto_entry_exists(entry->ephoto, path)) if (ephoto_entry_exists(entry->ephoto, ev->filename))
return; return ECORE_CALLBACK_PASS_ON;
if (elm_genlist_item_type_get(entry->item) == ELM_GENLIST_ITEM_TREE && if (elm_genlist_item_type_get(entry->item) == ELM_GENLIST_ITEM_TREE &&
elm_genlist_item_expanded_get(entry->item) == EINA_TRUE) elm_genlist_item_expanded_get(entry->item) == EINA_TRUE)
{ {
ic = _ephoto_dir_tree_class; ic = _ephoto_dir_tree_class;
snprintf(buf, PATH_MAX, "%s", path); snprintf(buf, PATH_MAX, "%s", ev->filename);
e = ephoto_entry_new(entry->ephoto, path, basename(buf), e = ephoto_entry_new(entry->ephoto, ev->filename, basename(buf),
EINA_FILE_DIR); EINA_FILE_DIR);
e->genlist = entry->genlist; e->genlist = entry->genlist;
e->parent = entry->item; e->parent = entry->item;
@ -745,7 +748,21 @@ _monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED,
elm_genlist_item_sorted_insert(entry->genlist, ic, e, elm_genlist_item_sorted_insert(entry->genlist, ic, e,
e->parent, ELM_GENLIST_ITEM_NONE, _entry_cmp, NULL, NULL); e->parent, ELM_GENLIST_ITEM_NONE, _entry_cmp, NULL, NULL);
if (e->item) if (e->item)
e->monitor = ecore_file_monitor_add(e->path, _monitor_cb, e); {
e->monitor = eio_monitor_add(e->path);
e->monitor_handlers =
eina_list_append(e->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_DIRECTORY_CREATED,
_monitor_cb, e));
e->monitor_handlers =
eina_list_append(e->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_DIRECTORY_MODIFIED,
_monitor_cb, e));
e->monitor_handlers =
eina_list_append(e->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_DIRECTORY_DELETED,
_monitor_cb, e));
}
} }
if (elm_genlist_item_type_get(entry->item) == ELM_GENLIST_ITEM_NONE) if (elm_genlist_item_type_get(entry->item) == ELM_GENLIST_ITEM_NONE)
{ {
@ -757,21 +774,37 @@ _monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED,
entry->parent, entry->item, ELM_GENLIST_ITEM_TREE, NULL, NULL); entry->parent, entry->item, ELM_GENLIST_ITEM_TREE, NULL, NULL);
entry->no_delete = EINA_TRUE; entry->no_delete = EINA_TRUE;
if (entry->monitor) if (entry->monitor)
ecore_file_monitor_del(entry->monitor); {
eio_monitor_del(entry->monitor);
EINA_LIST_FREE(entry->monitor_handlers, handler)
ecore_event_handler_del(handler);
}
elm_object_item_del(entry->item); elm_object_item_del(entry->item);
entry->item = parent; entry->item = parent;
entry->no_delete = EINA_FALSE; entry->no_delete = EINA_FALSE;
entry->monitor = ecore_file_monitor_add(entry->path, _monitor_cb, entry); entry->monitor = eio_monitor_add(entry->path);
entry->monitor_handlers =
eina_list_append(entry->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_DIRECTORY_CREATED,
_monitor_cb, entry));
entry->monitor_handlers =
eina_list_append(entry->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_DIRECTORY_MODIFIED,
_monitor_cb, entry));
entry->monitor_handlers =
eina_list_append(entry->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_DIRECTORY_DELETED,
_monitor_cb, entry));
} }
return; return ECORE_CALLBACK_PASS_ON;
} }
else if (event == ECORE_FILE_EVENT_DELETED_DIRECTORY) else if (type == EIO_MONITOR_DIRECTORY_DELETED)
{ {
item = elm_genlist_first_item_get(entry->genlist); item = elm_genlist_first_item_get(entry->genlist);
while (item) while (item)
{ {
e = elm_object_item_data_get(item); e = elm_object_item_data_get(item);
if (!strcmp(e->path, path)) if (!strcmp(e->path, ev->filename))
{ {
elm_object_item_del(e->item); elm_object_item_del(e->item);
//if (!strcmp(e->path, e->ephoto->config->directory)) //if (!strcmp(e->path, e->ephoto->config->directory))
@ -798,19 +831,19 @@ _monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED,
ephoto_directory_set(entry->ephoto, entry->path, entry->parent, 0, 1); ephoto_directory_set(entry->ephoto, entry->path, entry->parent, 0, 1);
ephoto_title_set(entry->ephoto, entry->path); ephoto_title_set(entry->ephoto, entry->path);
} }
return; return ECORE_CALLBACK_PASS_ON;
} }
else if (event == ECORE_FILE_EVENT_MODIFIED) else if (type == EIO_MONITOR_DIRECTORY_MODIFIED)
{ {
if (!ecore_file_is_dir(path)) if (!ecore_file_is_dir(ev->filename))
return; return ECORE_CALLBACK_PASS_ON;
if ((elm_genlist_item_expanded_get(entry->item) == EINA_TRUE)) if ((elm_genlist_item_expanded_get(entry->item) == EINA_TRUE))
{ {
item = elm_genlist_first_item_get(entry->genlist); item = elm_genlist_first_item_get(entry->genlist);
while (item) while (item)
{ {
e = elm_object_item_data_get(item); e = elm_object_item_data_get(item);
if (!strcmp(e->path, path)) if (!strcmp(e->path, ev->filename))
{ {
elm_genlist_item_update(e->item); elm_genlist_item_update(e->item);
break; break;
@ -818,35 +851,37 @@ _monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED,
item = elm_genlist_item_next_get(item); item = elm_genlist_item_next_get(item);
} }
} }
return; return ECORE_CALLBACK_PASS_ON;
} }
return ECORE_CALLBACK_PASS_ON;
} }
static void static Eina_Bool
_top_monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED, _top_monitor_cb(void *data, int type,
Ecore_File_Event event, const char *path) void *event)
{ {
Elm_Object_Item *item; Elm_Object_Item *item;
Ephoto_Directory_Browser *db = data; Ephoto_Directory_Browser *db = data;
Ephoto_Entry *e; Ephoto_Entry *e;
Eio_Monitor_Event *ev = event;
const Elm_Genlist_Item_Class *ic; const Elm_Genlist_Item_Class *ic;
char buf[PATH_MAX], file[PATH_MAX], dir[PATH_MAX]; char buf[PATH_MAX], file[PATH_MAX], dir[PATH_MAX];
if (!db) if (!db)
return; return ECORE_CALLBACK_PASS_ON;
snprintf(file, PATH_MAX, "%s", path); snprintf(file, PATH_MAX, "%s", ev->filename);
snprintf(dir, PATH_MAX, "%s", ecore_file_dir_get(file)); snprintf(dir, PATH_MAX, "%s", ecore_file_dir_get(file));
if (strcmp(db->ephoto->top_directory, dir)) if (strcmp(db->ephoto->top_directory, dir))
return; return ECORE_CALLBACK_PASS_ON;
if (event == ECORE_FILE_EVENT_CREATED_DIRECTORY) if (type == EIO_MONITOR_DIRECTORY_CREATED)
{ {
if (!ecore_file_is_dir(path)) if (!ecore_file_is_dir(ev->filename))
return; return ECORE_CALLBACK_PASS_ON;
if (ephoto_entry_exists(db->ephoto, path)) if (ephoto_entry_exists(db->ephoto, ev->filename))
return; return ECORE_CALLBACK_PASS_ON;
snprintf(buf, PATH_MAX, "%s", path); snprintf(buf, PATH_MAX, "%s", ev->filename);
e = ephoto_entry_new(db->ephoto, path, basename(buf), e = ephoto_entry_new(db->ephoto, ev->filename, basename(buf),
EINA_FILE_DIR); EINA_FILE_DIR);
e->genlist = db->fsel; e->genlist = db->fsel;
ic = _ephoto_dir_class; ic = _ephoto_dir_class;
@ -854,18 +889,32 @@ _top_monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED,
elm_genlist_item_append(db->fsel, ic, e, elm_genlist_item_append(db->fsel, ic, e,
NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
if (e->item) if (e->item)
e->monitor = ecore_file_monitor_add(e->path, _monitor_cb, e); {
return; e->monitor = eio_monitor_add(e->path);
e->monitor_handlers =
eina_list_append(e->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_DIRECTORY_CREATED,
_monitor_cb, e));
e->monitor_handlers =
eina_list_append(e->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_DIRECTORY_MODIFIED,
_monitor_cb, e));
e->monitor_handlers =
eina_list_append(e->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_DIRECTORY_DELETED,
_monitor_cb, e));
}
return ECORE_CALLBACK_PASS_ON;
} }
else if (event == ECORE_FILE_EVENT_DELETED_DIRECTORY) else if (type == EIO_MONITOR_DIRECTORY_DELETED)
{ {
item = elm_genlist_first_item_get(db->fsel); item = elm_genlist_first_item_get(db->fsel);
while (item) while (item)
{ {
e = elm_object_item_data_get(item); e = elm_object_item_data_get(item);
if (!strcmp(e->path, path)) if (!strcmp(e->path, ev->filename))
{ {
if (!strcmp(path, db->ephoto->config->directory)) if (!strcmp(ev->filename, db->ephoto->config->directory))
elm_genlist_item_expanded_set(e->parent, EINA_TRUE); elm_genlist_item_expanded_set(e->parent, EINA_TRUE);
else else
elm_object_item_del(e->item); elm_object_item_del(e->item);
@ -873,25 +922,26 @@ _top_monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED,
} }
item = elm_genlist_item_next_get(item); item = elm_genlist_item_next_get(item);
} }
return; return ECORE_CALLBACK_PASS_ON;
} }
else if (event == ECORE_FILE_EVENT_MODIFIED) else if (type == EIO_MONITOR_DIRECTORY_MODIFIED)
{ {
if (!ecore_file_is_dir(path)) if (!ecore_file_is_dir(ev->filename))
return; return ECORE_CALLBACK_PASS_ON;
item = elm_genlist_first_item_get(db->fsel); item = elm_genlist_first_item_get(db->fsel);
while (item) while (item)
{ {
e = elm_object_item_data_get(item); e = elm_object_item_data_get(item);
if (!strcmp(e->path, path)) if (!strcmp(e->path, ev->filename))
{ {
elm_genlist_item_update(e->item); elm_genlist_item_update(e->item);
break; break;
} }
item = elm_genlist_item_next_get(item); item = elm_genlist_item_next_get(item);
} }
return; return ECORE_CALLBACK_PASS_ON;
} }
return ECORE_CALLBACK_PASS_ON;
} }
static Eina_Bool static Eina_Bool
@ -942,8 +992,20 @@ _todo_items_process(void *data)
} }
else else
{ {
entry->monitor = ecore_file_monitor_add(entry->path, _monitor_cb, entry); entry->monitor = eio_monitor_add(entry->path);
entry->genlist = db->fsel; entry->monitor_handlers =
eina_list_append(entry->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_DIRECTORY_CREATED,
_monitor_cb, entry));
entry->monitor_handlers =
eina_list_append(entry->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_DIRECTORY_MODIFIED,
_monitor_cb, entry));
entry->monitor_handlers =
eina_list_append(entry->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_DIRECTORY_DELETED,
_monitor_cb, entry));
entry->genlist = db->fsel;
} }
} }
db->animator.processed++; db->animator.processed++;
@ -1036,7 +1098,11 @@ _ephoto_main_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
return; return;
} }
if (db->monitor) if (db->monitor)
ecore_file_monitor_del(db->monitor); {
eio_monitor_del(db->monitor);
EINA_LIST_FREE(db->monitor_handlers, handler)
ecore_event_handler_del(handler);
}
free(db); free(db);
} }
@ -1045,14 +1111,31 @@ ephoto_directory_browser_top_dir_set(Ephoto *ephoto, const char *dir)
{ {
Ephoto_Directory_Browser *db = Ephoto_Directory_Browser *db =
evas_object_data_get(ephoto->dir_browser, "directory_browser"); evas_object_data_get(ephoto->dir_browser, "directory_browser");
Ecore_Event_Handler *handler;
if (db->monitor) if (db->monitor)
ecore_file_monitor_del(db->monitor); {
eio_monitor_del(db->monitor);
EINA_LIST_FREE(db->monitor_handlers, handler)
ecore_event_handler_del(handler);
}
if (ephoto->top_directory) if (ephoto->top_directory)
eina_stringshare_replace(&ephoto->top_directory, dir); eina_stringshare_replace(&ephoto->top_directory, dir);
else else
ephoto->top_directory = eina_stringshare_add(dir); ephoto->top_directory = eina_stringshare_add(dir);
db->monitor = ecore_file_monitor_add(dir, _top_monitor_cb, db); db->monitor = eio_monitor_add(dir);
db->monitor_handlers =
eina_list_append(db->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_DIRECTORY_CREATED,
_top_monitor_cb, db));
db->monitor_handlers =
eina_list_append(db->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_DIRECTORY_MODIFIED,
_top_monitor_cb, db));
db->monitor_handlers =
eina_list_append(db->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_DIRECTORY_DELETED,
_top_monitor_cb, db));
} }
void void
@ -1124,7 +1207,19 @@ ephoto_directory_browser_initialize_structure(Ephoto *ephoto)
} }
else else
{ {
entry->monitor = ecore_file_monitor_add(entry->path, _monitor_cb, entry); entry->monitor = eio_monitor_add(entry->path);
entry->monitor_handlers =
eina_list_append(entry->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_DIRECTORY_CREATED,
_monitor_cb, entry));
entry->monitor_handlers =
eina_list_append(entry->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_DIRECTORY_MODIFIED,
_monitor_cb, entry));
entry->monitor_handlers =
eina_list_append(entry->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_DIRECTORY_DELETED,
_monitor_cb, entry));
entry->genlist = db->fsel; entry->genlist = db->fsel;
} }
if (n) if (n)

View File

@ -212,7 +212,11 @@ _win_free(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
if (ephoto->timer.thumb_regen) if (ephoto->timer.thumb_regen)
ecore_timer_del(ephoto->timer.thumb_regen); ecore_timer_del(ephoto->timer.thumb_regen);
if (ephoto->monitor) if (ephoto->monitor)
ecore_file_monitor_del(ephoto->monitor); {
eio_monitor_del(ephoto->monitor);
EINA_LIST_FREE(ephoto->monitor_handlers, handler)
ecore_event_handler_del(handler);
}
if (ephoto->overlay_timer) if (ephoto->overlay_timer)
ecore_timer_del(ephoto->overlay_timer); ecore_timer_del(ephoto->overlay_timer);
ephoto_config_save(ephoto); ephoto_config_save(ephoto);
@ -777,30 +781,31 @@ _ephoto_change_dir(void *data)
_ephoto_populate_entries(ed); _ephoto_populate_entries(ed);
} }
static void static Eina_Bool
_monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED, _monitor_cb(void *data, int type,
Ecore_File_Event event, const char *path) void *event)
{ {
Ephoto *ephoto = data; Ephoto *ephoto = data;
Eio_Monitor_Event *ev = event;
char file[PATH_MAX], dir[PATH_MAX]; char file[PATH_MAX], dir[PATH_MAX];
snprintf(file, PATH_MAX, "%s", path); snprintf(file, PATH_MAX, "%s", ev->filename);
snprintf(dir, PATH_MAX, "%s", ecore_file_dir_get(file)); snprintf(dir, PATH_MAX, "%s", ecore_file_dir_get(file));
if (strcmp(ephoto->config->directory, dir)) if (strcmp(ephoto->config->directory, dir))
return; return ECORE_CALLBACK_PASS_ON;
if (evas_object_image_extension_can_load_get(path)) if (evas_object_image_extension_can_load_get(ev->filename))
{ {
if (event == ECORE_FILE_EVENT_CREATED_FILE) if (type == EIO_MONITOR_FILE_CREATED)
{ {
Ephoto_Entry *entry; Ephoto_Entry *entry;
char buf[PATH_MAX]; char buf[PATH_MAX];
if (ephoto_entry_exists(ephoto, path)) if (ephoto_entry_exists(ephoto, ev->filename))
return; return ECORE_CALLBACK_PASS_ON;
snprintf(buf, PATH_MAX, "%s", path); snprintf(buf, PATH_MAX, "%s", ev->filename);
entry = ephoto_entry_new(ephoto, path, basename(buf), entry = ephoto_entry_new(ephoto, ev->filename, basename(buf),
EINA_FILE_REG); EINA_FILE_REG);
ephoto_single_browser_path_created(ephoto->single_browser, entry); ephoto_single_browser_path_created(ephoto->single_browser, entry);
if (!ephoto->entries) if (!ephoto->entries)
@ -824,25 +829,25 @@ _monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED,
near_node); near_node);
} }
ephoto_thumb_browser_insert(ephoto, entry); ephoto_thumb_browser_insert(ephoto, entry);
return; return ECORE_CALLBACK_PASS_ON;
} }
else if (event == ECORE_FILE_EVENT_DELETED_FILE) else if (type == EIO_MONITOR_FILE_DELETED)
{ {
Eina_List *l; Eina_List *l;
Ephoto_Entry *entry; Ephoto_Entry *entry;
EINA_LIST_FOREACH(ephoto->entries, l, entry) EINA_LIST_FOREACH(ephoto->entries, l, entry)
{ {
if (!strcmp(entry->path, path)) if (!strcmp(entry->path, ev->filename))
{ {
ephoto_thumb_browser_remove(ephoto, entry); ephoto_thumb_browser_remove(ephoto, entry);
ephoto_entry_free(ephoto, entry); ephoto_entry_free(ephoto, entry);
break; break;
} }
} }
return; return ECORE_CALLBACK_PASS_ON;
} }
else if (event == ECORE_FILE_EVENT_MODIFIED) else if (type == EIO_MONITOR_FILE_MODIFIED)
{ {
Eina_List *l; Eina_List *l;
Ephoto_Entry *entry; Ephoto_Entry *entry;
@ -850,7 +855,7 @@ _monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED,
EINA_LIST_FOREACH(ephoto->entries, l, entry) EINA_LIST_FOREACH(ephoto->entries, l, entry)
{ {
if (!strcmp(entry->path, path)) if (!strcmp(entry->path, ev->filename))
{ {
if (!ecore_file_exists(entry->path)) if (!ecore_file_exists(entry->path))
{ {
@ -872,10 +877,10 @@ _monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED,
{ {
char buf[PATH_MAX]; char buf[PATH_MAX];
if (ephoto_entry_exists(ephoto, path)) if (ephoto_entry_exists(ephoto, ev->filename))
return; return ECORE_CALLBACK_PASS_ON;
snprintf(buf, PATH_MAX, "%s", path); snprintf(buf, PATH_MAX, "%s", ev->filename);
entry = ephoto_entry_new(ephoto, path, basename(buf), entry = ephoto_entry_new(ephoto, ev->filename, basename(buf),
EINA_FILE_REG); EINA_FILE_REG);
ephoto_single_browser_path_created(ephoto->single_browser, entry); ephoto_single_browser_path_created(ephoto->single_browser, entry);
if (!ephoto->entries) if (!ephoto->entries)
@ -899,10 +904,11 @@ _monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED,
near_node); near_node);
} }
ephoto_thumb_browser_insert(ephoto, entry); ephoto_thumb_browser_insert(ephoto, entry);
return; return ECORE_CALLBACK_PASS_ON;
} }
} }
} }
return ECORE_CALLBACK_PASS_ON;
} }
void void
@ -910,6 +916,7 @@ ephoto_directory_set(Ephoto *ephoto, const char *path, Evas_Object *expanded,
Eina_Bool dirs_only, Eina_Bool thumbs_only) Eina_Bool dirs_only, Eina_Bool thumbs_only)
{ {
Ephoto_Dir_Data *ed; Ephoto_Dir_Data *ed;
Ecore_Event_Handler *handler;
ed = malloc(sizeof(Ephoto_Dir_Data)); ed = malloc(sizeof(Ephoto_Dir_Data));
ed->ephoto = ephoto; ed->ephoto = ephoto;
@ -928,8 +935,24 @@ ephoto_directory_set(Ephoto *ephoto, const char *path, Evas_Object *expanded,
ecore_job_del(ed->ephoto->job.change_dir); ecore_job_del(ed->ephoto->job.change_dir);
ed->ephoto->job.change_dir = ecore_job_add(_ephoto_change_dir, ed); ed->ephoto->job.change_dir = ecore_job_add(_ephoto_change_dir, ed);
if (ephoto->monitor) if (ephoto->monitor)
ecore_file_monitor_del(ephoto->monitor); {
ephoto->monitor = ecore_file_monitor_add(path, _monitor_cb, ephoto); eio_monitor_del(ephoto->monitor);
EINA_LIST_FREE(ephoto->monitor_handlers, handler)
ecore_event_handler_del(handler);
}
ephoto->monitor = eio_monitor_add(path);
ephoto->monitor_handlers =
eina_list_append(ephoto->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_FILE_CREATED,
_monitor_cb, ephoto));
ephoto->monitor_handlers =
eina_list_append(ephoto->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_FILE_MODIFIED,
_monitor_cb, ephoto));
ephoto->monitor_handlers =
eina_list_append(ephoto->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_FILE_DELETED,
_monitor_cb, ephoto));
} }
static Eina_Bool static Eina_Bool
@ -1095,6 +1118,7 @@ void
ephoto_entry_free(Ephoto *ephoto, Ephoto_Entry *entry) ephoto_entry_free(Ephoto *ephoto, Ephoto_Entry *entry)
{ {
Ephoto_Entry_Free_Listener *fl; Ephoto_Entry_Free_Listener *fl;
Ecore_Event_Handler *handler;
Eina_List *node; Eina_List *node;
EINA_LIST_FREE(entry->free_listeners, fl) EINA_LIST_FREE(entry->free_listeners, fl)
@ -1116,7 +1140,11 @@ ephoto_entry_free(Ephoto *ephoto, Ephoto_Entry *entry)
eina_stringshare_del(entry->path); eina_stringshare_del(entry->path);
eina_stringshare_del(entry->label); eina_stringshare_del(entry->label);
if (entry->monitor) if (entry->monitor)
ecore_file_monitor_del(entry->monitor); {
eio_monitor_del(entry->monitor);
EINA_LIST_FREE(entry->monitor_handlers, handler)
ecore_event_handler_del(handler);
}
free(entry); free(entry);
} }

View File

@ -32,7 +32,8 @@ struct _Ephoto_Single_Browser
struct _Ephoto_Viewer struct _Ephoto_Viewer
{ {
Eina_List *handlers; Eina_List *handlers;
Ecore_File_Monitor *monitor; Eio_Monitor *monitor;
Eina_List *monitor_handlers;
Evas_Object *scroller; Evas_Object *scroller;
Evas_Object *table; Evas_Object *table;
Evas_Object *image; Evas_Object *image;
@ -257,19 +258,24 @@ _viewer_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED) void *event_info EINA_UNUSED)
{ {
Ephoto_Viewer *v = data; Ephoto_Viewer *v = data;
Ecore_Event_Handler *handler;
if (v->monitor) if (v->monitor)
ecore_file_monitor_del(v->monitor); {
eio_monitor_del(v->monitor);
EINA_LIST_FREE(v->monitor_handlers, handler)
ecore_event_handler_del(handler);
}
free(v); free(v);
} }
static void static Eina_Bool
_monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED, _monitor_cb(void *data, int type,
Ecore_File_Event event, const char *path EINA_UNUSED) void *event EINA_UNUSED)
{ {
Ephoto_Single_Browser *sb = data; Ephoto_Single_Browser *sb = data;
Ephoto_Viewer *v = evas_object_data_get(sb->viewer, "viewer"); Ephoto_Viewer *v = evas_object_data_get(sb->viewer, "viewer");
if (event == ECORE_FILE_EVENT_MODIFIED) if (type == EIO_MONITOR_FILE_MODIFIED)
{ {
if (!ecore_file_exists(sb->entry->path)) if (!ecore_file_exists(sb->entry->path))
ephoto_entry_free(sb->ephoto, sb->entry); ephoto_entry_free(sb->ephoto, sb->entry);
@ -292,7 +298,7 @@ _monitor_cb(void *data, Ecore_File_Monitor *em EINA_UNUSED,
} }
} }
} }
return; return ECORE_CALLBACK_PASS_ON;
} }
static void static void
@ -1358,7 +1364,15 @@ _viewer_add(Evas_Object *parent, const char *path, Ephoto_Single_Browser *sb)
} }
v->monitor = ecore_file_monitor_add(path, _monitor_cb, sb); v->monitor = eio_monitor_add(path);
v->monitor_handlers =
eina_list_append(v->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_FILE_MODIFIED,
_monitor_cb, sb));
v->monitor_handlers =
eina_list_append(v->monitor_handlers,
ecore_event_handler_add(EIO_MONITOR_FILE_DELETED,
_monitor_cb, sb));
return v->scroller; return v->scroller;
error: error: