diff --git a/src/modules/everything-apps/e_mod_main.c b/src/modules/everything-apps/e_mod_main.c index 03c034c4f..3cb5d397d 100644 --- a/src/modules/everything-apps/e_mod_main.c +++ b/src/modules/everything-apps/e_mod_main.c @@ -838,8 +838,6 @@ _exec_sudo_action(Evry_Action *act) static int _open_with_action(Evry_Plugin *plugin, const Evry_Item *act, const Evry_Item *subj) { - PLUGIN(p, plugin); - return evry_util_exec_app(act, subj); return 0; @@ -926,7 +924,7 @@ _new_app_action(Evry_Action *act) } free(name); - if (!buf || strlen(buf) == 0) + if (strlen(buf) == 0) return 0; if (!app->desktop) @@ -956,9 +954,6 @@ _new_app_action(Evry_Action *act) return 1; } -//#define TIME_FACTOR(_now) (1.0 - (evry_hist->begin / _now)) / 1000000000000000.0 - - static Eina_Bool _plugins_init(void) { diff --git a/src/modules/everything-files/e_mod_main.c b/src/modules/everything-files/e_mod_main.c index 470b5bfca..1b5436a20 100644 --- a/src/modules/everything-files/e_mod_main.c +++ b/src/modules/everything-files/e_mod_main.c @@ -30,24 +30,24 @@ struct _Plugin Eina_Bool parent; Eina_List *hist_added; Eina_Bool show_hidden; - + Ecore_Thread *thread; Ecore_Thread *thread2; Ecore_File_Monitor *dir_mon; - Eina_Bool cleanup; + int cleanup; }; struct _Data { Plugin *plugin; + char *directory; long id; int level; int cnt; Eina_List *files; Eina_List *list; DIR *dirp; - Eina_Bool finished; - Eina_Bool scan_dirs; + Eina_Bool second_run; }; struct _Module_Config @@ -137,96 +137,92 @@ _scan_func(void *data) const char *mime; struct dirent *dp; Evry_Item_File *file; + Eina_List *l; char buf[4096]; int cnt = 0; - if (!d->dirp) - d->dirp = opendir(p->directory); - if (!d->dirp) return; - - while (dp = readdir(d->dirp)) + if (!d->files) { - if ((dp->d_name[0] == '.') && - ((dp->d_name[1] == '\0') || - ((dp->d_name[1] == '.') && - (dp->d_name[2] == '\0')))) - continue; - -#ifdef _DIRENT_HAVE_D_TYPE - if (dp->d_type == DT_FIFO || - dp->d_type == DT_BLK || - dp->d_type == DT_CHR || - dp->d_type == DT_SOCK) - continue; + d->dirp = opendir(d->directory); + if (!d->dirp) return; - if ((d->scan_dirs && (dp->d_type != DT_DIR) || - (dp->d_type == DT_UNKNOWN))) - continue; - else if (!d->scan_dirs && (dp->d_type == DT_DIR)) - continue; -#endif - if (!p->show_hidden) + while ((dp = readdir(d->dirp))) { - if (dp->d_name[0] == '.') + if ((dp->d_name[0] == '.') && + ((dp->d_name[1] == '\0') || + ((dp->d_name[1] == '.') && + (dp->d_name[2] == '\0')))) continue; - } - else - { - if (dp->d_name[0] != '.') - continue; - } - file = E_NEW(Evry_Item_File, 1); - if (!file) break; - - evry_item_new(EVRY_ITEM(file), EVRY_PLUGIN(p), NULL, _item_free); - filename = strdup(dp->d_name); - - EVRY_ITEM(file)->label = filename; - - snprintf(buf, sizeof(buf), "%s/%s", p->directory, filename); - file->path = strdup(buf); #ifdef _DIRENT_HAVE_D_TYPE - if (dp->d_type & DT_UNKNOWN) - { + if (dp->d_type == DT_FIFO || + dp->d_type == DT_BLK || + dp->d_type == DT_CHR || + dp->d_type == DT_SOCK) + continue; #endif - if (ecore_file_is_dir(file->path)) + if (!p->show_hidden) + { + if (dp->d_name[0] == '.') + continue; + } + else + { + if (dp->d_name[0] != '.') + continue; + } + + file = E_NEW(Evry_Item_File, 1); + if (!file) break; + + evry_item_new(EVRY_ITEM(file), EVRY_PLUGIN(p), NULL, _item_free); + filename = strdup(dp->d_name); + EVRY_ITEM(file)->label = filename; + d->files = eina_list_append(d->files, file); + +#ifdef _DIRENT_HAVE_D_TYPE + if (dp->d_type & DT_UNKNOWN) + { +#endif + if (ecore_file_is_dir(file->path)) + EVRY_ITEM(file)->browseable = EINA_TRUE; + +#ifdef _DIRENT_HAVE_D_TYPE + } + else if (dp->d_type & DT_DIR) { EVRY_ITEM(file)->browseable = EINA_TRUE; } - else if ((mime = efreet_mime_type_get(file->path))) - { - file->mime = mime; - } -#ifdef _DIRENT_HAVE_D_TYPE +#endif } - else if (dp->d_type & DT_DIR) - { - EVRY_ITEM(file)->browseable = EINA_TRUE; - } - else if (dp->d_type & DT_REG | DT_LNK) + closedir(d->dirp); + + d->files = eina_list_sort(d->files, -1, _cb_sort); + } + + EINA_LIST_FOREACH(d->files, l, file) + { + snprintf(buf, sizeof(buf), "%s/%s", + d->directory, + EVRY_ITEM(file)->label); + + file->path = strdup(buf); + + if (!EVRY_ITEM(file)->browseable) { + if (d->second_run) + usleep(2500); + if ((mime = efreet_mime_type_get(file->path))) { file->mime = mime; + + if (!strncmp(file->mime, "inode/", 6) && + ecore_file_is_dir(file->path)) + EVRY_ITEM(file)->browseable = EINA_TRUE; } } -#endif - d->files = eina_list_append(d->files, file); - - if (cnt++ > MAX_ITEMS) return; - } - - if (d->scan_dirs) - { - rewinddir(d->dirp); - d->scan_dirs = EINA_FALSE; - - } - else - { - d->finished = EINA_TRUE; - closedir(d->dirp); + if (cnt++ > MAX_ITEMS) break; } } @@ -237,9 +233,9 @@ _append_files(Plugin *p) int cnt = 0; Evry_Item_File *file; Eina_List *l; - + EVRY_PLUGIN_ITEMS_CLEAR(p); - + EINA_LIST_FOREACH(p->files, l, file) { if (cnt >= MAX_SHOWN) break; @@ -266,7 +262,6 @@ _scan_cancel_func(void *data) Data *d = data; Plugin *p = d->plugin; Evry_Item_File *file; - char *filename; EINA_LIST_FREE(d->files, file) { @@ -275,18 +270,18 @@ _scan_cancel_func(void *data) free(file); } - if (!d->finished) - closedir(d->dirp); - + free(d->directory); E_FREE(d); - if (p->directory) - eina_stringshare_del(p->directory); - p->thread = NULL; - if (p->cleanup) - E_FREE(p); + if (p->cleanup > 0) + { + p->cleanup--; + + if (!p->cleanup) + E_FREE(p); + } } static void @@ -297,11 +292,8 @@ _scan_end_func(void *data) Evry_Item *item; Evry_Item_File *f; char *filename, *path, *mime; - int cnt = 0; Eina_List *l; - p->thread = NULL; - EINA_LIST_FREE(d->files, item) { ITEM_FILE(file, item); @@ -309,6 +301,7 @@ _scan_end_func(void *data) filename = (char *)item->label; path = (char *) file->path; mime = (char *) file->mime; + if (!path) break; file->path = eina_stringshare_add(path); @@ -329,15 +322,10 @@ _scan_end_func(void *data) if (item->browseable) file->mime = eina_stringshare_ref(_mime_dir); else if (mime) - { - file->mime = eina_stringshare_add(mime); - if (!strncmp(file->mime, "inode/", 6) && - ecore_file_is_dir(file->path)) - EVRY_ITEM(file)->browseable = EINA_TRUE; - } + file->mime = eina_stringshare_add(mime); else file->mime = eina_stringshare_add("unknown"); - + item->context = eina_stringshare_ref(file->mime); item->id = eina_stringshare_ref(file->path); item->label = eina_stringshare_add(filename); @@ -349,19 +337,23 @@ _scan_end_func(void *data) evry_util_file_detail_set(file); } - if (!d->finished) + + if (d->files) { + d->second_run = EINA_TRUE; p->thread = ecore_thread_run(_scan_func, _scan_end_func, _scan_cancel_func, d); } else { + free(d->directory); E_FREE(d); + p->thread = NULL; } - + p->files = eina_list_sort(p->files, -1, _cb_sort); - _append_files(p); - + _append_files(p); + evry_plugin_async_update(EVRY_PLUGIN(p), EVRY_ASYNC_UPDATE_ADD); } @@ -372,51 +364,50 @@ _dir_watcher(void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const c Evry_Item_File *file; const char *label; Eina_List *ll, *l; - + EVRY_PLUGIN_ITEMS_CLEAR(p); - + switch (event) { case ECORE_FILE_EVENT_DELETED_SELF: EINA_LIST_FREE(p->files, file) evry_item_free(EVRY_ITEM(file)); break; - + case ECORE_FILE_EVENT_CREATED_DIRECTORY: case ECORE_FILE_EVENT_CREATED_FILE: file = E_NEW(Evry_Item_File, 1); if (!file) break; label = ecore_file_file_get(path); - + evry_item_new(EVRY_ITEM(file), EVRY_PLUGIN(p), label, _item_free); - file->path = eina_stringshare_add(path); + file->path = eina_stringshare_add(path); evry_util_file_detail_set(file); if (event == ECORE_FILE_EVENT_CREATED_DIRECTORY) { - file->mime = eina_stringshare_ref(_mime_dir); - EVRY_ITEM(file)->browseable; + file->mime = eina_stringshare_ref(_mime_dir); + EVRY_ITEM(file)->browseable = EINA_TRUE; } else { - _item_fill(file); + _item_fill(file); } - p->files = eina_list_append(p->files, file); + p->files = eina_list_append(p->files, file); break; - + case ECORE_FILE_EVENT_DELETED_FILE: case ECORE_FILE_EVENT_DELETED_DIRECTORY: - label = eina_stringshare_add(path); EINA_LIST_FOREACH_SAFE(p->files, l, ll, file) { if (file->path != label) continue; - - p->files = eina_list_remove_list(p->files, l); - p->hist_added = eina_list_remove(p->hist_added, file); + + p->files = eina_list_remove_list(p->files, l); + p->hist_added = eina_list_remove(p->hist_added, file); evry_item_free(EVRY_ITEM(file)); break; } @@ -428,7 +419,7 @@ _dir_watcher(void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const c } _append_files(p); - + evry_plugin_async_update(EVRY_PLUGIN(p), EVRY_ASYNC_UPDATE_ADD); } @@ -437,17 +428,14 @@ _read_directory(Plugin *p) { Data *d = E_NEW(Data, 1); d->plugin = p; + d->directory = strdup(p->directory); -#ifdef _DIRENT_HAVE_D_TYPE - d->scan_dirs = EINA_TRUE; -#endif - p->thread = ecore_thread_run(_scan_func, _scan_end_func, _scan_cancel_func, d); if (p->dir_mon) ecore_file_monitor_del(p->dir_mon); - p->dir_mon = ecore_file_monitor_add(p->directory, _dir_watcher, p); + p->dir_mon = ecore_file_monitor_add(p->directory, _dir_watcher, p); } static Evry_Plugin * @@ -526,7 +514,7 @@ _cleanup(Evry_Plugin *plugin) _hist_add(plugin, file); evry_item_free(EVRY_ITEM(file)); } - + EVRY_PLUGIN_ITEMS_CLEAR(p); if (p->input) @@ -536,62 +524,81 @@ _cleanup(Evry_Plugin *plugin) ecore_file_monitor_del(p->dir_mon); if (p->thread2) - ecore_thread_cancel(p->thread2); - + { + ecore_thread_cancel(p->thread2); + p->cleanup++; + } + else + EINA_LIST_FREE(p->hist_added, file) + evry_item_free(EVRY_ITEM(file)); + if (p->thread) { ecore_thread_cancel(p->thread); - p->cleanup = EINA_TRUE; - return; + p->cleanup++; } - E_FREE(p); + if (!p->cleanup) + E_FREE(p); } /* use thread only to not block ui for ecore_file_exists ... */ -/* static void - * _hist_func(void *data) - * { - * Plugin *p = data; - * Eina_List *l, *ll; - * Evry_Item_File *file; - * - * EINA_LIST_FOREACH_SAFE(p->hist_added, l, ll, file) - * { - * if (!ecore_file_exists(file->path)) - * { - * p->hist_added = eina_list_remove_list(p->hist_added, l); - * } - * } - * } - * - * static void - * _hist_cancel_func(void *data) - * { - * Plugin *p = data; - * Evry_Item_File *file; - * - * EINA_LIST_FREE(p->hist_added, file) - * { - * p->files = eina_list_remove(p->files, file); - * evry_item_free(EVRY_ITEM(file)); - * } - * p->thread2 = NULL; - * } - * - * static void - * _hist_end_func(void *data) - * { - * Plugin *p = data; - * Eina_List *l; - * Evry_Item_File *file; - * - * EINA_LIST_FOREACH(p->hist_added, l, file) - * { - * p->files = eina_list_append(p->files, file); - * } - * p->thread2 = NULL; - * } */ +static void +_hist_func(void *data) +{ + Plugin *p = data; + Eina_List *l, *ll; + Evry_Item_File *file; + + EINA_LIST_FOREACH_SAFE(p->hist_added, l, ll, file) + { + if (!ecore_file_exists(file->path)) + p->hist_added = eina_list_remove_list(p->hist_added, l); + } +} + +static void +_hist_cancel_func(void *data) +{ + Plugin *p = data; + Evry_Item_File *file; + + EINA_LIST_FREE(p->hist_added, file) + { + p->files = eina_list_remove(p->files, file); + evry_item_free(EVRY_ITEM(file)); + } + + p->thread2 = NULL; + + if (p->cleanup > 0) + { + p->cleanup--; + + if (!p->cleanup) + E_FREE(p); + } +} + +static void +_hist_end_func(void *data) +{ + Plugin *p = data; + Eina_List *l; + Evry_Item_File *file; + + EINA_LIST_FOREACH(p->hist_added, l, file) + { + evry_item_ref(EVRY_ITEM(file)); + p->files = eina_list_append(p->files, file); + } + + p->thread2 = NULL; + + _append_files(p); + + evry_plugin_async_update(EVRY_PLUGIN(p), EVRY_ASYNC_UPDATE_ADD); +} static Eina_Bool _hist_items_add_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata) @@ -614,8 +621,8 @@ _hist_items_add_cb(const Eina_Hash *hash, const void *key, void *data, void *fda return EINA_TRUE; /* XXX this blocks ui when drive is sleeping */ - if (!ecore_file_exists(key)) - continue; + /* if (!ecore_file_exists(key)) + * continue; */ label = ecore_file_file_get(key); if (!label) @@ -644,7 +651,7 @@ _hist_items_add_cb(const Eina_Hash *hash, const void *key, void *data, void *fda EVRY_ITEM(file)->browseable = EINA_TRUE; } - p->files = eina_list_append(p->files, file); + /* p->files = eina_list_append(p->files, file); */ p->hist_added = eina_list_append(p->hist_added, file); break; } @@ -660,7 +667,7 @@ _folder_item_add(Plugin *p, const char *path) evry_item_new(EVRY_ITEM(file), EVRY_PLUGIN(p), path, _item_free); file->path = eina_stringshare_add(path); - file->mime = eina_stringshare_add("inode/directory"); + file->mime = eina_stringshare_ref(_mime_dir); EVRY_ITEM(file)->browseable = EINA_TRUE; p->files = eina_list_append(p->files, file); EVRY_PLUGIN_ITEM_APPEND(p, file); @@ -670,16 +677,20 @@ static void _free_files(Plugin *p) { Evry_Item_File *file; - + if (p->thread) ecore_thread_cancel(p->thread); p->thread = NULL; + if (p->thread2) + ecore_thread_cancel(p->thread2); + p->thread2 = NULL; + EINA_LIST_FREE(p->files, file) evry_item_free(EVRY_ITEM(file)); - if (p->hist_added) - eina_list_free(p->hist_added); - p->hist_added = NULL; + + EINA_LIST_FREE(p->hist_added, file) + evry_item_free(EVRY_ITEM(file)); if (p->dir_mon) ecore_file_monitor_del(p->dir_mon); @@ -691,9 +702,7 @@ _fetch(Evry_Plugin *plugin, const char *input) { PLUGIN(p, plugin); Evry_Item_File *file; - Eina_List *l; - int cnt = 0; - + if (!p->command) EVRY_PLUGIN_ITEMS_CLEAR(p); @@ -706,7 +715,7 @@ _fetch(Evry_Plugin *plugin, const char *input) if (p->command != CMD_SHOW_ROOT) { _free_files(p); - + eina_stringshare_del(p->directory); p->directory = eina_stringshare_add("/"); _read_directory(p); @@ -720,29 +729,24 @@ _fetch(Evry_Plugin *plugin, const char *input) { if (p->command != CMD_SHOW_PARENT) { - char *end; - char dir[4096]; + char *dir; + char buf[PATH_MAX]; + + if (strncmp(p->directory, "/", 1)) + return 0; _free_files(p); - - if (strncmp(p->directory, "/", 1)) return 0; - if (!strcmp(p->directory, "/")) return 0; - - snprintf(dir, 4096, "%s", p->directory); - end = strrchr(dir, '/'); - while (end != dir) + strncpy(buf, p->directory, PATH_MAX); + + while (strlen(buf) > 1) { - char *tmp = strdup(dir); - snprintf(dir, (end - dir) + 1, "%s", tmp); - + buf[PATH_MAX - 1] = 0; + dir = dirname(buf); _folder_item_add(p, dir); - - end = strrchr(dir, '/'); - free(tmp); + strncpy(buf, dir, PATH_MAX); } - _folder_item_add(p, "/"); p->command = CMD_SHOW_PARENT; } return 1; @@ -750,9 +754,9 @@ _fetch(Evry_Plugin *plugin, const char *input) else if (p->directory && input && !strncmp(input, ".", 1)) { if (p->command != CMD_SHOW_HIDDEN) - { + { _free_files(p); - + p->show_hidden = EINA_TRUE; _read_directory(p); @@ -762,7 +766,7 @@ _fetch(Evry_Plugin *plugin, const char *input) } else if (p->command) { - /* clear command items */ + /* clear command items */ EINA_LIST_FREE(p->files, file) evry_item_free(EVRY_ITEM(file)); @@ -770,7 +774,7 @@ _fetch(Evry_Plugin *plugin, const char *input) { if (p->directory) eina_stringshare_del(p->directory); - + p->directory = eina_stringshare_add(e_user_homedir_get()); } @@ -783,19 +787,19 @@ _fetch(Evry_Plugin *plugin, const char *input) /* add recent files */ if ((!p->parent && !p->command && !p->hist_added) && - ((_conf->search_recent && input && strlen(input) > 2) || + ((_conf->search_recent && input && strlen(input) > 1) || (_conf->show_recent))) { - eina_hash_foreach(evry_hist->subjects, _hist_items_add_cb, p); - /* p->thread2 = ecore_thread_run(_hist_func, _hist_end_func, _hist_cancel_func, p); */ + eina_hash_foreach(evry_hist->subjects, _hist_items_add_cb, p); + p->thread2 = ecore_thread_run(_hist_func, _hist_end_func, _hist_cancel_func, p); } else if (p->hist_added && !input && _conf->search_recent) - { - EINA_LIST_FREE(p->hist_added, file) - { + { + EINA_LIST_FREE(p->hist_added, file) + { p->files = eina_list_remove(p->files, file); evry_item_free(EVRY_ITEM(file)); - } + } } if (input) @@ -807,7 +811,7 @@ _fetch(Evry_Plugin *plugin, const char *input) } _append_files(p); - + if (!EVRY_PLUGIN(p)->items) return 0; @@ -835,7 +839,7 @@ _icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) if (!o) o = evry_icon_mime_get("unknown", e); - + return o; } @@ -880,7 +884,7 @@ _open_term_action(Evry_Action *act) Evry_Item_App *tmp; char cwd[4096]; char *dir; - int ret = 0, ok; + int ret = 0; if (act->item1->browseable) dir = strdup(file->path); @@ -912,30 +916,34 @@ static int _file_trash_action(Evry_Action *act) { Efreet_Uri *uri; - + int ok = 0; + char buf[PATH_MAX]; + int force = !strcmp(act->data, "delete"); + ITEM_FILE(file, act->item1); if (!file->url) { /* efreet_uri_decode could be a litle less picky imo */ - char buf[4096]; snprintf(buf, sizeof(buf), "file://%s", file->path); - uri = efreet_uri_decode(buf); - printf("delete %s - %p\n", buf, uri); + uri = efreet_uri_decode(buf); + + printf("delete %s %p\n", buf, uri); } else { - uri = efreet_uri_decode(file->url); + uri = efreet_uri_decode(file->url); } if (uri) { - efreet_trash_delete_uri(uri, 0); - efreet_uri_free(uri); + ok = efreet_trash_delete_uri(uri, force); + efreet_uri_free(uri); + } - return 1; + return ok; } static int @@ -947,26 +955,26 @@ _file_copy_action(Evry_Action *act) char *path; char buf[PATH_MAX]; int ret; - + if (!ecore_file_is_dir(dst->path)) path = ecore_file_dir_get(dst->path); else path = strdup(dst->path); if (!path) return 0; - + snprintf(buf, sizeof(buf), "%s/%s", path, act->item1->label); free(path); if (!strcmp((char *)act->data, "cp")) { - ret = ecore_file_cp(file->path, buf); + ret = ecore_file_cp(file->path, buf); } else if (!strcmp((char *)act->data, "mv")) { ret = ecore_file_mv(file->path, buf); } - + return ret; } @@ -975,7 +983,7 @@ static Eina_Bool _plugins_init(void) { Evry_Action *act; - + if (!evry_api_version_check(EVRY_API_VERSION)) return EINA_FALSE; @@ -983,7 +991,7 @@ _plugins_init(void) _begin, _cleanup, _fetch, _icon_get, NULL); EVRY_PLUGIN(p1)->config_path = "extensions/everything-files"; evry_plugin_register(p1, 3); - + p2 = EVRY_PLUGIN_NEW(Evry_Plugin, N_("Files"), type_object, "FILE", "FILE", _begin, _cleanup, _fetch, _icon_get, NULL); EVRY_PLUGIN(p2)->config_path = "extensions/everything-files"; @@ -992,29 +1000,37 @@ _plugins_init(void) act = EVRY_ACTION_NEW(N_("Open Folder (EFM)"), "FILE", NULL, "folder-open", _open_folder_action, _open_folder_check); evry_action_register(act, 0); - _actions = eina_list_append(_actions, act); - + _actions = eina_list_append(_actions, act); + act = EVRY_ACTION_NEW(N_("Open Terminal here"), "FILE", NULL, "system-run", _open_term_action, NULL); evry_action_register(act, 2); _actions = eina_list_append(_actions, act); - + act = EVRY_ACTION_NEW(N_("Move to Trash"), "FILE", NULL, "edit-delete", _file_trash_action, NULL); + act->data = "trash"; evry_action_register(act, 2); - _actions = eina_list_append(_actions, act); + _actions = eina_list_append(_actions, act); + + act = EVRY_ACTION_NEW(N_("Delete"), "FILE", NULL, "list-remove", + _file_trash_action, NULL); + act->data = "delete"; + evry_action_register(act, 2); + + _actions = eina_list_append(_actions, act); act = EVRY_ACTION_NEW(N_("Copy To ..."), "FILE", "FILE", "go-next", _file_copy_action, NULL); act->data = "cp"; evry_action_register(act, 2); - _actions = eina_list_append(_actions, act); + _actions = eina_list_append(_actions, act); act = EVRY_ACTION_NEW(N_("Move To ..."), "FILE", "FILE", "go-next", _file_copy_action, NULL); act->data = "mv"; evry_action_register(act, 2); - _actions = eina_list_append(_actions, act); + _actions = eina_list_append(_actions, act); return EINA_TRUE; } @@ -1023,7 +1039,7 @@ static void _plugins_shutdown(void) { Evry_Action *act; - + EVRY_PLUGIN_FREE(p1); EVRY_PLUGIN_FREE(p2); @@ -1136,7 +1152,6 @@ _basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) C(show_recent); C(search_recent); #undef C - printf("apply\n"); e_config_domain_save("module.everything-files", conf_edd, _conf); e_config_save_queue(); @@ -1146,7 +1161,6 @@ _basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) static void _conf_new(void) { - printf("new!!!!!\n"); _conf = E_NEW(Module_Config, 1); _conf->version = (MOD_CONFIG_FILE_EPOCH << 16); @@ -1186,7 +1200,7 @@ _conf_init(E_Module *m) NULL, buf, _conf_dialog); conf_edd = E_CONFIG_DD_NEW("Module_Config", Module_Config); - + #undef T #undef D #define T Module_Config @@ -1236,7 +1250,7 @@ e_modapi_init(E_Module *m) _conf_init(m); _mime_dir = eina_stringshare_add("inode/directory"); - + e_module_delayed_set(m, 1); return m; @@ -1249,7 +1263,7 @@ e_modapi_shutdown(E_Module *m) _plugins_shutdown(); eina_stringshare_del(_mime_dir); - + _conf_shutdown(); return 1; diff --git a/src/modules/everything/Evry.h b/src/modules/everything/Evry.h index 1165d4d68..67450eafc 100644 --- a/src/modules/everything/Evry.h +++ b/src/modules/everything/Evry.h @@ -3,7 +3,7 @@ #include "e.h" -#define EVRY_API_VERSION 4 +#define EVRY_API_VERSION 5 #define EVRY_ACTION_OTHER 0 #define EVRY_ACTION_FINISHED 1 @@ -57,6 +57,7 @@ typedef struct _Plugin_Setting Plugin_Setting; #define EVRY_PLUGIN(_plugin) ((Evry_Plugin *) _plugin) #define EVRY_VIEW(_view) ((Evry_View *) _view) #define ITEM_FILE(_file, _item) Evry_Item_File *_file = (Evry_Item_File *) _item +#define ACTION_GET(_act, _item) Evry_Action *_act = (Evry_Action *) _item #define ITEM_APP(_app, _item) Evry_Item_App *_app = (Evry_Item_App *) _item #define PLUGIN(_p, _plugin) Plugin *_p = (Plugin*) _plugin #define VIEW(_v, _view) View *_v = (View*) _view @@ -131,6 +132,29 @@ struct _Evry_Item double usage; }; +struct _Evry_Action +{ + Evry_Item base; + + /* identifier */ + const char *name; + + const char *type_in1; + const char *type_in2; + + const Evry_Item *item1; + const Evry_Item *item2; + + int (*action) (Evry_Action *act); + int (*check_item) (Evry_Action *act, const Evry_Item *it); + int (*intercept) (Evry_Action *act); + void (*cleanup) (Evry_Action *act); + Eina_List *(*actions) (Evry_Action *act); + Evas_Object *(*icon_get) (Evry_Action *act, Evas *e); + + void *data; +}; + struct _Evry_Item_App { Evry_Item base; @@ -278,38 +302,6 @@ struct _Evry_View int priority; }; -struct _Evry_Action -{ - /* identifier */ - const char *name; - - /* shown title */ - const char *label; - - /* */ - const char *type_in1; - const char *type_in2; - - const Evry_Item *item1; - const Evry_Item *item2; - - int (*action) (Evry_Action *act); - int (*check_item) (Evry_Action *act, const Evry_Item *it); - int (*intercept) (Evry_Action *act); - void (*cleanup) (Evry_Action *act); - Eina_List *(*actions) (Evry_Action *act); - Evas_Object *(*icon_get) (Evry_Action *act, Evas *e); - - /* optional: use this when you keep stuff in 'data' */ - void (*free) (Evry_Action *act); - - /* use icon name from theme */ - const char *icon; - - void *data; - - int priority; -}; /* FIXME this should be exposed. - add functions to retrieve this stuff */ @@ -397,6 +389,12 @@ struct _History_Item const char *data; }; +#define EVRY_PLUGIN_NEW(_base, _name, _type, _in, _out, _begin, _cleanup, _fetch, _icon_get, _free) \ + evry_plugin_new(EVRY_PLUGIN(E_NEW(_base, 1)), _name, _(_name), _type, _in, _out, _begin, _cleanup, _fetch, _icon_get, _free) \ + +#define EVRY_ACTION_NEW(_name, _in1, _in2, _icon, _action, _check) \ + evry_action_new(_name, _(_name), _in1, _in2, _icon, _action, _check) + /* evry.c */ EAPI void evry_item_select(const Evry_State *s, Evry_Item *it); EAPI void evry_item_mark(const Evry_State *state, Evry_Item *it, Eina_Bool mark); @@ -436,12 +434,6 @@ EAPI void evry_history_unload(void); EAPI History_Item *evry_history_add(Eina_Hash *hist, Evry_Item *it, const char *ctxt, const char *input); EAPI int evry_history_item_usage_set(Eina_Hash *hist, Evry_Item *it, const char *input, const char *ctxt); -/* #define EVRY_PLUGIN_NEW(_base, _name, _type, _in, _out, _begin, _cleanup, _fetch, _icon_get, _free) \ - * evry_plugin_new(EVRY_PLUGIN(_base), _name, _(_name), _type, _in, _out, _begin, _cleanup, _fetch, _icon_get, _free) \ */ - -#define EVRY_PLUGIN_NEW(_base, _name, _type, _in, _out, _begin, _cleanup, _fetch, _icon_get, _free) \ - evry_plugin_new(EVRY_PLUGIN(E_NEW(_base, 1)), _name, _(_name), _type, _in, _out, _begin, _cleanup, _fetch, _icon_get, _free) \ - EAPI Evry_Plugin *evry_plugin_new(Evry_Plugin *base, const char *name, const char *label, int type, const char *type_in, const char *type_out, Evry_Plugin *(*begin) (Evry_Plugin *p, const Evry_Item *item), @@ -452,10 +444,6 @@ EAPI Evry_Plugin *evry_plugin_new(Evry_Plugin *base, const char *name, const cha EAPI void evry_plugin_free(Evry_Plugin *p, int free_pointer); - -#define EVRY_ACTION_NEW(_name, _in1, _in2, _icon, _action, _check) \ - evry_action_new(_name, _(_name), _in1, _in2, _icon, _action, _check) - EAPI Evry_Action *evry_action_new(const char *name, const char *label, const char *type_in1, const char *type_in2, const char *icon, diff --git a/src/modules/everything/e_mod_main.c b/src/modules/everything/e_mod_main.c index 0891619d8..0c235449d 100644 --- a/src/modules/everything/e_mod_main.c +++ b/src/modules/everything/e_mod_main.c @@ -111,7 +111,6 @@ EAPI int e_modapi_shutdown(E_Module *m __UNUSED__) { E_Config_Dialog *cfd; - Evry_Plugin *p; Evry_Action *a; evry_shutdown(); @@ -461,47 +460,11 @@ evry_plugin_free(Evry_Plugin *p, int free_pointer) E_FREE(p); } -Evry_Action * -evry_action_new(const char *name, const char *label, const char *type_in1, const char *type_in2, - const char *icon, - int (*action) (Evry_Action *act), - int (*check_item) (Evry_Action *act, const Evry_Item *it)) -{ - Evry_Action *act = E_NEW(Evry_Action, 1); - act->name = eina_stringshare_add(name); - act->label = eina_stringshare_add(label); - act->type_in1 = (type_in1 ? eina_stringshare_add(type_in1) : NULL); - act->type_in2 = (type_in2 ? eina_stringshare_add(type_in2) : NULL); - act->action = action; - act->check_item = check_item; - act->icon = (icon ? eina_stringshare_add(icon) : NULL); - - return act; -} - -void -evry_action_free(Evry_Action *act) -{ - evry_action_unregister(act); - - if (act->name) eina_stringshare_del(act->name); - if (act->label) eina_stringshare_del(act->label); - if (act->type_in1) eina_stringshare_del(act->type_in1); - if (act->type_in2) eina_stringshare_del(act->type_in2); - if (act->icon) eina_stringshare_del(act->icon); - - if (act->free) - act->free(act); - else - E_FREE(act); -} - - /* TODO make int return */ void evry_plugin_register(Evry_Plugin *p, int priority) { - Eina_List *l, *confs; + Eina_List *l; Plugin_Config *pc; Eina_List *conf[3]; int i = 0; @@ -565,20 +528,6 @@ evry_plugin_unregister(Evry_Plugin *p) } } -void -evry_action_register(Evry_Action *action, int priority) -{ - action->priority = priority; - evry_conf->actions = eina_list_append(evry_conf->actions, action); - /* TODO sorting, initialization, etc */ -} - -void -evry_action_unregister(Evry_Action *action) -{ - evry_conf->actions = eina_list_remove(evry_conf->actions, action); - /* cleanup */ -} static int diff --git a/src/modules/everything/e_mod_main.h b/src/modules/everything/e_mod_main.h index 3c2b19057..ef367a151 100644 --- a/src/modules/everything/e_mod_main.h +++ b/src/modules/everything/e_mod_main.h @@ -25,7 +25,7 @@ struct _Evry_Selector Evry_Plugin *actions; /* */ - Eina_List *cur_actions; + /* Eina_List *cur_actions; */ /* all plugins that belong to this selector*/ Eina_List *plugins; @@ -67,8 +67,8 @@ EAPI int e_modapi_shutdown (E_Module *m); EAPI int e_modapi_save (E_Module *m); EAPI E_Config_Dialog *evry_config_dialog(E_Container *con, const char *params); -EAPI Tab_View *evry_tab_view_new(const Evry_State *s, Evas *e); -EAPI void evry_tab_view_free(Tab_View *v); +Tab_View *evry_tab_view_new(const Evry_State *s, Evas *e); +void evry_tab_view_free(Tab_View *v); Eina_Bool view_thumb_init(void); void view_thumb_shutdown(void); @@ -90,11 +90,8 @@ int evry_shutdown(void); int evry_show(E_Zone *zone, const char *params); void evry_hide(void); -EAPI Evry_Plugin *evry_plug_aggregator_new(Evry_Selector *selector, int type); -EAPI void evry_plug_aggregator_free(Evry_Plugin *plugin); - -EAPI Evry_Plugin *evry_plug_actions_new(int type); -EAPI void evry_plug_actions_free(Evry_Plugin *plugin); +Evry_Plugin *evry_plug_aggregator_new(Evry_Selector *selector, int type); +Evry_Plugin *evry_plug_actions_new(Evry_Selector *selector, int type); void evry_history_init(void); void evry_history_free(void); diff --git a/src/modules/everything/evry.c b/src/modules/everything/evry.c index d479db8f2..b47ca911c 100644 --- a/src/modules/everything/evry.c +++ b/src/modules/everything/evry.c @@ -125,6 +125,7 @@ _evry_cb_item_changed(void *data, int type, void *event) if (sel->state && sel->state->cur_item == ev->item) { _evry_selector_update(sel); + _evry_selector_update_actions(sel); break; } } @@ -410,16 +411,11 @@ _evry_timer_cb_actions_get(void *data) static void _evry_selector_update_actions(Evry_Selector *sel) { - if (!sel->state) return; - - if (sel == selectors[0]) - { - Evry_Item *it = sel->state->cur_item; - sel = selectors[1]; - if (sel->update_timer) - ecore_timer_del(sel->update_timer); - sel->update_timer = ecore_timer_add(0.1, _evry_timer_cb_actions_get, it); - } + Evry_Item *it = sel->state->cur_item; + sel = selectors[1]; + if (sel->update_timer) + ecore_timer_del(sel->update_timer); + sel->update_timer = ecore_timer_add(0.1, _evry_timer_cb_actions_get, it); } EAPI void @@ -443,7 +439,8 @@ evry_item_select(const Evry_State *state, Evry_Item *it) if (s == sel->state) { _evry_selector_update(sel); - _evry_selector_update_actions(sel); + if (selector == selectors[0]) + _evry_selector_update_actions(sel); } } @@ -770,14 +767,14 @@ _evry_selector_new(int type) if (type == type_subject) { sel->history = evry_hist->subjects; - sel->actions = evry_plug_actions_new(type); + sel->actions = evry_plug_actions_new(sel, type); edje_object_part_swallow(win->o_main, "e.swallow.subject_selector", o); pcs = evry_conf->conf_subjects; } else if (type == type_action) { sel->history = evry_hist->actions; - sel->actions = evry_plug_actions_new(type); + sel->actions = evry_plug_actions_new(sel, type); edje_object_part_swallow(win->o_main, "e.swallow.action_selector", o); pcs = evry_conf->conf_actions; } @@ -1030,10 +1027,6 @@ _evry_selector_update(Evry_Selector *sel) if (item_changed && sel == selectors[0]) { _evry_selector_update_actions(sel); - /* sel = selectors[1]; - * if (sel->update_timer) - * ecore_timer_del(sel->update_timer); - * sel->update_timer = ecore_timer_add(0.1, _evry_timer_cb_actions_get, it); */ } } @@ -1325,17 +1318,19 @@ _evry_selectors_switch(int dir) else if (selector == selectors[1] && dir > 0) { int next_selector = 0; - Evry_Action *act; - - if ((s->cur_item) && - (s->cur_item->plugin == selector->actions) && - (act = s->cur_item->data) && - (act->type_in2)) + Evry_Item *it; + + if ((it = s->cur_item) && + (it->plugin == selector->actions)) { - _evry_selector_objects_get(act); - _evry_selector_update(selectors[2]); - edje_object_signal_emit(win->o_main, "e,state,object_selector_show", "e"); - next_selector = 2; + ACTION_GET(act,it); + if (act->type_in2) + { + _evry_selector_objects_get(act); + _evry_selector_update(selectors[2]); + edje_object_signal_emit(win->o_main, "e,state,object_selector_show", "e"); + next_selector = 2; + } } _evry_selector_activate(selectors[next_selector]); } @@ -1580,12 +1575,6 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event) { strcat(s->inp, ev->compose); - /* if (isspace(*ev->compose)) - * { - * /\* do not update matches on space *\/ - * _evry_update(selector, 0); - * } - * else */ _evry_update(selector, 1); } } @@ -1704,8 +1693,8 @@ _evry_clear(Evry_Selector *sel) static void _evry_plugin_action(Evry_Selector *sel, int finished) { - Evry_State *s_subject, *s_action, *s_object; - Evry_Item *it, *it_act; + Evry_State *s_subj, *s_act, *s_obj = NULL; + Evry_Item *it_subj, *it_act, *it_obj, *it; Eina_List *l; if (selectors[0]->update_timer) @@ -1714,15 +1703,16 @@ _evry_plugin_action(Evry_Selector *sel, int finished) _evry_selector_update(selectors[0]); } - s_subject = selectors[0]->state; + if (!(s_subj = selectors[0]->state)) + return; - if (!s_subject || !s_subject->cur_item) + if (!(it_subj = s_subj->cur_item)) return; if (selector == selectors[0] && selectors[1]->update_timer) { - _evry_selector_actions_get(s_subject->cur_item); + _evry_selector_actions_get(it_subj); if (!selectors[1]->state) return; @@ -1730,40 +1720,39 @@ _evry_plugin_action(Evry_Selector *sel, int finished) _evry_selector_update(selectors[1]); } - s_action = selectors[1]->state; - s_object = NULL; - - if (!s_action || !s_action->cur_item) + if (!(s_act = selectors[1]->state)) return; - if (s_action->cur_item->plugin == selectors[1]->actions) + if (!(it_act = s_act->cur_item)) + return; + + if (it_act->plugin == selectors[1]->actions) { - Evry_Item *it_object = NULL; - Evry_Action *act = s_action->cur_item->data; + ACTION_GET(act, it_act); /* get object item for action, when required */ if (act->type_in2) { /* check if object is provided */ - if (selectors[2] == selector) + if (selectors[2]->state) { - s_object = selector->state; - it_object = s_object->cur_item; + s_obj = selectors[2]->state; + it_obj = s_obj->cur_item; } - if (!it_object) + if (!it_obj) { if (selectors[1] == selector) _evry_selectors_switch(1); return; } - act->item2 = it_object; + act->item2 = it_obj; } - if (s_subject->sel_items) + if (s_subj->sel_items) { - EINA_LIST_REVERSE_FOREACH(s_subject->sel_items, l, it) + EINA_LIST_REVERSE_FOREACH(s_subj->sel_items, l, it) { if (it->plugin->type_out != act->type_in1) continue; @@ -1771,9 +1760,9 @@ _evry_plugin_action(Evry_Selector *sel, int finished) act->action(act); } } - else if (s_object && s_object->sel_items) + else if (s_obj && s_obj->sel_items) { - EINA_LIST_FOREACH(s_object->sel_items, l, it) + EINA_LIST_FOREACH(s_obj->sel_items, l, it) { if (it->plugin->type_out != act->type_in2) continue; @@ -1781,52 +1770,45 @@ _evry_plugin_action(Evry_Selector *sel, int finished) act->action(act); } } - else if (!act->action(act)) - return; - } - else if (s_action->plugin->action) - { - it_act = s_action->cur_item; - - if (s_subject->sel_items) + else { - EINA_LIST_REVERSE_FOREACH(s_subject->sel_items, l, it) + if (!act->action(act)) + return; + } + } + else if (s_act->plugin->action) + { + if (s_subj->sel_items) + { + EINA_LIST_REVERSE_FOREACH(s_subj->sel_items, l, it) { if (it->plugin->type_out != it_act->plugin->type_in) continue; - s_action->plugin->action(s_action->plugin, it_act, it); + s_act->plugin->action(s_act->plugin, it_act, it); } } else { - it = s_subject->cur_item; - if (!s_action->plugin->action(s_action->plugin, it_act, it)) + if (!s_act->plugin->action(s_act->plugin, it_act, it_subj)) return; } } else return; - if (s_subject) - evry_history_add(evry_hist->subjects, - s_subject->cur_item, - NULL, s_subject->input); + if (s_subj && it_subj) + evry_history_add(evry_hist->subjects, it_subj, NULL, s_subj->input); - if (s_action) - evry_history_add(evry_hist->actions, - s_action->cur_item, - s_subject->cur_item->context, - s_action->input); - if (s_object) - evry_history_add(evry_hist->subjects, - s_object->cur_item, - s_action->cur_item->context, - s_object->input); + if (s_act && it_act) + evry_history_add(evry_hist->actions, it_act, it_subj->context, s_act->input); + + if (s_obj && it_obj) + evry_history_add(evry_hist->subjects, it_obj, it_act->context, s_obj->input); /* let subject and object plugin know that an action was performed */ - /* if (s_subject->plugin->action) - * s_subject->plugin->action(s_subject->plugin, s_action->cur_item, s_subject->cur_item); */ - /* if (s_object && s_object->plugin->action) - * s_object->plugin->action(s_object->plugin, s_action->cur_item, s_object->cur_item); */ + /* if (s_subj->plugin->action) + * s_subj->plugin->action(s_subj->plugin, s_act->cur_item, s_subj->cur_item); */ + /* if (s_object && s_obj->plugin->action) + * s_object->plugin->action(s_obj->plugin, s_act->cur_item, s_obj->cur_item); */ if (finished) evry_hide(); diff --git a/src/modules/everything/evry_config.c b/src/modules/everything/evry_config.c index 042df0723..3498f27b5 100644 --- a/src/modules/everything/evry_config.c +++ b/src/modules/everything/evry_config.c @@ -333,9 +333,8 @@ _plugin_config_cb(void *data, void *data2) static Evas_Object * _create_plugin_page(E_Config_Dialog_Data *cfdata, Evas *e, Plugin_Page *page) { - Evas_Object *ot, *o, *of, *ob; + Evas_Object *o, *of, *ob; E_Radio_Group *rg; - Evas_Object *list; of = e_widget_framelist_add(e, _("Available Plugins"), 0); page->list = e_widget_ilist_add(e, 24, 24, NULL); @@ -406,7 +405,7 @@ _create_plugin_page(E_Config_Dialog_Data *cfdata, Evas *e, Plugin_Page *page) static Evas_Object * _basic_create_widgets(E_Config_Dialog *cfd, Evas *e, E_Config_Dialog_Data *cfdata) { - Evas_Object *ot, *o, *of, *ob, *otb, *otb2; + Evas_Object *o, *of, *ob, *otb, *otb2; E_Radio_Group *rg; otb = e_widget_toolbook_add(e, 48 * e_scale, 48 * e_scale); diff --git a/src/modules/everything/evry_plug_actions.c b/src/modules/everything/evry_plug_actions.c index 8ec14dc9b..8043b91ea 100644 --- a/src/modules/everything/evry_plug_actions.c +++ b/src/modules/everything/evry_plug_actions.c @@ -3,40 +3,36 @@ /* action selector plugin: provides list of actions registered for candidate types provided by current plugin */ +typedef struct _Plugin Plugin; + +struct _Plugin +{ + Evry_Plugin base; + Evry_Selector *selector; + Eina_List *actions; +}; + static void -_cleanup(Evry_Plugin *p) +_cleanup(Evry_Plugin *plugin) { + PLUGIN(p, plugin); Evry_Action *act; - Evry_Selector *sel; - if (p->type == type_subject) - sel = selectors[0]; - else - sel = selectors[1]; - - EVRY_PLUGIN_ITEMS_FREE(p); - - EINA_LIST_FREE(sel->cur_actions, act) + EINA_LIST_FREE(p->actions, act) if (act->cleanup) act->cleanup(act); } static Evry_Plugin * -_begin(Evry_Plugin *p, const Evry_Item *it) +_begin(Evry_Plugin *plugin, const Evry_Item *it) { + PLUGIN(p, plugin); Evry_Action *act; Eina_List *l; const char *type; - Evry_Selector *sel; - - if (p->type == type_subject) - sel = selectors[0]; - else - sel = selectors[1]; - - _cleanup(p); - - if (p->type == type_action) + int changed = 0; + + if (plugin->type == type_action) { if (!it) return NULL; type = it->plugin->type_out; @@ -45,22 +41,27 @@ _begin(Evry_Plugin *p, const Evry_Item *it) EINA_LIST_FOREACH(evry_conf->actions, l, act) { - if ((!act->type_in1) || - ((act->type_in1 == type) && (!act->check_item || act->check_item(act, it)))) + if ((!act->type_in1) || ((act->type_in1 == type) && + (!act->check_item || act->check_item(act, it)))) { act->item1 = it; - /* FIXME where is this used ?*/ - /* if (act->type_out && act->intercept && !(act->intercept(act))) - * continue;; */ - - sel->cur_actions = eina_list_append(sel->cur_actions, act); + act->base.plugin = plugin; + + if (!eina_list_data_find_list(p->actions, act)) + { + changed = 1; + p->actions = eina_list_append(p->actions, act); + } + continue; } + changed = 1; + p->actions = eina_list_remove(p->actions, act); } - if (!sel->cur_actions) return NULL; - - return p; + if (!p->actions) return NULL; + + return plugin; } static int @@ -88,40 +89,29 @@ _cb_sort(const void *data1, const void *data2) } static int -_fetch(Evry_Plugin *p, const char *input) +_fetch(Evry_Plugin *plugin, const char *input) { - Evry_Action *act; + PLUGIN(p, plugin); Eina_List *l; Evry_Item *it; - Evry_Selector *sel; - int match = 0; + int match; - if (p->type == type_subject) - sel = selectors[0]; - else - sel = selectors[1]; + EVRY_PLUGIN_ITEMS_CLEAR(p); - EVRY_PLUGIN_ITEMS_FREE(p); - - EINA_LIST_FOREACH(sel->cur_actions, l, act) + EINA_LIST_FOREACH(p->actions, l, it) { - if (input) - match = evry_fuzzy_match(act->name, input); + match = evry_fuzzy_match(it->label, input); if (!input || match) { - it = evry_item_new(NULL, p, act->label, NULL); it->fuzzy_match = match; - it->data = act; - it->priority = act->priority; EVRY_PLUGIN_ITEM_APPEND(p, it); } } - if (!p->items) return 0; + if (!plugin->items) return 0; - if (input) - EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort); + EVRY_PLUGIN_ITEMS_SORT(p, _cb_sort); return 1; } @@ -129,34 +119,94 @@ _fetch(Evry_Plugin *p, const char *input) static Evas_Object * _icon_get(Evry_Plugin *p __UNUSED__, const Evry_Item *it, Evas *e) { + ACTION_GET(act, it); Evas_Object *o = NULL; - Evry_Action *act = it->data; - - if (!act) return NULL; if (act->icon_get) - o = act->icon_get(act, e); - else if (act->icon) - o = evry_icon_theme_get(act->icon, e); + { + o = act->icon_get(act, e); + } + + if ((!o) && it->icon) + { + o = evry_icon_theme_get(it->icon, e); + } return o; } Evry_Plugin * -evry_plug_actions_new(int type) +evry_plug_actions_new(Evry_Selector *sel, int type) { - Evry_Plugin *p; + Evry_Plugin *plugin; - p = evry_plugin_new(NULL, action_selector, _("Actions"), type, "", "", + plugin = EVRY_PLUGIN_NEW(Plugin, N_("Actions"), type, "", "", _begin, _cleanup, _fetch, _icon_get, NULL); - evry_plugin_register(p, 2); - - return p; + PLUGIN(p, plugin); + p->selector = sel; + + evry_plugin_register(plugin, 2); + return plugin; } -void -evry_plug_actions_free(Evry_Plugin *plugin) +/***************************************************************************/ + +EAPI void +evry_action_register(Evry_Action *act, int priority) { - evry_plugin_free(plugin, 1); + EVRY_ITEM(act)->priority = priority; + + evry_conf->actions = eina_list_append(evry_conf->actions, act); + /* TODO sorting, initialization, etc */ +} + +EAPI void +evry_action_unregister(Evry_Action *act) +{ + evry_conf->actions = eina_list_remove(evry_conf->actions, act); + /* cleanup */ +} + +static void +_action_free_cb(Evry_Item *it) +{ + ACTION_GET(act, it); + + if (act->name) eina_stringshare_del(act->name); + if (act->type_in1) eina_stringshare_del(act->type_in1); + if (act->type_in2) eina_stringshare_del(act->type_in2); + + E_FREE(act); +} + +EAPI Evry_Action * +evry_action_new(const char *name, const char *label, + const char *type_in1, const char *type_in2, + const char *icon, + int (*action) (Evry_Action *act), + int (*check_item) (Evry_Action *act, const Evry_Item *it)) +{ + Evry_Action *act = E_NEW(Evry_Action, 1); + + evry_item_new(EVRY_ITEM(act), NULL, label, _action_free_cb); + act->base.icon = icon; + + act->name = eina_stringshare_add(name); + + act->type_in1 = (type_in1 ? eina_stringshare_add(type_in1) : NULL); + act->type_in2 = (type_in2 ? eina_stringshare_add(type_in2) : NULL); + + act->action = action; + act->check_item = check_item; + + return act; +} + +EAPI void +evry_action_free(Evry_Action *act) +{ + evry_action_unregister(act); + + evry_item_free(EVRY_ITEM(act)); } diff --git a/src/modules/everything/evry_plug_aggregator.c b/src/modules/everything/evry_plug_aggregator.c index 78effb08d..11e202147 100644 --- a/src/modules/everything/evry_plug_aggregator.c +++ b/src/modules/everything/evry_plug_aggregator.c @@ -127,8 +127,8 @@ _fetch(Evry_Plugin *plugin, const char *input) Plugin *p = (Plugin *) plugin; Evry_Plugin *pp; Evry_State *s; - Eina_List *l, *ll, *lll, *lp = NULL; - Evry_Item *it, *it2; + Eina_List *l, *ll, *lp = NULL; + Evry_Item *it; int i, cnt = 0; Eina_List *items = NULL; const char *context = NULL; diff --git a/src/modules/everything/evry_plug_text.c b/src/modules/everything/evry_plug_text.c index 7db09008a..021483b31 100644 --- a/src/modules/everything/evry_plug_text.c +++ b/src/modules/everything/evry_plug_text.c @@ -10,15 +10,6 @@ _cleanup(Evry_Plugin *p) EVRY_PLUGIN_ITEMS_FREE(p); } -static void -_cb_free_item_changed(void *data, void *event) -{ - Evry_Event_Item_Changed *ev = event; - - evry_item_free(ev->item); - E_FREE(ev); -} - static int _fetch(Evry_Plugin *p, const char *input) { diff --git a/src/modules/everything/evry_plug_view_thumb.c b/src/modules/everything/evry_plug_view_thumb.c index a0e504e74..f057e1d4e 100644 --- a/src/modules/everything/evry_plug_view_thumb.c +++ b/src/modules/everything/evry_plug_view_thumb.c @@ -627,7 +627,8 @@ _animator(void *data) { Smart_Data *sd = evas_object_smart_data_get(data); double da; - double spd = (25.0/(double)e_config->framerate) / (double) (1 + sd->view->zoom); + double spd = ((25.0/ (double)e_config->framerate) / + (double) (1 + sd->view->zoom)); /* if (sd->sliding) spd *= 1.5; */ if (spd > 0.9) spd = 0.9; @@ -635,7 +636,8 @@ _animator(void *data) if (sd->sel_pos != sd->sel_pos_to) { - sd->sel_pos = (sd->sel_pos * (1.0 - spd)) + (sd->sel_pos_to * spd); + sd->sel_pos = ((sd->sel_pos * (1.0 - spd)) + + (sd->sel_pos_to * spd)); da = sd->sel_pos - sd->sel_pos_to; if (da < 0.0) da = -da; @@ -649,7 +651,8 @@ _animator(void *data) if (sd->scroll_align != sd->scroll_align_to) { - sd->scroll_align = (sd->scroll_align * (1.0 - spd)) + (sd->scroll_align_to * spd); + sd->scroll_align = ((sd->scroll_align * (1.0 - spd)) + + (sd->scroll_align_to * spd)); da = sd->scroll_align - sd->scroll_align_to; if (da < 0.0) da = -da; @@ -658,12 +661,14 @@ _animator(void *data) else wait++; - e_scrollframe_child_pos_set(sd->view->sframe, 0, sd->scroll_align); + e_scrollframe_child_pos_set(sd->view->sframe, + 0, sd->scroll_align); } if (sd->sliding) { - sd->slide = (sd->slide * (1.0 - spd)) + (sd->slide_to * spd); + sd->slide = ((sd->slide * (1.0 - spd)) + + (sd->slide_to * spd)); da = sd->slide - sd->slide_to; if (da < 0.0) da = -da; @@ -673,7 +678,9 @@ _animator(void *data) sd->sliding = 0; if (sd->view->mode == VIEW_MODE_THUMB && sd->cur_item &&sd->cur_item->frame) - edje_object_signal_emit(sd->cur_item->frame, "e,state,selected", "e"); + edje_object_signal_emit(sd->cur_item->frame, + "e,state,selected", "e"); + if (sd->clearing) { @@ -708,7 +715,8 @@ _pan_item_select(Evas_Object *obj, Item *it, int scroll) prev = sd->cur_item->y / sd->cur_item->h; sd->cur_item->selected = EINA_FALSE; if (!sd->cur_item->item->marked) - edje_object_signal_emit(sd->cur_item->frame, "e,state,unselected", "e"); + edje_object_signal_emit(sd->cur_item->frame, + "e,state,unselected", "e"); } sd->cur_item = NULL; @@ -788,14 +796,16 @@ _pan_item_select(Evas_Object *obj, Item *it, int scroll) } } - /* edje_object_signal_emit(sd->cur_item->frame, "e,state,selected", "e"); */ + /* edje_object_signal_emit(sd->cur_item->frame, + * "e,state,selected", "e"); */ align *= it->h; } else { if (sd->view->zoom < 2) { - edje_object_signal_emit(sd->cur_item->frame, "e,state,selected", "e"); + edje_object_signal_emit(sd->cur_item->frame, + "e,state,selected", "e"); } if ((it->y + it->h) - sd->cy > sd->h) @@ -819,7 +829,8 @@ _pan_item_select(Evas_Object *obj, Item *it, int scroll) { sd->scroll_align = align; sd->scroll_align_to = align; - e_scrollframe_child_pos_set(sd->view->sframe, 0, sd->scroll_align); + e_scrollframe_child_pos_set(sd->view->sframe, + 0, sd->scroll_align); } if (sd->animator) ecore_animator_del(sd->animator); @@ -1009,8 +1020,6 @@ _view_update(Evry_View *view, int slide) v_it->pos = pos; - /* set selected state -> TODO remove*/ - /* if (p_it == v->state->cur_item) */ if (p_it->selected) { sd->cur_item = v_it; @@ -1021,7 +1030,6 @@ _view_update(Evry_View *view, int slide) v_it->selected = EINA_FALSE; edje_object_signal_emit(v_it->frame, "e,state,unselected", "e"); } - break; } pos++; @@ -1068,9 +1076,7 @@ _view_update(Evry_View *view, int slide) v_it->pos = pos; - /* TODO no needed */ if (p_it == v->state->cur_item) - /* if (p_it->selected) */ { sd->cur_item = v_it; v_it->selected = EINA_TRUE; @@ -1100,9 +1106,17 @@ _view_update(Evry_View *view, int slide) { if (sd->items && !sd->animator) sd->animator = ecore_animator_add(_animator, v->span); - sd->sliding = 1; - sd->slide_to = sd->x; - sd->slide = sd->x + sd->w * -slide; + + sd->clearing = EINA_FALSE; + + if (!sd->sliding) + sd->slide_to = sd->x; + else + sd->slide_to += sd->w; + + sd->slide = sd->x + sd->w * -slide; + + sd->sliding = 1; } else if (sd->sliding) { @@ -1123,12 +1137,12 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) Item *it = NULL; const Evry_State *s = v->state; int slide; - + if (!s->plugin) return 0; const char *key = ev->key; - + if (s->plugin->view_mode == VIEW_MODE_NONE) { if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) && @@ -1220,7 +1234,7 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) { if (!sd->cur_item) goto end; - + if (!sd->cur_item->item->marked) { edje_object_signal_emit(sd->cur_item->frame, "e,state,marked", "e"); @@ -1231,7 +1245,7 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) edje_object_signal_emit(sd->cur_item->frame, "e,state,unmarked", "e"); evry_item_mark(s, sd->cur_item->item, 0); } - + if(!strcmp(key, "comma")) { key = "Down"; @@ -1270,8 +1284,6 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) } else if (!strcmp(key, "Left")) { - /* if (!sd->items) goto end; */ - if (l && l->prev) it = l->prev->data; @@ -1285,8 +1297,6 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) } if (!strcmp(key, "Down")) { - /* if (!sd->items) goto end; */ - if (!evry_conf->cycle_mode) { EINA_LIST_FOREACH(l, ll, it) @@ -1309,8 +1319,6 @@ _cb_key_down(Evry_View *view, const Ecore_Event_Key *ev) } else if (!strcmp(key, "Up")) { - /* if (!sd->items) goto end; */ - if (!evry_conf->cycle_mode) { for(ll = l; ll; ll = ll->prev)