From 6978e98dc6247373e7a2a3ec2ec58b37ff404c01 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Wed, 25 Feb 2009 11:03:47 +0000 Subject: [PATCH] * estickies, * etk, * PROTO/exalt, * E-MODULES-EXTRA/diskio, * E-MODULES-EXTRA/drawer, * E-MODULES-EXTRA/penguins, * E-MODULES-EXTRA/slideshow, * E-MODULES-EXTRA/mail, * E-MODULES-EXTRA/forecasts, * E-MODULES-EXTRA/iiirk, * E-MODULES-EXTRA/places, * e, * ewl, * ecore, * elitaire, * entrance, * e_dbus, * efreet: Here we go, move from Ecore_List to Eina_List. NOTE: This patch is huge, I did test it a lot, and I hope nothing is broken. But if you think something change after this commit, please contact me ASAP. SVN revision: 39200 --- legacy/ecore/src/lib/ecore/Ecore_Data.h | 10 +- legacy/ecore/src/lib/ecore/ecore_getopt.c | 9 +- legacy/ecore/src/lib/ecore/ecore_path.c | 53 +- legacy/ecore/src/lib/ecore/ecore_plugin.c | 33 +- legacy/ecore/src/lib/ecore_con/ecore_con.c | 28 +- .../ecore/src/lib/ecore_con/ecore_con_info.c | 15 +- .../ecore/src/lib/ecore_con/ecore_con_url.c | 72 +-- .../lib/ecore_config/ecore_config_ipc_ecore.c | 1 + .../ecore/src/lib/ecore_evas/ecore_evas_fb.c | 21 +- legacy/ecore/src/lib/ecore_fb/ecore_fb_li.c | 10 +- legacy/ecore/src/lib/ecore_file/Ecore_File.h | 4 +- legacy/ecore/src/lib/ecore_file/ecore_file.c | 14 +- .../src/lib/ecore_file/ecore_file_download.c | 29 +- .../lib/ecore_file/ecore_file_monitor_poll.c | 27 +- .../src/lib/ecore_file/ecore_file_path.c | 62 +- legacy/ecore/src/lib/ecore_imf/Ecore_IMF.h | 4 +- .../src/lib/ecore_imf/ecore_imf_context.c | 14 +- .../src/lib/ecore_imf/ecore_imf_module.c | 53 +- .../src/lib/ecore_imf/ecore_imf_private.h | 6 +- legacy/ecore/src/lib/ecore_ipc/Ecore_Ipc.h | 2 +- legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c | 44 +- .../src/lib/ecore_ipc/ecore_ipc_private.h | 6 +- .../src/lib/ecore_x/xcb/ecore_xcb_reply.c | 36 +- legacy/efreet/src/bin/ef_cache.c | 9 +- legacy/efreet/src/bin/ef_data_dirs.c | 18 +- legacy/efreet/src/bin/ef_desktop.c | 127 ++-- legacy/efreet/src/bin/ef_icon_theme.c | 111 ++-- legacy/efreet/src/bin/ef_menu.c | 17 +- legacy/efreet/src/bin/efreet_spec_test.c | 4 +- legacy/efreet/src/bin/main.c | 34 +- legacy/efreet/src/lib/Efreet_Trash.h | 2 +- legacy/efreet/src/lib/efreet_base.c | 32 +- legacy/efreet/src/lib/efreet_base.h | 4 +- legacy/efreet/src/lib/efreet_desktop.c | 249 ++++---- legacy/efreet/src/lib/efreet_desktop.h | 22 +- legacy/efreet/src/lib/efreet_icon.c | 245 ++++---- legacy/efreet/src/lib/efreet_icon.h | 22 +- legacy/efreet/src/lib/efreet_ini.c | 2 - legacy/efreet/src/lib/efreet_menu.c | 548 +++++++++--------- legacy/efreet/src/lib/efreet_menu.h | 2 +- legacy/efreet/src/lib/efreet_mime.c | 124 ++-- legacy/efreet/src/lib/efreet_private.h | 11 +- legacy/efreet/src/lib/efreet_trash.c | 6 +- legacy/efreet/src/lib/efreet_utils.c | 239 ++++---- legacy/efreet/src/lib/efreet_utils.h | 16 +- 45 files changed, 1113 insertions(+), 1284 deletions(-) diff --git a/legacy/ecore/src/lib/ecore/Ecore_Data.h b/legacy/ecore/src/lib/ecore/Ecore_Data.h index 2a8331e647..2397ccb410 100644 --- a/legacy/ecore/src/lib/ecore/Ecore_Data.h +++ b/legacy/ecore/src/lib/ecore/Ecore_Data.h @@ -1,8 +1,6 @@ #ifndef _ECORE_DATA_H # define _ECORE_DATA_H -#include - #ifdef EAPI # undef EAPI #endif @@ -32,6 +30,8 @@ /* we need this for size_t */ #include +#include + /** * @file Ecore_Data.h * @brief Contains threading, list, hash, debugging and tree functions. @@ -300,7 +300,7 @@ extern "C" { struct _ecore_path_group { - Ecore_List *paths; + Eina_List *paths; }; /* @@ -331,7 +331,7 @@ extern "C" { /* * Get a list of all the available files in a path set */ - EAPI Ecore_List * ecore_path_group_available_get(Ecore_Path_Group *group); + EAPI Eina_List * ecore_path_group_available_get(Ecore_Path_Group *group); typedef struct _ecore_plugin Ecore_Plugin; @@ -355,7 +355,7 @@ extern "C" { */ EAPI void *ecore_plugin_symbol_get(Ecore_Plugin * plugin, const char *symbol_name); - EAPI Ecore_List *ecore_plugin_available_get(Ecore_Path_Group *group); + EAPI Eina_List *ecore_plugin_available_get(Ecore_Path_Group *group); typedef struct _ecore_heap Ecore_Sheap; diff --git a/legacy/ecore/src/lib/ecore/ecore_getopt.c b/legacy/ecore/src/lib/ecore/ecore_getopt.c index fc897c81d6..75c198c025 100644 --- a/legacy/ecore/src/lib/ecore/ecore_getopt.c +++ b/legacy/ecore/src/lib/ecore/ecore_getopt.c @@ -1635,11 +1635,10 @@ ecore_getopt_parse(const Ecore_Getopt *parser, Ecore_Getopt_Value *values, int a Eina_List * ecore_getopt_list_free(Eina_List *list) { - while (list) - { - free(list->data); - list = eina_list_remove_list(list, list); - } + void *data; + + EINA_LIST_FREE(list, data) + free(data); return NULL; } diff --git a/legacy/ecore/src/lib/ecore/ecore_path.c b/legacy/ecore/src/lib/ecore/ecore_path.c index ea1431e091..bb1f195bff 100644 --- a/legacy/ecore/src/lib/ecore/ecore_path.c +++ b/legacy/ecore/src/lib/ecore/ecore_path.c @@ -45,11 +45,12 @@ ecore_path_group_new(void) EAPI void ecore_path_group_del(Ecore_Path_Group *group) { + char *path; + CHECK_PARAM_POINTER("group", group); - if (group->paths) - ecore_list_destroy(group->paths); - + EINA_LIST_FREE(group->paths, path) + free(path); free(group); } @@ -65,13 +66,7 @@ ecore_path_group_add(Ecore_Path_Group *group, const char *path) CHECK_PARAM_POINTER("group", group); CHECK_PARAM_POINTER("path", path); - if (!group->paths) - { - group->paths = ecore_list_new(); - ecore_list_free_cb_set(group->paths, free); - } - - ecore_list_append(group->paths, strdup(path)); + group->paths = eina_list_append(group->paths, strdup(path)); } /** @@ -94,16 +89,16 @@ ecore_path_group_remove(Ecore_Path_Group *group, const char *path) /* * Find the path in the list of available paths */ - ecore_list_first_goto(group->paths); - - while ((found = ecore_list_current(group->paths)) && strcmp(found, path)) - ecore_list_next(group->paths); + found = eina_list_search_unsorted(group->paths, strcmp, path); /* * If the path is found, remove and free it */ if (found) - ecore_list_remove_destroy(group->paths); + { + group->paths = eina_list_remove(group->paths, found); + free(found); + } } /** @@ -117,6 +112,7 @@ ecore_path_group_remove(Ecore_Path_Group *group, const char *path) EAPI char * ecore_path_group_find(Ecore_Path_Group *group, const char *name) { + Eina_List *l; int r; char *p; struct stat st; @@ -131,15 +127,13 @@ ecore_path_group_find(Ecore_Path_Group *group, const char *name) /* * Search the paths of the path group for the specified file name */ - ecore_list_first_goto(group->paths); - p = ecore_list_next(group->paths); - do + EINA_LIST_FOREACH(group->paths, l, p) { snprintf(path, PATH_MAX, "%s/%s", p, name); r = stat(path, &st); + if ((r >= 0) && S_ISREG(st.st_mode)) + break; } - while (((r < 0) || !S_ISREG(st.st_mode)) && - (p = ecore_list_next(group->paths))); if (p) p = strdup(path); @@ -154,20 +148,19 @@ ecore_path_group_find(Ecore_Path_Group *group, const char *name) * identified by @p group_id. @c NULL otherwise. * @ingroup Ecore_Path_Group */ -EAPI Ecore_List * +EAPI Eina_List * ecore_path_group_available_get(Ecore_Path_Group *group) { - Ecore_List *avail = NULL; + Eina_List *avail = NULL; + Eina_List *l; char *path; CHECK_PARAM_POINTER_RETURN("group", group, NULL); - if (!group->paths || ecore_list_empty_is(group->paths)) + if (!group->paths || !eina_list_count(group->paths)) return NULL; - ecore_list_first_goto(group->paths); - - while ((path = ecore_list_next(group->paths)) != NULL) + EINA_LIST_FOREACH(group->paths, l, path) { DIR *dir; struct stat st; @@ -203,13 +196,11 @@ ecore_path_group_available_get(Ecore_Path_Group *group) strncpy(n, d->d_name, l - 2); */ - if (!avail) - avail = ecore_list_new(); - -/* ecore_list_append(avail, strdup(n));*/ - ecore_list_append(avail, strdup(d->d_name)); +/* avail = eina_list_append(avail, strdup(n));*/ + avail = eina_list_append(avail, strdup(d->d_name)); } } return avail; } + diff --git a/legacy/ecore/src/lib/ecore/ecore_plugin.c b/legacy/ecore/src/lib/ecore/ecore_plugin.c index 0162a27b68..8b79dc134f 100644 --- a/legacy/ecore/src/lib/ecore/ecore_plugin.c +++ b/legacy/ecore/src/lib/ecore/ecore_plugin.c @@ -28,7 +28,7 @@ #include "ecore_private.h" -static Ecore_List *loaded_plugins = NULL; +static Eina_List *loaded_plugins = NULL; static Eina_Bool _hash_keys(const Eina_Hash *hash, const char *key, @@ -106,10 +106,8 @@ ecore_plugin_load(Ecore_Path_Group *group, const char *plugin_name, const char * /* * Now add it to the list of the groups loaded plugins */ - if (!loaded_plugins) - loaded_plugins = ecore_list_new(); - ecore_list_append(loaded_plugins, plugin); + loaded_plugins = eina_list_append(loaded_plugins, plugin); FREE(path); @@ -129,14 +127,7 @@ ecore_plugin_unload(Ecore_Plugin *plugin) if (!plugin->handle) return; - if (ecore_list_goto(loaded_plugins, plugin)) - ecore_list_remove(loaded_plugins); - - if (ecore_list_empty_is(loaded_plugins)) - { - ecore_list_destroy(loaded_plugins); - loaded_plugins = NULL; - } + loaded_plugins = eina_list_remove(loaded_plugins, plugin); dlclose(plugin->handle); @@ -173,23 +164,23 @@ ecore_plugin_symbol_get(Ecore_Plugin *plugin, const char *symbol_name) * paths identified by @p group_id. @c NULL otherwise. * @ingroup Ecore_Plugin */ -EAPI Ecore_List * +EAPI Eina_List * ecore_plugin_available_get(Ecore_Path_Group *group) { - Ecore_List *avail = NULL; + Eina_List *avail = NULL; + Eina_List *l; Eina_Hash *plugins = NULL; Eina_Iterator *it = NULL; char *path; CHECK_PARAM_POINTER_RETURN("group", group, NULL); - if (!group->paths || ecore_list_empty_is(group->paths)) + if (!group->paths || !eina_list_count(group->paths)) return NULL; - ecore_list_first_goto(group->paths); plugins = eina_hash_string_superfast_new(NULL); - while ((path = ecore_list_next(group->paths)) != NULL) + EINA_LIST_FOREACH(group->paths, l, path) { DIR *dir; struct stat st; @@ -239,14 +230,10 @@ ecore_plugin_available_get(Ecore_Path_Group *group) closedir(dir); } - avail = ecore_list_new(); - ecore_list_free_cb_set(avail, free); - - it = eina_hash_iterator_data_new(plugins); if (it) { - eina_iterator_foreach(it, EINA_EACH(_hash_keys), avail); + eina_iterator_foreach(it, EINA_EACH(_hash_keys), &avail); eina_iterator_free(it); } @@ -259,6 +246,6 @@ ecore_plugin_available_get(Ecore_Path_Group *group) static Eina_Bool _hash_keys(const Eina_Hash *hash __UNUSED__, const char *key, void *list) { - ecore_list_append(list, strdup(key)); + *(Eina_List **)list = eina_list_append(*(Eina_List **)list, key); return EINA_TRUE; } diff --git a/legacy/ecore/src/lib/ecore_con/ecore_con.c b/legacy/ecore/src/lib/ecore_con/ecore_con.c index 5b83ed4738..d9199ef5a4 100644 --- a/legacy/ecore/src/lib/ecore_con/ecore_con.c +++ b/legacy/ecore/src/lib/ecore_con/ecore_con.c @@ -57,7 +57,7 @@ EAPI int ECORE_CON_EVENT_SERVER_DEL = 0; EAPI int ECORE_CON_EVENT_CLIENT_DATA = 0; EAPI int ECORE_CON_EVENT_SERVER_DATA = 0; -static Ecore_List *servers = NULL; +static Eina_List *servers = NULL; static int init_count = 0; #define LENGTH_OF_SOCKADDR_UN(s) (strlen((s)->sun_path) + (size_t)(((struct sockaddr_un *)NULL)->sun_path)) @@ -94,8 +94,6 @@ ecore_con_init(void) ecore_con_dns_init(); ecore_con_info_init(); - servers = ecore_list_new(); - return init_count; } @@ -110,10 +108,8 @@ ecore_con_shutdown(void) { if (--init_count != 0) return init_count; - while (!ecore_list_empty_is(servers)) - _ecore_con_server_free(ecore_list_first_remove(servers)); - ecore_list_destroy(servers); - servers = NULL; + while (servers) + _ecore_con_server_free(eina_list_data_get(servers)); ecore_con_info_shutdown(); ecore_con_dns_shutdown(); @@ -239,7 +235,7 @@ ecore_con_server_add(Ecore_Con_Type compl_type, const char *name, int port, socket_unix.sun_family = AF_UNIX; if (type == ECORE_CON_LOCAL_ABSTRACT) { -#ifdef HAVE_ABSTRACT_SOCKETS +#ifdef HAVE_ABSTRACT_SOCKET /* . is a placeholder */ snprintf(socket_unix.sun_path, sizeof(socket_unix.sun_path), ".%s", name); /* first char null indicates abstract namespace */ @@ -285,7 +281,7 @@ ecore_con_server_add(Ecore_Con_Type compl_type, const char *name, int port, if (!ecore_con_info_udp_listen(svr, _ecore_con_cb_udp_listen, svr)) goto error; } - ecore_list_append(servers, svr); + servers = eina_list_append(servers, svr); ECORE_MAGIC_SET(svr, ECORE_MAGIC_CON_SERVER); return svr; @@ -463,7 +459,7 @@ ecore_con_server_connect(Ecore_Con_Type compl_type, const char *name, int port, if (!ecore_con_info_udp_connect(svr, _ecore_con_cb_udp_connect, svr)) goto error; } - ecore_list_append(servers, svr); + servers = eina_list_append(servers, svr); ECORE_MAGIC_SET(svr, ECORE_MAGIC_CON_SERVER); return svr; @@ -494,6 +490,8 @@ ecore_con_server_del(Ecore_Con_Server *svr) ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_server_del"); return NULL; } + if (svr->delete_me) return NULL; + data = svr->data; svr->data = NULL; svr->delete_me = 1; @@ -508,7 +506,6 @@ ecore_con_server_del(Ecore_Con_Server *svr) else { _ecore_con_server_free(svr); - if (ecore_list_goto(servers, svr)) ecore_list_remove(servers); } return data; } @@ -886,12 +883,8 @@ _ecore_con_server_free(Ecore_Con_Server *svr) } } if (svr->write_buf) free(svr->write_buf); - while (svr->clients) - { - cl = eina_list_data_get(svr->clients); - svr->clients = eina_list_remove(svr->clients, cl); + EINA_LIST_FREE(svr->clients, cl) _ecore_con_client_free(cl); - } if ((svr->created) && (svr->path) && (svr->ppid == getpid())) unlink(svr->path); if (svr->fd >= 0) close(svr->fd); @@ -900,6 +893,7 @@ _ecore_con_server_free(Ecore_Con_Server *svr) if (svr->path) free(svr->path); if (svr->ip) free(svr->ip); if (svr->fd_handler) ecore_main_fd_handler_del(svr->fd_handler); + servers = eina_list_remove(servers, svr); free(svr); } @@ -1389,7 +1383,7 @@ static int _ecore_con_svr_udp_handler(void *data, Ecore_Fd_Handler *fd_handler) { Ecore_Con_Server *svr; - Ecore_Con_Client *cl; + Ecore_Con_Client *cl = NULL; svr = data; if (svr->dead) return 1; diff --git a/legacy/ecore/src/lib/ecore_con/ecore_con_info.c b/legacy/ecore/src/lib/ecore_con/ecore_con_info.c index de21a00e10..019dd99c47 100644 --- a/legacy/ecore/src/lib/ecore_con/ecore_con_info.c +++ b/legacy/ecore/src/lib/ecore_con/ecore_con_info.c @@ -198,9 +198,10 @@ ecore_con_info_get(Ecore_Con_Server *svr, char service[NI_MAXSERV]; char hbuf[NI_MAXHOST]; char sbuf[NI_MAXSERV]; - void *tosend; + void *tosend = NULL; int tosend_len; int canonname_len = 0; + int err; /* FIXME with EINA */ snprintf(service, NI_MAXSERV, "%i", svr->port); @@ -210,12 +211,13 @@ ecore_con_info_get(Ecore_Con_Server *svr, if (result->ai_canonname) canonname_len = strlen(result->ai_canonname) + 1; tosend_len = sizeof(Ecore_Con_Info) + result->ai_addrlen + canonname_len; - tosend = malloc(tosend_len); + + if ((tosend = malloc(tosend_len))); + goto on_error; + memset(tosend, 0, tosend_len); container = (Ecore_Con_Info *)tosend; container->size = tosend_len; - memset(container->ip, 0, sizeof(container->ip)); - memset(container->service, 0, sizeof(container->service)); memcpy(&container->info, result, sizeof(struct addrinfo)); memcpy(tosend + sizeof(Ecore_Con_Info), result->ai_addr, result->ai_addrlen); @@ -228,13 +230,14 @@ ecore_con_info_get(Ecore_Con_Server *svr, memcpy(container->ip, hbuf, sizeof(container->ip)); memcpy(container->service, sbuf, sizeof(container->service)); } - write(fd[1], tosend, tosend_len); + err = write(fd[1], tosend, tosend_len); free(tosend); } else - write(fd[1], "", 1); + err = write(fd[1], "", 1); +on_error: close(fd[1]); # ifdef __USE_ISOC99 _Exit(0); diff --git a/legacy/ecore/src/lib/ecore_con/ecore_con_url.c b/legacy/ecore/src/lib/ecore_con/ecore_con_url.c index 9461aa6313..bbff69036c 100644 --- a/legacy/ecore/src/lib/ecore_con/ecore_con_url.c +++ b/legacy/ecore/src/lib/ecore_con/ecore_con_url.c @@ -80,7 +80,7 @@ static void _ecore_con_event_url_free(void *data __UNUSED__, void *ev); static int _ecore_con_url_process_completed_jobs(Ecore_Con_Url *url_con_to_match); static Ecore_Idler *_fd_idler_handler = NULL; -static Ecore_List *_url_con_list = NULL; +static Eina_List *_url_con_list = NULL; static CURLM *curlm = NULL; static fd_set _current_fd_set; static int init_count = 0; @@ -129,6 +129,8 @@ EAPI int ecore_con_url_init(void) { #ifdef HAVE_CURL + Ecore_Con_Url *url_con; + if (!ECORE_CON_EVENT_URL_DATA) { ECORE_CON_EVENT_URL_DATA = ecore_event_type_new(); @@ -136,27 +138,21 @@ ecore_con_url_init(void) ECORE_CON_EVENT_URL_PROGRESS = ecore_event_type_new(); } - if (!_url_con_list) - { - _url_con_list = ecore_list_new(); - if (!_url_con_list) return 0; - } - if (!curlm) { FD_ZERO(&_current_fd_set); if (curl_global_init(CURL_GLOBAL_NOTHING)) { - ecore_list_destroy(_url_con_list); - _url_con_list = NULL; + EINA_LIST_FREE(_url_con_list, url_con) + ecore_con_url_destroy(url_con); return 0; } curlm = curl_multi_init(); if (!curlm) { - ecore_list_destroy(_url_con_list); - _url_con_list = NULL; + EINA_LIST_FREE(_url_con_list, url_con) + ecore_con_url_destroy(url_con); return 0; } } @@ -176,24 +172,14 @@ EAPI int ecore_con_url_shutdown(void) { #ifdef HAVE_CURL + Ecore_Con_Url *url_con; if (!init_count) return 0; init_count--; - if (_url_con_list) - { - if (!ecore_list_empty_is(_url_con_list)) - { - Ecore_Con_Url *url_con; - while ((url_con = ecore_list_first(_url_con_list))) - { + EINA_LIST_FREE(_url_con_list, url_con) ecore_con_url_destroy(url_con); - } - } - ecore_list_destroy(_url_con_list); - _url_con_list = NULL; - } if (curlm) { @@ -286,8 +272,7 @@ ecore_con_url_destroy(Ecore_Con_Url *url_con) { if (url_con->active) { - if (ecore_list_find(_url_con_list, ecore_direct_compare, url_con) == url_con) - ecore_list_remove(_url_con_list); + _url_con_list = eina_list_remove(_url_con_list, url_con); url_con->active = 0; curl_multi_remove_handle(curlm, url_con->curl_easy); @@ -615,14 +600,14 @@ ecore_con_url_ftp_use_epsv_set(Ecore_Con_Url *url_con, int use_epsv) static int _ecore_con_url_suspend_fd_handler(void) { + Eina_List *l; Ecore_Con_Url *url_con; int deleted = 0; if (!_url_con_list) return 0; - ecore_list_first_goto(_url_con_list); - while ((url_con = ecore_list_current(_url_con_list))) + EINA_LIST_FOREACH(_url_con_list, l, url_con) { if (url_con->active && url_con->fd_handler) { @@ -630,7 +615,6 @@ _ecore_con_url_suspend_fd_handler(void) url_con->fd_handler = NULL; deleted++; } - ecore_list_next(_url_con_list); } return deleted; @@ -639,25 +623,23 @@ _ecore_con_url_suspend_fd_handler(void) static int _ecore_con_url_restart_fd_handler(void) { + Eina_List *l; Ecore_Con_Url *url_con; int activated = 0; if (!_url_con_list) return 0; - ecore_list_first_goto(_url_con_list); - while ((url_con = ecore_list_current(_url_con_list))) + EINA_LIST_FOREACH(_url_con_list, l, url_con) { - if (url_con->fd_handler == NULL - && url_con->fd != -1) + if (url_con->fd_handler == NULL && url_con->fd != -1) { - url_con->fd_handler = ecore_main_fd_handler_add(url_con->fd, + url_con->fd_handler == ecore_main_fd_handler_add(url_con->fd, url_con->flags, _ecore_con_url_fd_handler, NULL, NULL, NULL); activated++; } - ecore_list_next(_url_con_list); } return activated; @@ -781,7 +763,7 @@ _ecore_con_url_perform(Ecore_Con_Url *url_con) int still_running; int completed_immediately = 0; - ecore_list_append(_url_con_list, url_con); + _url_con_list = eina_list_append(_url_con_list, url_con); url_con->active = 1; curl_multi_add_handle(curlm, url_con->curl_easy); @@ -874,7 +856,9 @@ _ecore_con_url_fd_handler(void *data __UNUSED__, Ecore_Fd_Handler *fd_handler __ static int _ecore_con_url_process_completed_jobs(Ecore_Con_Url *url_con_to_match) { + Eina_List *l; Ecore_Con_Url *url_con; + Ecore_Con_Event_Url_Complete *e; CURLMsg *curlmsg; int n_remaining; int job_matched = 0; @@ -885,16 +869,13 @@ _ecore_con_url_process_completed_jobs(Ecore_Con_Url *url_con_to_match) if (curlmsg->msg != CURLMSG_DONE) continue; /* find the job which is done */ - ecore_list_first_goto(_url_con_list); - while ((url_con = ecore_list_current(_url_con_list))) + EINA_LIST_FOREACH(_url_con_list, l, url_con) { if (curlmsg->easy_handle == url_con->curl_easy) { - /* We have found the completed job in our job list */ - if (url_con_to_match && (url_con == url_con_to_match)) { + if (url_con_to_match && (url_con == url_con_to_match)) job_matched = 1; - } - if (url_con->fd != -1) + if(url_con->fd != -1) { FD_CLR(url_con->fd, &_current_fd_set); if (url_con->fd_handler) @@ -902,27 +883,22 @@ _ecore_con_url_process_completed_jobs(Ecore_Con_Url *url_con_to_match) url_con->fd = -1; url_con->fd_handler = NULL; } - ecore_list_remove(_url_con_list); + _url_con_list = eina_list_remove(_url_con_list, url_con); url_con->active = 0; - { - Ecore_Con_Event_Url_Complete *e; e = calloc(1, sizeof(Ecore_Con_Event_Url_Complete)); if (e) { e->url_con = url_con; - e->status = 0; curl_easy_getinfo(curlmsg->easy_handle, CURLINFO_RESPONSE_CODE, &e->status); - _url_complete_push_event(ECORE_CON_EVENT_URL_COMPLETE, e); } - } curl_multi_remove_handle(curlm, url_con->curl_easy); break; } - ecore_list_next(_url_con_list); } } + return job_matched; } diff --git a/legacy/ecore/src/lib/ecore_config/ecore_config_ipc_ecore.c b/legacy/ecore/src/lib/ecore_config/ecore_config_ipc_ecore.c index ad4ec35a0b..bd2ec03022 100644 --- a/legacy/ecore/src/lib/ecore_config/ecore_config_ipc_ecore.c +++ b/legacy/ecore/src/lib/ecore_config/ecore_config_ipc_ecore.c @@ -364,6 +364,7 @@ _ecore_config_ipc_ecore_exit(void **data) } ecore_ipc_shutdown(); + ecore_shutdown(); return ret; } diff --git a/legacy/ecore/src/lib/ecore_evas/ecore_evas_fb.c b/legacy/ecore/src/lib/ecore_evas/ecore_evas_fb.c index e97d864ad5..6c187a8000 100644 --- a/legacy/ecore/src/lib/ecore_evas/ecore_evas_fb.c +++ b/legacy/ecore/src/lib/ecore_evas/ecore_evas_fb.c @@ -23,7 +23,7 @@ static int _ecore_evas_init_count = 0; static int _ecore_evas_fps_debug = 0; static char *ecore_evas_default_display = "0"; -static Ecore_List *ecore_evas_input_devices = NULL; +static Eina_List *ecore_evas_input_devices = NULL; static Ecore_Evas *ecore_evases = NULL; static Ecore_Event_Handler *ecore_evas_event_handlers[6] = {NULL, NULL, NULL, NULL, NULL, NULL}; static Ecore_Idle_Enterer *ecore_evas_idle_enterer = NULL; @@ -76,6 +76,7 @@ static void _ecore_evas_fb_lose(void *data __UNUSED__) { Ecore_List2 *l; + Eina_List *ll; Ecore_Fb_Input_Device *dev; for (l = (Ecore_List2 *)ecore_evases; l; l = l->next) @@ -87,8 +88,7 @@ _ecore_evas_fb_lose(void *data __UNUSED__) } if (ecore_evas_input_devices) { - ecore_list_first_goto(ecore_evas_input_devices); - while ((dev = ecore_list_next(ecore_evas_input_devices))) + EINA_LIST_FOREACH(ecore_evas_input_devices, ll, dev) ecore_fb_input_device_listen(dev, 0); } } @@ -97,6 +97,7 @@ static void _ecore_evas_fb_gain(void *data __UNUSED__) { Ecore_List2 *l; + Eina_List *l; Ecore_Fb_Input_Device *dev; for (l = (Ecore_List2 *)ecore_evases; l; l = l->next) @@ -112,8 +113,7 @@ _ecore_evas_fb_gain(void *data __UNUSED__) } if (ecore_evas_input_devices) { - ecore_list_first_goto(ecore_evas_input_devices); - while ((dev = ecore_list_next(ecore_evas_input_devices))) + EINA_LIST_FOREACH(ecore_evas_input_devices, ll, dev) ecore_fb_input_device_listen(dev, 1); } } @@ -274,7 +274,6 @@ _ecore_evas_fb_init(int w, int h) input_dir = opendir("/dev/input/"); if (!input_dir) return _ecore_evas_init_count; - ecore_evas_input_devices = ecore_list_new(); while ((input_entry = readdir(input_dir))) { char device_path[256]; @@ -295,7 +294,7 @@ _ecore_evas_fb_init(int w, int h) { ecore_fb_input_device_axis_size_set(device, w, h); ecore_fb_input_device_listen(device,1); - ecore_list_append(ecore_evas_input_devices, device); + ecore_evas_input_devices = eina_list_append(ecore_evas_input_devices, device); if (!mouse_handled) { ecore_evas_event_handlers[2] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, _ecore_evas_event_mouse_button_down, NULL); @@ -309,7 +308,7 @@ _ecore_evas_fb_init(int w, int h) else if ((caps & ECORE_FB_INPUT_DEVICE_CAP_KEYS_OR_BUTTONS) && !(caps & ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE)) { ecore_fb_input_device_listen(device,1); - ecore_list_append(ecore_evas_input_devices, device); + ecore_evas_input_devices = eina_list_append(ecore_evas_input_devices, device); if (!keyboard_handled) { ecore_evas_event_handlers[0] = ecore_event_handler_add(ECORE_FB_EVENT_KEY_DOWN, _ecore_evas_event_key_down, NULL); @@ -480,6 +479,7 @@ _ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int h static void _ecore_evas_fullscreen_set(Ecore_Evas *ee, int on) { + Eina_List *l; int resized = 0; if (((ee->prop.fullscreen) && (on)) || @@ -520,9 +520,8 @@ _ecore_evas_fullscreen_set(Ecore_Evas *ee, int on) { Ecore_Fb_Input_Device *dev; - ecore_list_first_goto(ecore_evas_input_devices); - while ((dev = ecore_list_next(ecore_evas_input_devices))) - ecore_fb_input_device_axis_size_set(dev, ee->w, ee->h); + EINA_LIST_FOREACH(ecore_evas_input_devices, l, dev) + ecore_fb_input_device_axis_size_set(dev, ee->wn ee->h); } if (resized) { diff --git a/legacy/ecore/src/lib/ecore_fb/ecore_fb_li.c b/legacy/ecore/src/lib/ecore_fb/ecore_fb_li.c index bc0e11f009..547aef42dd 100644 --- a/legacy/ecore/src/lib/ecore_fb/ecore_fb_li.c +++ b/legacy/ecore/src/lib/ecore_fb/ecore_fb_li.c @@ -11,7 +11,7 @@ #define CLICK_THRESHOLD_DEFAULT 0.25 -static Ecore_List *_ecore_fb_li_devices = NULL; +static Eina_List *_ecore_fb_li_devices = NULL; static const char *_ecore_fb_li_kbd_syms[128 * 6] = { @@ -374,9 +374,6 @@ ecore_fb_input_device_open(const char *dev) device = calloc(1, sizeof(Ecore_Fb_Input_Device)); if(!device) return NULL; - if(!_ecore_fb_li_devices) - _ecore_fb_li_devices = ecore_list_new(); - if((fd = open(dev, O_RDONLY, O_NONBLOCK)) < 0) { fprintf(stderr, "[ecore_fb_li:device_open] %s %s", dev, strerror(errno)); @@ -433,7 +430,7 @@ ecore_fb_input_device_open(const char *dev) break; } } - ecore_list_append(_ecore_fb_li_devices, device); + _ecore_fb_li_devices = eina_list_append(_ecore_fb_li_devices, device); return device; error_caps: @@ -450,8 +447,7 @@ ecore_fb_input_device_close(Ecore_Fb_Input_Device *dev) /* close the fd */ close(dev->fd); /* remove the element from the list */ - if(ecore_list_goto(_ecore_fb_li_devices, dev)) - ecore_list_remove(_ecore_fb_li_devices); + _ecore_fb_li_devices = eina_list_remove(_ecore_fb_li_devices, dev); free(dev); } diff --git a/legacy/ecore/src/lib/ecore_file/Ecore_File.h b/legacy/ecore/src/lib/ecore_file/Ecore_File.h index 03c2355f22..5bb8f0b1da 100644 --- a/legacy/ecore/src/lib/ecore_file/Ecore_File.h +++ b/legacy/ecore/src/lib/ecore_file/Ecore_File.h @@ -84,7 +84,7 @@ extern "C" { EAPI int ecore_file_can_write (const char *file); EAPI int ecore_file_can_exec (const char *file); EAPI char *ecore_file_readlink (const char *link); - EAPI Ecore_List *ecore_file_ls (const char *dir); + EAPI Eina_List *ecore_file_ls (const char *dir); EAPI char *ecore_file_app_exe_get (const char *app); EAPI char *ecore_file_escape_name (const char *filename); EAPI char *ecore_file_strip_ext (const char *file); @@ -100,7 +100,7 @@ extern "C" { EAPI int ecore_file_path_dir_exists(const char *in_dir); EAPI int ecore_file_app_installed(const char *exe); - EAPI Ecore_List *ecore_file_app_list(void); + EAPI Eina_List *ecore_file_app_list(void); EAPI int ecore_file_download(const char *url, const char *dst, void (*completion_cb)(void *data, diff --git a/legacy/ecore/src/lib/ecore_file/ecore_file.c b/legacy/ecore/src/lib/ecore_file/ecore_file.c index eb3f4f0982..6efe5e0502 100644 --- a/legacy/ecore/src/lib/ecore_file/ecore_file.c +++ b/legacy/ecore/src/lib/ecore_file/ecore_file.c @@ -509,36 +509,32 @@ ecore_file_readlink(const char *link) * For more information see the manual pages of strcoll and setlocale. * The list will not contain the directory entries for '.' and '..'. * @param dir The name of the directory to list - * @return Return an Ecore_List containing all the files in the directory; + * @return Return an Eina_List containing all the files in the directory; * on failure it returns NULL. */ -EAPI Ecore_List * +EAPI Eina_List * ecore_file_ls(const char *dir) { char *f; DIR *dirp; struct dirent *dp; - Ecore_List *list; + Eina_List *list = NULL; dirp = opendir(dir); if (!dirp) return NULL; - list = ecore_list_new(); - ecore_list_free_cb_set(list, free); - while ((dp = readdir(dirp))) { if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, ".."))) { f = strdup(dp->d_name); - ecore_list_append(list, f); + list = eina_list_append(list, f); } } closedir(dirp); - ecore_list_sort(list, ECORE_COMPARE_CB(strcoll), ECORE_SORT_MIN); + list = eina_list_sort(list, ECORE_SORT_MIN, ECORE_COMPARE_CB(strcoll)); - ecore_list_first_goto(list); return list; } diff --git a/legacy/ecore/src/lib/ecore_file/ecore_file_download.c b/legacy/ecore/src/lib/ecore_file/ecore_file_download.c index 4506f72f7f..c855c7135e 100644 --- a/legacy/ecore/src/lib/ecore_file/ecore_file_download.c +++ b/legacy/ecore/src/lib/ecore_file/ecore_file_download.c @@ -45,7 +45,7 @@ static void _ecore_file_download_abort(Ecore_File_Download_Job *job); static int init = 0; static Ecore_Event_Handler *_url_complete_handler = NULL; static Ecore_Event_Handler *_url_progress_download = NULL; -static Ecore_List *_job_list; +static Eina_List *_job_list; EAPI int ecore_file_download_init(void) @@ -60,11 +60,6 @@ ecore_file_download_init(void) _url_progress_download = ecore_event_handler_add(ECORE_CON_EVENT_URL_PROGRESS, _ecore_file_download_url_progress_cb, NULL); #endif } - if (!_job_list) - { - _job_list = ecore_list_new(); - if (!_job_list) return 0; - } return 1; #else @@ -84,9 +79,7 @@ ecore_file_download_shutdown(void) ecore_event_handler_del(_url_progress_download); _url_complete_handler = NULL; _url_progress_download = NULL; - if (_job_list) - ecore_list_destroy(_job_list); - _job_list = NULL; + ecore_file_download_abort_all(); } return ecore_con_url_shutdown(); @@ -98,16 +91,10 @@ ecore_file_download_shutdown(void) EAPI void ecore_file_download_abort_all(void) { - if (!ecore_list_empty_is(_job_list)) - { Ecore_File_Download_Job *job; - while ((job = ecore_list_first_remove(_job_list))) - { + EINA_LIST_FREE(_job_list, job) _ecore_file_download_abort(job); - } - } - ecore_list_clear(_job_list); } /** @@ -212,10 +199,10 @@ _ecore_file_download_url_complete_cb(void *data, int type, void *event) Ecore_Con_Event_Url_Complete *ev = event; Ecore_File_Download_Job *job; - job = ecore_list_find(_job_list, _ecore_file_download_url_compare_job, ev->url_con); + job = eina_list_search_unsorted(_job_list, _ecore_file_download_url_compare_job, ev->url_con); if (!ECORE_MAGIC_CHECK(job, ECORE_MAGIC_FILE_DOWNLOAD_JOB)) return 1; - ecore_list_remove(_job_list); + _job_list = eina_list_remove(_job_list, job); if (job->completion_cb) job->completion_cb(ecore_con_url_data_get(job->url_con), job->dst, !ev->status); @@ -233,7 +220,7 @@ _ecore_file_download_url_progress_cb(void *data, int type, void *event) Ecore_Con_Event_Url_Progress *ev = event; Ecore_File_Download_Job *job; - job = ecore_list_find(_job_list, _ecore_file_download_url_compare_job, ev->url_con); + job = eina_list_search_unsorted(_job_list, _ecore_file_download_url_compare_job, ev->url_con); if (!ECORE_MAGIC_CHECK(job, ECORE_MAGIC_FILE_DOWNLOAD_JOB)) return 1; if (job->progress_cb) @@ -241,7 +228,7 @@ _ecore_file_download_url_progress_cb(void *data, int type, void *event) (long int) ev->down.total, (long int) ev->down.now, (long int) ev->up.total, (long int) ev->up.now) != 0) { - ecore_list_remove(_job_list); + _job_list = eina_list_remove(_job_list, job); _ecore_file_download_abort(job); } @@ -285,7 +272,7 @@ _ecore_file_download_curl(const char *url, const char *dst, job->completion_cb = completion_cb; job->progress_cb = progress_cb; - ecore_list_append(_job_list, job); + _job_list = eina_list_append(_job_list, job); ecore_con_url_send(job->url_con, NULL, 0, NULL); diff --git a/legacy/ecore/src/lib/ecore_file/ecore_file_monitor_poll.c b/legacy/ecore/src/lib/ecore_file/ecore_file_monitor_poll.c index 6573539dc1..76bdc702ea 100644 --- a/legacy/ecore/src/lib/ecore_file/ecore_file_monitor_poll.c +++ b/legacy/ecore/src/lib/ecore_file/ecore_file_monitor_poll.c @@ -117,29 +117,28 @@ ecore_file_monitor_poll_add(const char *path, if (ecore_file_is_dir(em->path)) { /* Check for subdirs */ - Ecore_List *files; + Eina_List *files; char *file; files = ecore_file_ls(em->path); - if (files) - { - while ((file = ecore_list_next(files))) + EINA_LIST_FREE(files, file) { Ecore_File *f; char buf[PATH_MAX]; f = calloc(1, sizeof(Ecore_File)); if (!f) + { + free(file); continue; + } snprintf(buf, sizeof(buf), "%s/%s", em->path, file); - f->name = strdup(file); + f->name = file; f->mtime = ecore_file_mod_time(buf); f->is_dir = ecore_file_is_dir(buf); em->files = _ecore_list2_append(em->files, f); } - ecore_list_destroy(files); - } } } else @@ -307,7 +306,8 @@ _ecore_file_monitor_poll_check(Ecore_File_Monitor *em) /* Check for new files */ if (ECORE_FILE_MONITOR_POLL(em)->mtime < mtime) { - Ecore_List *files; + Eina_List *files; + Eina_List *l; char *file; /* Files have been added or removed */ @@ -315,7 +315,7 @@ _ecore_file_monitor_poll_check(Ecore_File_Monitor *em) if (files) { /* Are we a directory? We should check first, rather than rely on null here*/ - while ((file = ecore_list_next(files))) + EINA_LIST_FOREACH(files, l, file) { Ecore_File *f; char buf[PATH_MAX]; @@ -331,7 +331,7 @@ _ecore_file_monitor_poll_check(Ecore_File_Monitor *em) f->name = strdup(file); f->mtime = ecore_file_mod_time(buf); - f->is_dir = ecore_file_is_dir(buf); + f->is_dir = ecore_file_mod_time(buf); if (f->is_dir) event = ECORE_FILE_EVENT_CREATED_DIRECTORY; else @@ -339,7 +339,12 @@ _ecore_file_monitor_poll_check(Ecore_File_Monitor *em) em->func(em->data, em, event, buf); em->files = _ecore_list2_append(em->files, f); } - ecore_list_destroy(files); + while (files) + { + file = eina_list_data_get(files); + free(file); + files = eina_list_remove_list(files, files); + } } if (!ecore_file_is_dir(em->path)) diff --git a/legacy/ecore/src/lib/ecore_file/ecore_file_path.c b/legacy/ecore/src/lib/ecore_file/ecore_file_path.c index de2b4dc4d4..dd1e95f0ec 100644 --- a/legacy/ecore/src/lib/ecore_file/ecore_file_path.c +++ b/legacy/ecore/src/lib/ecore_file/ecore_file_path.c @@ -12,36 +12,35 @@ #include "ecore_file_private.h" static int init = 0; -static Ecore_List *__ecore_file_path_bin = NULL; +static Eina_List *__ecore_file_path_bin = NULL; -static Ecore_List *_ecore_file_path_from_env(const char *env); +static Eina_List *_ecore_file_path_from_env(const char *env); int ecore_file_path_init(void) { if (++init != 1) return init; __ecore_file_path_bin = _ecore_file_path_from_env("PATH"); - ecore_list_free_cb_set(__ecore_file_path_bin, free); return init; } int ecore_file_path_shutdown(void) { + char *dir; + if (--init != 0) return init; - ecore_list_destroy(__ecore_file_path_bin); - __ecore_file_path_bin = NULL; + EINA_LIST_FREE(__ecore_file_path_bin, dir) + free(dir); return init; } -Ecore_List * +Eina_List * _ecore_file_path_from_env(const char *env) { - Ecore_List *path; + Eina_List *path = NULL; char *env_path, *p, *last; - path = ecore_list_new(); - env_path = getenv(env); if (!env_path) return path; @@ -56,12 +55,12 @@ _ecore_file_path_from_env(const char *env) if (!*p) { if (!ecore_file_path_dir_exists(last)) - ecore_list_append(path, strdup(last)); + path = eina_list_append(path, strdup(last)); last = p + 1; } } if (p > last) - ecore_list_append(path, strdup(last)); + path = eina_list_append(path, strdup(last)); free(env_path); return path; @@ -75,14 +74,16 @@ _ecore_file_path_from_env(const char *env) EAPI int ecore_file_path_dir_exists(const char *in_dir) { + Eina_List *l; char *dir; if (!__ecore_file_path_bin) return 0; - ecore_list_first_goto(__ecore_file_path_bin); - while ((dir = ecore_list_next(__ecore_file_path_bin)) != NULL) + EINA_LIST_FOREACH(__ecore_file_path_bin, l, dir) { - if (!strcmp(dir, in_dir)) return 1; + if (strcmp(dir, in_dir)) + return 1; } + return 0; } @@ -96,50 +97,47 @@ ecore_file_path_dir_exists(const char *in_dir) EAPI int ecore_file_app_installed(const char *exe) { + Eina_List *l; char *dir; char buf[PATH_MAX]; if (!exe) return 0; if (ecore_file_can_exec(exe)) return 1; - ecore_list_first_goto(__ecore_file_path_bin); - while ((dir = ecore_list_next(__ecore_file_path_bin)) != NULL) + EINA_LIST_FOREACH(__ecore_file_path_bin, l, dir) { snprintf(buf, sizeof(buf), "%s/%s", dir, exe); - if (ecore_file_can_exec(buf)) return 1; + if (ecore_file_can_exec(buf)) + return 1; } + return 0; } /** * Get a list of all the applications installed on the system - * @return An Ecore_List containing all the executable files in the system + * @return An Eina_List containing all the executable files in the system */ -EAPI Ecore_List * +EAPI Eina_List * ecore_file_app_list(void) { - Ecore_List *list, *files; + Eina_List *list = NULL; + Eina_List *files; + Eina_List *l; char buf[PATH_MAX], *dir, *exe; - list = ecore_list_new(); - if (!list) return NULL; - ecore_list_free_cb_set(list, free); - ecore_list_first_goto(__ecore_file_path_bin); - while ((dir = ecore_list_next(__ecore_file_path_bin)) != NULL) + EINA_LIST_FOREACH(__ecore_file_path_bin, l, dir) { files = ecore_file_ls(dir); - if (files) - { - ecore_list_first_goto(files); - while ((exe = ecore_list_next(files)) != NULL) + EINA_LIST_FREE(files, exe) { snprintf(buf, sizeof(buf), "%s/%s", dir, exe); if ((ecore_file_can_exec(buf)) && (!ecore_file_is_dir(buf))) - ecore_list_append(list, strdup(buf)); - } - ecore_list_destroy(files); + list = eina_list_append(list, strdup(buf)); + free(exe); } } + return list; } diff --git a/legacy/ecore/src/lib/ecore_imf/Ecore_IMF.h b/legacy/ecore/src/lib/ecore_imf/Ecore_IMF.h index 71f890f27c..1ae870846f 100644 --- a/legacy/ecore/src/lib/ecore_imf/Ecore_IMF.h +++ b/legacy/ecore/src/lib/ecore_imf/Ecore_IMF.h @@ -294,8 +294,8 @@ extern "C" { EAPI int ecore_imf_init(void); EAPI int ecore_imf_shutdown(void); - EAPI Ecore_List *ecore_imf_context_available_ids_get(void); - EAPI Ecore_List *ecore_imf_context_available_ids_by_canvas_type_get(const char *canvas_type); + EAPI Eina_List *ecore_imf_context_available_ids_get(void); + EAPI Eina_List *ecore_imf_context_available_ids_by_canvas_type_get(const char *canvas_type); EAPI const char *ecore_imf_context_default_id_get(void); EAPI const char *ecore_imf_context_default_id_by_canvas_type_get(const char *canvas_type); EAPI const Ecore_IMF_Context_Info *ecore_imf_context_info_by_id_get(const char *id); diff --git a/legacy/ecore/src/lib/ecore_imf/ecore_imf_context.c b/legacy/ecore/src/lib/ecore_imf/ecore_imf_context.c index 827b794ec1..d8b7ce1104 100644 --- a/legacy/ecore/src/lib/ecore_imf/ecore_imf_context.c +++ b/legacy/ecore/src/lib/ecore_imf/ecore_imf_context.c @@ -24,20 +24,20 @@ /** * Get the list of the available Input Method Context ids. * - * Note that the caller is responsible for freeing the Ecore_List + * Note that the caller is responsible for freeing the Eina_List * when finished with it. There is no need to finish the list strings. * - * @return Return an Ecore_List of strings; + * @return Return an EIna_List of strings; * on failure it returns NULL. * @ingroup Ecore_IMF_Context_Group */ -EAPI Ecore_List * +EAPI Eina_List * ecore_imf_context_available_ids_get(void) { return ecore_imf_module_context_ids_get(); } -EAPI Ecore_List * +EAPI Eina_List * ecore_imf_context_available_ids_by_canvas_type_get(const char *canvas_type) { return ecore_imf_module_context_ids_by_canvas_type_get(canvas_type); @@ -85,7 +85,7 @@ EAPI const char * ecore_imf_context_default_id_by_canvas_type_get(const char *canvas_type) { const char *id; - Ecore_List *modules; + Eina_List *modules; Ecore_IMF_Module *module; char *locale; char *tmp; @@ -113,8 +113,7 @@ ecore_imf_context_default_id_by_canvas_type_get(const char *canvas_type) id = NULL; - ecore_list_first_goto(modules); - while ((module = ecore_list_next(modules))) + EINA_LIST_FREE(modules, module) { if (canvas_type && strcmp(module->info->canvas_type, canvas_type) == 0) @@ -135,7 +134,6 @@ ecore_imf_context_default_id_by_canvas_type_get(const char *canvas_type) p = q ? q + 1 : NULL; } } - ecore_list_destroy(modules); free(locale); return id; diff --git a/legacy/ecore/src/lib/ecore_imf/ecore_imf_module.c b/legacy/ecore/src/lib/ecore_imf/ecore_imf_module.c index 78de2dc98e..07fd849168 100644 --- a/legacy/ecore/src/lib/ecore_imf/ecore_imf_module.c +++ b/legacy/ecore/src/lib/ecore_imf/ecore_imf_module.c @@ -66,33 +66,25 @@ ecore_imf_module_shutdown(void) static Eina_Bool _hash_module_available_get(const Eina_Hash *hash, int *data, void *list) { - ecore_list_append(list, data); + *(Eina_List**)list = eina_list_append(*(Eina_List**)list, data); return EINA_TRUE; } -Ecore_List * +Eina_List * ecore_imf_module_available_get(void) { - Ecore_List *values; + Eina_List *values = NULL; Eina_Iterator *it = NULL; if (!modules) return NULL; - values = ecore_list_new(); - if (!values) return NULL; - it = eina_hash_iterator_data_new(modules); if (!it) - { - ecore_list_destroy(values); return NULL; - } - eina_iterator_foreach(it, EINA_EACH(_hash_module_available_get), values); + eina_iterator_foreach(it, EINA_EACH(_hash_module_available_get), &values); eina_iterator_free(it); - ecore_list_first_goto(values); - return values; } @@ -128,29 +120,23 @@ ecore_imf_module_context_create(const char *ctx_id) static Eina_Bool _hash_ids_get(const Eina_Hash *hash, const char *key, void *list) { - ecore_list_append(list, key); + *(Eina_List**)list = eina_list_append(*(Eina_List**)list, key); return EINA_TRUE; } -Ecore_List * +Eina_List * ecore_imf_module_context_ids_get(void) { - Ecore_List *l = NULL; + Eina_List *l = NULL; Eina_Iterator *it = NULL; if (!modules) return NULL; - l = ecore_list_new(); - if (!l) return NULL; - it = eina_hash_iterator_key_new(modules); if (!it) - { - ecore_list_destroy(l); return NULL; - } - eina_iterator_foreach(it, EINA_EACH(_hash_ids_get), l); + eina_iterator_foreach(it, EINA_EACH(_hash_ids_get), &l); eina_iterator_free(it); return l; @@ -163,16 +149,16 @@ _hash_ids_by_canvas_type_get(const Eina_Hash *hash, void *data, void *fdata) Ecore_IMF_Selector *selector = fdata; if (!strcmp(module->info->canvas_type, selector->toselect)) - ecore_list_append(selector->selected, (void *)module->info->id); + selector->selected = eina_list_append(selector->selected, (void *)module->info->id); return EINA_TRUE; } -Ecore_List * +Eina_List * ecore_imf_module_context_ids_by_canvas_type_get(const char *canvas_type) { Ecore_IMF_Selector selector; - Ecore_List *values; + Eina_List *values = NULL; Eina_Iterator *it = NULL; if (!modules) return NULL; @@ -180,30 +166,22 @@ ecore_imf_module_context_ids_by_canvas_type_get(const char *canvas_type) if (!canvas_type) return ecore_imf_module_context_ids_get(); - values = ecore_list_new(); - if (!values) return NULL; - it = eina_hash_iterator_data_new(modules); if (!it) - { - ecore_list_destroy(values); return NULL; - } selector.toselect = canvas_type; selector.selected = values; eina_iterator_foreach(it, EINA_EACH(_hash_ids_by_canvas_type_get), &selector); eina_iterator_free(it); - ecore_list_first_goto(values); - return values; } static void _ecore_imf_module_load_all(void) { - Ecore_List *avail; + Eina_List *avail; char *filename; Ecore_Plugin *plugin; const Ecore_IMF_Context_Info *info = NULL; @@ -213,8 +191,7 @@ _ecore_imf_module_load_all(void) avail = ecore_plugin_available_get(ecore_imf_modules_path); if (!avail) return; - ecore_list_first_goto(avail); - while ((filename = ecore_list_next(avail))) + EINA_LIST_FREE(avail, filename) { plugin = ecore_plugin_load(ecore_imf_modules_path, filename, NULL); if (!plugin) @@ -255,8 +232,6 @@ _ecore_imf_module_load_all(void) _ecore_imf_module_append(plugin, info, imf_module_create); } - - ecore_list_destroy(avail); } static void @@ -267,7 +242,7 @@ _ecore_imf_module_append(Ecore_Plugin *plugin, Ecore_IMF_Module *module; if (!modules) - modules = eina_hash_string_superfast_new(_ecore_imf_module_free); + modules = eina_hash_string_superfast_new(EINA_FREE_CB(_ecore_imf_module_free)); module = malloc(sizeof(Ecore_IMF_Module)); module->plugin = plugin; diff --git a/legacy/ecore/src/lib/ecore_imf/ecore_imf_private.h b/legacy/ecore/src/lib/ecore_imf/ecore_imf_private.h index dd951e2c89..e6812e7866 100644 --- a/legacy/ecore/src/lib/ecore_imf/ecore_imf_private.h +++ b/legacy/ecore/src/lib/ecore_imf/ecore_imf_private.h @@ -29,10 +29,10 @@ struct _Ecore_IMF_Module void ecore_imf_module_init(void); void ecore_imf_module_shutdown(void); -Ecore_List *ecore_imf_module_available_get(void); +Eina_List *ecore_imf_module_available_get(void); Ecore_IMF_Module *ecore_imf_module_get(const char *ctx_id); Ecore_IMF_Context *ecore_imf_module_context_create(const char *ctx_id); -Ecore_List *ecore_imf_module_context_ids_get(void); -Ecore_List *ecore_imf_module_context_ids_by_canvas_type_get(const char *canvas_type); +Eina_List *ecore_imf_module_context_ids_get(void); +Eina_List *ecore_imf_module_context_ids_by_canvas_type_get(const char *canvas_type); #endif diff --git a/legacy/ecore/src/lib/ecore_ipc/Ecore_Ipc.h b/legacy/ecore/src/lib/ecore_ipc/Ecore_Ipc.h index 8e07366880..9c26a749d8 100644 --- a/legacy/ecore/src/lib/ecore_ipc/Ecore_Ipc.h +++ b/legacy/ecore/src/lib/ecore_ipc/Ecore_Ipc.h @@ -297,7 +297,7 @@ EAPI unsigned long long _ecore_ipc_swap_64(unsigned long long v); EAPI void *ecore_ipc_server_del(Ecore_Ipc_Server *svr); EAPI void *ecore_ipc_server_data_get(Ecore_Ipc_Server *svr); EAPI int ecore_ipc_server_connected_get(Ecore_Ipc_Server *svr); - EAPI Ecore_List *ecore_ipc_server_clients_get(Ecore_Ipc_Server *svr); + EAPI Eina_List *ecore_ipc_server_clients_get(Ecore_Ipc_Server *svr); /* FIXME: this needs to become an ipc message */ EAPI int ecore_ipc_server_send(Ecore_Ipc_Server *svr, int major, int minor, int ref, int ref_to, int response, const void *data, int size); EAPI void ecore_ipc_server_client_limit_set(Ecore_Ipc_Server *svr, int client_limit, char reject_excess_clients); diff --git a/legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c b/legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c index 6bfc04bbbc..e69866aa51 100644 --- a/legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c +++ b/legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c @@ -241,7 +241,7 @@ EAPI int ECORE_IPC_EVENT_CLIENT_DATA = 0; EAPI int ECORE_IPC_EVENT_SERVER_DATA = 0; static int init_count = 0; -static Ecore_Ipc_Server *servers = NULL; +static Eina_List *servers = NULL; static Ecore_Event_Handler *handler[6]; /** @@ -300,7 +300,7 @@ ecore_ipc_shutdown(void) if (--init_count != 0) return init_count; - while (servers) ecore_ipc_server_del(servers); + while (servers) ecore_ipc_server_del(eina_list_data_get(servers)); for (i = 0; i < 6; i++) ecore_event_handler_del(handler[i]); @@ -364,9 +364,7 @@ ecore_ipc_server_add(Ecore_Ipc_Type compl_type, const char *name, int port, cons } svr->max_buf_size = 32 * 1024; svr->data = (void *)data; - svr->client_list = ecore_list_new(); - ecore_list_init(svr->client_list); - servers = _ecore_list2_append(servers, svr); + servers = eina_list_append(servers, svr); ECORE_MAGIC_SET(svr, ECORE_MAGIC_IPC_SERVER); return svr; } @@ -422,7 +420,7 @@ ecore_ipc_server_connect(Ecore_Ipc_Type compl_type, char *name, int port, const } svr->max_buf_size = -1; svr->data = (void *)data; - servers = _ecore_list2_append(servers, svr); + servers = eina_list_append(servers, svr); ECORE_MAGIC_SET(svr, ECORE_MAGIC_IPC_SERVER); return svr; } @@ -444,17 +442,21 @@ ecore_ipc_server_del(Ecore_Ipc_Server *svr) "ecore_ipc_server_del"); return NULL; } + if (svr->delete_me) return NULL; + data = svr->data; svr->data = NULL; svr->delete_me = 1; if (svr->event_count == 0) { - while (svr->clients) - ecore_ipc_client_del((Ecore_Ipc_Client *)svr->clients); + Ecore_Ipc_Client *cl; + + EINA_LIST_FREE(svr->clients, cl) + ecore_ipc_client_del(cl); ecore_con_server_del(svr->server); - servers = _ecore_list2_remove(servers, svr); + servers = eina_list_remove(servers, svr); + if (svr->buf) free(svr->buf); - if (svr->client_list) ecore_list_destroy(svr->client_list); ECORE_MAGIC_SET(svr, ECORE_MAGIC_NONE); free(svr); } @@ -500,10 +502,10 @@ ecore_ipc_server_connected_get(Ecore_Ipc_Server *svr) /** * Retrieves the list of clients for this server. * @param svr The given IPC server. - * @return An Ecore_List with the clients. + * @return An Eina_List with the clients. * @ingroup Ecore_IPC_Server_Group */ -EAPI Ecore_List * +EAPI Eina_List * ecore_ipc_server_clients_get(Ecore_Ipc_Server *svr) { if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_IPC_SERVER)) @@ -1000,7 +1002,7 @@ _ecore_ipc_event_client_add(void *data __UNUSED__, int ev_type __UNUSED__, void Ecore_Con_Event_Client_Add *e; e = ev; - if (!_ecore_list2_find(servers, ecore_con_server_data_get(ecore_con_client_server_get(e->client)))) return 1; + if (!eina_list_data_find(servers, ecore_con_server_data_get(ecore_con_client_server_get(e->client)))) return 1; /* handling code here */ { Ecore_Ipc_Client *cl; @@ -1014,7 +1016,7 @@ _ecore_ipc_event_client_add(void *data __UNUSED__, int ev_type __UNUSED__, void cl->max_buf_size = 32 * 1024; ecore_con_client_data_set(cl->client, (void *)cl); svr->clients = _ecore_list2_append(svr->clients, cl); - ecore_list_append(svr->client_list, cl); + svr->client_list = eina_list_append(svr->client_list, cl); if (!cl->delete_me) { Ecore_Ipc_Event_Client_Add *e2; @@ -1038,7 +1040,7 @@ _ecore_ipc_event_client_del(void *data __UNUSED__, int ev_type __UNUSED__, void Ecore_Con_Event_Client_Del *e; e = ev; - if (!_ecore_list2_find(servers, ecore_con_server_data_get(ecore_con_client_server_get(e->client)))) return 1; + if (!eina_list_data_find(servers, ecore_con_server_data_get(ecore_con_client_server_get(e->client)))) return 1; /* handling code here */ { Ecore_Ipc_Client *cl; @@ -1049,9 +1051,7 @@ _ecore_ipc_event_client_del(void *data __UNUSED__, int ev_type __UNUSED__, void Ecore_Ipc_Server *svr; svr = ecore_con_server_data_get(ecore_con_client_server_get(e->client)); - ecore_list_goto(svr->client_list, cl); - ecore_list_remove(svr->client_list); - ecore_list_first_goto(svr->client_list); + svr->client_list = eina_list_remove(svr->client_list, cl); if (!cl->delete_me) { e2 = calloc(1, sizeof(Ecore_Ipc_Event_Client_Del)); @@ -1074,7 +1074,7 @@ _ecore_ipc_event_server_add(void *data __UNUSED__, int ev_type __UNUSED__, void Ecore_Con_Event_Server_Add *e; e = ev; - if (!_ecore_list2_find(servers, ecore_con_server_data_get(e->server))) return 1; + if (!eina_list_data_find(servers, ecore_con_server_data_get(e->server))) return 1; /* handling code here */ { Ecore_Ipc_Server *svr; @@ -1103,7 +1103,7 @@ _ecore_ipc_event_server_del(void *data __UNUSED__, int ev_type __UNUSED__, void Ecore_Con_Event_Server_Del *e; e = ev; - if (!_ecore_list2_find(servers, ecore_con_server_data_get(e->server))) return 1; + if (!eina_list_data_find(servers, ecore_con_server_data_get(e->server))) return 1; /* handling code here */ { Ecore_Ipc_Server *svr; @@ -1173,7 +1173,7 @@ _ecore_ipc_event_client_data(void *data __UNUSED__, int ev_type __UNUSED__, void Ecore_Con_Event_Client_Data *e; e = ev; - if (!_ecore_list2_find(servers, ecore_con_server_data_get(ecore_con_client_server_get(e->client)))) return 1; + if (!eina_list_data_find(servers, ecore_con_server_data_get(ecore_con_client_server_get(e->client)))) return 1; /* handling code here */ { Ecore_Ipc_Client *cl; @@ -1365,7 +1365,7 @@ _ecore_ipc_event_server_data(void *data __UNUSED__, int ev_type __UNUSED__, void Ecore_Con_Event_Server_Data *e; e = ev; - if (!_ecore_list2_find(servers, ecore_con_server_data_get(e->server))) return 1; + if (!eina_list_data_find(servers, ecore_con_server_data_get(e->server))) return 1; /* handling code here */ { Ecore_Ipc_Server *svr; diff --git a/legacy/ecore/src/lib/ecore_ipc/ecore_ipc_private.h b/legacy/ecore/src/lib/ecore_ipc/ecore_ipc_private.h index f8813a8999..9595975018 100644 --- a/legacy/ecore/src/lib/ecore_ipc/ecore_ipc_private.h +++ b/legacy/ecore/src/lib/ecore_ipc/ecore_ipc_private.h @@ -39,7 +39,6 @@ __attribute__ ((packed)); struct _Ecore_Ipc_Client { - Ecore_List __list_data; ECORE_MAGIC; Ecore_Con_Client *client; void *data; @@ -57,11 +56,10 @@ struct _Ecore_Ipc_Client struct _Ecore_Ipc_Server { - Ecore_List __list_data; ECORE_MAGIC; Ecore_Con_Server *server; - Ecore_Ipc_Client *clients; - Ecore_List *client_list; + Eina_List *clients; + Eina_List *client_list; void *data; unsigned char *buf; int buf_size; diff --git a/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_reply.c b/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_reply.c index f27f3b0860..13402b66e5 100644 --- a/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_reply.c +++ b/legacy/ecore/src/lib/ecore_x/xcb/ecore_xcb_reply.c @@ -19,7 +19,7 @@ * but its code is commented. */ -static Ecore_List *_ecore_xcb_cookies = NULL; +static Eina_List *_ecore_xcb_cookies = NULL; static void *_ecore_xcb_reply = NULL; typedef struct _Ecore_Xcb_Data Ecore_Xcb_Data; @@ -33,35 +33,22 @@ struct _Ecore_Xcb_Data int _ecore_x_reply_init () { - _ecore_xcb_cookies = ecore_list_new(); - if (!_ecore_xcb_cookies) - return 0; - - if (!ecore_list_init(_ecore_xcb_cookies)) - { - ecore_list_destroy(_ecore_xcb_cookies); - return 0; - } - - if (!ecore_list_free_cb_set(_ecore_xcb_cookies, ECORE_FREE_CB(free))) - { - ecore_list_destroy(_ecore_xcb_cookies); - return 0; - } - return 1; } void _ecore_x_reply_shutdown () { + Ecore_Xcb_Data *data; + if (_ecore_xcb_reply) free(_ecore_xcb_reply); if (!_ecore_xcb_cookies) return; - ecore_list_destroy(_ecore_xcb_cookies); + EINA_LIST_FREE(_ecore_xcb_cookies, data) + free(data); } void @@ -78,7 +65,8 @@ _ecore_xcb_cookie_cache (unsigned int cookie) data->cookie = cookie; - if (!ecore_list_append(_ecore_xcb_cookies, data)) + _ecore_xcb_cookies = eina_list_append(_ecore_xcb_cookies, data); + if (!eina_list_data_find(_ecore_xcb_cookies, data)) { free(data); return; @@ -94,16 +82,14 @@ _ecore_xcb_cookie_get (void) if (!_ecore_xcb_cookies) return 0; - data = ecore_list_first_remove(_ecore_xcb_cookies); - if (data) - { + data = eina_list_data_get(_ecore_xcb_cookies); + if (!data) return 0; + + _ecore_xcb_cookies = eina_list_remove_list(_ecore_xcb_cookies, _ecore_xcb_cookies); cookie = data->cookie; free(data); return cookie; - } - - return 0; } void diff --git a/legacy/efreet/src/bin/ef_cache.c b/legacy/efreet/src/bin/ef_cache.c index 45ffd80e56..73fd0dff2a 100644 --- a/legacy/efreet/src/bin/ef_cache.c +++ b/legacy/efreet/src/bin/ef_cache.c @@ -5,7 +5,8 @@ static int timer(void *data __UNUSED__) { - Ecore_List *list; + Eina_List *list; + Eina_List *l; Efreet_Desktop *desktop; double start; @@ -22,12 +23,12 @@ timer(void *data __UNUSED__) list = efreet_util_desktop_mime_list("application/ogg"); if (list) { - ecore_list_first_goto(list); - while ((desktop = ecore_list_next(list))) + EINA_LIST_FOREACH(list, l, desktop) { printf("application/ogg: %s\n", desktop->name); } - ecore_list_destroy(list); + while (list) + list = eina_list_remove_list(list, list); } return 0; diff --git a/legacy/efreet/src/bin/ef_data_dirs.c b/legacy/efreet/src/bin/ef_data_dirs.c index 291273dd29..02e3ae3b2b 100644 --- a/legacy/efreet/src/bin/ef_data_dirs.c +++ b/legacy/efreet/src/bin/ef_data_dirs.c @@ -153,7 +153,7 @@ ef_cb_efreet_cache_home(void) int ef_cb_efreet_data_dirs(void) { - Ecore_List *tmp; + Eina_List *tmp, *l; int ret = 1, i; char dirs[128], *val; char *vals[] = {"/var/tmp/a", "/tmp/b", "/usr/local/share", "/etc", NULL}; @@ -172,8 +172,7 @@ ef_cb_efreet_data_dirs(void) i = 0; tmp = efreet_data_dirs_get(); - ecore_list_first_goto(tmp); - while ((val = ecore_list_next(tmp))) + EINA_LIST_FOREACH(tmp, l, val) { if (vals[i] == NULL) { @@ -199,14 +198,13 @@ ef_cb_efreet_data_dirs(void) i = 0; tmp = efreet_data_dirs_get(); - if (ecore_list_count(tmp) != 2) + if (eina_list_count(tmp) != 2) { printf("efreet_data_dirs_get() nodes is differnet from expected default\n"); ret = 0; } - ecore_list_first_goto(tmp); - while ((val = ecore_list_next(tmp))) + EINA_LIST_FOREACH(tmp, l, val) { if (def_vals[i] == NULL) { @@ -231,7 +229,7 @@ ef_cb_efreet_data_dirs(void) int ef_cb_efreet_config_dirs(void) { - Ecore_List *tmp; + Eina_List *tmp, *l; int ret = 1, i; char dirs[128], *val; char *vals[] = {"/var/tmp/a", "/tmp/b", "/usr/local/share", "/etc", NULL}; @@ -251,8 +249,7 @@ ef_cb_efreet_config_dirs(void) i = 0; tmp = efreet_config_dirs_get(); - ecore_list_first_goto(tmp); - while ((val = ecore_list_next(tmp))) + EINA_LIST_FOREACH(tmp, l, val) { if (vals[i] == NULL) { @@ -278,8 +275,7 @@ ef_cb_efreet_config_dirs(void) i = 0; tmp = efreet_config_dirs_get(); - ecore_list_first_goto(tmp); - while ((val = ecore_list_next(tmp))) + EINA_LIST_FOREACH(tmp, l, val) { if (def_vals[i] == NULL) { diff --git a/legacy/efreet/src/bin/ef_desktop.c b/legacy/efreet/src/bin/ef_desktop.c index af7cfadb76..7713cced82 100644 --- a/legacy/efreet/src/bin/ef_desktop.c +++ b/legacy/efreet/src/bin/ef_desktop.c @@ -14,6 +14,7 @@ int ef_cb_desktop_parse(void) { Efreet_Desktop *desktop; + Eina_List *l; int ret = 1; desktop = efreet_desktop_get(PACKAGE_DATA_DIR"/test/test.desktop"); @@ -48,8 +49,7 @@ ef_cb_desktop_parse(void) const char *cat; int num_categories = 2, i = 0; - ecore_list_first_goto(desktop->categories); - while ((cat = ecore_list_next(desktop->categories))) + EINA_LIST_FOREACH(desktop->categories, l, cat) { if (i >= num_categories) { @@ -141,10 +141,9 @@ ef_cb_desktop_save(void) desktop->type = EFREET_DESKTOP_TYPE_APPLICATION; desktop->generic_name = strdup("Test Application"); desktop->exec = strdup("efreet_test"); - desktop->categories = ecore_list_new(); - ecore_list_free_cb_set(desktop->categories, ECORE_FREE_CB(free)); - ecore_list_append(desktop->categories, strdup("Test")); - ecore_list_append(desktop->categories, strdup("Enlightenment")); + desktop->categories = NULL; + desktop->categories = eina_list_append(desktop->categories, strdup("Test")); + desktop->categories = eina_list_append(desktop->categories, strdup("Enlightenment")); printf("save test: %d\n", efreet_desktop_save(desktop)); unlink("/tmp/test.desktop"); efreet_desktop_free(desktop); @@ -154,7 +153,7 @@ ef_cb_desktop_save(void) typedef struct { - Ecore_List *expected; + Eina_List *expected; int error; char type; } Test_Info; @@ -163,7 +162,7 @@ int ef_cb_desktop_command_get(void) { Efreet_Desktop *desktop; - Ecore_List *files, *expected; + Eina_List *files, *expected; char olddir[PATH_MAX]; Test_Info *info; int ret; @@ -177,14 +176,15 @@ ef_cb_desktop_command_get(void) desktop->name = strdup("App Name"); desktop->icon = strdup("icon.png"); - files = ecore_list_new(); - ecore_list_append(files, "/tmp/absolute_path"); - ecore_list_append(files, "relative_path"); - ecore_list_append(files, "file:///tmp/absolute_uri"); - ecore_list_append(files, "file:relative_uri"); + files = NULL; + files = eina_list_append(files, "/tmp/absolute_path"); + files = eina_list_append(files, "relative_path"); + files = eina_list_append(files, "file:///tmp/absolute_uri"); + files = eina_list_append(files, "file:relative_uri"); info = NEW(Test_Info, 1); - expected = ecore_list_new(); + expected = NULL; + // FIXME: info->expected needs to be update. info->expected = expected; info->error = 0; @@ -192,129 +192,131 @@ ef_cb_desktop_command_get(void) info->type = 'f'; IF_FREE(desktop->exec); desktop->exec = strdup("app %f"); - ecore_list_append(expected, "app '/tmp/absolute_path'"); - ecore_list_append(expected, "app '/relative_path'"); - ecore_list_append(expected, "app '/tmp/absolute_uri'"); - ecore_list_append(expected, "app '/relative_uri'"); + expected = eina_list_append(expected, "app '/tmp/absolute_path'"); + expected = eina_list_append(expected, "app '/relative_path'"); + expected = eina_list_append(expected, "app '/tmp/absolute_uri'"); + expected = eina_list_append(expected, "app '/relative_uri'"); - ecore_list_first_goto(expected); efreet_desktop_command_get(desktop, files, _cb_command, info); - ecore_list_clear(expected); + while (expected) + expected = eina_list_remove_list(expected, expected); /* test single uri */ info->type = 'u'; IF_FREE(desktop->exec); desktop->exec = strdup("app %u"); - ecore_list_append(expected, "app 'file:///tmp/absolute_path'"); - ecore_list_append(expected, "app 'file:///relative_path'"); - ecore_list_append(expected, "app 'file:///tmp/absolute_uri'"); - ecore_list_append(expected, "app 'file:///relative_uri'"); + expected = eina_list_append(expected, "app 'file:///tmp/absolute_path'"); + expected = eina_list_append(expected, "app 'file:///relative_path'"); + expected = eina_list_append(expected, "app 'file:///tmp/absolute_uri'"); + expected = eina_list_append(expected, "app 'file:///relative_uri'"); - ecore_list_first_goto(expected); efreet_desktop_command_get(desktop, files, _cb_command, info); - ecore_list_clear(expected); + while (expected) + expected = eina_list_remove_list(expected, expected); /* test single dir */ info->type = 'd'; IF_FREE(desktop->exec); desktop->exec = strdup("app %d"); - ecore_list_append(expected, "app '/tmp'"); - ecore_list_append(expected, "app '/'"); - ecore_list_append(expected, "app '/tmp'"); - ecore_list_append(expected, "app '/'"); + expected = eina_list_append(expected, "app '/tmp'"); + expected = eina_list_append(expected, "app '/'"); + expected = eina_list_append(expected, "app '/tmp'"); + expected = eina_list_append(expected, "app '/'"); - ecore_list_first_goto(expected); efreet_desktop_command_get(desktop, files, _cb_command, info); - ecore_list_clear(expected); + while (expected) + expected = eina_list_remove_list(expected, expected); /* test single names */ info->type = 'n'; IF_FREE(desktop->exec); desktop->exec = strdup("app %n"); - ecore_list_append(expected, "app 'absolute_path'"); - ecore_list_append(expected, "app 'relative_path'"); - ecore_list_append(expected, "app 'absolute_uri'"); - ecore_list_append(expected, "app 'relative_uri'"); + expected = eina_list_append(expected, "app 'absolute_path'"); + expected = eina_list_append(expected, "app 'relative_path'"); + expected = eina_list_append(expected, "app 'absolute_uri'"); + expected = eina_list_append(expected, "app 'relative_uri'"); - ecore_list_first_goto(expected); efreet_desktop_command_get(desktop, files, _cb_command, info); - ecore_list_clear(expected); + while (expected) + expected = eina_list_remove_list(expected, expected); /* test multiple fullpaths */ info->type = 'F'; IF_FREE(desktop->exec); desktop->exec = strdup("app %F"); - ecore_list_append(expected, "app '/tmp/absolute_path' '/relative_path' '/tmp/absolute_uri' '/relative_uri'"); + expected = eina_list_append(expected, "app '/tmp/absolute_path' '/relative_path' '/tmp/absolute_uri' '/relative_uri'"); - ecore_list_first_goto(expected); efreet_desktop_command_get(desktop, files, _cb_command, info); - ecore_list_clear(expected); + while (expected) + expected = eina_list_remove_list(expected, expected); /* test multiple URIs */ info->type = 'U'; IF_FREE(desktop->exec); desktop->exec = strdup("app %U"); - ecore_list_append(expected, "app 'file:///tmp/absolute_path' 'file:///relative_path' 'file:///tmp/absolute_uri' 'file:///relative_uri'"); + expected = eina_list_append(expected, "app 'file:///tmp/absolute_path' 'file:///relative_path' 'file:///tmp/absolute_uri' 'file:///relative_uri'"); - ecore_list_first_goto(expected); efreet_desktop_command_get(desktop, files, _cb_command, info); - ecore_list_clear(expected); + while (expected) + expected = eina_list_remove_list(expected, expected); /* test multiple dirs */ info->type = 'D'; IF_FREE(desktop->exec); desktop->exec = strdup("app %D"); - ecore_list_append(expected, "app '/tmp' '/' '/tmp' '/'"); + expected = eina_list_append(expected, "app '/tmp' '/' '/tmp' '/'"); - ecore_list_first_goto(expected); efreet_desktop_command_get(desktop, files, _cb_command, info); - ecore_list_clear(expected); + while (expected) + expected = eina_list_remove_list(expected, expected); /* test multiple names */ info->type = 'N'; IF_FREE(desktop->exec); desktop->exec = strdup("app %N"); - ecore_list_append(expected, "app 'absolute_path' 'relative_path' 'absolute_uri' 'relative_uri'"); + expected = eina_list_append(expected, "app 'absolute_path' 'relative_path' 'absolute_uri' 'relative_uri'"); - ecore_list_first_goto(expected); efreet_desktop_command_get(desktop, files, _cb_command, info); - ecore_list_clear(expected); + while (expected) + expected = eina_list_remove_list(expected, expected); /* test icon appending */ info->type = 'i'; IF_FREE(desktop->exec); desktop->exec = strdup("app %i"); - ecore_list_append(expected, "app --icon 'icon.png'"); + expected = eina_list_append(expected, "app --icon 'icon.png'"); - ecore_list_first_goto(expected); efreet_desktop_command_get(desktop, NULL, _cb_command, info); - ecore_list_clear(expected); + while (expected) + expected = eina_list_remove_list(expected, expected); /* test app name */ info->type = 'c'; IF_FREE(desktop->exec); desktop->exec = strdup("app %c"); - ecore_list_append(expected, "app 'App Name'"); + expected = eina_list_append(expected, "app 'App Name'"); - ecore_list_first_goto(expected); efreet_desktop_command_get(desktop, NULL, _cb_command, info); - ecore_list_clear(expected); + while (expected) + expected = eina_list_remove_list(expected, expected); /* test desktop path */ info->type = 'k'; IF_FREE(desktop->exec); desktop->exec = strdup("app %k"); - ecore_list_append(expected, "app 'test.desktop'"); + expected = eina_list_append(expected, "app 'test.desktop'"); - ecore_list_first_goto(expected); efreet_desktop_command_get(desktop, NULL, _cb_command, info); - ecore_list_clear(expected); + while (expected) + expected = eina_list_remove_list(expected, expected); /* clean up */ efreet_desktop_free(desktop); - ecore_list_destroy(files); - ecore_list_destroy(expected); + while (files) + files = eina_list_remove_list(files, expected); + while (expected) + expected = eina_list_remove_list(expected, expected); ret = info->error > 0 ? 0 : 1; free(info); @@ -331,7 +333,8 @@ _cb_command(void *data, Efreet_Desktop *desktop __UNUSED__, Test_Info *info = data; char *expected; - expected = ecore_list_next(info->expected); + expected = eina_list_data_get(info->expected); + info->expected = eina_list_demote_list(info->expected, info->expected); if (!expected) { printf(" ERROR: (%%%c) got \"%s\", expected nothing\n", info->type, exec); diff --git a/legacy/efreet/src/bin/ef_icon_theme.c b/legacy/efreet/src/bin/ef_icon_theme.c index 56dcaf8b2d..369a4b8c1a 100644 --- a/legacy/efreet/src/bin/ef_icon_theme.c +++ b/legacy/efreet/src/bin/ef_icon_theme.c @@ -15,7 +15,7 @@ static Eina_Bool _hash_keys(Eina_Hash *hash, const char *key, void *list); static void ef_icon_theme_themes_find(const char *search_dir, Eina_Hash *themes); -static void ef_icons_find(Efreet_Icon_Theme *theme, Ecore_List *themes, +static void ef_icons_find(Efreet_Icon_Theme *theme, Eina_List *themes, Eina_Hash *icons); static void ef_read_dir(const char *dir, Eina_Hash *icons); @@ -56,7 +56,9 @@ ef_cb_efreet_icon_theme(void) static Eina_Bool _hash_keys(Eina_Hash *hash, const char *key, void *list) { - ecore_list_append(list, key); + Eina_List **l = list; + + *l = eina_list_append(*l, key); return EINA_TRUE; } @@ -64,11 +66,12 @@ int ef_cb_efreet_icon_theme_list(void) { int ret = 1; - Ecore_List *themes; + Eina_List *themes; + Eina_List *icon_dirs; + Eina_List *l; Eina_Hash *dirs; Eina_Iterator *it; Efreet_Icon_Theme *theme; - Ecore_List *icon_dirs; const char *dir; char buf[PATH_MAX]; void *value; @@ -76,10 +79,9 @@ ef_cb_efreet_icon_theme_list(void) dirs = eina_hash_string_superfast_new(free); icon_dirs = efreet_data_dirs_get(); - ecore_list_first_goto(icon_dirs); ef_icon_theme_themes_find(efreet_icon_user_dir_get(), dirs); - while ((dir = ecore_list_next(icon_dirs))) + EINA_LIST_FOREACH(icon_dirs, l, dir) { snprintf(buf, sizeof(buf), "%s/icons", dir); ef_icon_theme_themes_find(buf, dirs); @@ -87,8 +89,7 @@ ef_cb_efreet_icon_theme_list(void) ef_icon_theme_themes_find("/usr/share/pixmaps", dirs); themes = efreet_icon_theme_list_get(); - ecore_list_first_goto(themes); - while ((theme = ecore_list_next(themes))) + EINA_LIST_FOREACH(themes, l, theme) { if ((eina_hash_find(dirs, theme->name.internal))) eina_hash_del(dirs, theme->name.internal, NULL); @@ -99,26 +100,31 @@ ef_cb_efreet_icon_theme_list(void) ret = 0; } } - ecore_list_destroy(themes); + while (themes) + { + themes = eina_list_remove_list(themes, themes); + } - themes = ecore_list_new(); + themes = NULL; it = eina_hash_iterator_key_new(dirs); - eina_iterator_foreach(it, EINA_EACH(_hash_keys), themes); + eina_iterator_foreach(it, EINA_EACH(_hash_keys), &themes); eina_iterator_free(it); - if (ecore_list_count(themes) > 0) + if (eina_list_count(themes) > 0) { char *dir; printf("efreet_icon_theme_list_get() missed: "); - ecore_list_first_goto(themes); - while ((dir = ecore_list_next(themes))) + EINA_LIST_FOREACH(themes, l, dir) printf("%s ", dir); printf("\n"); ret = 0; } - ecore_list_destroy(themes); + while (themes) + { + themes = eina_list_remove_list(themes, themes); + } eina_hash_free(dirs); return ret; @@ -127,7 +133,7 @@ ef_cb_efreet_icon_theme_list(void) static void ef_icon_theme_themes_find(const char *search_dir, Eina_Hash *themes) { - Ecore_List *dirs; + Eina_List *dirs; char *dir; if (!search_dir || !themes) return; @@ -135,10 +141,11 @@ ef_icon_theme_themes_find(const char *search_dir, Eina_Hash *themes) dirs = ecore_file_ls(search_dir); if (!dirs) return; - while ((dir = ecore_list_first_remove(dirs))) + while ((dir = eina_list_data_get(dirs))) { char p[PATH_MAX]; + dirs = eina_list_remove_list(dirs, dirs); /* if we've already added the theme we're done */ if (eina_hash_find(themes, dir)) { @@ -170,7 +177,6 @@ ef_icon_theme_themes_find(const char *search_dir, Eina_Hash *themes) } free(dir); } - ecore_list_destroy(dirs); } const char *icons[] = @@ -440,11 +446,11 @@ ef_cb_efreet_icon_match(void) int i, ret = 1; Eina_Hash *icon_hash; Efreet_Icon_Theme *theme; - Ecore_List *themes; + Eina_List *themes; + Eina_List *l; themes = efreet_icon_theme_list_get(); - ecore_list_first_goto(themes); - while ((theme = ecore_list_next(themes))) + EINA_LIST_FOREACH(themes, l, theme) { if (!strcmp(theme->name.internal, THEME)) break; @@ -453,14 +459,16 @@ ef_cb_efreet_icon_match(void) if (!theme) { printf("Theme not installed, SKIPPED.\n"); - ecore_list_destroy(themes); + while (themes) + themes = eina_list_remove_list(themes, themes); return 1; } icon_hash = eina_hash_string_superfast_new(free); ef_icons_find(theme, themes, icon_hash); - ecore_list_destroy(themes); + while (themes) + themes = eina_list_remove_list(themes, themes); double start = ecore_time_get(); for (i = 0; icons[i] != NULL; i++) @@ -527,67 +535,33 @@ ef_cb_efreet_icon_match(void) } static void -ef_icons_find(Efreet_Icon_Theme *theme, Ecore_List *themes, Eina_Hash *icons) +ef_icons_find(Efreet_Icon_Theme *theme, Eina_List *themes, Eina_Hash *icons) { + Eina_List *l, *ll; char path[PATH_MAX]; + const char *theme_path; if (!theme || !icons) return; - if (theme->paths.count == 1) + EINA_LIST_FOREACH(theme->paths, l, theme_path) { Efreet_Icon_Theme_Directory *dir; - ecore_list_first_goto(theme->directories); - while ((dir = ecore_list_next(theme->directories))) - { - if (theme->paths.count > 1) - { - Ecore_List *list; - char *tmp; - - list = theme->paths.path; - ecore_list_first_goto(list); - while ((tmp = ecore_list_next(list))) - { - snprintf(path, sizeof(path), "%s/%s/", tmp, dir->name); - ef_read_dir(path, icons); - } - } - else if (theme->paths.count == 1) - { - snprintf(path, sizeof(path), "%s/%s/", (char *)theme->paths.path, dir->name); - ef_read_dir(path, icons); - } - } - } - else if (theme->paths.count > 1) - { - const char *theme_path; - - ecore_list_first_goto(theme->paths.path); - while ((theme_path = ecore_list_next(theme->paths.path))) - { - Efreet_Icon_Theme_Directory *dir; - - ecore_list_first_goto(theme->directories); - while ((dir = ecore_list_next(theme->directories))) + EINA_LIST_FOREACH(theme->directories, ll, dir) { snprintf(path, sizeof(path), "%s/%s/", theme_path, dir->name); ef_read_dir(path, icons); } } - } if (theme->inherits) { Efreet_Icon_Theme *parent_theme; char *parent; - ecore_list_first_goto(theme->inherits); - while ((parent = ecore_list_next(theme->inherits))) + EINA_LIST_FOREACH(theme->inherits, l, parent) { - ecore_list_first_goto(themes); - while ((parent_theme = ecore_list_next(themes))) + EINA_LIST_FOREACH(themes, ll, parent_theme) { if (!strcmp(parent_theme->name.internal, parent)) ef_icons_find(parent_theme, themes, icons); @@ -598,8 +572,7 @@ ef_icons_find(Efreet_Icon_Theme *theme, Ecore_List *themes, Eina_Hash *icons) { Efreet_Icon_Theme *parent_theme; - ecore_list_first_goto(themes); - while ((parent_theme = ecore_list_next(themes))) + EINA_LIST_FOREACH(themes, l, parent_theme) { if (!strcmp(parent_theme->name.internal, "hicolor")) ef_icons_find(parent_theme, themes, icons); @@ -612,7 +585,7 @@ ef_icons_find(Efreet_Icon_Theme *theme, Ecore_List *themes, Eina_Hash *icons) static void ef_read_dir(const char *dir, Eina_Hash *icons) { - Ecore_List *files; + Eina_List *files; char *file; if (!dir || !icons) return; @@ -620,10 +593,11 @@ ef_read_dir(const char *dir, Eina_Hash *icons) files = ecore_file_ls(dir); if (!files) return; - while ((file = ecore_list_first_remove(files))) + while ((file = eina_list_data_get(files))) { char *p; + files = eina_list_remove_list(files, files); p = strrchr(file, '.'); if (!p) { @@ -640,5 +614,4 @@ ef_read_dir(const char *dir, Eina_Hash *icons) FREE(file); } - ecore_list_destroy(files); } diff --git a/legacy/efreet/src/bin/ef_menu.c b/legacy/efreet/src/bin/ef_menu.c index 9894b4f5f0..e15a93dd82 100644 --- a/legacy/efreet/src/bin/ef_menu.c +++ b/legacy/efreet/src/bin/ef_menu.c @@ -8,20 +8,20 @@ static void ef_menu_desktop_exec(Efreet_Menu *menu) { + Eina_List *l; + if (menu->entries) { Efreet_Desktop *desktop; - ecore_list_first_goto(menu->entries); - while ((desktop = ecore_list_next(menu->entries))) + EINA_LIST_FOREACH(menu->entries, l, desktop) efreet_desktop_exec(desktop, NULL); } if (menu->sub_menus) { Efreet_Menu *sub_menu; - ecore_list_first_goto(menu->sub_menus); - while ((sub_menu = ecore_list_next(menu->sub_menus))) + EINA_LIST_FOREACH(menu->sub_menus, l, sub_menu) ef_menu_desktop_exec(sub_menu); } } @@ -113,8 +113,7 @@ ef_cb_menu_edit(void) efreet_menu_dump(menu, ""); printf("\n"); #endif - ecore_list_first_goto(menu->entries); - entry = ecore_list_current(menu->entries); + entry = eina_list_data_get(menu->entries); if (desktop != entry->desktop) { efreet_menu_free(menu); @@ -127,8 +126,7 @@ ef_cb_menu_edit(void) efreet_menu_dump(menu, ""); printf("\n"); #endif - ecore_list_index_goto(menu->entries, 2); - entry = ecore_list_current(menu->entries); + entry = eina_list_nth(menu->entries, 2); if (desktop != entry->desktop) { efreet_menu_free(menu); @@ -141,8 +139,7 @@ ef_cb_menu_edit(void) efreet_menu_dump(menu, ""); printf("\n"); #endif - ecore_list_last_goto(menu->entries); - entry = ecore_list_current(menu->entries); + entry = eina_list_data_get(eina_list_last(menu->entries)); if (desktop != entry->desktop) { efreet_menu_free(menu); diff --git a/legacy/efreet/src/bin/efreet_spec_test.c b/legacy/efreet/src/bin/efreet_spec_test.c index a5ef2a60e8..ed93ea5ced 100644 --- a/legacy/efreet/src/bin/efreet_spec_test.c +++ b/legacy/efreet/src/bin/efreet_spec_test.c @@ -35,11 +35,11 @@ static void dump(Efreet_Menu *menu, const char *path) { Efreet_Menu *entry; + Eina_List *l; if (!menu || !menu->entries) return; - ecore_list_first_goto(menu->entries); - while ((entry = ecore_list_next(menu->entries))) + EINA_LIST_FOREACH(menu->entries, l, entry) { if (entry->type == EFREET_MENU_ENTRY_DESKTOP) { diff --git a/legacy/efreet/src/bin/main.c b/legacy/efreet/src/bin/main.c index 105a057679..b515f8cc4a 100644 --- a/legacy/efreet/src/bin/main.c +++ b/legacy/efreet/src/bin/main.c @@ -77,34 +77,34 @@ static Efreet_Test tests[] = { }; extern char **environ; -static Ecore_List *environment = NULL; +static Eina_List *environment = NULL; void environment_store(void) { + char *env; char **e; - if (environment) - ecore_list_clear(environment); - else + while (environment) { - environment = ecore_list_new(); - ecore_list_free_cb_set(environment, ECORE_FREE_CB(free)); + env = eina_list_data_get(environment); + free(env); + environment = eina_list_remove_list(environment, environment); } for (e = environ; *e; e++) - ecore_list_append(environment, strdup(*e)); + environment = eina_list_append(environment, strdup(*e)); } void environment_restore(void) { + Eina_List *l; char *e; if (!environment) return; *environ = NULL; - ecore_list_first_goto(environment); - while ((e = ecore_list_next(environment))) + EINA_LIST_FOREACH(environment, l, e) putenv(e); } @@ -112,13 +112,12 @@ int main(int argc, char ** argv) { int i, passed = 0, num_tests = 0; - Ecore_List *run = NULL; + Eina_List *run = NULL; double total; total = ecore_time_get(); if (argc > 1) { - run = ecore_list_new(); for (i = 1; i < argc; i++) { if ((!strcmp(argv[i], "-h")) || @@ -130,7 +129,7 @@ main(int argc, char ** argv) } return 1; } - ecore_list_append(run, argv[i]); + run = eina_list_append(run, argv[i]); } } @@ -141,7 +140,7 @@ main(int argc, char ** argv) double start; /* we've been given specific tests and it isn't in the list */ - if (run && !ecore_list_find(run, ECORE_COMPARE_CB(strcasecmp), + if (run && !eina_list_search_unsorted(run, ECORE_COMPARE_CB(strcasecmp), tests[i].name)) continue; @@ -166,10 +165,15 @@ main(int argc, char ** argv) } printf("\n-----------------\n"); - if (environment) ecore_list_destroy(environment); + while (environment) + { + free(eina_list_data_get(environment)); + environment = eina_list_remove_list(environment, environment); + } printf("Passed %d of %d tests.\n", passed, num_tests); - if (run) ecore_list_destroy(run); + while (run) + run = eina_list_remove_list(run, run); printf("Total run: %.3f seconds\n", ecore_time_get() - total); return 0; diff --git a/legacy/efreet/src/lib/Efreet_Trash.h b/legacy/efreet/src/lib/Efreet_Trash.h index febf70d6eb..897f6464c4 100644 --- a/legacy/efreet/src/lib/Efreet_Trash.h +++ b/legacy/efreet/src/lib/Efreet_Trash.h @@ -41,7 +41,7 @@ EAPI void efreet_trash_shutdown(void); EAPI const char *efreet_trash_dir_get(void); EAPI int efreet_trash_delete_uri(Efreet_Uri *uri, int force_delete); -EAPI Ecore_List *efreet_trash_ls(void); +EAPI Eina_List *efreet_trash_ls(void); EAPI int efreet_trash_is_empty(void); EAPI int efreet_trash_empty_trash(void); diff --git a/legacy/efreet/src/lib/efreet_base.c b/legacy/efreet/src/lib/efreet_base.c index 3be459e6ee..f4738e1538 100644 --- a/legacy/efreet/src/lib/efreet_base.c +++ b/legacy/efreet/src/lib/efreet_base.c @@ -6,11 +6,11 @@ static const char *efreet_home_dir = NULL; static const char *xdg_data_home = NULL; static const char *xdg_config_home = NULL; static const char *xdg_cache_home = NULL; -static Ecore_List *xdg_data_dirs = NULL; -static Ecore_List *xdg_config_dirs = NULL; +static Eina_List *xdg_data_dirs = NULL; +static Eina_List *xdg_config_dirs = NULL; static const char *efreet_dir_get(const char *key, const char *fallback); -static Ecore_List *efreet_dirs_get(const char *key, +static Eina_List *efreet_dirs_get(const char *key, const char *fallback); /** @@ -77,15 +77,15 @@ efreet_data_home_get(void) } /** - * @return Returns the Ecore_List of preference ordered extra data directories - * @brief Returns the Ecore_List of prefernece oredred extra data + * @return Returns the Eina_List of preference ordered extra data directories + * @brief Returns the Eina_List of prefernece oredred extra data * directories * * @note The returned list is static inside Efreet. If you add/remove from the * list then the next call to efreet_data_dirs_get() will return your * modified values. DO NOT free this list. */ -EAPI Ecore_List * +EAPI Eina_List * efreet_data_dirs_get(void) { if (xdg_data_dirs) return xdg_data_dirs; @@ -107,15 +107,15 @@ efreet_config_home_get(void) } /** - * @return Returns the Ecore_List of preference ordered extra config directories - * @brief Returns the Ecore_List of prefernece oredred extra config + * @return Returns the Eina_List of preference ordered extra config directories + * @brief Returns the Eina_List of prefernece oredred extra config * directories * * @note The returned list is static inside Efreet. If you add/remove from the * list then the next call to efreet_config_dirs_get() will return your * modified values. DO NOT free this list. */ -EAPI Ecore_List * +EAPI Eina_List * efreet_config_dirs_get(void) { if (xdg_config_dirs) return xdg_config_dirs; @@ -177,18 +177,16 @@ efreet_dir_get(const char *key, const char *fallback) * @brief Creates a list of directories as given in the environment key @a * key or from the fallbacks in @a fallback */ -static Ecore_List * +static Eina_List * efreet_dirs_get(const char *key, const char *fallback) { - Ecore_List *dirs; + Eina_List *dirs = NULL; const char *path; char *tmp, *s, *p; path = getenv(key); if (!path || (path[0] == '\0')) path = fallback; - dirs = ecore_list_new(); - ecore_list_free_cb_set(dirs, ECORE_FREE_CB(eina_stringshare_del)); if (!path) return dirs; tmp = strdup(path); @@ -197,14 +195,14 @@ efreet_dirs_get(const char *key, const char *fallback) while (p) { *p = '\0'; - if (!ecore_list_find(dirs, ECORE_COMPARE_CB(strcmp), s)) - ecore_list_append(dirs, (void *)eina_stringshare_add(s)); + if (!eina_list_search_unsorted(dirs, (Eina_Compare_Cb)strcmp, s)) + dirs = eina_list_append(dirs, (void *)eina_stringshare_add(s)); s = ++p; p = strchr(s, ':'); } - if (!ecore_list_find(dirs, ECORE_COMPARE_CB(strcmp), s)) - ecore_list_append(dirs, (void *)eina_stringshare_add(s)); + if (!eina_list_search_unsorted(dirs, ECORE_COMPARE_CB(strcmp), s)) + dirs = eina_list_append(dirs, (void *)eina_stringshare_add(s)); FREE(tmp); return dirs; diff --git a/legacy/efreet/src/lib/efreet_base.h b/legacy/efreet/src/lib/efreet_base.h index 021c89b3c2..d6b9f243c2 100644 --- a/legacy/efreet/src/lib/efreet_base.h +++ b/legacy/efreet/src/lib/efreet_base.h @@ -16,10 +16,10 @@ #include EAPI const char *efreet_data_home_get(void); -EAPI Ecore_List *efreet_data_dirs_get(void); +EAPI Eina_List *efreet_data_dirs_get(void); EAPI const char *efreet_config_home_get(void); -EAPI Ecore_List *efreet_config_dirs_get(void); +EAPI Eina_List *efreet_config_dirs_get(void); EAPI const char *efreet_cache_home_get(void); diff --git a/legacy/efreet/src/lib/efreet_desktop.c b/legacy/efreet/src/lib/efreet_desktop.c index b0f057e207..5db998a857 100644 --- a/legacy/efreet/src/lib/efreet_desktop.c +++ b/legacy/efreet/src/lib/efreet_desktop.c @@ -18,7 +18,7 @@ static Eina_Hash *efreet_desktop_cache = NULL; /** * A list of the desktop types available */ -static Ecore_List *efreet_desktop_types = NULL; +static Eina_List *efreet_desktop_types = NULL; /** * A unique id for each tmp file created while building a command @@ -74,7 +74,7 @@ static char *efreet_string_append(char *dest, int *size, int *len, const char *src); static char *efreet_string_append_char(char *dest, int *size, int *len, char c); -static Ecore_List *efreet_desktop_command_build(Efreet_Desktop_Command *command); +static Eina_List *efreet_desktop_command_build(Efreet_Desktop_Command *command); static void efreet_desktop_command_free(Efreet_Desktop_Command *command); static char *efreet_desktop_command_append_quoted(char *dest, int *size, int *len, char *src); @@ -106,7 +106,7 @@ static void *efreet_desktop_exec_cb(void *data, Efreet_Desktop *desktop, static void efreet_desktop_type_info_free(Efreet_Desktop_Type_Info *info); static int efreet_desktop_command_flags_get(Efreet_Desktop *desktop); -static void *efreet_desktop_command_execs_process(Efreet_Desktop_Command *command, Ecore_List *execs); +static void *efreet_desktop_command_execs_process(Efreet_Desktop_Command *command, Eina_List *execs); /** * @internal @@ -121,10 +121,7 @@ efreet_desktop_init(void) if (!ecore_file_init()) return --init; efreet_desktop_cache = eina_hash_string_superfast_new(NULL); - - efreet_desktop_types = ecore_list_new(); - ecore_list_free_cb_set(efreet_desktop_types, - ECORE_FREE_CB(efreet_desktop_type_info_free)); + efreet_desktop_types = NULL; EFREET_DESKTOP_TYPE_APPLICATION = efreet_desktop_type_add("Application", efreet_desktop_application_fields_parse, @@ -147,13 +144,21 @@ efreet_desktop_init(void) int efreet_desktop_shutdown(void) { + Efreet_Desktop_Type_Info *info; + if (--init) return init; ecore_file_shutdown(); eina_stringshare_shutdown(); IF_RELEASE(desktop_environment); IF_FREE_HASH(efreet_desktop_cache); - IF_FREE_LIST(efreet_desktop_types); + while (efreet_desktop_types) + { + info = eina_list_data_get(efreet_desktop_types); + efreet_desktop_type_info_free(info); + efreet_desktop_types = eina_list_remove_list(efreet_desktop_types, + efreet_desktop_types); + } return init; } @@ -353,6 +358,8 @@ efreet_desktop_read(Efreet_Desktop *desktop) static void efreet_desktop_clear(Efreet_Desktop *desktop) { + char *data; + IF_FREE(desktop->name); IF_FREE(desktop->generic_name); IF_FREE(desktop->comment); @@ -366,15 +373,25 @@ efreet_desktop_clear(Efreet_Desktop *desktop) IF_FREE_LIST(desktop->only_show_in); IF_FREE_LIST(desktop->not_show_in); - IF_FREE_LIST(desktop->categories); - IF_FREE_LIST(desktop->mime_types); + while (desktop->categories) + { + data = eina_list_data_get(desktop->categories); + eina_stringshare_del(data); + desktop->categories = eina_list_remove_list(desktop->categories, desktop->categories); + } + while (desktop->mime_types) + { + data = eina_list_data_get(desktop->mime_types); + eina_stringshare_del(data); + desktop->mime_types = eina_list_remove_list(desktop->mime_types, desktop->mime_types); + } IF_FREE_HASH(desktop->x); if (desktop->type_data) { Efreet_Desktop_Type_Info *info; - info = ecore_list_index_goto(efreet_desktop_types, desktop->type); + info = eina_list_nth(efreet_desktop_types, desktop->type); if (info->free_func) info->free_func(desktop->type_data); } @@ -397,7 +414,7 @@ efreet_desktop_save(Efreet_Desktop *desktop) efreet_ini_section_add(ini, "Desktop Entry"); efreet_ini_section_set(ini, "Desktop Entry"); - info = ecore_list_index_goto(efreet_desktop_types, desktop->type); + info = eina_list_nth(efreet_desktop_types, desktop->type); if (info) { efreet_ini_string_set(ini, "Type", info->type); @@ -494,15 +511,24 @@ efreet_desktop_free(Efreet_Desktop *desktop) IF_FREE_LIST(desktop->only_show_in); IF_FREE_LIST(desktop->not_show_in); - IF_FREE_LIST(desktop->categories); - IF_FREE_LIST(desktop->mime_types); + + while (desktop->categories) + { + eina_stringshare_del(eina_list_data_get(desktop->categories)); + desktop->categories = eina_list_remove_list(desktop->categories, desktop->categories); + } + while (desktop->mime_types) + { + eina_stringshare_del(eina_list_data_get(desktop->mime_types)); + desktop->mime_types = eina_list_remove_list(desktop->mime_types, desktop->mime_types); + } IF_FREE_HASH(desktop->x); if (desktop->type_data) { Efreet_Desktop_Type_Info *info; - info = ecore_list_index_goto(efreet_desktop_types, desktop->type); + info = eina_list_nth(efreet_desktop_types, desktop->type); if (info->free_func) info->free_func(desktop->type_data); } @@ -518,7 +544,7 @@ efreet_desktop_free(Efreet_Desktop *desktop) * @brief Parses the @a desktop exec line and returns an Ecore_Exe. */ EAPI void -efreet_desktop_exec(Efreet_Desktop *desktop, Ecore_List *files, void *data) +efreet_desktop_exec(Efreet_Desktop *desktop, Eina_List *files, void *data) { efreet_desktop_command_get(desktop, files, efreet_desktop_exec_cb, data); } @@ -564,7 +590,7 @@ EAPI unsigned int efreet_desktop_category_count_get(Efreet_Desktop *desktop) { if (!desktop || !desktop->categories) return 0; - return ecore_list_count(desktop->categories); + return eina_list_count(desktop->categories); } /** @@ -577,17 +603,10 @@ efreet_desktop_category_add(Efreet_Desktop *desktop, const char *category) { if (!desktop) return; - if (!desktop->categories) - { - desktop->categories = ecore_list_new(); - ecore_list_free_cb_set(desktop->categories, - ECORE_FREE_CB(eina_stringshare_del)); - } - else - if (ecore_list_find(desktop->categories, - ECORE_COMPARE_CB(strcmp), category)) return; + if (eina_list_search_unsorted(desktop->categories, + (Eina_Compare_Cb)strcmp, category)) return; - ecore_list_append(desktop->categories, + desktop->categories = eina_list_append(desktop->categories, (void *)eina_stringshare_add(category)); } @@ -600,17 +619,20 @@ efreet_desktop_category_add(Efreet_Desktop *desktop, const char *category) EAPI int efreet_desktop_category_del(Efreet_Desktop *desktop, const char *category) { - int found = 0; + char *found = NULL; + if (!desktop || !desktop->categories) return 0; - if (ecore_list_find(desktop->categories, - ECORE_COMPARE_CB(strcmp), category)) + if ((found = eina_list_search_unsorted(desktop->categories, + (Eina_Compare_Cb)strcmp, category))) { - found = 1; - ecore_list_remove(desktop->categories); + eina_stringshare_del(found); + desktop->categories = eina_list_remove(desktop->categories, found); + + return 1; } - return found; + return 0; } /** @@ -632,7 +654,7 @@ efreet_desktop_type_add(const char *type, Efreet_Desktop_Type_Parse_Cb parse_fun info = NEW(Efreet_Desktop_Type_Info, 1); if (!info) return 0; - id = ecore_list_count(efreet_desktop_types); + id = eina_list_count(efreet_desktop_types); info->id = id; info->type = strdup(type); @@ -640,7 +662,7 @@ efreet_desktop_type_add(const char *type, Efreet_Desktop_Type_Parse_Cb parse_fun info->save_func = save_func; info->free_func = free_func; - ecore_list_append(efreet_desktop_types, info); + efreet_desktop_types = eina_list_append(efreet_desktop_types, info); return id; } @@ -657,7 +679,7 @@ EAPI int efreet_desktop_type_alias(int from_type, const char *alias) { Efreet_Desktop_Type_Info *info; - info = ecore_list_index_goto(efreet_desktop_types, from_type); + info = eina_list_nth(efreet_desktop_types, from_type); if (!info) return -1; return efreet_desktop_type_add(alias, info->parse_func, info->save_func, info->free_func); @@ -696,11 +718,11 @@ static Efreet_Desktop_Type_Info * efreet_desktop_type_parse(const char *type_str) { Efreet_Desktop_Type_Info *info; + Eina_List *l; if (!type_str) return NULL; - ecore_list_first_goto(efreet_desktop_types); - while ((info = ecore_list_next(efreet_desktop_types))) + EINA_LIST_FOREACH(efreet_desktop_types, l, info) { if (!strcmp(info->type, type_str)) return info; @@ -711,23 +733,18 @@ efreet_desktop_type_parse(const char *type_str) /** * @param string: the raw string list - * @return an Ecore_List of ecore string's + * @return an Eina_List of ecore string's * @brief Parse ';' separate list of strings according to the desktop spec */ -EAPI Ecore_List * +EAPI Eina_List * efreet_desktop_string_list_parse(const char *string) { - Ecore_List *list; + Eina_List *list = NULL; char *tmp; char *s, *p; if (!string) return NULL; - list = ecore_list_new(); - if (!list) return NULL; - - ecore_list_free_cb_set(list, ECORE_FREE_CB(eina_stringshare_del)); - tmp = strdup(string); s = tmp; @@ -735,7 +752,7 @@ efreet_desktop_string_list_parse(const char *string) { if (p > tmp && *(p-1) == '\\') continue; *p = '\0'; - ecore_list_append(list, (void *)eina_stringshare_add(s)); + list = eina_list_append(list, (void *)eina_stringshare_add(s)); s = p + 1; } /* If this is true, the .desktop file does not follow the standard */ @@ -745,7 +762,7 @@ efreet_desktop_string_list_parse(const char *string) printf("[Efreet]: Found a string list without ';' " "at the end: %s\n", string); #endif - ecore_list_append(list, (void *)eina_stringshare_add(s)); + list = eina_list_append(list, (void *)eina_stringshare_add(s)); } free(tmp); @@ -754,25 +771,25 @@ efreet_desktop_string_list_parse(const char *string) } /** - * @param list: Ecore_List with strings + * @param list: Eina_List with strings * @return a raw string list * @brief Create a ';' separate list of strings according to the desktop spec */ EAPI char * -efreet_desktop_string_list_join(Ecore_List *list) +efreet_desktop_string_list_join(Eina_List *list) { + Eina_List *l; const char *tmp; char *string; size_t size, pos, len; - if (ecore_list_empty_is(list)) return strdup(""); + if (!list) return strdup(""); size = 1024; string = malloc(size); pos = 0; - ecore_list_first_goto(list); - while ((tmp = ecore_list_next(list))) + EINA_LIST_FOREACH(list, l, tmp) { len = strlen(tmp); /* +1 for ';' */ @@ -1041,54 +1058,35 @@ efreet_desktop_x_fields_save(const Eina_Hash *hash, const void *key, void *value static int efreet_desktop_environment_check(Efreet_Ini *ini) { - Ecore_List *list; - const char *val; + Eina_List *list, *l; + int found = 0; + char *val; + + if (!desktop_environment) + return 1; list = efreet_desktop_string_list_parse(efreet_ini_string_get(ini, "OnlyShowIn")); if (list) { - int found = 0; - - if (desktop_environment) - { - ecore_list_first_goto(list); - while ((val = ecore_list_next(list))) + EINA_LIST_FREE(list, val) { if (!strcmp(val, desktop_environment)) - { found = 1; - break; - } - } + eina_stringshare_del(val); } - ecore_list_destroy(list); return found; } - if (desktop_environment) - { - int found = 0; - list = efreet_desktop_string_list_parse(efreet_ini_string_get(ini, "NotShowIn")); - if (list) - { - ecore_list_first_goto(list); - while ((val = ecore_list_next(list))) + EINA_LIST_FREE(list, val) { if (!strcmp(val, desktop_environment)) - { found = 1; - break; - } - } - ecore_list_destroy(list); + eina_stringshare_del(val); } return !found; - } - - return 1; } @@ -1102,7 +1100,7 @@ efreet_desktop_environment_check(Efreet_Ini *ini) * @brief Get a command to use to execute a desktop entry. */ EAPI void * -efreet_desktop_command_get(Efreet_Desktop *desktop, Ecore_List *files, +efreet_desktop_command_get(Efreet_Desktop *desktop, Eina_List *files, Efreet_Desktop_Command_Cb func, void *data) { return efreet_desktop_command_progress_get(desktop, files, func, NULL, data); @@ -1116,30 +1114,25 @@ efreet_desktop_command_get(Efreet_Desktop *desktop, Ecore_List *files, * * The returned list and each of its elements must be freed. */ -EAPI Ecore_List * -efreet_desktop_command_local_get(Efreet_Desktop *desktop, Ecore_List *files) +EAPI Eina_List * +efreet_desktop_command_local_get(Efreet_Desktop *desktop, Eina_List *files) { Efreet_Desktop_Command *command; char *file; - Ecore_List *execs; + Eina_List *execs, *l; if (!desktop || !desktop->exec) return NULL; command = NEW(Efreet_Desktop_Command, 1); if (!command) return 0; - command->files = ecore_list_new(); command->desktop = desktop; - ecore_list_free_cb_set(command->files, - ECORE_FREE_CB(efreet_desktop_command_file_free)); - command->flags = efreet_desktop_command_flags_get(desktop); /* get the required info for each file passed in */ if (files) { - ecore_list_first_goto(files); - while ((file = ecore_list_next(files))) + EINA_LIST_FOREACH(files, l, file) { Efreet_Desktop_Command_File *dcf; @@ -1150,7 +1143,7 @@ efreet_desktop_command_local_get(Efreet_Desktop *desktop, Ecore_List *files) efreet_desktop_command_file_free(dcf); continue; } - ecore_list_append(command->files, dcf); + command->files = eina_list_append(command->files, dcf); } } @@ -1173,13 +1166,15 @@ efreet_desktop_command_local_get(Efreet_Desktop *desktop, Ecore_List *files) * updates for downloading of remote URI's passed in. */ EAPI void * -efreet_desktop_command_progress_get(Efreet_Desktop *desktop, Ecore_List *files, +efreet_desktop_command_progress_get(Efreet_Desktop *desktop, Eina_List *files, Efreet_Desktop_Command_Cb cb_command, Efreet_Desktop_Progress_Cb cb_progress, void *data) { Efreet_Desktop_Command *command; + Eina_List *l; char *file; + char *exec; void *ret = NULL; if (!desktop || !cb_command || !desktop->exec) return NULL; @@ -1190,34 +1185,34 @@ efreet_desktop_command_progress_get(Efreet_Desktop *desktop, Ecore_List *files, command->cb_command = cb_command; command->cb_progress = cb_progress; command->data = data; - command->files = ecore_list_new(); command->desktop = desktop; - ecore_list_free_cb_set(command->files, - ECORE_FREE_CB(efreet_desktop_command_file_free)); - command->flags = efreet_desktop_command_flags_get(desktop); /* get the required info for each file passed in */ if (files) { - ecore_list_first_goto(files); - while ((file = ecore_list_next(files))) + EINA_LIST_FOREACH(files, l, file) { Efreet_Desktop_Command_File *dcf; dcf = efreet_desktop_command_file_process(command, file); if (!dcf) continue; - ecore_list_append(command->files, dcf); + command->files = eina_list_append(command->files, dcf); command->num_pending += dcf->pending; } } if (command->num_pending == 0) { - Ecore_List *execs; + Eina_List *execs; execs = efreet_desktop_command_build(command); ret = efreet_desktop_command_execs_process(command, execs); - ecore_list_destroy(execs); + while (execs) + { + exec = eina_list_data_get(execs); + free(exec); + execs = eina_list_remove_list(execs, execs); + } efreet_desktop_command_free(command); } @@ -1289,15 +1284,15 @@ efreet_desktop_command_flags_get(Efreet_Desktop *desktop) * @param execs */ static void * -efreet_desktop_command_execs_process(Efreet_Desktop_Command *command, Ecore_List *execs) +efreet_desktop_command_execs_process(Efreet_Desktop_Command *command, Eina_List *execs) { + Eina_List *l; char *exec; int num; void *ret = NULL; - num = ecore_list_count(execs); - ecore_list_first_goto(execs); - while ((exec = ecore_list_next(execs))) + num = eina_list_count(execs); + EINA_LIST_FOREACH(execs, l, exec) { ret = command->cb_command(command->data, command->desktop, exec, --num); } @@ -1313,31 +1308,26 @@ efreet_desktop_command_execs_process(Efreet_Desktop_Command *command, Ecore_List * @param command: the command to build * @return a list of executable strings */ -static Ecore_List * +static Eina_List * efreet_desktop_command_build(Efreet_Desktop_Command *command) { Efreet_Desktop_Command_File *file = NULL; - int first = 1; - Ecore_List *execs; + Eina_List *execs = NULL; + Eina_List *l; char *exec; - execs = ecore_list_new(); - - ecore_list_first_goto(command->files); /* if the Exec field appends multiple, that will run the list to the end, * causing this loop to only run once. otherwise, this loop will generate a * command for each file in the list. if the list is empty, this * will run once, removing any file field codes */ - while ((file = ecore_list_next(command->files)) || first) + EINA_LIST_FOREACH(command->files, l, file) { const char *p; int len = 0; int size = PATH_MAX; int file_added = 0; - first = 0; - exec = malloc(size); p = command->desktop->exec; len = 0; @@ -1437,7 +1427,7 @@ efreet_desktop_command_build(Efreet_Desktop_Command *command) #endif exec[len++] = '\0'; - ecore_list_append(execs, exec); + execs = eina_list_append(execs, exec); /* If no file was added, then the Exec field doesn't contain any file * fields (fFuUdDnN). We only want to run the app once in this case. */ @@ -1450,9 +1440,17 @@ efreet_desktop_command_build(Efreet_Desktop_Command *command) static void efreet_desktop_command_free(Efreet_Desktop_Command *command) { + Efreet_Desktop_Command_File *dcf; + if (!command) return; - IF_FREE_LIST(command->files); + while (command->files) + { + dcf = eina_list_data_get(command->files); + efreet_desktop_command_file_free(dcf); + command->files = eina_list_remove_list(command->files, + command->files); + } FREE(command); } @@ -1490,12 +1488,12 @@ efreet_desktop_command_append_multiple(char *dest, int *size, int *len, char type) { Efreet_Desktop_Command_File *file; + Eina_List *l; int first = 1; if (!command->files) return dest; - ecore_list_first_goto(command->files); - while ((file = ecore_list_next(command->files))) + EINA_LIST_FOREACH(command->files, l, file) { if (first) first = 0; @@ -1759,6 +1757,8 @@ efreet_desktop_cb_download_complete(void *data, const char *file __UNUSED__, int status __UNUSED__) { Efreet_Desktop_Command_File *f; + char *exec; + f = data; /* XXX check status... error handling, etc */ @@ -1767,11 +1767,16 @@ efreet_desktop_cb_download_complete(void *data, const char *file __UNUSED__, if (f->command->num_pending <= 0) { - Ecore_List *execs; + Eina_List *execs; execs = efreet_desktop_command_build(f->command); /* TODO: Need to handle the return value from efreet_desktop_command_execs_process */ efreet_desktop_command_execs_process(f->command, execs); - ecore_list_destroy(execs); + while (execs) + { + exec = eina_list_data_get(execs); + free(exec); + execs = eina_list_remove_list(execs, execs); + } efreet_desktop_command_free(f->command); } } diff --git a/legacy/efreet/src/lib/efreet_desktop.h b/legacy/efreet/src/lib/efreet_desktop.h index a830edeb7a..f301463cd6 100644 --- a/legacy/efreet/src/lib/efreet_desktop.h +++ b/legacy/efreet/src/lib/efreet_desktop.h @@ -75,12 +75,12 @@ struct _Efreet_Desktop the given string as it's WM class or WM name */ char *url; /**< URL to access if type is EFREET_TYPE_LINK */ - Ecore_List *only_show_in; /**< list of environments that should + Eina_List *only_show_in; /**< list of environments that should display the icon */ - Ecore_List *not_show_in; /**< list of environments that shoudn't + Eina_List *not_show_in; /**< list of environments that shoudn't display the icon */ - Ecore_List *categories; /**< Categories in which item should be shown */ - Ecore_List *mime_types; /**< The mime types supppored by this app */ + Eina_List *categories; /**< Categories in which item should be shown */ + Eina_List *mime_types; /**< The mime types supppored by this app */ unsigned char no_display:1; /**< Don't display this application in menus */ unsigned char hidden:1; /**< User delete the item */ @@ -103,21 +103,21 @@ EAPI int efreet_desktop_save_as(Efreet_Desktop *desktop, const char *file); EAPI void efreet_desktop_exec(Efreet_Desktop *desktop, - Ecore_List *files, void *data); + Eina_List *files, void *data); EAPI void efreet_desktop_environment_set(const char *environment); EAPI const char *efreet_desktop_environment_get(void); EAPI void *efreet_desktop_command_progress_get(Efreet_Desktop *desktop, - Ecore_List *files, + Eina_List *files, Efreet_Desktop_Command_Cb cb_command, Efreet_Desktop_Progress_Cb cb_prog, void *data); EAPI void *efreet_desktop_command_get(Efreet_Desktop *desktop, - Ecore_List *files, + Eina_List *files, Efreet_Desktop_Command_Cb func, void *data); -EAPI Ecore_List * efreet_desktop_command_local_get(Efreet_Desktop *desktop, - Ecore_List *files); +EAPI Eina_List * efreet_desktop_command_local_get(Efreet_Desktop *desktop, + Eina_List *files); EAPI unsigned int efreet_desktop_category_count_get(Efreet_Desktop *desktop); EAPI void efreet_desktop_category_add(Efreet_Desktop *desktop, @@ -133,8 +133,8 @@ EAPI int efreet_desktop_type_alias (int from_type, const char *alias); EAPI void *efreet_desktop_type_data_get(Efreet_Desktop *desktop); -EAPI Ecore_List *efreet_desktop_string_list_parse(const char *string); -EAPI char *efreet_desktop_string_list_join(Ecore_List *list); +EAPI Eina_List *efreet_desktop_string_list_parse(const char *string); +EAPI char *efreet_desktop_string_list_join(Eina_List *list); EAPI void efreet_desktop_cache_flush(void); diff --git a/legacy/efreet/src/lib/efreet_icon.c b/legacy/efreet/src/lib/efreet_icon.c index 5b95662e9a..aead8b5dcf 100644 --- a/legacy/efreet/src/lib/efreet_icon.c +++ b/legacy/efreet/src/lib/efreet_icon.c @@ -5,8 +5,8 @@ static char *efreet_icon_deprecated_user_dir = NULL; static char *efreet_icon_user_dir = NULL; static Eina_Hash *efreet_icon_themes = NULL; -static Ecore_List *efreet_icon_extensions = NULL; -static Ecore_List *efreet_extra_icon_dirs = NULL; +static Eina_List *efreet_icon_extensions = NULL; +static Eina_List *efreet_extra_icon_dirs = NULL; static Eina_Hash *efreet_icon_cache = NULL; static int efreet_icon_init_count = 0; @@ -27,12 +27,12 @@ static char *efreet_icon_find_fallback(Efreet_Icon_Theme *theme, const char *icon, unsigned int size); static char *efreet_icon_list_find_fallback(Efreet_Icon_Theme *theme, - Ecore_List *icons, + Eina_List *icons, unsigned int size); static char *efreet_icon_find_helper(Efreet_Icon_Theme *theme, const char *icon, unsigned int size); static char *efreet_icon_list_find_helper(Efreet_Icon_Theme *theme, - Ecore_List *icons, unsigned int size); + Eina_List *icons, unsigned int size); static char *efreet_icon_lookup_icon(Efreet_Icon_Theme *theme, const char *icon_name, unsigned int size); static char *efreet_icon_fallback_icon(const char *icon_name); @@ -74,11 +74,20 @@ static int efreet_icon_theme_cache_check_dir(Efreet_Icon_Theme *theme, const char *dir); static int efreet_icon_cache_find(Efreet_Icon_Cache *value, const char *key); -static void efreet_icon_cache_flush(Ecore_List *list); +static void efreet_icon_cache_flush(Eina_List *list); static void efreet_icon_cache_free(Efreet_Icon_Cache *value); static char *efreet_icon_cache_check(Efreet_Icon_Theme *theme, const char *icon, unsigned int size); static void efreet_icon_cache_add(Efreet_Icon_Theme *theme, const char *icon, unsigned int size, const char *value); +static void +_efreet_icon_cache_list_destroy(Eina_List *list) +{ + Efreet_Icon_Cache *cache; + + EINA_LIST_FREE(list, cache) + efreet_icon_cache_free(cache); +} + /** * @internal * @return Returns 1 on success or 0 on failure @@ -102,16 +111,13 @@ efreet_icon_init(void) } /* setup the default extension list */ - efreet_icon_extensions = ecore_list_new(); - ecore_list_free_cb_set(efreet_icon_extensions, free); - for (i = 0; default_exts[i] != NULL; i++) - ecore_list_append(efreet_icon_extensions, strdup(default_exts[i])); + efreet_icon_extensions = eina_list_append(efreet_icon_extensions, strdup(default_exts[i])); efreet_icon_themes = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_icon_theme_free)); - efreet_extra_icon_dirs = ecore_list_new(); - efreet_icon_cache = eina_hash_pointer_new(EINA_FREE_CB(ecore_list_destroy)); + efreet_extra_icon_dirs = NULL; + efreet_icon_cache = eina_hash_pointer_new(EINA_FREE_CB(_efreet_icon_cache_list_destroy)); } return 1; @@ -185,7 +191,7 @@ efreet_icon_user_dir_get(void) EAPI void efreet_icon_extension_add(const char *ext) { - ecore_list_prepend(efreet_icon_extensions, strdup(ext)); + efreet_icon_extensions = eina_list_prepend(efreet_icon_extensions, strdup(ext)); } /** @@ -196,7 +202,7 @@ efreet_icon_extension_add(const char *ext) * from first to last directory in this list. the strings in the list should * be created with eina_stringshare_add(). */ -EAPI Ecore_List * +EAPI Eina_List * efreet_icon_extra_list_get(void) { return efreet_extra_icon_dirs; @@ -205,7 +211,7 @@ efreet_icon_extra_list_get(void) static Eina_Bool _hash_keys(Eina_Hash *hash, const void *key, void *list) { - ecore_list_append(list, key); + *(Eina_List**)list = eina_list_append(*(Eina_List**)list, key); return EINA_TRUE; } /** @@ -214,10 +220,11 @@ _hash_keys(Eina_Hash *hash, const void *key, void *list) * @brief Retrieves all of the non-hidden icon themes available on the system. * The returned list must be freed. Do not free the list data. */ -EAPI Ecore_List * +EAPI Eina_List * efreet_icon_theme_list_get(void) { - Ecore_List *list, *theme_list; + Eina_List *list = NULL; + Eina_List *theme_list = NULL; char *dir; Eina_Iterator *it; @@ -226,13 +233,11 @@ efreet_icon_theme_list_get(void) efreet_icon_theme_dir_validity_check(); /* create the list for the user */ - list = ecore_list_new(); - theme_list = ecore_list_new(); it = eina_hash_iterator_key_new(efreet_icon_themes); - eina_iterator_foreach(it, EINA_EACH(_hash_keys), theme_list); + eina_iterator_foreach(it, EINA_EACH(_hash_keys), &theme_list); eina_iterator_free(it); - ecore_list_first_goto(theme_list); - while ((dir = ecore_list_next(theme_list))) + + EINA_LIST_FREE(theme_list, dir) { Efreet_Icon_Theme *theme; @@ -242,9 +247,8 @@ efreet_icon_theme_list_get(void) if (!theme->name.name) continue; #endif - ecore_list_append(list, theme); + list = eina_list_append(list, theme); } - ecore_list_destroy(theme_list); return list; } @@ -282,6 +286,7 @@ efreet_icon_theme_find(const char *theme_name) static char * efreet_icon_remove_extension(const char *icon) { + Eina_List *l; char *tmp = NULL, *ext = NULL; tmp = strdup(icon); @@ -289,8 +294,7 @@ efreet_icon_remove_extension(const char *icon) if (ext) { const char *ext2; - ecore_list_first_goto(efreet_icon_extensions); - while ((ext2 = ecore_list_next(efreet_icon_extensions))) + EINA_LIST_FOREACH(efreet_icon_extensions, l, ext2) { if (!strcmp(ext, ext2)) { @@ -386,28 +390,31 @@ efreet_icon_path_find(const char *theme_name, const char *icon, unsigned int siz * back. This is useful when searching for mimetype icons. */ EAPI char * -efreet_icon_list_find(const char *theme_name, Ecore_List *icons, +efreet_icon_list_find(const char *theme_name, Eina_List *icons, unsigned int size) { + Eina_List *l; const char *icon = NULL; char *value = NULL; + char *data; Efreet_Icon_Theme *theme; theme = efreet_icon_find_theme_check(theme_name); - ecore_list_first_goto(icons); #ifdef SLOPPY_SPEC { - Ecore_List *tmps = NULL; + Eina_List *tmps = NULL; - tmps = ecore_list_new(); - ecore_list_free_cb_set(tmps, free); - ecore_list_first_goto(icons); - while ((icon = ecore_list_next(icons))) - ecore_list_append(tmps, efreet_icon_remove_extension(icon)); + EINA_LIST_FOREACH(icons, l, icon) + tmps = eina_list_append(tmps, efreet_icon_remove_extension(icon)); value = efreet_icon_list_find_helper(theme, tmps, size); - ecore_list_destroy(tmps); + while (tmps) + { + data = eina_list_data_get(tmps); + free(data); + tmps = eina_list_remove_list(tmps, tmps); + } } #else value = efreet_icon_list_find_helper(theme, icons, size); @@ -418,8 +425,7 @@ efreet_icon_list_find(const char *theme_name, Ecore_List *icons, */ if (!value || (value == NON_EXISTING)) { - ecore_list_first_goto(icons); - while ((icon = ecore_list_next(icons))) + EINA_LIST_FOREACH(icons, l, icon) { value = efreet_icon_fallback_icon(icon); if (value && (value != NON_EXISTING)) @@ -470,13 +476,13 @@ static char * efreet_icon_find_fallback(Efreet_Icon_Theme *theme, const char *icon, unsigned int size) { + Eina_List *l; char *parent = NULL; char *value = NULL; if (theme->inherits) { - ecore_list_first_goto(theme->inherits); - while ((parent = ecore_list_next(theme->inherits))) + EINA_LIST_FOREACH(theme->inherits, l, parent) { Efreet_Icon_Theme *parent_theme; @@ -547,15 +553,15 @@ efreet_icon_find_helper(Efreet_Icon_Theme *theme, */ static char * efreet_icon_list_find_fallback(Efreet_Icon_Theme *theme, - Ecore_List *icons, unsigned int size) + Eina_List *icons, unsigned int size) { + Eina_List *l; char *parent = NULL; char *value = NULL; if (theme->inherits) { - ecore_list_first_goto(theme->inherits); - while ((parent = ecore_list_next(theme->inherits))) + EINA_LIST_FOREACH(theme->inherits, l, parent) { Efreet_Icon_Theme *parent_theme; @@ -595,8 +601,9 @@ efreet_icon_list_find_fallback(Efreet_Icon_Theme *theme, */ static char * efreet_icon_list_find_helper(Efreet_Icon_Theme *theme, - Ecore_List *icons, unsigned int size) + Eina_List *icons, unsigned int size) { + Eina_List *l; char *value = NULL; const char *icon = NULL; static int recurse = 0; @@ -610,8 +617,7 @@ efreet_icon_list_find_helper(Efreet_Icon_Theme *theme, if (recurse > 256) return NULL; recurse++; - ecore_list_first_goto(icons); - while ((icon = ecore_list_next(icons))) + EINA_LIST_FOREACH(icons, l, icon) { value = efreet_icon_lookup_icon(theme, icon, size); if (value && (value != NON_EXISTING)) @@ -639,19 +645,19 @@ static char * efreet_icon_lookup_icon(Efreet_Icon_Theme *theme, const char *icon_name, unsigned int size) { + Eina_List *l; char *icon = NULL, *tmp = NULL; Efreet_Icon_Theme_Directory *dir; int minimal_size = INT_MAX; - if (!theme || (theme->paths.count == 0) || !icon_name || !size) + if (!theme || (theme->paths == NULL) || !icon_name || !size) return NULL; icon = efreet_icon_cache_check(theme, icon_name, size); if (icon) return icon; /* search for allowed size == requested size */ - ecore_list_first_goto(theme->directories); - while ((dir = ecore_list_next(theme->directories))) + EINA_LIST_FOREACH(theme->directories, l, dir) { if (!efreet_icon_directory_size_match(dir, size)) continue; icon = efreet_icon_lookup_directory(theme, dir, @@ -664,8 +670,7 @@ efreet_icon_lookup_icon(Efreet_Icon_Theme *theme, const char *icon_name, } /* search for any icon that matches */ - ecore_list_first_goto(theme->directories); - while ((dir = ecore_list_next(theme->directories))) + EINA_LIST_FOREACH(theme->directories, l, dir) { int distance; @@ -701,21 +706,15 @@ efreet_icon_lookup_directory(Efreet_Icon_Theme *theme, Efreet_Icon_Theme_Directory *dir, const char *icon_name) { - if (theme->paths.count == 1) - return efreet_icon_lookup_directory_helper(dir, theme->paths.path, icon_name); - - else - { + Eina_List *l; char *icon; const char *path; - ecore_list_first_goto(theme->paths.path); - while ((path = ecore_list_next(theme->paths.path))) + EINA_LIST_FOREACH(theme->paths, l, path) { icon = efreet_icon_lookup_directory_helper(dir, path, icon_name); if (icon) return icon; } - } return NULL; } @@ -802,12 +801,11 @@ efreet_icon_fallback_icon(const char *icon_name) icon = efreet_icon_fallback_dir_scan(efreet_icon_user_dir_get(), icon_name); if (!icon) { - Ecore_List *xdg_dirs; + Eina_List *xdg_dirs, *l; const char *dir; char path[PATH_MAX]; - ecore_list_first_goto(efreet_extra_icon_dirs); - while ((dir = ecore_list_next(efreet_extra_icon_dirs))) + EINA_LIST_FOREACH(efreet_extra_icon_dirs, l, dir) { icon = efreet_icon_fallback_dir_scan(dir, icon_name); if (icon) @@ -818,8 +816,8 @@ efreet_icon_fallback_icon(const char *icon_name) } xdg_dirs = efreet_data_dirs_get(); - ecore_list_first_goto(xdg_dirs); - while ((dir = ecore_list_next(xdg_dirs))) + + EINA_LIST_FOREACH(xdg_dirs, l, dir) { snprintf(path, PATH_MAX, "%s/icons", dir); icon = efreet_icon_fallback_dir_scan(path, icon_name); @@ -848,6 +846,7 @@ efreet_icon_fallback_icon(const char *icon_name) static char * efreet_icon_fallback_dir_scan(const char *dir, const char *icon_name) { + Eina_List *l; char *icon = NULL; char path[PATH_MAX], *ext; const char *icon_path[] = { dir, "/", icon_name, NULL }; @@ -856,8 +855,7 @@ efreet_icon_fallback_dir_scan(const char *dir, const char *icon_name) if (!dir || !icon_name) return NULL; size = efreet_array_cat(path, sizeof(path), icon_path); - ecore_list_first_goto(efreet_icon_extensions); - while ((ext = ecore_list_next(efreet_icon_extensions))) + EINA_LIST_FOREACH(efreet_icon_extensions, l, ext) { ecore_strlcpy(path + size, ext, sizeof(path) - size); @@ -899,6 +897,7 @@ static char * efreet_icon_lookup_directory_helper(Efreet_Icon_Theme_Directory *dir, const char *path, const char *icon_name) { + Eina_List *l; char *icon = NULL; char file_path[PATH_MAX]; const char *ext, *path_strs[] = { path, "/", dir->name, "/", icon_name, NULL }; @@ -906,8 +905,7 @@ efreet_icon_lookup_directory_helper(Efreet_Icon_Theme_Directory *dir, len = efreet_array_cat(file_path, sizeof(file_path), path_strs); - ecore_list_first_goto(efreet_icon_extensions); - while ((ext = ecore_list_next(efreet_icon_extensions))) + EINA_LIST_FOREACH(efreet_icon_extensions, l, ext) { ecore_strlcpy(file_path + len, ext, sizeof(file_path) - len); @@ -1062,10 +1060,6 @@ efreet_icon_populate(Efreet_Icon *icon, const char *file) { char *t, *s, *p; - icon->attach_points = ecore_list_new(); - ecore_list_free_cb_set(icon->attach_points, - ECORE_FREE_CB(efreet_icon_point_free)); - t = strdup(tmp); s = t; p = t; @@ -1087,7 +1081,8 @@ efreet_icon_populate(Efreet_Icon *icon, const char *file) if (p) *p = '\0'; point->y = atoi(s); - ecore_list_append(icon->attach_points, point); + + icon->attach_points = eina_list_append(icon->attach_points, point); if (p) s = ++p; else s = NULL; @@ -1130,11 +1125,7 @@ efreet_icon_theme_free(Efreet_Icon_Theme *theme) IF_FREE(theme->comment); IF_FREE(theme->example_icon); - if (theme->paths.count == 1) - IF_FREE(theme->paths.path); - else - IF_FREE_LIST(theme->paths.path); - + IF_FREE_LIST(theme->paths); IF_FREE_LIST(theme->inherits); IF_FREE_LIST(theme->directories); @@ -1154,24 +1145,7 @@ efreet_icon_theme_path_add(Efreet_Icon_Theme *theme, const char *path) { if (!theme || !path) return; - if (theme->paths.count == 0) - theme->paths.path = strdup(path); - - else if (theme->paths.count > 1) - ecore_list_append(theme->paths.path, strdup(path)); - - else - { - char *old; - - old = theme->paths.path; - theme->paths.path = ecore_list_new(); - ecore_list_free_cb_set(theme->paths.path, free); - - ecore_list_append(theme->paths.path, old); - ecore_list_append(theme->paths.path, strdup(path)); - } - theme->paths.count++; + theme->paths = eina_list_append(theme->paths, strdup(path)); } /** @@ -1187,6 +1161,7 @@ efreet_icon_theme_path_add(Efreet_Icon_Theme *theme, const char *path) static void efreet_icon_theme_cache_check(Efreet_Icon_Theme *theme) { + Eina_List *l; double new_check; new_check = ecore_time_get(); @@ -1197,15 +1172,11 @@ efreet_icon_theme_cache_check(Efreet_Icon_Theme *theme) if (theme->fake) efreet_icon_theme_dir_scan_all(theme->name.internal); - else if (theme->paths.count == 1) - efreet_icon_theme_cache_check_dir(theme, theme->paths.path); - - else if (theme->paths.count > 1) + else { char *path; - ecore_list_first_goto(theme->paths.path); - while ((path = ecore_list_next(theme->paths.path))) + EINA_LIST_FOREACH(theme->paths, l, path) { if (!efreet_icon_theme_cache_check_dir(theme, path)) break; @@ -1248,15 +1219,14 @@ efreet_icon_theme_cache_check_dir(Efreet_Icon_Theme *theme, const char *dir) static void efreet_icon_theme_dir_scan_all(const char *theme_name) { - Ecore_List *xdg_dirs; + Eina_List *xdg_dirs, *l; char path[PATH_MAX], *dir; efreet_icon_theme_dir_scan(efreet_icon_deprecated_user_dir_get(), theme_name); efreet_icon_theme_dir_scan(efreet_icon_user_dir_get(), theme_name); xdg_dirs = efreet_data_dirs_get(); - ecore_list_first_goto(xdg_dirs); - while ((dir = ecore_list_next(xdg_dirs))) + EINA_LIST_FOREACH(xdg_dirs, l, dir) { snprintf(path, sizeof(path), "%s/icons", dir); efreet_icon_theme_dir_scan(path, theme_name); @@ -1384,9 +1354,6 @@ efreet_icon_theme_index_read(Efreet_Icon_Theme *theme, const char *path) { char *t, *s, *p; - theme->inherits = ecore_list_new(); - ecore_list_free_cb_set(theme->inherits, free); - t = strdup(tmp); s = t; p = strchr(s, ','); @@ -1395,11 +1362,11 @@ efreet_icon_theme_index_read(Efreet_Icon_Theme *theme, const char *path) { *p = '\0'; - ecore_list_append(theme->inherits, strdup(s)); + theme->inherits = eina_list_append(theme->inherits, strdup(s)); s = ++p; p = strchr(s, ','); } - ecore_list_append(theme->inherits, strdup(s)); + theme->inherits = eina_list_append(theme->inherits, strdup(s)); FREE(t); } @@ -1411,10 +1378,6 @@ efreet_icon_theme_index_read(Efreet_Icon_Theme *theme, const char *path) { char *t, *s, *p; - theme->directories = ecore_list_new(); - ecore_list_free_cb_set(theme->directories, - ECORE_FREE_CB(efreet_icon_theme_directory_free)); - t = strdup(tmp); s = t; p = s; @@ -1425,7 +1388,7 @@ efreet_icon_theme_index_read(Efreet_Icon_Theme *theme, const char *path) if (p) *p = '\0'; - ecore_list_append(theme->directories, + theme->directories = eina_list_append(theme->directories, efreet_icon_theme_directory_new(ini, s)); if (p) s = ++p; @@ -1449,16 +1412,16 @@ efreet_icon_theme_index_read(Efreet_Icon_Theme *theme, const char *path) static void efreet_icon_theme_dir_validity_check(void) { - Ecore_List *keys; + Eina_List *keys, *l; const char *name; Eina_Iterator *it; - keys = ecore_list_new(); + keys = NULL; it = eina_hash_iterator_key_new(efreet_icon_themes); - eina_iterator_foreach(it, EINA_EACH(_hash_keys), keys); + eina_iterator_foreach(it, EINA_EACH(_hash_keys), &keys); eina_iterator_free(it); - ecore_list_first_goto(keys); - while ((name = ecore_list_next(keys))) + + EINA_LIST_FOREACH(keys, l, name) { Efreet_Icon_Theme *theme; @@ -1466,7 +1429,8 @@ efreet_icon_theme_dir_validity_check(void) if (theme && !theme->valid && !theme->fake) eina_hash_del(efreet_icon_themes, name, theme); } - ecore_list_destroy(keys); + while (keys) + keys = eina_list_remove_list(keys, keys); } /** @@ -1561,18 +1525,21 @@ efreet_icon_cache_find(Efreet_Icon_Cache *value, const char *key) } static void -efreet_icon_cache_flush(Ecore_List *list) +efreet_icon_cache_flush(Eina_List *list) { /* TODO: * * Dynamic cache size * * Maybe add references to cache, so that we sort on how often a value is used */ - while (ecore_list_count(list) > 100) + while (eina_list_count(list) > 100) { Efreet_Icon_Cache *cache; + Eina_List *last; - cache = ecore_list_last_remove(list); + last = eina_list_last(list); + cache = eina_list_data_get(last); efreet_icon_cache_free(cache); + list = eina_list_remove_list(list, last); } } @@ -1589,36 +1556,30 @@ efreet_icon_cache_free(Efreet_Icon_Cache *value) static char * efreet_icon_cache_check(Efreet_Icon_Theme *theme, const char *icon, unsigned int size) { - Ecore_List *list; + Eina_List *list; Efreet_Icon_Cache *cache; char key[4096]; struct stat st; list = eina_hash_find(efreet_icon_cache, &theme); - if (!list) - { - list = ecore_list_new(); - ecore_list_free_cb_set(list, ECORE_FREE_CB(efreet_icon_cache_free)); - eina_hash_add(efreet_icon_cache, &theme, list); - return NULL; - } + if (!list) return NULL; snprintf(key, sizeof(key), "%s %d", icon, size); - cache = ecore_list_find(list, ECORE_COMPARE_CB(efreet_icon_cache_find), key); + cache = eina_list_search_unsorted(list, (Eina_Compare_Cb)efreet_icon_cache_find, key); if (cache) { - ecore_list_remove(list); if (!cache->path) { - ecore_list_prepend(list, cache); + list = eina_list_promote_list(list, eina_list_data_find_list(list, cache)); return NON_EXISTING; } else if (!stat(cache->path, &st) && st.st_mtime == cache->lasttime) { - ecore_list_prepend(list, cache); + list = eina_list_promote_list(list, eina_list_data_find_list(list, cache)); return strdup(cache->path); } efreet_icon_cache_free(cache); + list = eina_list_remove(list, cache); } return NULL; } @@ -1626,18 +1587,12 @@ efreet_icon_cache_check(Efreet_Icon_Theme *theme, const char *icon, unsigned int static void efreet_icon_cache_add(Efreet_Icon_Theme *theme, const char *icon, unsigned int size, const char *value) { - Ecore_List *list; + Eina_List *list, *l; Efreet_Icon_Cache *cache; char key[4096]; struct stat st; list = eina_hash_find(efreet_icon_cache, &theme); - if (!list) - { - list = ecore_list_new(); - ecore_list_free_cb_set(list, ECORE_FREE_CB(efreet_icon_cache_free)); - eina_hash_add(efreet_icon_cache, &theme, list); - } snprintf(key, sizeof(key), "%s %d", icon, size); cache = NEW(Efreet_Icon_Cache, 1); @@ -1649,6 +1604,12 @@ efreet_icon_cache_add(Efreet_Icon_Theme *theme, const char *icon, unsigned int s } else cache->lasttime = ecore_time_get(); - ecore_list_prepend(list, cache); + + l = list; + list = eina_list_prepend(list, cache); + + if (!l) eina_hash_add(efreet_icon_cache, &theme, list); + else eina_hash_modify(efreet_icon_cache, &theme, list); + efreet_icon_cache_flush(list); } diff --git a/legacy/efreet/src/lib/efreet_icon.h b/legacy/efreet/src/lib/efreet_icon.h index 118307e6cb..76d5272f7b 100644 --- a/legacy/efreet/src/lib/efreet_icon.h +++ b/legacy/efreet/src/lib/efreet_icon.h @@ -66,17 +66,11 @@ struct Efreet_Icon_Theme char *example_icon; /**< Icon to use as an example of the theme */ /* An icon theme can have multiple directories that store it's icons. We - * need to be able to find a search each one. If count is 1 then path - * will be a char * pointing to the directory. If count > 1 then path - * will be an Ecore_List of char *'s pointing to the directories */ - struct - { - void *path; /**< The paths */ - int count; /**< The number of path's */ - } paths; /**< The paths to this theme */ + * need to be able to find a search each one. */ - Ecore_List *inherits; /**< Icon themes we inherit from */ - Ecore_List *directories; /**< List of subdirectories for this theme */ + Eina_List *paths; /**< The paths */ + Eina_List *inherits; /**< Icon themes we inherit from */ + Eina_List *directories; /**< List of subdirectories for this theme */ double last_cache_check; /**< Last time the cache was checked */ @@ -135,7 +129,7 @@ struct Efreet_Icon } embedded_text_rectangle; /**< Rectangle where text can be displayed on the icon */ - Ecore_List *attach_points; /**< List of points to be used as anchor + Eina_List *attach_points; /**< List of points to be used as anchor points for emblems/overlays */ unsigned int ref_count; /**< References to this icon */ @@ -161,14 +155,14 @@ struct Efreet_Icon_Point EAPI const char *efreet_icon_user_dir_get(void); EAPI void efreet_icon_extension_add(const char *ext); -EAPI Ecore_List *efreet_icon_extra_list_get(void); -EAPI Ecore_List *efreet_icon_theme_list_get(void); +EAPI Eina_List *efreet_icon_extra_list_get(void); +EAPI Eina_List *efreet_icon_theme_list_get(void); EAPI Efreet_Icon_Theme *efreet_icon_theme_find(const char *theme_name); EAPI Efreet_Icon *efreet_icon_find(const char *theme_name, const char *icon, unsigned int size); EAPI char *efreet_icon_list_find(const char *theme_name, - Ecore_List *icons, + Eina_List *icons, unsigned int size); EAPI char *efreet_icon_path_find(const char *theme_name, const char *icon, diff --git a/legacy/efreet/src/lib/efreet_ini.c b/legacy/efreet/src/lib/efreet_ini.c index da1cb969eb..15e8f240b6 100644 --- a/legacy/efreet/src/lib/efreet_ini.c +++ b/legacy/efreet/src/lib/efreet_ini.c @@ -141,7 +141,6 @@ efreet_ini_parse(const char *file) if (line_start[header_length] == ']') { - Eina_Hash *old; const char *header; header = alloca(header_length * sizeof(unsigned char)); @@ -180,7 +179,6 @@ efreet_ini_parse(const char *file) if (sep < line_length) { const char *key, *value; - char *old; int key_end, value_start, value_end; /* trim whitespace from end of key */ diff --git a/legacy/efreet/src/lib/efreet_menu.c b/legacy/efreet/src/lib/efreet_menu.c index 69508e25bf..3ec7d46db1 100644 --- a/legacy/efreet/src/lib/efreet_menu.c +++ b/legacy/efreet/src/lib/efreet_menu.c @@ -45,22 +45,22 @@ struct Efreet_Menu_Internal Efreet_Menu_Move *current_move; /**< The current move */ - Ecore_List *app_dirs; /**< .desktop application directories */ + Eina_List *app_dirs; /**< .desktop application directories */ - Ecore_List *app_pool; /**< application pool */ - Ecore_List *applications; /**< applications in this menu */ + Eina_List *app_pool; /**< application pool */ + Eina_List *applications; /**< applications in this menu */ Ecore_DList *directory_dirs; /**< .directory file directories */ Eina_Hash *directory_cache; /**< .directory dirs */ - Ecore_List *moves; /**< List of moves to be handled by the menu */ - Ecore_List *filters; /**< Include and Exclude filters */ + Eina_List *moves; /**< List of moves to be handled by the menu */ + Eina_List *filters; /**< Include and Exclude filters */ Efreet_Menu_Internal *parent; /**< Our parent menu */ - Ecore_List *sub_menus; /**< Our sub menus */ + Eina_List *sub_menus; /**< Our sub menus */ - Ecore_List *layout; /**< This menus layout */ - Ecore_List *default_layout; /**< Default layout */ + Eina_List *layout; /**< This menus layout */ + Eina_List *default_layout; /**< Default layout */ char show_empty; /**< Whether to show empty menus */ char in_line; /**< Whether this meny can be inlined */ char inline_limit; /**< Number of elements which triggers inline */ @@ -130,10 +130,10 @@ typedef struct Efreet_Menu_Filter_Op Efreet_Menu_Filter_Op; struct Efreet_Menu_Filter_Op { Efreet_Menu_Filter_Op_Type type; /**< The type of operation */ - Ecore_List *categories; /**< The categories this op applies too */ - Ecore_List *filenames; /**< The filenames this op applies too */ + Eina_List *categories; /**< The categories this op applies too */ + Eina_List *filenames; /**< The filenames this op applies too */ - Ecore_List *filters; /**< Child filters */ + Eina_List *filters; /**< Child filters */ unsigned char all:1; /**< Applies to all .desktop files */ }; @@ -208,7 +208,7 @@ struct Efreet_Menu_Desktop }; static char *efreet_menu_prefix = NULL; /**< The $XDG_MENU_PREFIX env var */ -Ecore_List *efreet_menu_kde_legacy_dirs = NULL; /**< The directories to use for KDELegacy entries */ +Eina_List *efreet_menu_kde_legacy_dirs = NULL; /**< The directories to use for KDELegacy entries */ static const char *efreet_tag_menu = NULL; static char *efreet_menu_file = NULL; /**< A menu file set explicityl as default */ @@ -248,7 +248,7 @@ static Efreet_Desktop *efreet_menu_directory_get(Efreet_Menu_Internal *internal, const char *path); static void efreet_menu_process_filters(Efreet_Menu_Internal *internal, unsigned int only_unallocated); -static void efreet_menu_process_app_pool(Ecore_List *pool, Ecore_List *applications, +static Eina_List * efreet_menu_process_app_pool(Eina_List *pool, Eina_List *applications, Eina_Hash *matches, Efreet_Menu_Filter *filter, unsigned int only_unallocated); @@ -507,10 +507,6 @@ efreet_menu_kde_legacy_init(void) f = popen("kde-config --path apps", "r"); if (!f) return 0; - efreet_menu_kde_legacy_dirs = ecore_list_new(); - ecore_list_free_cb_set(efreet_menu_kde_legacy_dirs, - ECORE_FREE_CB(eina_stringshare_del)); - /* XXX if the return from kde-config is a line longer than PATH_MAX, * this won't be correct (increase buffer and get the rest...) */ if (!fgets(buf, PATH_MAX, f)) @@ -524,14 +520,14 @@ efreet_menu_kde_legacy_init(void) while (p) { *p = '\0'; - ecore_list_append(efreet_menu_kde_legacy_dirs, + efreet_menu_kde_legacy_dirs = eina_list_append(efreet_menu_kde_legacy_dirs, (void *)eina_stringshare_add(s)); s = p + 1; p = strchr(s, ':'); } if (*s) - ecore_list_append(efreet_menu_kde_legacy_dirs, + efreet_menu_kde_legacy_dirs = eina_list_append(efreet_menu_kde_legacy_dirs, (void *)eina_stringshare_add(s)); pclose(f); @@ -604,7 +600,7 @@ efreet_menu_get(void) { char menu[PATH_MAX]; const char *dir; - Ecore_List *config_dirs; + Eina_List *config_dirs, *l; /* check the users config directory first */ snprintf(menu, sizeof(menu), "%s/menus/%sapplications.menu", @@ -620,8 +616,7 @@ efreet_menu_get(void) /* fallback to the XDG_CONFIG_DIRS */ config_dirs = efreet_config_dirs_get(); - ecore_list_first_goto(config_dirs); - while ((dir = ecore_list_next(config_dirs))) + EINA_LIST_FOREACH(config_dirs, l, dir) { snprintf(menu, sizeof(menu), "%s/menus/%sapplications.menu", dir, efreet_menu_prefix_get()); @@ -644,7 +639,7 @@ efreet_menu_parse(const char *path) Efreet_Xml *xml; Efreet_Menu_Internal *internal = NULL; Efreet_Menu *entry = NULL; - Ecore_List *search_dirs; + Eina_List *search_dirs; xml = efreet_xml_new(path); if (!xml) return NULL; @@ -737,6 +732,8 @@ efreet_menu_save(Efreet_Menu *menu, const char *path) static int efreet_menu_save_menu(Efreet_Menu *menu, FILE *f, int indent) { + Eina_List *l; + efreet_menu_save_indent(f, indent); fprintf(f, "\n"); if (menu->name) @@ -767,8 +764,7 @@ efreet_menu_save_menu(Efreet_Menu *menu, FILE *f, int indent) efreet_menu_save_indent(f, indent + 1); fprintf(f, "\n"); - ecore_list_first_goto(menu->entries); - while ((entry = ecore_list_next(menu->entries))) + EINA_LIST_FOREACH(menu->entries, l, entry) { if (entry->type == EFREET_MENU_ENTRY_MENU) { @@ -795,8 +791,7 @@ efreet_menu_save_menu(Efreet_Menu *menu, FILE *f, int indent) { efreet_menu_save_indent(f, indent + 1); fprintf(f, "\n"); - ecore_list_first_goto(menu->entries); - while ((entry = ecore_list_next(menu->entries))) + EINA_LIST_FOREACH(menu->entries, l, entry) { if (entry->type == EFREET_MENU_ENTRY_DESKTOP) { @@ -810,8 +805,7 @@ efreet_menu_save_menu(Efreet_Menu *menu, FILE *f, int indent) if (has_menu) { - ecore_list_first_goto(menu->entries); - while ((entry = ecore_list_next(menu->entries))) + EINA_LIST_FOREACH(menu->entries, l, entry) { if (entry->type == EFREET_MENU_ENTRY_MENU) efreet_menu_save_menu(entry, f, indent + 1); @@ -859,18 +853,12 @@ efreet_menu_desktop_insert(Efreet_Menu *menu, Efreet_Desktop *desktop, int pos) efreet_desktop_ref(desktop); entry->desktop = desktop; - if (!menu->entries) - { - menu->entries = ecore_list_new(); - ecore_list_free_cb_set(menu->entries, ECORE_FREE_CB(efreet_menu_free)); - } - - if (pos < 0 || pos >= ecore_list_count(menu->entries)) - ecore_list_append(menu->entries, entry); + if (pos < 0 || pos >= eina_list_count(menu->entries)) + menu->entries = eina_list_append(menu->entries, entry); else { - ecore_list_index_goto(menu->entries, pos); - ecore_list_insert(menu->entries, entry); + menu->entries = eina_list_append_relative(menu->entries, entry, + eina_list_nth(menu->entries, pos)); } return 1; } @@ -889,12 +877,12 @@ efreet_menu_desktop_remove(Efreet_Menu *menu, Efreet_Desktop *desktop) if (!desktop || !menu) return 0; - entry = ecore_list_find(menu->entries, - ECORE_COMPARE_CB(efreet_menu_cb_entry_compare_desktop), + entry = eina_list_search_unsorted(menu->entries, + (Eina_Compare_Cb)efreet_menu_cb_entry_compare_desktop, desktop); if (entry) { - ecore_list_remove(menu->entries); + menu->entries = eina_list_remove(menu->entries, entry); efreet_menu_free(entry); return 1; } @@ -911,6 +899,8 @@ efreet_menu_desktop_remove(Efreet_Menu *menu, Efreet_Desktop *desktop) EAPI void efreet_menu_dump(Efreet_Menu *menu, const char *indent) { + Eina_List *l; + printf("%s%s: ", indent, menu->name); printf("%s\n", (menu->icon ? menu->icon : "No icon")); @@ -926,8 +916,7 @@ efreet_menu_dump(Efreet_Menu *menu, const char *indent) new_indent = malloc(sizeof(char *) * len); snprintf(new_indent, len, "%s ", indent); - ecore_list_first_goto(menu->entries); - while ((entry = ecore_list_next(menu->entries))) + EINA_LIST_FOREACH(menu->entries, l, entry) { if (entry->type == EFREET_MENU_ENTRY_SEPARATOR) printf("%s|---\n", new_indent); @@ -951,25 +940,22 @@ efreet_menu_dump(Efreet_Menu *menu, const char *indent) * @brief Creates the list of directories based on the user * dir, system dirs and given suffix. */ -Ecore_List * -efreet_default_dirs_get(const char *user_dir, Ecore_List *system_dirs, +Eina_List * +efreet_default_dirs_get(const char *user_dir, Eina_List *system_dirs, const char *suffix) { const char *xdg_dir; char dir[PATH_MAX]; - Ecore_List *list; - - list = ecore_list_new(); - ecore_list_free_cb_set(list, ECORE_FREE_CB(free)); + Eina_List *list = NULL; + Eina_List *l; snprintf(dir, sizeof(dir), "%s/%s", user_dir, suffix); - ecore_list_append(list, strdup(dir)); + list = eina_list_append(list, strdup(dir)); - ecore_list_first_goto(system_dirs); - while ((xdg_dir = ecore_list_next(system_dirs))) + EINA_LIST_FOREACH(system_dirs, l, xdg_dir) { snprintf(dir, sizeof(dir), "%s/%s", xdg_dir, suffix); - ecore_list_append(list, strdup(dir)); + list = eina_list_append(list, strdup(dir)); } return list; @@ -1109,15 +1095,16 @@ efreet_menu_handle_sub_menu(Efreet_Menu_Internal *parent, Efreet_Xml *xml) /* if this menu already exists we just take this one and stick it on the * start of the existing one */ - if ((match = ecore_list_find(parent->sub_menus, - ECORE_COMPARE_CB(efreet_menu_cb_menu_compare), internal))) + if ((match = eina_list_search_unsorted(parent->sub_menus, + (Eina_Compare_Cb)efreet_menu_cb_menu_compare, + internal))) { efreet_menu_concatenate(match, internal); efreet_menu_internal_free(internal); } else - ecore_list_prepend(parent->sub_menus, internal); + parent->sub_menus = eina_list_prepend(parent->sub_menus, internal); return 1; } @@ -1142,8 +1129,9 @@ efreet_menu_handle_app_dir(Efreet_Menu_Internal *parent, Efreet_Xml *xml) if (!path) return 0; /* we've already got this guy in our list we can skip it */ - if (ecore_list_find(parent->app_dirs, - ECORE_COMPARE_CB(efreet_menu_cb_app_dirs_compare), path)) + if (eina_list_search_unsorted(parent->app_dirs, + (Eina_Compare_Cb)efreet_menu_cb_app_dirs_compare, + path)) { FREE(path); return 1; @@ -1152,7 +1140,7 @@ efreet_menu_handle_app_dir(Efreet_Menu_Internal *parent, Efreet_Xml *xml) app_dir = efreet_menu_app_dir_new(); app_dir->path = path; - ecore_list_prepend(parent->app_dirs, app_dir); + parent->app_dirs = eina_list_prepend(parent->app_dirs, app_dir); return 1; } @@ -1167,7 +1155,8 @@ efreet_menu_handle_app_dir(Efreet_Menu_Internal *parent, Efreet_Xml *xml) static int efreet_menu_handle_default_app_dirs(Efreet_Menu_Internal *parent, Efreet_Xml *xml __UNUSED__) { - Ecore_List *dirs, *prepend; + Eina_List *prepend = NULL; + Eina_List *dirs; char *dir; if (!parent) return 0; @@ -1175,24 +1164,23 @@ efreet_menu_handle_default_app_dirs(Efreet_Menu_Internal *parent, Efreet_Xml *xm efreet_menu_create_app_dirs_list(parent); dirs = efreet_default_dirs_get(efreet_data_home_get(), efreet_data_dirs_get(), "applications"); - prepend = ecore_list_new(); - ecore_list_first_goto(dirs); - while ((dir = ecore_list_next(dirs))) + EINA_LIST_FREE(dirs, dir) { Efreet_Menu_App_Dir *app_dir; - if (ecore_list_find(parent->app_dirs, - ECORE_COMPARE_CB(efreet_menu_cb_app_dirs_compare), dir)) + if (eina_list_search_unsorted(parent->app_dirs, + (Eina_Compare_Cb)efreet_menu_cb_app_dirs_compare, + dir)) continue; app_dir = efreet_menu_app_dir_new(); app_dir->path = strdup(dir); - ecore_list_append(prepend, app_dir); + prepend = eina_list_append(prepend, app_dir); + + free(dir); } - ecore_list_destroy(dirs); - ecore_list_prepend_list(parent->app_dirs, prepend); - ecore_list_destroy(prepend); + parent->app_dirs = eina_list_merge(prepend, parent->app_dirs); return 1; } @@ -1237,7 +1225,7 @@ efreet_menu_handle_directory_dir(Efreet_Menu_Internal *parent, Efreet_Xml *xml) static int efreet_menu_handle_default_directory_dirs(Efreet_Menu_Internal *parent, Efreet_Xml *xml __UNUSED__) { - Ecore_List *dirs; + Eina_List *dirs, *l; char *dir; if (!parent) return 0; @@ -1245,8 +1233,7 @@ efreet_menu_handle_default_directory_dirs(Efreet_Menu_Internal *parent, Efreet_X efreet_menu_create_directory_dirs_list(parent); dirs = efreet_default_dirs_get(efreet_data_home_get(), efreet_data_dirs_get(), "desktop-directories"); - ecore_list_first_goto(dirs); - while ((dir = ecore_list_next(dirs))) + EINA_LIST_FOREACH(dirs, l, dir) { if (ecore_list_find(parent->directory_dirs, ECORE_COMPARE_CB(strcmp), dir)) continue; @@ -1254,7 +1241,11 @@ efreet_menu_handle_default_directory_dirs(Efreet_Menu_Internal *parent, Efreet_X ecore_dlist_prepend(parent->directory_dirs, strdup(dir)); } - ecore_list_destroy(dirs); + while (dirs) + { + free(eina_list_data_get(dirs)); + dirs = eina_list_remove_list(dirs, dirs); + } return 1; } @@ -1429,13 +1420,7 @@ efreet_menu_handle_filename(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml) { if (!op || !xml) return 0; - if (!op->filenames) - { - op->filenames = ecore_list_new(); - ecore_list_free_cb_set(op->filenames, free); - } - - ecore_list_append(op->filenames, strdup(xml->text)); + op->filenames = eina_list_append(op->filenames, strdup(xml->text)); return 1; } @@ -1452,13 +1437,8 @@ efreet_menu_handle_category(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml) { if (!op || !xml) return 0; - if (!op->categories) - { - op->categories = ecore_list_new(); - ecore_list_free_cb_set(op->categories, free); - } - ecore_list_append(op->categories, strdup(xml->text)); + op->categories = eina_list_append(op->categories, strdup(xml->text)); return 1; } @@ -1538,6 +1518,7 @@ efreet_menu_handle_not(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml) static int efreet_menu_handle_merge_file(Efreet_Menu_Internal *parent, Efreet_Xml *xml) { + Eina_List *l; char *path = NULL; const char *attr = NULL; int is_path = 1; @@ -1558,7 +1539,7 @@ efreet_menu_handle_merge_file(Efreet_Menu_Internal *parent, Efreet_Xml *xml) * dir after ours (if we're in a config dir) */ else { - Ecore_List *search_dirs; + Eina_List *search_dirs; const char *dir, *p; int len = 0; @@ -1578,12 +1559,11 @@ efreet_menu_handle_merge_file(Efreet_Menu_Internal *parent, Efreet_Xml *xml) * be left at the next pointer so we can start looking for the menu * from that point */ - ecore_list_first_goto(search_dirs); dir = efreet_config_home_get(); len = strlen(dir); if (strncmp(dir, parent->file.path, len)) { - while ((dir = ecore_list_next(search_dirs))) + EINA_LIST_FOREACH(search_dirs, l, dir) { if (!strncmp(dir, parent->file.path, len)) break; @@ -1603,7 +1583,7 @@ efreet_menu_handle_merge_file(Efreet_Menu_Internal *parent, Efreet_Xml *xml) /* whatever dirs are left in the search dir we need to look for the * menu with the same relative filename */ - while ((dir = ecore_list_next(search_dirs))) + EINA_LIST_FOREACH(search_dirs, l, dir) { char file[PATH_MAX]; @@ -1762,7 +1742,7 @@ efreet_menu_merge_dir(Efreet_Menu_Internal *parent, Efreet_Xml *xml, const char static int efreet_menu_handle_default_merge_dirs(Efreet_Menu_Internal *parent, Efreet_Xml *xml) { - Ecore_List *dirs; + Eina_List *dirs; char path[PATH_MAX], *p; const char *prefix; @@ -1790,13 +1770,13 @@ efreet_menu_handle_default_merge_dirs(Efreet_Menu_Internal *parent, Efreet_Xml * dirs = efreet_default_dirs_get(efreet_config_home_get(), efreet_config_dirs_get(), path); - ecore_list_first_goto(dirs); - while ((p = ecore_list_first_remove(dirs))) + + while ((p = eina_list_data_get(dirs))) { + dirs = eina_list_remove_list(dirs, dirs); efreet_menu_merge_dir(parent, xml, p); FREE(p); } - ecore_list_destroy(dirs); return 1; } @@ -1867,7 +1847,7 @@ efreet_menu_handle_legacy_dir_helper(Efreet_Menu_Internal *root, if (prefix && !strchr(prefix, '/')) app_dir->prefix = strdup(prefix); efreet_menu_create_app_dirs_list(legacy_internal); - ecore_list_append(legacy_internal->app_dirs, app_dir); + legacy_internal->app_dirs = eina_list_append(legacy_internal->app_dirs, app_dir); #ifndef STRICT_SPEC if (root) { @@ -1876,7 +1856,7 @@ efreet_menu_handle_legacy_dir_helper(Efreet_Menu_Internal *root, app_dir->path = strdup(path); app_dir->legacy = 1; if (prefix && !strchr(prefix, '/')) app_dir->prefix = strdup(prefix); - ecore_list_append(root->app_dirs, app_dir); + root->app_dirs = eina_list_append(root->app_dirs, app_dir); } #endif @@ -1890,11 +1870,9 @@ efreet_menu_handle_legacy_dir_helper(Efreet_Menu_Internal *root, filter->type = EFREET_MENU_FILTER_INCLUDE; filter->op->type = EFREET_MENU_FILTER_OP_OR; - filter->op->filenames = ecore_list_new(); - ecore_list_free_cb_set(filter->op->filenames, free); efreet_menu_create_filter_list(legacy_internal); - ecore_list_append(legacy_internal->filters, filter); + legacy_internal->filters = eina_list_append(legacy_internal->filters, filter); path_len = strlen(path); files = opendir(path); @@ -1926,7 +1904,7 @@ efreet_menu_handle_legacy_dir_helper(Efreet_Menu_Internal *root, } efreet_menu_create_sub_menu_list(legacy_internal); - ecore_list_prepend(legacy_internal->sub_menus, ret); + legacy_internal->sub_menus = eina_list_prepend(legacy_internal->sub_menus, ret); continue; } @@ -1960,10 +1938,10 @@ efreet_menu_handle_legacy_dir_helper(Efreet_Menu_Internal *root, if (prefix) { snprintf(buf, PATH_MAX, "%s%s", prefix, file->d_name); - ecore_list_append(filter->op->filenames, strdup(buf)); + filter->op->filenames = eina_list_append(filter->op->filenames, strdup(buf)); } else - ecore_list_append(filter->op->filenames, strdup(file->d_name)); + filter->op->filenames = eina_list_append(filter->op->filenames, strdup(file->d_name)); count++; efreet_desktop_free(desktop); @@ -1984,6 +1962,7 @@ efreet_menu_handle_legacy_dir_helper(Efreet_Menu_Internal *root, static int efreet_menu_handle_kde_legacy_dirs(Efreet_Menu_Internal *parent, Efreet_Xml *xml __UNUSED__) { + Eina_List *l; const char *dir; if (!parent) return 0; @@ -1992,8 +1971,7 @@ efreet_menu_handle_kde_legacy_dirs(Efreet_Menu_Internal *parent, Efreet_Xml *xml /* XXX if one _helper() call succeeds, we return success. should this be flipped? * (return fail if on of them failed) */ - ecore_list_first_goto(efreet_menu_kde_legacy_dirs); - while ((dir = ecore_list_next(efreet_menu_kde_legacy_dirs))) + EINA_LIST_FOREACH(efreet_menu_kde_legacy_dirs, l, dir) { Efreet_Menu_Internal *kde; @@ -2073,16 +2051,21 @@ efreet_menu_handle_old(Efreet_Menu_Internal *parent, Efreet_Xml *xml) /* If we already moved this menu, remove the old move */ /* XXX This seems wrong, but it makes efreet pass the fdo tests */ #ifndef STRICT_SPEC - move = ecore_list_find(parent->moves, - ECORE_COMPARE_CB(efreet_menu_cb_move_compare), xml->text); - if (move) ecore_list_remove_destroy(parent->moves); + move = eina_list_search_unsorted(parent->moves, + (Eina_Compare_Cb)efreet_menu_cb_move_compare, + xml->text); + if (move) + { + efreet_menu_move_free(move); + parent->moves = eina_list_remove(parent->moves, move); + } #endif move = efreet_menu_move_new(); move->old_name = strdup(xml->text); parent->current_move = move; - ecore_list_append(parent->moves, move); + parent->moves = eina_list_append(parent->moves, move); return 1; } @@ -2243,8 +2226,8 @@ efreet_menu_handle_layout_menuname(Efreet_Menu_Internal *parent, Efreet_Xml *xml val = efreet_xml_attribute_get(xml, "inline_alias"); if (val) layout->inline_alias = !strcmp(val, "true"); - if (def) ecore_list_append(parent->default_layout, layout); - else ecore_list_append(parent->layout, layout); + if (def) parent->default_layout = eina_list_append(parent->default_layout, layout); + else parent->layout = eina_list_append(parent->layout, layout); return 1; } @@ -2267,8 +2250,8 @@ efreet_menu_handle_layout_filename(Efreet_Menu_Internal *parent, Efreet_Xml *xml layout->type = EFREET_MENU_LAYOUT_FILENAME; layout->name = strdup(xml->text); - if (def) ecore_list_append(parent->default_layout, layout); - else ecore_list_append(parent->layout, layout); + if (def) parent->default_layout = eina_list_append(parent->default_layout, layout); + else parent->layout = eina_list_append(parent->layout, layout); return 1; } @@ -2283,9 +2266,9 @@ efreet_menu_handle_layout_separator(Efreet_Menu_Internal *parent, Efreet_Xml *xm layout = efreet_menu_layout_new(); layout->type = EFREET_MENU_LAYOUT_SEPARATOR; if (def) - ecore_list_append(parent->default_layout, layout); + parent->default_layout = eina_list_append(parent->default_layout, layout); else - ecore_list_append(parent->layout, layout); + parent->layout = eina_list_append(parent->layout, layout); return 1; } @@ -2316,8 +2299,8 @@ efreet_menu_handle_layout_merge(Efreet_Menu_Internal *parent, Efreet_Xml *xml, i layout->type = EFREET_MENU_LAYOUT_MERGE; layout->name = strdup(attr); - if (def) ecore_list_append(parent->default_layout, layout); - else ecore_list_append(parent->layout, layout); + if (def) parent->default_layout = eina_list_append(parent->default_layout, layout); + else parent->layout = eina_list_append(parent->layout, layout); return 1; } @@ -2349,7 +2332,7 @@ efreet_menu_handle_filter(Efreet_Menu_Internal *parent, Efreet_Xml *xml, return 0; } - ecore_list_prepend(parent->filters, filter); + parent->filters = eina_list_prepend(parent->filters, filter); return 1; } @@ -2577,14 +2560,7 @@ efreet_menu_handle_filter_child_op(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml, return 0; } - if (!op->filters) - { - op->filters = ecore_list_new(); - ecore_list_free_cb_set(op->filters, - ECORE_FREE_CB(efreet_menu_filter_op_free)); - } - - ecore_list_append(op->filters, child_op); + op->filters = eina_list_append(op->filters, child_op); return 1; } @@ -2600,6 +2576,8 @@ efreet_menu_handle_filter_child_op(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml, static int efreet_menu_process(Efreet_Menu_Internal *internal, unsigned int only_unallocated) { + Eina_List *l; + /* a menu _MUST_ have a name */ if (!internal->name.internal || (internal->name.internal[0] == '\0')) return 0; @@ -2612,8 +2590,7 @@ efreet_menu_process(Efreet_Menu_Internal *internal, unsigned int only_unallocate { Efreet_Menu_Internal *sub_internal; - ecore_list_first_goto(internal->sub_menus); - while ((sub_internal = ecore_list_next(internal->sub_menus))) + EINA_LIST_FOREACH(internal->sub_menus, l, sub_internal) { sub_internal->parent = internal; efreet_menu_process(sub_internal, only_unallocated); @@ -2629,6 +2606,8 @@ efreet_menu_process(Efreet_Menu_Internal *internal, unsigned int only_unallocate static int efreet_menu_process_dirs(Efreet_Menu_Internal *internal) { + Eina_List *l; + /* Scan application directories for .desktop files */ if (!efreet_menu_app_dirs_process(internal)) return 0; @@ -2641,8 +2620,7 @@ efreet_menu_process_dirs(Efreet_Menu_Internal *internal) { Efreet_Menu_Internal *sub_internal; - ecore_list_first_goto(internal->sub_menus); - while ((sub_internal = ecore_list_next(internal->sub_menus))) + EINA_LIST_FOREACH(internal->sub_menus, l, sub_internal) { sub_internal->parent = internal; efreet_menu_process_dirs(sub_internal); @@ -2666,21 +2644,22 @@ static void efreet_menu_process_filters(Efreet_Menu_Internal *internal, unsigned int only_unallocated) { Efreet_Menu_Filter *filter; + Efreet_Menu_Desktop *md; + Eina_List *l, *ll; + int included = 0; /* nothing to do if we're checking the other option */ if (only_unallocated != internal->only_unallocated) return; - if (!internal->applications) internal->applications = ecore_list_new(); - else ecore_list_clear(internal->applications); + while (internal->applications) + internal->applications = eina_list_remove_list(internal->applications, + internal->applications); if (!internal->filters) return; - ecore_list_first_goto(internal->filters); - while ((filter = ecore_list_next(internal->filters))) + EINA_LIST_FOREACH(internal->filters, l, filter) { - Efreet_Menu_Desktop *md; - /* skip excludes until we get an include */ if (!included && (filter->type == EFREET_MENU_FILTER_EXCLUDE)) continue; @@ -2691,7 +2670,7 @@ efreet_menu_process_filters(Efreet_Menu_Internal *internal, unsigned int only_un Eina_Hash *matches; matches = eina_hash_string_superfast_new(NULL); - efreet_menu_process_app_pool(internal->app_pool, internal->applications, + internal->applications = efreet_menu_process_app_pool(internal->app_pool, internal->applications, matches, filter, internal->only_unallocated); if (internal->parent) { @@ -2699,7 +2678,7 @@ efreet_menu_process_filters(Efreet_Menu_Internal *internal, unsigned int only_un parent = internal->parent; do { - efreet_menu_process_app_pool(parent->app_pool, + internal->applications = efreet_menu_process_app_pool(parent->app_pool, internal->applications, matches, filter, internal->only_unallocated); } while ((parent = parent->parent)); @@ -2709,13 +2688,13 @@ efreet_menu_process_filters(Efreet_Menu_Internal *internal, unsigned int only_un else { /* check each item in our menu so far and see if it's excluded */ - ecore_list_first_goto(internal->applications); - while ((md = ecore_list_current(internal->applications))) + l = internal->applications; + while ((md = eina_list_data_get(l))) { + ll = eina_list_next(l); if (efreet_menu_filter_matches(filter->op, md)) - ecore_list_remove(internal->applications); - else - ecore_list_next(internal->applications); + internal->applications = eina_list_remove_list(internal->applications, l); + l = ll; } } } @@ -2726,7 +2705,7 @@ efreet_menu_process_filters(Efreet_Menu_Internal *internal, unsigned int only_un { int count; - count = ecore_list_count(internal->applications); + count = eina_list_count(internal->applications); if (count) { Ecore_Sheap *sheap; @@ -2734,21 +2713,20 @@ efreet_menu_process_filters(Efreet_Menu_Internal *internal, unsigned int only_un sheap = ecore_sheap_new( ECORE_COMPARE_CB(efreet_menu_cb_md_compare), count); - while ((md = ecore_list_first_remove(internal->applications))) + while ((md = eina_list_data_get(internal->applications))) + { + internal->applications = eina_list_remove_list(internal->applications, + internal->applications); ecore_sheap_insert(sheap, md); - + } while ((md = ecore_sheap_extract(sheap))) { if (md->desktop->no_display) continue; - ecore_list_append(internal->applications, md); + internal->applications = eina_list_append(internal->applications, md); } ecore_sheap_destroy(sheap); } - - /* Don't keep the list if it is empty */ - if (ecore_list_empty_is(internal->applications)) - IF_FREE_LIST(internal->applications); } } @@ -2765,28 +2743,29 @@ efreet_menu_process_filters(Efreet_Menu_Internal *internal, unsigned int only_un * in @a matches. If @a only_unallocated is set we'll only only at the * .desktop files that haven't been previoulsy matched */ -static -void efreet_menu_process_app_pool(Ecore_List *pool, Ecore_List *applications, +static Eina_List * +efreet_menu_process_app_pool(Eina_List *pool, Eina_List *applications, Eina_Hash *matches, Efreet_Menu_Filter *filter, unsigned int only_unallocated) { Efreet_Menu_Desktop *md; + Eina_List *l; - if (!pool) return; + if (!pool) return NULL; - ecore_list_first_goto(pool); - while ((md = ecore_list_next(pool))) + EINA_LIST_FOREACH(pool, l, md) { if (eina_hash_find(matches, md->id)) continue; if (only_unallocated && md->allocated) continue; if (efreet_menu_filter_matches(filter->op, md)) { - ecore_list_append(applications, md); + applications = eina_list_append(applications, md); eina_hash_add(matches, (void *)md->id, md); md->allocated = 1; } } + return applications; } /** @@ -2822,31 +2801,30 @@ static int efreet_menu_filter_or_matches(Efreet_Menu_Filter_Op *op, Efreet_Menu_Desktop *md) { Efreet_Menu_Filter_Op *child; + Eina_List *l; char *t; if (op->all) return 1; if (op->categories && md->desktop->categories) { - ecore_list_first_goto(op->categories); - while ((t = ecore_list_next(op->categories))) + EINA_LIST_FOREACH(op->categories, l, t) { - if (ecore_list_find(md->desktop->categories, ECORE_COMPARE_CB(strcmp), t)) + if (eina_list_search_unsorted(md->desktop->categories, + (Eina_Compare_Cb)strcmp, t)) return 1; } } if (op->filenames) { - ecore_list_first_goto(op->filenames); - while ((t = ecore_list_next(op->filenames))) + EINA_LIST_FOREACH(op->filenames, l, t) if (!strcmp(t, md->id)) return 1; } if (op->filters) { - ecore_list_first_goto(op->filters); - while ((child = ecore_list_next(op->filters))) + EINA_LIST_FOREACH(op->filters, l, child) { if (efreet_menu_filter_matches(child, md)) return 1; @@ -2867,25 +2845,25 @@ static int efreet_menu_filter_and_matches(Efreet_Menu_Filter_Op *op, Efreet_Menu_Desktop *md) { Efreet_Menu_Filter_Op *child; + Eina_List *l; char *t; if (op->categories) { - if ((ecore_list_count(op->categories) > 0) && !md->desktop->categories) + if ((eina_list_count(op->categories) > 0) && !md->desktop->categories) return 0; - ecore_list_first_goto(op->categories); - while ((t = ecore_list_next(op->categories))) + EINA_LIST_FOREACH(op->categories, l, t) { - if (!ecore_list_find(md->desktop->categories, ECORE_COMPARE_CB(strcmp), t)) + if (!eina_list_search_unsorted(md->desktop->categories, + (Eina_Compare_Cb)strcmp, t)) return 0; } } if (op->filenames) { - ecore_list_first_goto(op->filenames); - while ((t = ecore_list_next(op->filenames))) + EINA_LIST_FOREACH(op->filenames, l, t) { if (strcmp(t, md->id)) return 0; } @@ -2893,8 +2871,7 @@ efreet_menu_filter_and_matches(Efreet_Menu_Filter_Op *op, Efreet_Menu_Desktop *m if (op->filters) { - ecore_list_first_goto(op->filters); - while ((child = ecore_list_next(op->filters))) + EINA_LIST_FOREACH(op->filters, l, child) { if (!efreet_menu_filter_matches(child, md)) return 0; @@ -2915,6 +2892,7 @@ static int efreet_menu_filter_not_matches(Efreet_Menu_Filter_Op *op, Efreet_Menu_Desktop *md) { Efreet_Menu_Filter_Op *child; + Eina_List *l; char *t; /* !all means no desktops match */ @@ -2922,21 +2900,20 @@ efreet_menu_filter_not_matches(Efreet_Menu_Filter_Op *op, Efreet_Menu_Desktop *m if (op->categories) { - if ((ecore_list_count(op->categories) > 0) && !md->desktop->categories) + if ((eina_list_count(op->categories) > 0) && !md->desktop->categories) return 1; - ecore_list_first_goto(op->categories); - while ((t = ecore_list_next(op->categories))) + EINA_LIST_FOREACH(op->categories, l, t) { - if (ecore_list_find(md->desktop->categories, ECORE_COMPARE_CB(strcmp), t)) + if (eina_list_search_unsorted(md->desktop->categories, + (Eina_Compare_Cb)strcmp, t)) return 0; } } if (op->filenames) { - ecore_list_first_goto(op->filenames); - while ((t = ecore_list_next(op->filenames))) + EINA_LIST_FOREACH(op->filenames, l, t) { if (!strcmp(t, md->id)) return 0; } @@ -2944,8 +2921,7 @@ efreet_menu_filter_not_matches(Efreet_Menu_Filter_Op *op, Efreet_Menu_Desktop *m if (op->filters) { - ecore_list_first_goto(op->filters); - while ((child = ecore_list_next(op->filters))) + EINA_LIST_FOREACH(op->filters, l, child) { if (efreet_menu_filter_matches(child, md)) return 0; @@ -2997,7 +2973,8 @@ efreet_menu_concatenate(Efreet_Menu_Internal *dest, Efreet_Menu_Internal *src) if (src->app_dirs) { efreet_menu_create_app_dirs_list(dest); - ecore_list_prepend_list(dest->app_dirs, src->app_dirs); + dest->app_dirs = eina_list_merge(src->app_dirs, dest->app_dirs); + src->app_dirs = NULL; } if (src->directory_dirs) @@ -3009,32 +2986,36 @@ efreet_menu_concatenate(Efreet_Menu_Internal *dest, Efreet_Menu_Internal *src) if (src->moves) { efreet_menu_create_move_list(dest); - ecore_list_prepend_list(dest->moves, src->moves); + dest->moves = eina_list_merge(src->moves, dest->moves); + src->moves = NULL; } if (src->filters) { efreet_menu_create_filter_list(dest); - ecore_list_prepend_list(dest->filters, src->filters); + dest->filters = eina_list_merge(src->filters, dest->filters); + src->filters = NULL; } if (src->sub_menus) { efreet_menu_create_sub_menu_list(dest); - while ((submenu = ecore_list_last_remove(src->sub_menus))) + while ((submenu = eina_list_data_get(eina_list_last(src->sub_menus)))) { Efreet_Menu_Internal *match; + src->sub_menus = eina_list_remove(src->sub_menus, submenu); /* if this menu is in the list already we just add to that */ - if ((match = ecore_list_find(dest->sub_menus, - ECORE_COMPARE_CB(efreet_menu_cb_menu_compare), submenu))) + if ((match = eina_list_search_unsorted(dest->sub_menus, + (Eina_Compare_Cb)efreet_menu_cb_menu_compare, + submenu))) { efreet_menu_concatenate(match, submenu); efreet_menu_internal_free(submenu); } else - ecore_list_prepend(dest->sub_menus, submenu); + dest->sub_menus = eina_list_prepend(dest->sub_menus, submenu); } } } @@ -3050,20 +3031,19 @@ efreet_menu_resolve_moves(Efreet_Menu_Internal *internal) { Efreet_Menu_Internal *child; Efreet_Menu_Move *move; + Eina_List *l; /* child moves are handled before parent moves */ if (internal->sub_menus) { - ecore_list_first_goto(internal->sub_menus); - while ((child = ecore_list_next(internal->sub_menus))) + EINA_LIST_FOREACH(internal->sub_menus, l, child) efreet_menu_resolve_moves(child); } /* nothing to do if this menu has no moves */ if (!internal->moves) return; - ecore_list_first_goto(internal->moves); - while ((move = ecore_list_next(internal->moves))) + EINA_LIST_FOREACH(internal->moves, l, move) { Efreet_Menu_Internal *origin, *dest, *parent; @@ -3072,7 +3052,7 @@ efreet_menu_resolve_moves(Efreet_Menu_Internal *internal) if (!origin) continue; /* remove the origin menu from the parent */ - ecore_list_remove(parent->sub_menus); + parent->sub_menus = eina_list_remove(parent->sub_menus, origin); /* if the destination path doesn't exist we just rename the origin * menu and append to the parents list of children */ @@ -3096,7 +3076,7 @@ efreet_menu_resolve_moves(Efreet_Menu_Internal *internal) ancestor->name.internal = eina_stringshare_add(tmp); efreet_menu_create_sub_menu_list(parent); - ecore_list_append(parent->sub_menus, ancestor); + parent->sub_menus = eina_list_append(parent->sub_menus, ancestor); parent = ancestor; tmp = ++path; @@ -3107,7 +3087,7 @@ efreet_menu_resolve_moves(Efreet_Menu_Internal *internal) origin->name.internal = eina_stringshare_add(tmp); efreet_menu_create_sub_menu_list(parent); - ecore_list_append(parent->sub_menus, origin); + parent->sub_menus = eina_list_append(parent->sub_menus, origin); FREE(t); } @@ -3144,14 +3124,14 @@ efreet_menu_by_name_find(Efreet_Menu_Internal *internal, const char *name, Efree { *part = '\0'; - if (!ecore_list_find(internal->sub_menus, - ECORE_COMPARE_CB(efreet_menu_cb_compare_names), ptr)) + if (!(internal = eina_list_search_unsorted(internal->sub_menus, + (Eina_Compare_Cb)efreet_menu_cb_compare_names, + ptr))) { FREE(tmp); return NULL; } - internal = ecore_list_current(internal->sub_menus); ptr = ++part; part = strchr(ptr, '/'); } @@ -3159,15 +3139,16 @@ efreet_menu_by_name_find(Efreet_Menu_Internal *internal, const char *name, Efree if (parent) *parent = internal; /* find the menu in the parent list */ - if (!ecore_list_find(internal->sub_menus, - ECORE_COMPARE_CB(efreet_menu_cb_compare_names), ptr)) + if (!(internal = eina_list_search_unsorted(internal->sub_menus, + (Eina_Compare_Cb)efreet_menu_cb_compare_names, + ptr))) { FREE(tmp); return NULL; } FREE(tmp); - return ecore_list_current(internal->sub_menus); + return internal; } static void @@ -3270,9 +3251,7 @@ efreet_menu_create_sub_menu_list(Efreet_Menu_Internal *internal) { if (!internal || internal->sub_menus) return; - internal->sub_menus = ecore_list_new(); - ecore_list_free_cb_set(internal->sub_menus, - ECORE_FREE_CB(efreet_menu_internal_free)); + internal->sub_menus = NULL; } static void @@ -3280,9 +3259,7 @@ efreet_menu_create_app_dirs_list(Efreet_Menu_Internal *internal) { if (!internal || internal->app_dirs) return; - internal->app_dirs = ecore_list_new(); - ecore_list_free_cb_set(internal->app_dirs, - ECORE_FREE_CB(efreet_menu_app_dir_free)); + internal->app_dirs = NULL; } static void @@ -3291,7 +3268,6 @@ efreet_menu_create_directory_dirs_list(Efreet_Menu_Internal *internal) if (!internal || internal->directory_dirs) return; internal->directory_dirs = ecore_dlist_new(); - ecore_list_free_cb_set(internal->directory_dirs, ECORE_FREE_CB(free)); } static void @@ -3299,8 +3275,7 @@ efreet_menu_create_move_list(Efreet_Menu_Internal *internal) { if (!internal || internal->moves) return; - internal->moves = ecore_list_new(); - ecore_list_free_cb_set(internal->moves, ECORE_FREE_CB(efreet_menu_move_free)); + internal->moves = NULL; } static void @@ -3308,9 +3283,7 @@ efreet_menu_create_filter_list(Efreet_Menu_Internal *internal) { if (!internal || internal->filters) return; - internal->filters = ecore_list_new(); - ecore_list_free_cb_set(internal->filters, - ECORE_FREE_CB(efreet_menu_filter_free)); + internal->filters = NULL; } static void @@ -3318,9 +3291,7 @@ efreet_menu_create_layout_list(Efreet_Menu_Internal *internal) { if (!internal || internal->layout) return; - internal->layout = ecore_list_new(); - ecore_list_free_cb_set(internal->layout, - ECORE_FREE_CB(efreet_menu_layout_free)); + internal->layout = NULL; } static void @@ -3328,9 +3299,7 @@ efreet_menu_create_default_layout_list(Efreet_Menu_Internal *internal) { if (!internal || internal->default_layout) return; - internal->default_layout = ecore_list_new(); - ecore_list_free_cb_set(internal->default_layout, - ECORE_FREE_CB(efreet_menu_layout_free)); + internal->default_layout = NULL; } static void @@ -3339,7 +3308,6 @@ efreet_menu_create_directories_list(Efreet_Menu_Internal *internal) if (!internal || internal->directories) return; internal->directories = ecore_dlist_new(); - ecore_list_free_cb_set(internal->directories, free); } static char * @@ -3378,22 +3346,15 @@ static int efreet_menu_app_dirs_process(Efreet_Menu_Internal *internal) { Efreet_Menu_App_Dir *app_dir; + Efreet_Menu_Desktop *md; + Eina_List *l; - if (internal->app_pool) - { - ecore_list_destroy(internal->app_pool); - internal->app_pool = NULL; - } + EINA_LIST_FREE(internal->app_pool, md) + efreet_menu_desktop_free(md); - if (internal->app_dirs) - { - internal->app_pool = ecore_list_new(); - ecore_list_free_cb_set(internal->app_pool, ECORE_FREE_CB(efreet_menu_desktop_free)); - - ecore_list_first_goto(internal->app_dirs); - while ((app_dir = ecore_list_next(internal->app_dirs))) + EINA_LIST_FOREACH(internal->app_dirs, l, app_dir) efreet_menu_app_dir_scan(internal, app_dir->path, app_dir->prefix, app_dir->legacy); - } + return 1; } @@ -3437,13 +3398,15 @@ efreet_menu_app_dir_scan(Efreet_Menu_Internal *internal, const char *path, const continue; } /* Don't add two files with the same id in the app pool */ - if (ecore_list_find(internal->app_pool, - ECORE_COMPARE_CB(efreet_menu_cb_md_compare_ids), buf2)) continue; + if (eina_list_search_unsorted(internal->app_pool, + (Eina_Compare_Cb)efreet_menu_cb_md_compare_ids, + buf2)) + continue; menu_desktop = efreet_menu_desktop_new(); menu_desktop->desktop = desktop; menu_desktop->id = eina_stringshare_add(buf2); - ecore_list_prepend(internal->app_pool, menu_desktop); + internal->app_pool = eina_list_prepend(internal->app_pool, menu_desktop); } } closedir(files); @@ -3601,7 +3564,8 @@ static Efreet_Menu * efreet_menu_layout_menu(Efreet_Menu_Internal *internal) { Efreet_Menu *entry; - Ecore_List *layout = NULL; + Eina_List *layout = NULL; + Eina_List *l; if (internal->parent) { @@ -3638,14 +3602,14 @@ efreet_menu_layout_menu(Efreet_Menu_Internal *internal) efreet_desktop_ref(internal->directory); entry->desktop = internal->directory; } - entry->entries = ecore_list_new(); - ecore_list_free_cb_set(entry->entries, ECORE_FREE_CB(efreet_menu_free)); + entry->entries = NULL; #if 1 //STRICT_SPEC if (internal->sub_menus) { - ecore_list_sort(internal->sub_menus, - ECORE_COMPARE_CB(efreet_menu_cb_menu_compare), ECORE_SORT_MIN); + internal->sub_menus = eina_list_sort(internal->sub_menus, + 0, + (Eina_Compare_Cb)efreet_menu_cb_menu_compare); } #endif @@ -3653,8 +3617,7 @@ efreet_menu_layout_menu(Efreet_Menu_Internal *internal) { Efreet_Menu_Layout *lay; - ecore_list_first_goto(layout); - while ((lay = ecore_list_next(layout))) + EINA_LIST_FOREACH(layout, l, lay) efreet_menu_layout_entries_get(entry, internal, lay); } else @@ -3664,8 +3627,7 @@ efreet_menu_layout_menu(Efreet_Menu_Internal *internal) { Efreet_Menu_Internal *sub; - ecore_list_first_goto(internal->sub_menus); - while ((sub = ecore_list_next(internal->sub_menus))) + EINA_LIST_FOREACH(internal->sub_menus, l, sub) { Efreet_Menu *sub_entry; if ((sub->directory && sub->directory->no_display) || sub->deleted) continue; @@ -3676,7 +3638,7 @@ efreet_menu_layout_menu(Efreet_Menu_Internal *internal) efreet_menu_free(sub_entry); continue; } - ecore_list_append(entry->entries, sub_entry); + entry->entries = eina_list_append(entry->entries, sub_entry); } } @@ -3684,18 +3646,16 @@ efreet_menu_layout_menu(Efreet_Menu_Internal *internal) { Efreet_Menu_Desktop *md; - ecore_list_first_goto(internal->applications); - while ((md = ecore_list_next(internal->applications))) + EINA_LIST_FOREACH(internal->applications, l, md) { Efreet_Menu *sub_entry; sub_entry = efreet_menu_layout_desktop(md); - ecore_list_append(entry->entries, sub_entry); + entry->entries = eina_list_append(entry->entries, sub_entry); } } } /* Don't keep this list around if it is empty */ - if (ecore_list_empty_is(entry->entries)) IF_FREE_LIST(entry->entries); return entry; } @@ -3745,8 +3705,8 @@ efreet_menu_layout_entries_get(Efreet_Menu *entry, Efreet_Menu_Internal *interna if (layout->inline_alias == -1) inline_alias = internal->inline_alias; else inline_alias = layout->inline_alias; - sub = ecore_list_find(internal->sub_menus, - ECORE_COMPARE_CB(efreet_menu_cb_compare_names), layout->name); + sub = eina_list_search_unsorted(internal->sub_menus, + (Eina_Compare_Cb)efreet_menu_cb_compare_names, layout->name); if (sub) { if (!(sub->directory && sub->directory->no_display) && !sub->deleted) @@ -3756,26 +3716,27 @@ efreet_menu_layout_entries_get(Efreet_Menu *entry, Efreet_Menu_Internal *interna efreet_menu_free(sub_entry); else if (in_line && ((inline_limit == 0) || - (!sub_entry->entries || (ecore_list_count(sub_entry->entries) <= inline_limit)))) + (!sub_entry->entries || (eina_list_count(sub_entry->entries) <= inline_limit)))) { /* Inline */ if (!sub_entry->entries) { /* Can't inline an empty submenu */ - ecore_list_append(entry->entries, sub_entry); + entry->entries = eina_list_append(entry->entries, sub_entry); } - else if (inline_alias && (ecore_list_count(sub_entry->entries) == 1)) + else if (inline_alias && (eina_list_count(sub_entry->entries) == 1)) { Efreet_Menu *tmp; - tmp = ecore_list_first_remove(sub_entry->entries); + tmp = eina_list_data_get(sub_entry->entries); + sub_entry->entries = eina_list_remove_list(sub_entry->entries, sub_entry->entries); IF_RELEASE(tmp->name); tmp->name = sub_entry->name; sub_entry->name = NULL; IF_RELEASE(tmp->icon); tmp->icon = sub_entry->icon; sub_entry->icon = NULL; - ecore_list_append(entry->entries, tmp); + entry->entries = eina_list_append(entry->entries, tmp); efreet_menu_free(sub_entry); } else @@ -3790,34 +3751,34 @@ efreet_menu_layout_entries_get(Efreet_Menu *entry, Efreet_Menu_Internal *interna sub_entry->name = NULL; tmp->icon = sub_entry->icon; sub_entry->icon = NULL; - ecore_list_append(entry->entries, tmp); + entry->entries = eina_list_append(entry->entries, tmp); + } + while ((tmp = eina_list_data_get(sub_entry->entries))) + { + sub_entry->entries = eina_list_remove_list(sub_entry->entries, sub_entry->entries); + entry->entries = eina_list_append(entry->entries, tmp); } - ecore_list_first_goto(sub_entry->entries); - while ((tmp = ecore_list_first_remove(sub_entry->entries))) - ecore_list_append(entry->entries, tmp); efreet_menu_free(sub_entry); } } else - ecore_list_append(entry->entries, sub_entry); + entry->entries = eina_list_append(entry->entries, sub_entry); } - ecore_list_remove(internal->sub_menus); + internal->sub_menus = eina_list_remove(internal->sub_menus, sub); efreet_menu_internal_free(sub); } - if (ecore_list_empty_is(internal->sub_menus)) IF_FREE_LIST(internal->sub_menus); } else if (internal->applications && layout->type == EFREET_MENU_LAYOUT_FILENAME) { Efreet_Menu_Desktop *md; - md = ecore_list_find(internal->applications, - ECORE_COMPARE_CB(efreet_menu_cb_md_compare_ids), layout->name); + md = eina_list_search_unsorted(internal->applications, + (Eina_Compare_Cb)efreet_menu_cb_md_compare_ids, layout->name); if (md) { sub_entry = efreet_menu_layout_desktop(md); - ecore_list_append(entry->entries, sub_entry); - ecore_list_remove(internal->applications); + entry->entries = eina_list_append(entry->entries, sub_entry); + internal->applications = eina_list_remove(internal->applications, md); } - if (ecore_list_empty_is(internal->applications)) IF_FREE_LIST(internal->applications); } else if (layout->type == EFREET_MENU_LAYOUT_MERGE) { @@ -3825,15 +3786,17 @@ efreet_menu_layout_entries_get(Efreet_Menu *entry, Efreet_Menu_Internal *interna { Efreet_Menu_Desktop *md; - ecore_list_first_goto(internal->applications); - while ((md = ecore_list_first_remove(internal->applications))) + while ((md = eina_list_data_get(internal->applications))) { - sub_entry = ecore_list_find(entry->entries, - ECORE_COMPARE_CB(efreet_menu_cb_entry_compare_desktop), md->desktop); + internal->applications = eina_list_remove_list(internal->applications, + internal->applications); + sub_entry = eina_list_search_unsorted(entry->entries, + (Eina_Compare_Cb)efreet_menu_cb_entry_compare_desktop, + md->desktop); if (!sub_entry) { sub_entry = efreet_menu_layout_desktop(md); - ecore_list_append(entry->entries, sub_entry); + entry->entries = eina_list_append(entry->entries, sub_entry); } } IF_FREE_LIST(internal->applications); @@ -3842,16 +3805,17 @@ efreet_menu_layout_entries_get(Efreet_Menu *entry, Efreet_Menu_Internal *interna { Efreet_Menu_Internal *sub; - ecore_list_first_goto(internal->sub_menus); - while ((sub = ecore_list_first_remove(internal->sub_menus))) + while ((sub = eina_list_data_get(internal->sub_menus))) { + internal->sub_menus = eina_list_remove_list(internal->sub_menus, internal->sub_menus); if ((sub->directory && sub->directory->no_display) || sub->deleted) { efreet_menu_internal_free(sub); continue; } - sub_entry = ecore_list_find(entry->entries, - ECORE_COMPARE_CB(efreet_menu_cb_entry_compare_menu), sub); + sub_entry = eina_list_search_unsorted(entry->entries, + (Eina_Compare_Cb)efreet_menu_cb_entry_compare_menu, + sub); if (!sub_entry) { sub_entry = efreet_menu_layout_menu(sub); @@ -3859,19 +3823,20 @@ efreet_menu_layout_entries_get(Efreet_Menu *entry, Efreet_Menu_Internal *interna efreet_menu_free(sub_entry); else if (internal->in_line && ((internal->inline_limit == 0) || - (!sub_entry->entries || (ecore_list_count(sub_entry->entries) <= internal->inline_limit)))) + (!sub_entry->entries || (eina_list_count(sub_entry->entries) <= internal->inline_limit)))) { /* Inline */ if (!sub_entry->entries) { /* Can't inline an empty submenu */ - ecore_list_append(entry->entries, sub_entry); + entry->entries = eina_list_append(entry->entries, sub_entry); } - else if (internal->inline_alias && (ecore_list_count(sub_entry->entries) == 1)) + else if (internal->inline_alias && (eina_list_count(sub_entry->entries) == 1)) { Efreet_Menu *tmp; - tmp = ecore_list_first_remove(sub_entry->entries); + tmp = eina_list_data_get(sub_entry->entries); + sub_entry->entries = eina_list_remove_list(sub_entry->entries, sub_entry->entries); eina_stringshare_del(tmp->name); tmp->name = sub_entry->name; sub_entry->name = NULL; @@ -3881,7 +3846,7 @@ efreet_menu_layout_entries_get(Efreet_Menu *entry, Efreet_Menu_Internal *interna tmp->icon = sub_entry->icon; sub_entry->icon = NULL; } - ecore_list_append(entry->entries, tmp); + entry->entries = eina_list_append(entry->entries, tmp); efreet_menu_free(sub_entry); } else @@ -3896,16 +3861,19 @@ efreet_menu_layout_entries_get(Efreet_Menu *entry, Efreet_Menu_Internal *interna sub_entry->name = NULL; if (sub_entry->icon) tmp->icon = sub_entry->icon; sub_entry->icon = NULL; - ecore_list_append(entry->entries, tmp); + entry->entries = eina_list_append(entry->entries, tmp); + } + while ((tmp = eina_list_data_get(sub_entry->entries))) + { + sub_entry->entries = eina_list_remove_list(sub_entry->entries, + sub_entry->entries); + entry->entries = eina_list_append(entry->entries, tmp); } - ecore_list_first_goto(sub_entry->entries); - while ((tmp = ecore_list_first_remove(sub_entry->entries))) - ecore_list_append(entry->entries, tmp); efreet_menu_free(sub_entry); } } else - ecore_list_append(entry->entries, sub_entry); + entry->entries = eina_list_append(entry->entries, sub_entry); } efreet_menu_internal_free(sub); } @@ -3927,7 +3895,7 @@ efreet_menu_layout_entries_get(Efreet_Menu *entry, Efreet_Menu_Internal *interna { sub_entry = efreet_menu_entry_new(); sub_entry->type = EFREET_MENU_ENTRY_SEPARATOR; - ecore_list_append(entry->entries, sub_entry); + entry->entries = eina_list_append(entry->entries, sub_entry); } } @@ -3955,11 +3923,11 @@ static int efreet_menu_layout_is_empty(Efreet_Menu *entry) { Efreet_Menu *sub_entry; + Eina_List *l; if (!entry->entries) return 1; - ecore_list_first_goto(entry->entries); - while ((sub_entry = ecore_list_next(entry->entries))) + EINA_LIST_FOREACH(entry->entries, l, sub_entry) { if (sub_entry->type == EFREET_MENU_ENTRY_MENU) return 0; if (sub_entry->type == EFREET_MENU_ENTRY_DESKTOP) return 0; diff --git a/legacy/efreet/src/lib/efreet_menu.h b/legacy/efreet/src/lib/efreet_menu.h index e9537876f7..a6643d3d26 100644 --- a/legacy/efreet/src/lib/efreet_menu.h +++ b/legacy/efreet/src/lib/efreet_menu.h @@ -46,7 +46,7 @@ struct Efreet_Menu const char *icon; /**< Icon for this entry */ Efreet_Desktop *desktop; /**< The desktop we refer too */ - Ecore_List *entries; /**< The menu items */ + Eina_List *entries; /**< The menu items */ }; EAPI int efreet_menu_kde_legacy_init(void); diff --git a/legacy/efreet/src/lib/efreet_mime.c b/legacy/efreet/src/lib/efreet_mime.c index 10291ffbd5..415b171523 100644 --- a/legacy/efreet/src/lib/efreet_mime.c +++ b/legacy/efreet/src/lib/efreet_mime.c @@ -7,8 +7,8 @@ #include #include -static Ecore_List *globs = NULL; /* contains Efreet_Mime_Glob structs */ -static Ecore_List *magics = NULL; /* contains Efreet_Mime_Magic structs */ +static Eina_List *globs = NULL; /* contains Efreet_Mime_Glob structs */ +static Eina_List *magics = NULL; /* contains Efreet_Mime_Magic structs */ static Eina_Hash *wild = NULL; /* contains *.ext and mime.types globs*/ static Eina_Hash *monitors = NULL; /* contains file monitors */ @@ -50,7 +50,7 @@ struct Efreet_Mime_Magic { unsigned int priority; const char *mime; - Ecore_List *entries; + Eina_List *entries; }; /** @@ -175,7 +175,8 @@ EAPI char * efreet_mime_type_icon_get(const char *mime, const char *theme, unsigned int size) { char *icon = NULL; - Ecore_List *icons = NULL; + char *data; + Eina_List *icons = NULL; const char *env = NULL; char *p = NULL, *pp = NULL, *ppp = NULL; char buf[PATH_MAX]; @@ -183,9 +184,6 @@ efreet_mime_type_icon_get(const char *mime, const char *theme, unsigned int size if (!mime || !theme || !size) return NULL; - icons = ecore_list_new(); - ecore_list_free_cb_set(icons, free); - /* Standard icon name */ p = strdup(mime); pp = p; @@ -194,21 +192,21 @@ efreet_mime_type_icon_get(const char *mime, const char *theme, unsigned int size if (*pp == '/') *pp = '-'; pp++; } - ecore_list_append(icons, p); + icons = eina_list_append(icons, p); /* Environment Based icon names */ if ((env = efreet_desktop_environment_get())) { snprintf(buf, sizeof(buf), "%s-mime-%s", env, p); - ecore_list_append(icons, strdup(buf)); + icons = eina_list_append(icons, strdup(buf)); snprintf(buf, sizeof(buf), "%s-%s", env, p); - ecore_list_append(icons, strdup(buf)); + icons = eina_list_append(icons, strdup(buf)); } /* Mime prefixed icon names */ snprintf(buf, sizeof(buf), "mime-%s", p); - ecore_list_append(icons, strdup(buf)); + icons = eina_list_append(icons, strdup(buf)); /* Generic icons */ pp = strdup(p); @@ -217,16 +215,21 @@ efreet_mime_type_icon_get(const char *mime, const char *theme, unsigned int size *ppp = '\0'; snprintf(buf, sizeof(buf), "%s-generic", pp); - ecore_list_append(icons, strdup(buf)); + icons = eina_list_append(icons, strdup(buf)); snprintf(buf, sizeof(buf), "%s", pp); - ecore_list_append(icons, strdup(buf)); + icons = eina_list_append(icons, strdup(buf)); } FREE(pp); /* Search for icons using list */ icon = efreet_icon_list_find(theme, icons, size); - ecore_list_destroy(icons); + while (icons) + { + data = eina_list_data_get(icons); + free(data); + icons = eina_list_remove_list(icons, icons); + } return icon; } @@ -250,6 +253,7 @@ efreet_mime_magic_type_get(const char *file) EAPI const char * efreet_mime_globs_type_get(const char *file) { + Eina_List *l; Efreet_Mime_Glob *g; char *sl, *p; const char *s; @@ -272,8 +276,7 @@ efreet_mime_globs_type_get(const char *file) } /* Fallback to the other globs if not found */ - ecore_list_first_goto(globs); - while ((g = ecore_list_next(globs))) + EINA_LIST_FOREACH(globs, l, g) { if (efreet_mime_glob_match(file, g->glob)) return g->mime; @@ -282,8 +285,7 @@ efreet_mime_globs_type_get(const char *file) ext = alloca(strlen(file) + 1); for (s = file, p = ext; *s; s++, p++) *p = tolower(*s); *p = 0; - ecore_list_first_goto(globs); - while ((g = ecore_list_next(globs))) + EINA_LIST_FOREACH(globs, l, g) { if (efreet_mime_glob_case_match(ext, g->glob)) return g->mime; @@ -358,17 +360,19 @@ efreet_mime_monitor_add(const char *file) * Also reads the /etc/mime.types file. */ static void -efreet_mime_load_globs(Ecore_List *datadirs, const char *datahome) +efreet_mime_load_globs(Eina_List *datadirs, const char *datahome) { + Eina_List *l; char buf[4096]; const char *datadir = NULL; IF_FREE_HASH(wild); wild = eina_hash_string_superfast_new(EINA_FREE_CB(eina_stringshare_del)); - IF_FREE_LIST(globs); - globs = ecore_list_new(); - ecore_list_free_cb_set(globs, efreet_mime_glob_free); - + while (globs) + { + efreet_mime_glob_free(eina_list_data_get(globs)); + globs = eina_list_remove_list(globs, globs); + } /* * This is here for legacy reasons. It is mentioned briefly @@ -379,13 +383,13 @@ efreet_mime_load_globs(Ecore_List *datadirs, const char *datahome) efreet_mime_mime_types_load("/etc/mime.types"); datadir = datahome; - ecore_list_first_goto(datadirs); - while (datadir) - { snprintf(buf, sizeof(buf), "%s/mime/globs", datadir); efreet_mime_shared_mimeinfo_globs_load(buf); - datadir = ecore_list_next(datadirs); + EINA_LIST_FOREACH(datadirs, l, datadir) + { + snprintf(buf, sizeof(buf), "%s/mime/globs", datadir); + efreet_mime_shared_mimeinfo_globs_load(buf); } } @@ -397,23 +401,26 @@ efreet_mime_load_globs(Ecore_List *datadirs, const char *datahome) * @brief Read all magic files in XDG data/home dirs. */ static void -efreet_mime_load_magics(Ecore_List *datadirs, const char *datahome) +efreet_mime_load_magics(Eina_List *datadirs, const char *datahome) { + Eina_List *l; char buf[4096]; const char *datadir = NULL; - IF_FREE_LIST(magics); - magics = ecore_list_new(); - ecore_list_free_cb_set(magics, efreet_mime_magic_free); + while (magics) + { + efreet_mime_magic_free(eina_list_data_get(magics)); + magics = eina_list_remove_list(magics, magics); + } datadir = datahome; - ecore_list_first_goto(datadirs); - while (datadir) - { snprintf(buf, sizeof(buf), "%s/mime/magic", datadir); efreet_mime_shared_mimeinfo_magic_load(buf); - datadir = ecore_list_next(datadirs); + EINA_LIST_FOREACH(datadirs, l, datadir) + { + snprintf(buf, sizeof(buf), "%s/mime/magic", datadir); + efreet_mime_shared_mimeinfo_magic_load(buf); } } @@ -435,7 +442,7 @@ efreet_mime_cb_update_file(void *data __UNUSED__, Ecore_File_Event event __UNUSED__, const char *path) { - Ecore_List *datadirs = NULL; + Eina_List *datadirs = NULL; const char *datahome = NULL; if (!(datahome = efreet_data_home_get())) @@ -460,7 +467,8 @@ efreet_mime_cb_update_file(void *data __UNUSED__, static int efreet_mime_init_files(void) { - Ecore_List *datadirs = NULL; + Eina_List *l; + Eina_List *datadirs = NULL; char buf[PATH_MAX]; const char *datahome, *datadir = NULL; @@ -475,13 +483,13 @@ efreet_mime_init_files(void) * We watch the directories so we can watch for new files */ datadir = datahome; - ecore_list_first_goto(datadirs); - while (datadir) - { snprintf(buf, PATH_MAX, "%s/mime", datadir); efreet_mime_monitor_add(buf); - datadir = ecore_list_next(datadirs); + EINA_LIST_FOREACH(datadirs, l, datadir) + { + snprintf(buf, PATH_MAX, "%s/mime", datadir); + efreet_mime_monitor_add(buf); } efreet_mime_monitor_add("/etc/mime.types"); @@ -622,19 +630,14 @@ efreet_mime_glob_remove(const char *glob) { Efreet_Mime_Glob *mime = NULL; - mime = ecore_list_first_goto(globs); - while ((mime = ecore_list_current(globs))) - { - if (!strcmp(glob, mime->glob)) + if ((mime = eina_list_search_unsorted(globs, (Eina_Compare_Cb)strcmp, glob))) { - ecore_list_remove(globs); + globs = eina_list_remove(globs, mime); IF_RELEASE(mime->glob); IF_RELEASE(mime->mime); FREE(mime); return 1; } - ecore_list_next(globs); - } return 0; } @@ -763,7 +766,7 @@ efreet_mime_shared_mimeinfo_globs_load(const char *file) else { efreet_mime_glob_remove(ext); - ecore_list_append(globs, mime); + globs = eina_list_append(globs, mime); } } } @@ -882,10 +885,7 @@ efreet_mime_shared_mimeinfo_magic_parse(char *data, int size) char *val, buf[512]; mime = NEW(Efreet_Mime_Magic, 1); - mime->entries = ecore_list_new(); - ecore_list_free_cb_set(mime->entries, - efreet_mime_magic_entry_free); - ecore_list_append(magics, mime); + magics = eina_list_append(magics, mime); val = ++ptr; while ((*val != ':')) val++; @@ -926,7 +926,7 @@ efreet_mime_shared_mimeinfo_magic_parse(char *data, int size) entry->value = NULL; ptr++; - ecore_list_append(mime->entries, entry); + mime->entries = eina_list_append(mime->entries, entry); } switch(*ptr) @@ -1050,6 +1050,7 @@ efreet_mime_magic_check_priority(const char *file, { Efreet_Mime_Magic *m = NULL; Efreet_Mime_Magic_Entry *e = NULL; + Eina_List *l, *ll; FILE *f = NULL; unsigned int i = 0, offset = 0,level = 0, match = 0, bytes_read = 0; const char *last_mime = NULL; @@ -1058,7 +1059,7 @@ efreet_mime_magic_check_priority(const char *file, f = fopen(file, "rb"); if (!f) return NULL; - if (!(m = ecore_list_first_goto(magics))) + if (!magics) { fclose(f); return NULL; @@ -1070,7 +1071,7 @@ efreet_mime_magic_check_priority(const char *file, return NULL; } - while ((m = ecore_list_next(magics))) + EINA_LIST_FOREACH(magics, l, m) { if ((start != 0) && (m->priority > start)) continue; @@ -1078,8 +1079,7 @@ efreet_mime_magic_check_priority(const char *file, if (m->priority < end) break; - ecore_list_first_goto(m->entries); - while ((e = ecore_list_next(m->entries))) + EINA_LIST_FOREACH(m->entries, ll, e) { if ((level < e->indent) && !match) continue; @@ -1157,9 +1157,15 @@ static void efreet_mime_magic_free(void *data) { Efreet_Mime_Magic *m = data; + Efreet_Mime_Magic_Entry *entry = NULL; IF_RELEASE(m->mime); - IF_FREE_LIST(m->entries); + while (m->entries) + { + entry = eina_list_data_get(m->entries); + efreet_mime_magic_entry_free(entry); + m->entries = eina_list_remove_list(m->entries, m->entries); + } IF_FREE(m); } diff --git a/legacy/efreet/src/lib/efreet_private.h b/legacy/efreet/src/lib/efreet_private.h index 38d81da22e..8bcdde9c85 100644 --- a/legacy/efreet/src/lib/efreet_private.h +++ b/legacy/efreet/src/lib/efreet_private.h @@ -71,10 +71,7 @@ * If x is a valid pointer destroy x and set to NULL */ #define IF_FREE_LIST(x) do { \ - if (x) { \ - Ecore_List *__tmp; __tmp = (x); (x) = NULL; ecore_list_destroy(__tmp); \ - } \ - (x) = NULL; \ + x = eina_list_free(x); \ } while (0) /** @@ -146,7 +143,7 @@ struct Efreet_Desktop_Command Efreet_Desktop_Progress_Cb cb_progress; void *data; - Ecore_List *files; /**< list of Efreet_Desktop_Command_File */ + Eina_List *files; /**< list of Efreet_Desktop_Command_File */ }; /** @@ -178,8 +175,8 @@ void efreet_icon_shutdown(void); int efreet_menu_init(void); void efreet_menu_shutdown(void); -Ecore_List *efreet_default_dirs_get(const char *user_dir, - Ecore_List *system_dirs, +Eina_List *efreet_default_dirs_get(const char *user_dir, + Eina_List *system_dirs, const char *suffix); int efreet_ini_init(void); diff --git a/legacy/efreet/src/lib/efreet_trash.c b/legacy/efreet/src/lib/efreet_trash.c index 60f83dff48..3fd279f2fb 100644 --- a/legacy/efreet/src/lib/efreet_trash.c +++ b/legacy/efreet/src/lib/efreet_trash.c @@ -178,12 +178,12 @@ efreet_trash_empty_trash(void) * when you don't need anymore) * @brief List all the files and directory currently inside the trash. */ -EAPI Ecore_List* +EAPI Eina_List* efreet_trash_ls(void) { char *infofile; char buf[PATH_MAX]; - Ecore_List *files; + Eina_List *files, *l; // NOTE THIS FUNCTION NOW IS NOT COMPLETE AS I DON'T NEED IT // TODO read the name from the infofile instead of the filename @@ -191,7 +191,7 @@ efreet_trash_ls(void) snprintf(buf, PATH_MAX, "%s/files", efreet_trash_dir_get()); files = ecore_file_ls(buf); - while ((infofile = ecore_list_next(files))) + EINA_LIST_FOREACH(files, l, infofile) printf("FILE: %s\n", infofile); return files; diff --git a/legacy/efreet/src/lib/efreet_utils.c b/legacy/efreet/src/lib/efreet_utils.c index de56146c94..92d33f1b83 100644 --- a/legacy/efreet/src/lib/efreet_utils.c +++ b/legacy/efreet/src/lib/efreet_utils.c @@ -11,7 +11,7 @@ typedef struct Efreet_Util_Desktop Efreet_Util_Desktop; struct Efreet_Cache_Fill { - Ecore_List *dirs; + Eina_List *dirs; Efreet_Cache_Fill_Dir *current; DIR *files; }; @@ -32,7 +32,7 @@ struct Efreet_Cache_Search struct Efreet_Cache_Search_List { - Ecore_List *list; + Eina_List *list; const char *what; }; @@ -74,7 +74,7 @@ static void efreet_util_monitor(const char *path, const char *file_id, int prior static void efreet_util_monitor_cb(void *data, Ecore_File_Monitor *monitor, Ecore_File_Event event, const char *path); static void efreet_util_monitor_free(void *data); -static void efreet_util_menus_find_helper(Ecore_List *menus, const char *config_dir); +static void efreet_util_menus_find_helper(Eina_List *menus, const char *config_dir); static void efreet_util_desktops_by_category_add(Efreet_Desktop *desktop); static void efreet_util_desktops_by_category_remove(Efreet_Desktop *desktop); @@ -89,7 +89,7 @@ static Eina_Hash *desktops_by_category = NULL; static Ecore_Idler *idler = NULL; static Efreet_Cache_Fill *fill = NULL; -static Ecore_List *monitors = NULL; +static Eina_List *monitors = NULL; static int init = 0; @@ -99,7 +99,7 @@ EAPI int EFREET_EVENT_DESKTOP_CHANGE = 0; EAPI int efreet_util_init(void) { - Ecore_List *dirs; + Eina_List *dirs; if (init++) return init; @@ -109,14 +109,11 @@ efreet_util_init(void) EFREET_EVENT_DESKTOP_CHANGE = ecore_event_type_new(); desktop_by_file_id = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_util_desktop_free)); file_id_by_desktop_path = eina_hash_string_superfast_new(EINA_FREE_CB(eina_stringshare_del)); - desktops_by_category = eina_hash_string_superfast_new(EINA_FREE_CB(ecore_list_destroy)); + desktops_by_category = eina_hash_string_superfast_new(EINA_FREE_CB(eina_list_free)); - monitors = ecore_list_new(); - ecore_list_free_cb_set(monitors, efreet_util_monitor_free); + monitors = NULL; fill = NEW(Efreet_Cache_Fill, 1); - fill->dirs = ecore_list_new(); - ecore_list_free_cb_set(fill->dirs, efreet_util_cache_dir_free); dirs = efreet_default_dirs_get(efreet_data_home_get(), efreet_data_dirs_get(), "applications"); if (dirs) @@ -125,14 +122,15 @@ efreet_util_init(void) char *path; int priority = 0; - while ((path = ecore_list_first_remove(dirs))) + while (dirs) { + path = eina_list_data_get(dirs); dir = NEW(Efreet_Cache_Fill_Dir, 1); dir->path = path; dir->priority = priority++; - ecore_list_append(fill->dirs, dir); + fill->dirs = eina_list_append(fill->dirs, dir); + dirs = eina_list_remove_list(dirs, dirs); } - ecore_list_destroy(dirs); } idler = ecore_idler_add(efreet_util_cache_fill, NULL); return init; @@ -141,12 +139,21 @@ efreet_util_init(void) EAPI int efreet_util_shutdown(void) { + Efreet_Monitor *em; + Efreet_Cache_Fill_Dir *dir; + if (--init) return init; if (idler) { ecore_idler_del(idler); - IF_FREE_LIST(fill->dirs); + while (fill->dirs) + { + dir = eina_list_data_get(fill->dirs); + efreet_util_cache_dir_free(dir); + fill->dirs = eina_list_remove_list(fill->dirs, fill->dirs); + } + if (fill->current) efreet_util_cache_dir_free(fill->current); if (fill->files) closedir(fill->files); free(fill); @@ -156,7 +163,12 @@ efreet_util_shutdown(void) IF_FREE_HASH(desktop_by_file_id); IF_FREE_HASH(file_id_by_desktop_path); - IF_FREE_LIST(monitors); + while (monitors) + { + em = eina_list_data_get(monitors); + efreet_util_monitor_free(em); + monitors = eina_list_remove_list(monitors, monitors); + } IF_FREE_HASH(desktops_by_category); @@ -166,27 +178,29 @@ efreet_util_shutdown(void) static char * efreet_util_path_in_default(const char *section, const char *path) { - Ecore_List *dirs; + Eina_List *dirs, *l; char *ret = NULL; char *dir; dirs = efreet_default_dirs_get(efreet_data_home_get(), efreet_data_dirs_get(), section); - ecore_list_first_goto(dirs); - while ((dir = ecore_list_next(dirs))) + EINA_LIST_FREE(dirs, dir) { size_t len; len = strlen(dir); if (!strncmp(path, dir, strlen(dir))) { - ret = strdup(dir); + ret = dir; break; } + free(dir); } - ecore_list_destroy(dirs); + EINA_LIST_FREE(dirs, dir) + if (ret != dir) free(dir); + return ret; } @@ -232,13 +246,13 @@ efreet_util_path_to_file_id(const char *path) return file_id; } -EAPI Ecore_List * +EAPI Eina_List * efreet_util_desktop_mime_list(const char *mime) { Efreet_Cache_Search_List search; Eina_Iterator *it; - search.list = ecore_list_new(); + search.list = NULL; search.what = eina_stringshare_add(mime); it = eina_hash_iterator_data_new(desktop_by_file_id); @@ -247,7 +261,6 @@ efreet_util_desktop_mime_list(const char *mime) eina_stringshare_del(search.what); - if (ecore_list_empty_is(search.list)) IF_FREE_LIST(search.list); return search.list; } @@ -268,7 +281,11 @@ efreet_util_desktop_wm_class_find(const char *wmname, const char *wmclass) eina_iterator_free(it); ud = search.result; - if (ud) return ud->desktop; + if (ud) + { + efreet_desktop_ref(ud->desktop); + return ud->desktop; + } return NULL; } @@ -277,7 +294,7 @@ efreet_util_desktop_file_id_find(const char *file_id) { Efreet_Desktop *desktop = NULL; Efreet_Util_Desktop *ud = NULL; - Ecore_List *dirs; + Eina_List *dirs, *l; const char *dir; int priority = 0; @@ -289,8 +306,7 @@ efreet_util_desktop_file_id_find(const char *file_id) "applications"); if (!dirs) return NULL; - ecore_list_first_goto(dirs); - while ((dir = ecore_list_next(dirs))) + EINA_LIST_FOREACH(dirs, l, dir) { char *tmp, *p; char buf[PATH_MAX]; @@ -310,7 +326,11 @@ efreet_util_desktop_file_id_find(const char *file_id) if (desktop) break; priority++; } - ecore_list_destroy(dirs); + while (dirs) + { + free(eina_list_data_get(dirs)); + dirs = eina_list_remove_list(dirs, dirs); + } if (desktop) { Efreet_Event_Desktop_Change *ev; @@ -347,8 +367,10 @@ efreet_util_desktop_exec_find(const char *exec) eina_iterator_foreach(it, EINA_EACH(efreet_util_cache_search_exec), &search); eina_iterator_free(it); - if (search.result) return search.result->desktop; - return NULL; + if (!search.result) return NULL; + + efreet_desktop_ref(search.result->desktop); + return search.result->desktop; } EAPI Efreet_Desktop * @@ -366,8 +388,8 @@ efreet_util_desktop_name_find(const char *name) eina_iterator_foreach(it, EINA_EACH(efreet_util_cache_search_name), &search); eina_iterator_free(it); - if (search.result) return search.result->desktop; - return NULL; + efreet_desktop_ref(search.result->desktop); + return search.result->desktop; } EAPI Efreet_Desktop * @@ -385,95 +407,99 @@ efreet_util_desktop_generic_name_find(const char *generic_name) eina_iterator_foreach(it, EINA_EACH(efreet_util_cache_search_generic_name), &search); eina_iterator_free(it); - if (search.result) return search.result->desktop; - return NULL; + efreet_desktop_ref(search.result->desktop); + return search.result->desktop; } -EAPI Ecore_List * +EAPI Eina_List * efreet_util_desktop_name_glob_list(const char *glob) { Efreet_Cache_Search_List search; Eina_Iterator *it; - search.list = ecore_list_new(); + search.list = NULL; search.what = glob; it = eina_hash_iterator_data_new(desktop_by_file_id); eina_iterator_foreach(it, EINA_EACH(efreet_util_cache_search_name_glob), &search); eina_iterator_free(it); - if (ecore_list_empty_is(search.list)) IF_FREE_LIST(search.list); return search.list; } -EAPI Ecore_List * +EAPI Eina_List * efreet_util_desktop_exec_glob_list(const char *glob) { Efreet_Cache_Search_List search; Eina_Iterator *it; - search.list = ecore_list_new(); + search.list = NULL; search.what = glob; it = eina_hash_iterator_data_new(desktop_by_file_id); eina_iterator_foreach(it, EINA_EACH(efreet_util_cache_search_exec_glob), &search); eina_iterator_free(it); - if (ecore_list_empty_is(search.list)) IF_FREE_LIST(search.list); return search.list; } -EAPI Ecore_List * +EAPI Eina_List * efreet_util_desktop_generic_name_glob_list(const char *glob) { Efreet_Cache_Search_List search; Eina_Iterator *it; - search.list = ecore_list_new(); + search.list = NULL; search.what = glob; it = eina_hash_iterator_data_new(desktop_by_file_id); eina_iterator_foreach(it, EINA_EACH(efreet_util_cache_search_generic_name_glob), &search); eina_iterator_free(it); - if (ecore_list_empty_is(search.list)) IF_FREE_LIST(search.list); return search.list; } -EAPI Ecore_List * +EAPI Eina_List * efreet_util_desktop_comment_glob_list(const char *glob) { Efreet_Cache_Search_List search; Eina_Iterator *it; - search.list = ecore_list_new(); + search.list = NULL; search.what = glob; it = eina_hash_iterator_data_new(desktop_by_file_id); eina_iterator_foreach(it, EINA_EACH(efreet_util_cache_search_comment_glob), &search); eina_iterator_free(it); - if (ecore_list_empty_is(search.list)) IF_FREE_LIST(search.list); return search.list; } +static Eina_Bool +_hash_keys(Eina_Hash *hash, const void *key, void *fdata) +{ + Eina_List **l = fdata; + + *l = eina_list_append(*l, key); + return EINA_TRUE; +} + /** * Find all desktop categories * This list must be freed using ecore_list_destroy() * - * @return an Ecore_List of category names (const char *) + * @return an Eina_List of category names (const char *) */ -EAPI Ecore_List * +EAPI Eina_List * efreet_util_desktop_categories_list(void) { Eina_Iterator *it; - Ecore_List *list; + Eina_List *list = NULL; - list = ecore_list_new(); - if (list) - { it = eina_hash_iterator_key_new(desktops_by_category); - eina_iterator_foreach(it, EINA_EACH(desktops_by_category), list); + if (it) + { + eina_iterator_foreach(it, EINA_EACH(_hash_keys), &list); eina_iterator_free(it); } @@ -488,7 +514,7 @@ efreet_util_desktop_categories_list(void) * @param category the category name * @return a list of desktops */ -EAPI Ecore_List * +EAPI Eina_List * efreet_util_desktop_category_list(const char *category) { return eina_hash_find(desktops_by_category, category); @@ -505,6 +531,7 @@ dump(Eina_Hash *hash, const char *key, void *value, __UNUSED__ void *data) static int efreet_util_cache_fill(__UNUSED__ void *data) { + Efreet_Cache_Fill_Dir *dir; struct dirent *file = NULL; double start; char buf[PATH_MAX]; @@ -521,10 +548,17 @@ efreet_util_cache_fill(__UNUSED__ void *data) } if (!fill->current) { - fill->current = ecore_list_first_remove(fill->dirs); + fill->current = eina_list_data_get(fill->dirs); + fill->dirs = eina_list_remove_list(fill->dirs, fill->dirs); if (!fill->current) { - IF_FREE_LIST(fill->dirs); + while (fill->dirs) + { + dir = eina_list_data_get(fill->dirs); + efreet_util_cache_dir_free(dir); + fill->dirs = eina_list_remove_list(fill->dirs, fill->dirs); + } + free(fill); idler = NULL; fill = NULL; @@ -572,7 +606,7 @@ efreet_util_cache_fill(__UNUSED__ void *data) dir->path = strdup(buf); dir->file_id = strdup(file_id); dir->priority = fill->current->priority; - ecore_list_append(fill->dirs, dir); + fill->dirs = eina_list_append(fill->dirs, dir); } else efreet_util_cache_add(buf, file_id, fill->current->priority, 0); @@ -781,21 +815,20 @@ efreet_util_cache_search_mime(__UNUSED__ const Eina_Hash *hash, void *value, voi { Efreet_Cache_Search_List *search; Efreet_Util_Desktop *ud; + Eina_List *l; const char *mime; search = fdata; ud = value; if (!ud->desktop->mime_types) return EINA_FALSE; - ecore_list_first_goto(ud->desktop->mime_types); - while ((mime = ecore_list_next(ud->desktop->mime_types))) - { + EINA_LIST_FOREACH(ud->desktop->mime_types, l, mime) if (search->what == mime) { - ecore_list_append(search->list, ud->desktop); + efreet_desktop_ref(ud->desktop); + search->list = eina_list_append(search->list, ud->desktop); break; } - } return EINA_TRUE; } @@ -808,6 +841,7 @@ efreet_util_cache_search_wm_class(__UNUSED__ const Eina_Hash *hash, void *value, ud = value; search = fdata; + if (!ud->desktop) return EINA_TRUE; if (!ud->desktop->startup_wm_class) return EINA_TRUE; if ((search->what2) && (!strcmp(ud->desktop->startup_wm_class, search->what2))) { @@ -899,8 +933,12 @@ efreet_util_cache_search_name_glob(__UNUSED__ const Eina_Hash *hash, void *value search = fdata; ud = value; + if (!ud->desktop) return EINA_TRUE; if (efreet_util_glob_match(ud->desktop->name, search->what)) - ecore_list_append(search->list, ud->desktop); + { + efreet_desktop_ref(ud->desktop); + search->list = eina_list_append(search->list, ud->desktop); + } return EINA_TRUE; } @@ -916,12 +954,14 @@ efreet_util_cache_search_exec_glob(__UNUSED__ const Eina_Hash *hash, void *value if (!ud->desktop->exec) return EINA_FALSE; exec = ecore_file_app_exe_get(ud->desktop->exec); - if (exec) - { + if (!exec) return EINA_TRUE; + if (efreet_util_glob_match(exec, search->what)) - ecore_list_append(search->list, ud->desktop); - free(exec); + { + efreet_desktop_ref(ud->desktop); + search->list = eina_list_append(search->list, ud->desktop); } + free(exec); return EINA_TRUE; } @@ -935,7 +975,10 @@ efreet_util_cache_search_generic_name_glob(__UNUSED__ const Eina_Hash *hash, voi ud = value; if (efreet_util_glob_match(ud->desktop->generic_name, search->what)) - ecore_list_append(search->list, ud->desktop); + { + efreet_desktop_ref(ud->desktop); + search->list = eina_list_append(search->list, ud->desktop); + } return EINA_TRUE; } @@ -949,7 +992,10 @@ efreet_util_cache_search_comment_glob(__UNUSED__ const Eina_Hash *hash, void *va ud = value; if (efreet_util_glob_match(ud->desktop->comment, search->what)) - ecore_list_append(search->list, ud->desktop); + { + efreet_desktop_ref(ud->desktop); + search->list = eina_list_append(search->list, ud->desktop); + } return EINA_TRUE; } @@ -977,7 +1023,7 @@ efreet_util_monitor(const char *path, const char *file_id, int priority) em->monitor = ecore_file_monitor_add(path, efreet_util_monitor_cb, em); if (file_id) em->file_id = strdup(file_id); em->priority = priority; - ecore_list_append(monitors, em); + monitors = eina_list_append(monitors, em); } static void @@ -1007,15 +1053,13 @@ efreet_util_monitor_cb(void *data, Ecore_File_Monitor *monitor __UNUSED__, if (!fill) { fill = NEW(Efreet_Cache_Fill, 1); - fill->dirs = ecore_list_new(); - ecore_list_free_cb_set(fill->dirs, efreet_util_cache_dir_free); } dir = NEW(Efreet_Cache_Fill_Dir, 1); dir->path = strdup(path); dir->file_id = strdup(file_id); dir->priority = em->priority; - ecore_list_append(fill->dirs, dir); + fill->dirs = eina_list_append(fill->dirs, dir); if (!idler) idler = ecore_idler_add(efreet_util_cache_fill, NULL); @@ -1028,8 +1072,8 @@ efreet_util_monitor_cb(void *data, Ecore_File_Monitor *monitor __UNUSED__, /* Ignore, we should already have a monitor on any subdir */ break; case ECORE_FILE_EVENT_DELETED_SELF: - if (ecore_list_goto(monitors, em)) - ecore_list_remove(monitors); + if (eina_list_data_find(monitors, em)) + eina_list_remove(monitors, em); efreet_util_monitor_free(em); break; case ECORE_FILE_EVENT_MODIFIED: @@ -1053,27 +1097,24 @@ efreet_util_monitor_free(void *data) * Returns a list of .menu files found in the various config dirs. * @return An ecore list of menu file paths (const char *). This must be freed with ecore_list_destroy(). */ -EAPI Ecore_List * +EAPI Eina_List * efreet_util_menus_find(void) { - Ecore_List *menus, *dirs; + Eina_List *menus = NULL; + Eina_List *dirs, *l; const char *dir; - menus = ecore_list_new(); - ecore_list_free_cb_set(menus, ECORE_FREE_CB(free)); - efreet_util_menus_find_helper(menus, efreet_config_home_get()); dirs = efreet_config_dirs_get(); - ecore_list_first_goto(dirs); - while ((dir = ecore_list_next(dirs))) + EINA_LIST_FOREACH(dirs, l, dir) efreet_util_menus_find_helper(menus, dir); return menus; } static void -efreet_util_menus_find_helper(Ecore_List *menus, const char *config_dir) +efreet_util_menus_find_helper(Eina_List *menus, const char *config_dir) { DIR *files = NULL; struct dirent *file = NULL; @@ -1091,7 +1132,7 @@ efreet_util_menus_find_helper(Ecore_List *menus, const char *config_dir) snprintf(fbuf, PATH_MAX, "%s/%s", dbuf, file->d_name); if (ecore_file_is_dir(fbuf)) continue; - ecore_list_append(menus, strdup(fbuf)); + menus = eina_list_append(menus, strdup(fbuf)); } closedir(files); } @@ -1099,42 +1140,40 @@ efreet_util_menus_find_helper(Ecore_List *menus, const char *config_dir) static void efreet_util_desktops_by_category_add(Efreet_Desktop *desktop) { + Eina_List *l; const char *category; if (!desktop->categories) return; - ecore_list_first_goto(desktop->categories); - while ((category = ecore_list_next(desktop->categories))) + EINA_LIST_FOREACH(desktop->categories, l, category) { - Ecore_List *list; + Eina_List *list; list = eina_hash_find(desktops_by_category, category); - if (!list) - { - list = ecore_list_new(); - eina_hash_add(desktops_by_category, category, list); - } - if (!ecore_list_goto(list, desktop)) - ecore_list_append(list, desktop); + if (!eina_list_data_find(list, desktop)) + list = eina_list_append(list, desktop); + eina_hash_modify(desktops_by_category, category, list); } } static void efreet_util_desktops_by_category_remove(Efreet_Desktop *desktop) { + Eina_List *l; const char *category; if (!desktop->categories) return; - ecore_list_first_goto(desktop->categories); - while ((category = ecore_list_next(desktop->categories))) + EINA_LIST_FOREACH(desktop->categories, l, category) { - Ecore_List *list; + Eina_List *list; list = eina_hash_find(desktops_by_category, category); if (!list) continue; - if (ecore_list_goto(list, desktop)) - ecore_list_remove(list); - if (ecore_list_empty_is(list)) + if (eina_list_data_find(list, desktop)) + list = eina_list_remove(list, desktop); + if (!list) eina_hash_del(desktops_by_category, category, list); + else + eina_hash_modify(desktops_by_category, category, list); } } diff --git a/legacy/efreet/src/lib/efreet_utils.h b/legacy/efreet/src/lib/efreet_utils.h index 988e66f329..eb21b5fee5 100644 --- a/legacy/efreet/src/lib/efreet_utils.h +++ b/legacy/efreet/src/lib/efreet_utils.h @@ -25,7 +25,7 @@ EAPI int efreet_util_shutdown(void); EAPI const char *efreet_util_path_to_file_id(const char *path); -EAPI Ecore_List *efreet_util_desktop_mime_list(const char *mime); +EAPI Eina_List *efreet_util_desktop_mime_list(const char *mime); EAPI Efreet_Desktop *efreet_util_desktop_wm_class_find(const char *wmname, const char *wmclass); EAPI Efreet_Desktop *efreet_util_desktop_file_id_find(const char *file_id); @@ -33,15 +33,15 @@ EAPI Efreet_Desktop *efreet_util_desktop_exec_find(const char *exec); EAPI Efreet_Desktop *efreet_util_desktop_name_find(const char *name); EAPI Efreet_Desktop *efreet_util_desktop_generic_name_find(const char *generic_name); -EAPI Ecore_List *efreet_util_desktop_name_glob_list(const char *glob); -EAPI Ecore_List *efreet_util_desktop_exec_glob_list(const char *glob); -EAPI Ecore_List *efreet_util_desktop_generic_name_glob_list(const char *glob); -EAPI Ecore_List *efreet_util_desktop_comment_glob_list(const char *glob); +EAPI Eina_List *efreet_util_desktop_name_glob_list(const char *glob); +EAPI Eina_List *efreet_util_desktop_exec_glob_list(const char *glob); +EAPI Eina_List *efreet_util_desktop_generic_name_glob_list(const char *glob); +EAPI Eina_List *efreet_util_desktop_comment_glob_list(const char *glob); -EAPI Ecore_List *efreet_util_desktop_categories_list(void); -EAPI Ecore_List *efreet_util_desktop_category_list(const char *category); +EAPI Eina_List *efreet_util_desktop_categories_list(void); +EAPI Eina_List *efreet_util_desktop_category_list(const char *category); -EAPI Ecore_List *efreet_util_menus_find(void); +EAPI Eina_List *efreet_util_menus_find(void); EAPI extern int EFREET_EVENT_DESKTOP_LIST_CHANGE; EAPI extern int EFREET_EVENT_DESKTOP_CHANGE;