diff --git a/src/backends/default/open.c b/src/backends/default/open.c index 04d2be2..59ae978 100644 --- a/src/backends/default/open.c +++ b/src/backends/default/open.c @@ -37,7 +37,6 @@ typedef struct Ecore_Exe *exe; Ecore_Timer *busy_delay_timer; } Thumb; - static Ecore_Event_Handler *thumb_exe_del_handler = NULL; static Eina_List *thumb_queue = NULL; static Eina_List *thumb_busy_queue = NULL; @@ -79,6 +78,27 @@ static Eina_List *sub_queue = NULL; static Sub *_sub_open(const char *path, const char *backend); +static Sub * +_sub_find(const char *path) +{ + Eina_List *l; + Sub *sub; + + EINA_LIST_FOREACH(sub_queue, l, sub) + { + if (!strcmp(path, sub->path)) return sub; + } + return NULL; +} + +static void +_sub_timer_free(Sub_Timer *st) +{ + ecore_timer_del(st->timer); + eina_stringshare_del(st->name); + free(st); +} + static Eina_Bool _cb_sub_timer(void *data) { @@ -89,18 +109,22 @@ _cb_sub_timer(void *data) cmd_strbuf_exe_consume(buf, st->sub->exe); if (st->repeat) return EINA_TRUE; st->sub->timers = eina_list_remove(st->sub->timers, st); - eina_stringshare_del(st->name); - free(st); + _sub_timer_free(st); return EINA_FALSE; } static void _sub_del(Sub *sub) { + Sub_Timer *st; + Eina_Strbuf *buf; + sub_queue = eina_list_remove(sub_queue, sub); eina_stringshare_replace(&(sub->path), NULL); ecore_event_handler_del(sub->handler_exe_del); ecore_event_handler_del(sub->handler_exe_data); + EINA_LIST_FREE(sub->cmd_pending, buf) eina_strbuf_free(buf); + EINA_LIST_FREE(sub->timers, st) _sub_timer_free(st); ecore_exe_free(sub->exe); free(sub); } @@ -191,14 +215,12 @@ _sub_command(Sub *sub, const char *str) if (!strcmp(st->name, name)) { sub->timers = eina_list_remove_list(sub->timers, l); - eina_stringshare_del(st->name); - ecore_timer_del(st->timer); - free(st); + _sub_timer_free(st); } } } } - // XXX: handle: dir-request + // XXX: handle: dir-request ... cmd_free(c); } @@ -229,6 +251,7 @@ _cb_sub_exe_data(void *data, int ev_type EINA_UNUSED, void *event) static Sub * _sub_open(const char *path, const char *backend) { + // XXX: this sub should exit on its own if its idle for some time Eina_Strbuf *buf; const char *s; Sub *sub = calloc(1, sizeof(Sub)); @@ -251,10 +274,15 @@ _sub_open(const char *path, const char *backend) { eina_strbuf_reset(buf); - eina_strbuf_append(buf, elm_app_lib_dir_get()); - eina_strbuf_append(buf, "/efm/backends/"); - eina_strbuf_append(buf, backend); - eina_strbuf_append(buf, "/open"); + // XXX: this could be better! + s = getenv("EFM_BACKEND_DIR"); + if (s) + { + eina_strbuf_append(buf, s); + eina_strbuf_append(buf, "/../"); + eina_strbuf_append(buf, backend); + eina_strbuf_append(buf, "/open"); + } } sub->handler_exe_del = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _cb_sub_exe_del, sub); @@ -265,6 +293,7 @@ _sub_open(const char *path, const char *backend) ECORE_EXE_PIPE_READ_LINE_BUFFERED | ECORE_EXE_PIPE_WRITE, sub); + fprintf(stderr, "SUB %s\n", eina_strbuf_string_get(buf)); eina_strbuf_free(buf); buf = cmd_strbuf_new("dir-set"); cmd_strbuf_append(buf, "path", path); @@ -1068,10 +1097,20 @@ static void _dir_del(const char *path) { Eina_Strbuf *strbuf; + const char *mondir; + char *realpath; - strbuf = cmd_strbuf_new("dir-del"); - cmd_strbuf_append(strbuf, "path", path); - cmd_strbuf_print_consume(strbuf); + if (!mon) return; + mondir = ecore_file_monitor_path_get(mon); + if (!mondir) return; + realpath = ecore_file_realpath(mondir); + if ((!strcmp(mondir, path)) || + ((realpath) && (!strcmp(realpath, path)))) + { + strbuf = cmd_strbuf_new("dir-del"); + cmd_strbuf_print_consume(strbuf); + } + free(realpath); } static void @@ -1191,12 +1230,27 @@ _handle_drop_paste(const char *over, const char *action, const char *path) mondir = ecore_file_monitor_path_get(mon); if (!mondir) return; if (over) - fprintf(stderr, "DROP over=[%s] action=[%s] > [%s]\n", over, action, path); - else - fprintf(stderr, "DROP action=[%s] > [%s]\n", action, path); - // XXX: decide what to do with file and tell frontend - // XXX: action = copy, move, ask, list, link, description - // XXX: if over, then spin up backedn for that over dir and hand work to that + { // if you are dropping over a dir then spint up a sub open and pass + // the dnd to it + Eina_Strbuf *strbuf; + Sub *sub; + + sub = _sub_find(over); + if (!sub) sub = _sub_open(over, "default"); + strbuf = cmd_strbuf_new("dnd-drop"); + cmd_strbuf_append(strbuf, "action", action); + cmd_strbuf_append(strbuf, "path", path); + _sub_cmd_send(sub, strbuf); + fprintf(stderr, "DROP in [%s] over=[%s] action=[%s] > [%s]\n", + mondir, over, action, path); + } + else + { + fprintf(stderr, "DROP in [%s] action=[%s] > [%s]\n", mondir, action, + path); + // XXX: do the real operation here + // XXX: action = copy, move, ask, list, link, description + } } void diff --git a/src/efm/efm_back_end.c b/src/efm/efm_back_end.c index 31a26ed..20d6ef9 100644 --- a/src/efm/efm_back_end.c +++ b/src/efm/efm_back_end.c @@ -567,6 +567,12 @@ _cb_thread_notify(void *data, Ecore_Thread *th EINA_UNUSED, void *msg) } CMD_DONE; } + else if (!strcmp(c->command, "dir-del")) + { + // XXX: handle if the dir was deleted + printf("XXX: dir del...\n"); + CMD_DONE; + } // below commands all send a path for a specific file path = file = cmd_key_find(c, "path"); diff --git a/src/shared/cmd.h b/src/shared/cmd.h index e1a8883..fbe1939 100644 --- a/src/shared/cmd.h +++ b/src/shared/cmd.h @@ -20,9 +20,11 @@ // viewmode-set // force a specific view mode from backend // detail-header-set // set detail header text, size // dir-request // backend requests to show a new dir +// backend-set // swich to a new named backend // timer-add // backend can ask for a timer to be added // timer-del // backend can ask for a timer to be deleted // timer // event from front to backend that a timer ticked +// file-detail // update the file detail in custom detail mode // file-detail-change // user interacted with detail - changed it // file-detail-clicked // user interacted with detail - clicked it // file-detail-select // user interacted with detail - selected sub item @@ -36,11 +38,11 @@ // dnd-hover // // file-run // double-click file (or enter on kbd) -// file-clicked -// file-selected -// file-unselected -// file-delete -// file-rename +// file-clicked // a single click +// file-selected // file became selected +// file-unselected // file became unselected +// file-delete // user requested to delete file +// file-rename // user provided a new name for file // ////////////////////