static void volume_items_sort(Scan *s) { Eina_List *l; s->items = eina_list_sort(s->items, eina_list_count(s->items), volume_item_sort); for (l = s->items; l; l = l->next) items = eina_list_append(items, l->data); items = eina_list_sort(items, eina_list_count(items), volume_item_sort); }
static Eina_List * _font_list_get(const Evas *e) { Eina_List *flist = evas_font_available_list(e); Eina_List *itr, *nitr; const char *font, *prev_font = NULL; flist = eina_list_sort(flist, eina_list_count(flist), (Eina_Compare_Cb) strcasecmp); EINA_LIST_FOREACH_SAFE(flist, itr, nitr, font) { Elm_Font_Properties *efp; efp = elm_font_properties_get(font); /* Remove dups */ if (prev_font && !strcmp(efp->name, prev_font)) { flist = eina_list_remove_list(flist, itr); } else { eina_stringshare_replace(&font, efp->name); prev_font = font; eina_list_data_set(itr, font); } elm_font_properties_free(efp); }
void evry_util_items_sort(Eina_List **items, int flags) { _sort_flags = flags; *items = eina_list_sort(*items, -1, _evry_items_sort_func); _sort_flags = 0; }
//Sort subtitles by start time void eclair_subtitles_sort(Eclair_Subtitles *subtitles) { if (!subtitles || !subtitles->subtitles) return; subtitles->subtitles = eina_list_sort(subtitles->subtitles, eina_list_count(subtitles->subtitles), _eclair_subtitles_sort_cb); }
menu_screen_error_e list_sort(app_list *list, int (*_sort_cb)(const void *d1, const void *d2)) { retv_if(NULL == list, MENU_SCREEN_ERROR_INVALID_PARAMETER); list->list = eina_list_sort(list->list, eina_list_count(list->list), _sort_cb); retv_if(NULL == list->list, MENU_SCREEN_ERROR_FAIL); return MENU_SCREEN_ERROR_OK; }
Eina_Bool eli_highscore_entry_add(const char * game, const char * username, float points, pointsType type) { Eina_List * l = NULL; Eli_Highscore_Entry * entry; int (*list_sort) (const void *, const void *); int count = 0; if (!game || !username || !eet_file_name) return 0; entry = _eli_entry_new(username, points, type); l = eli_highscore_get(game); if (l) count = eina_list_count(l); else count = 0; /* select the right sorting function */ switch (type) { case POINTS_TYPE_INTEGER_BAD: case POINTS_TYPE_FLOAT_BAD: list_sort = _eli_highscore_list_sort_bad; break; default: list_sort = _eli_highscore_list_sort_good; break; } /* 10 entries should be enough */ if (count >= 10) { Eina_List * last_l; Eli_Highscore_Entry * last_e; last_l = eina_list_last(l); last_e = eina_list_data_get(last_l); if ( list_sort(last_e, entry) < 0) { free(entry->username); free(entry); return 0; } } l = eina_list_append(l, entry); if (count) l = eina_list_sort(l, (count + 1), list_sort); if (count >= 10) l = eina_list_remove_list(l, eina_list_last(l)); ecore_hash_set(hiscore_hash, strdup(game), l); _eli_highscore_write(game); return 1; }
E_API void * e_modapi_init(E_Module *m) { Eina_List *files; char buf[PATH_MAX]; char *file; wiz_module = m; e_wizard_init(); e_config->scale.use_dpi = 0; e_config->scale.use_custom = 1; e_config->scale.factor = 1.2; e_scale_update(); snprintf(buf, sizeof(buf), "%s/%s", e_module_dir_get(m), MODULE_ARCH); files = ecore_file_ls(buf); files = eina_list_sort(files, 0, (Eina_Compare_Cb)_cb_sort_files); EINA_LIST_FREE(files, file) { if ((!strncmp(file, "page_", 5)) && (eina_str_has_extension(file, ".so"))) { void *handle; snprintf(buf, sizeof(buf), "%s/%s/%s", e_module_dir_get(m), MODULE_ARCH, file); handle = dlopen(buf, RTLD_NOW | RTLD_GLOBAL); if (handle) e_wizard_page_add(handle, dlsym(handle, "wizard_page_init"), dlsym(handle, "wizard_page_shutdown"), dlsym(handle, "wizard_page_show"), dlsym(handle, "wizard_page_hide"), dlsym(handle, "wizard_page_apply")); else { // if its an executable... // XXX // else... printf("%s\n", dlerror()); } } free(file); } e_wizard_go(); return m; }
EAPI void * e_modapi_init(E_Module *m) { Eina_List *files; char buf[PATH_MAX]; char *file; default_e_theme = NULL; conf_module = m; e_wizard_init(); snprintf(buf, sizeof(buf), "%s/%s", e_module_dir_get(m), MODULE_ARCH); files = ecore_file_ls(buf); files = eina_list_sort(files, 0, (Eina_Compare_Cb)_cb_sort_files); EINA_LIST_FREE(files, file) { if (!strncmp(file, "page_", 5)) { void *handle; snprintf(buf, sizeof(buf), "%s/%s/%s", e_module_dir_get(m), MODULE_ARCH, file); handle = dlopen(buf, RTLD_NOW | RTLD_GLOBAL); if (handle) { e_wizard_page_add(handle, dlsym(handle, "wizard_page_init"), dlsym(handle, "wizard_page_shutdown"), dlsym(handle, "wizard_page_show"), dlsym(handle, "wizard_page_hide"), dlsym(handle, "wizard_page_apply")); } else printf("%s\n", dlerror()); } free(file); } e_wizard_go(); return m; }
Eina_List * etui_img_cbt_entries_get(Etui_Img_Cbt *tar) { Etui_Img_Cbt_Entry *e; Eina_List *list = NULL; if (!tar) return NULL; e = _etui_img_cbt_entry_first_get(tar); do { list = eina_list_append(list, e); e = _etui_img_cbt_entry_next_get(tar); } while (e); list = eina_list_sort(list, eina_list_count(list), _etui_img_cbt_sort_cb); return list; }
static void _fill_list (Evasxx::Object *obj) { DIR *d; struct dirent *de; Eina_List *dirs = NULL, *l; char *real; if (!(d = opendir(getenv("HOME")))) return; while ((de = readdir(d)) != NULL) { char buff[PATH_MAX]; if (de->d_name[0] == '.') continue; snprintf(buff, sizeof(buff), "%s/%s", getenv("HOME"), de->d_name); if (!ecore_file_is_dir(buff)) continue; real = ecore_file_realpath(buff); dirs = eina_list_append(dirs, real); } closedir(d); dirs = eina_list_sort(dirs, eina_list_count(dirs), EINA_COMPARE_CB(strcoll)); #if 0 EINA_LIST_FOREACH(dirs, l, real) { Eina_Bool result = EINA_FALSE; result = _dir_has_subs(real); if (!result) elm_genlist_item_append(obj, &itc, eina_stringshare_add(real), NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); else elm_genlist_item_append(obj, &itc, eina_stringshare_add(real), NULL, ELM_GENLIST_ITEM_TREE, NULL, NULL); free(real); }
static int _cb_sort_desks(Efreet_Desktop *d1, Efreet_Desktop *d2) { if (!d1->name) return 1; if (!d2->name) return -1; return strcmp(d1->name, d2->name); } EAPI int wizard_page_init(E_Wizard_Page *pg __UNUSED__) { Eina_List *desks = NULL; Efreet_Desktop *desk; desks = efreet_util_desktop_name_glob_list("*"); desks = eina_list_sort(desks, 0, (Eina_Compare_Cb)_cb_sort_desks); EINA_LIST_FREE(desks, desk) { if (!desk->exec) { efreet_desktop_free(desk); continue; } desktops = eina_list_append(desktops, desk); } if (desktops) { desktops_num = eina_list_count(desktops); desktops_add = calloc(sizeof(int), desktops_num); } return 1;
int main(int argc, char **argv) { /* TODO: * - Add file monitor on files, so that we catch changes on files * during whilst this program runs. * - Maybe linger for a while to reduce number of cache re-creates. */ Efreet_Cache_Hash hash; Efreet_Cache_Version version; Eina_List *dirs = NULL; Eina_List *systemdirs = NULL; Eina_List *extra_dirs = NULL; Eina_List *l = NULL; Eina_Inarray *stack = NULL; int priority = 0; char *dir = NULL; char *path; int lockfd = -1, tmpfd; int changed = 0; int i; char file[PATH_MAX] = { '\0' }; char util_file[PATH_MAX] = { '\0' }; mode_t um; if (!eina_init()) goto eina_error; _efreet_desktop_cache_log_dom = eina_log_domain_register("efreet_desktop_cache", EFREET_DEFAULT_LOG_COLOR); if (_efreet_desktop_cache_log_dom < 0) { EINA_LOG_ERR("Efreet: Could not create a log domain for efreet_desktop_cache."); return -1; } for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-v")) eina_log_domain_level_set("efreet_desktop_cache", EINA_LOG_LEVEL_DBG); else if ((!strcmp(argv[i], "-h")) || (!strcmp(argv[i], "-help")) || (!strcmp(argv[i], "--h")) || (!strcmp(argv[i], "--help"))) { printf("Options:\n"); printf(" -v Verbose mode\n"); printf(" -d dir1 dir2 Extra dirs\n"); exit(0); } else if (!strcmp(argv[i], "-d")) { while ((i < (argc - 1)) && (argv[(i + 1)][0] != '-')) extra_dirs = eina_list_append(extra_dirs, argv[++i]); } } extra_dirs = eina_list_sort(extra_dirs, -1, EINA_COMPARE_CB(strcmp)); #ifdef HAVE_SYS_RESOURCE_H setpriority(PRIO_PROCESS, 0, 19); #elif _WIN32 SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS); #endif /* init external subsystems */ if (!eet_init()) goto eet_error; if (!ecore_init()) goto ecore_error; efreet_cache_update = 0; /* finish efreet init */ if (!efreet_init()) goto efreet_error; /* create homedir */ snprintf(file, sizeof(file), "%s/efreet", efreet_cache_home_get()); if (!ecore_file_exists(file)) { if (!ecore_file_mkpath(file)) goto efreet_error; efreet_setowner(file); } /* lock process, so that we only run one copy of this program */ lockfd = cache_lock_file(); if (lockfd == -1) goto efreet_error; edd = efreet_desktop_edd(); if (!edd) goto edd_error; /* read user dirs from old cache */ ef = eet_open(efreet_desktop_util_cache_file(), EET_FILE_MODE_READ); if (ef) { old_file_ids = eet_data_read(ef, efreet_hash_string_edd(), "file_id"); eet_close(ef); } /* create cache */ snprintf(file, sizeof(file), "%s.XXXXXX", efreet_desktop_cache_file()); /* set secure umask for temporary files */ um = umask(0077); tmpfd = mkstemp(file); umask(um); if (tmpfd < 0) goto error; close(tmpfd); ef = eet_open(file, EET_FILE_MODE_READ_WRITE); if (!ef) goto error; snprintf(util_file, sizeof(util_file), "%s.XXXXXX", efreet_desktop_util_cache_file()); /* set secure umask for temporary files */ um = umask(0077); tmpfd = mkstemp(util_file); umask(um); if (tmpfd < 0) goto error; close(tmpfd); util_ef = eet_open(util_file, EET_FILE_MODE_READ_WRITE); if (!util_ef) goto error; /* write cache version */ version.major = EFREET_DESKTOP_UTILS_CACHE_MAJOR; version.minor = EFREET_DESKTOP_UTILS_CACHE_MINOR; eet_data_write(util_ef, efreet_version_edd(), EFREET_CACHE_VERSION, &version, 1); version.major = EFREET_DESKTOP_CACHE_MAJOR; version.minor = EFREET_DESKTOP_CACHE_MINOR; eet_data_write(ef, efreet_version_edd(), EFREET_CACHE_VERSION, &version, 1); desktops = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_desktop_free)); file_ids = eina_hash_string_superfast_new(NULL); paths = eina_hash_string_superfast_new(NULL); mime_types = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free)); categories = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free)); startup_wm_class = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free)); name = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free)); generic_name = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free)); comment = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free)); exec = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free)); dirs = efreet_default_dirs_get(efreet_data_home_get(), efreet_data_dirs_get(), "applications"); if (!dirs) goto error; stack = eina_inarray_new(sizeof(struct stat), 16); if (!stack) goto error; EINA_LIST_FREE(dirs, path) { char file_id[PATH_MAX] = { '\0' }; eina_inarray_flush(stack); if (!cache_scan(stack, path, file_id, priority++, 1, &changed)) goto error; systemdirs = eina_list_append(systemdirs, path); }
Eina_List * evry_fuzzy_match_sort(Eina_List *items) { return eina_list_sort(items, -1, _evry_fuzzy_match_sort_cb); }
it->fuzzy_match = evry_fuzzy_match(it->label, input); if (match_detail) { match = evry_fuzzy_match(it->detail, input); if (!(it->fuzzy_match) || (match && (match < it->fuzzy_match))) it->fuzzy_match = match; } if (it->fuzzy_match) p->items = eina_list_append(p->items, it); } p->items = eina_list_sort(p->items, -1, _evry_items_sort_func); return !!(p->items); } Evas_Object * evry_icon_theme_get(const char *icon, Evas *e) { Evas_Object *o = NULL; if (!icon) return NULL; o = e_icon_add(e); e_icon_scale_size_set(o, 128); e_icon_preload_set(o, 1);
/* * List depends on: * - state->sort * - state->tags * - state->filter * - dir contents on FS */ static Eina_Array * _fill_files(const madshelf_state_t *state, const char *dir, int *old_pos) { char *old_file = curdir_get(dir); if(old_pos) *old_pos = -1; Eina_Array *files = eina_array_new(10); /* HACK: using global variable to pas state into sort function */ cur_dir = !strcmp(dir, "/") ? "" : dir; Eina_List *ls = ecore_file_ls(dir); ls = eina_list_sort(ls, eina_list_count(ls), state->sort == MADSHELF_SORT_NAME ? &_name : (state->sort == MADSHELF_SORT_NAMEREV ? &_namerev : &_daterev)); /* First select directories */ for (Eina_List *i = ls; i; i = eina_list_next(i)) { const char *file = eina_list_data_get(i); char *filename = xasprintf("%s/%s", !strcmp(dir, "/") ? "" : dir, file); if (!ecore_file_is_dir(filename)) { free(filename); continue; } if (!state->show_hidden && is_hidden(state, filename)) { free(filename); continue; } if (old_file && old_pos) if (!strcmp(old_file, file)) *old_pos = eina_array_count_get(files); eina_array_push(files, filename); } /* Then files */ for (Eina_List *i = ls; i; i = eina_list_next(i)) { const char *file = eina_list_data_get(i); char *filename = xasprintf("%s/%s", !strcmp(dir, "/") ? "" : dir, file); if (ecore_file_is_dir(filename)) { free(filename); continue; } if (!state->show_hidden && is_hidden(state, filename)) { free(filename); continue; } if (old_file && old_pos) if (!strcmp(old_file, file)) *old_pos = eina_array_count_get(files); eina_array_push(files, filename); } char* s; EINA_LIST_FREE(ls, s) free(s); free(old_file); return files; }
static int _info_list(void) { Eina_Iterator *itr; Eina_List *types; const Eina_Hash_Tuple *tuple; const Eina_List *l; const char *name, *last_module; Eina_Bool module_found = EINA_FALSE, type_found = EINA_FALSE; Eina_Bool in_module = EINA_FALSE; EINA_LIST_FOREACH(modules, l, name) { if (!module_matches(name)) { DBG("filter out module '%s': does not match '%s'", name, module_patterns_str); continue; } if (!edje_module_load(name)) { ERR("error loading external '%s'", name); continue; } module_found = EINA_TRUE; } itr = edje_external_iterator_get(); types = NULL; EINA_ITERATOR_FOREACH(itr, tuple) { const Edje_External_Type *type = tuple->data; name = tuple->key; if (!type) { ERR("no type value for '%s'", name); continue; } else if (type->abi_version != edje_external_type_abi_version_get()) { ERR("type '%s' with incorrect abi_version %u (expected %u)", name, type->abi_version, edje_external_type_abi_version_get()); continue; } if (!type_matches(name)) { DBG("filter out type '%s': does not match '%s'", name, type_glob); continue; } types = eina_list_append(types, tuple); type_found = EINA_TRUE; } eina_iterator_free(itr); last_module = NULL; types = eina_list_sort(types, 0, _types_sort); EINA_LIST_FREE(types, tuple) { Eina_Bool changed_module = EINA_FALSE; const Edje_External_Type *type = tuple->data; const Edje_External_Param_Info *param; name = tuple->key; if ((last_module) && (type->module)) { changed_module = ((last_module != type->module) && (!strcmp(last_module, type->module))); } else if ((!last_module) && (type->module)) changed_module = EINA_TRUE; if (changed_module) { if (in_module) { if (machine) puts("TYPES-END\nMODULE-END"); else puts(INDENT "}\n}"); } if (machine) printf("MODULE-BEGIN\n" "NAME: %s\n" "FRIENDLY-NAME: %s\n" "TYPES-BEGIN\n", type->module, type->module_name); else printf("module {\n" INDENT "name: \"%s\";\n" INDENT "friendly_name: \"%s\";\n" INDENT "types {\n", type->module, type->module_name); in_module = EINA_TRUE; } if (machine) printf("TYPE-BEGIN\nNAME: %s\n", name); else printf(INDENT2 "type {\n" INDENT3 "name: \"%s\";\n", name); if (detail > 1) { const char *str; if (!type->label_get) str = NULL; else str = type->label_get(type->data); if (machine) printf("LABEL: %s\n", str ? str : ""); else if (str) printf(INDENT3 "label: \"%s\";\n", str); if (!type->description_get) str = NULL; else str = type->description_get(type->data); if (machine) printf("DESCRIPTION: %s\n", str ? str : ""); else if (str) printf(INDENT3 "description: \"%s\";\n", str); } if (machine) puts("PARAMS-BEGIN"); else puts(INDENT3 "params {"); for (param = type->parameters_info; param->name != NULL; param++) { const char *pt = _param_type_str_get(param); char buf[128]; if (machine) printf("PARAM-BEGIN\nNAME: %s\nTYPE: %s\n", param->name, pt); else printf(INDENT4 "%s: \"%s\"", pt, param->name); if (detail > 0) { const char *str = _param_value_str_get (type, param, buf, sizeof(buf)); if (machine) printf("DEFAULT: %s\n", str ? str : ""); else if (str) printf(" \"%s\"", str); if (detail > 1) { if (!machine) putchar(';'); _param_extra_details(type, param); } } if (machine) puts("PARAM-END"); else if (detail > 1) putchar('\n'); else puts(";"); } if (machine) puts("PARAMS-END\nTYPE-END"); else puts(INDENT3 "}\n" INDENT2 "}"); last_module = type->module; }
static void on_trash(void *data, Evas_Object *obj, void *event_info) { Evas_Object *sc, *bx2; Eina_List *l, *mlist = NULL; int from, num, i; if (content) evas_object_del(content); sc = elm_scroller_add(window); evas_object_size_hint_weight_set(sc, 1.0, 1.0); evas_object_size_hint_align_set(sc, -1.0, -1.0); elm_box_pack_end(box, sc); evas_object_show(sc); content = sc; bx2 = elm_box_add(window); evas_object_size_hint_weight_set(bx2, 1.0, 0.0); evas_object_size_hint_align_set(bx2, -1.0, -1.0); elm_scroller_content_set(sc, bx2); evas_object_show(bx2); tzset(); for (l = (Eina_List *)data_message_all_list(); l; l = l->next) { // FIXME: use filter mlist = eina_list_append(mlist, l->data); } // sort newest first mlist = eina_list_sort(mlist, eina_list_count(mlist), _sort_msg_newest); // FIXME: from and num are inputs from = 0; // from message # 0 num = 50; // 50 messages max; for (l = mlist, i = 0; l; l = l->next, i++) { Data_Message *msg = l->data; if (!(msg->flags & DATA_MESSAGE_TRASH)) continue; if (i >= from) { if (i == from) { if (l->prev) { // FIXME: add a "newer" button } } Evas_Object *msgui = _create_message(window, msg); elm_box_pack_end(bx2, msgui); evas_object_show(msgui); } if (i >= (from + num - 1)) { if (l->next) { // FIXME: add a "older" button } break; } } eina_list_free(mlist); }