Ecore_List -> Eina_List

This commit is contained in:
Jaime Thomas 2008-12-18 18:54:50 +00:00
parent 7ef32690c2
commit 2d514dcf28
8 changed files with 102 additions and 86 deletions

View File

@ -14,6 +14,12 @@ main(int argc, char **argv)
{ {
int ret = 0; int ret = 0;
if (!eina_init())
{
printf("Cannot initialize Eina!\n");
return 1;
}
/* Do I really need all of these? */ /* Do I really need all of these? */
if (!ecore_init()) if (!ecore_init())
{ {
@ -150,6 +156,7 @@ SHUTDOWN:
ecore_shutdown(); ecore_shutdown();
edje_shutdown(); edje_shutdown();
efreet_shutdown(); efreet_shutdown();
eina_shutdown();
printf("Program Done\n"); printf("Program Done\n");
return ret; return ret;
@ -162,7 +169,6 @@ ecdb_setup(void)
em = calloc(1, sizeof(Ecdb_Main)); em = calloc(1, sizeof(Ecdb_Main));
em->drives = NULL; em->drives = NULL;
em->drop_object = NULL; em->drop_object = NULL;
em->dnd_candidates = ecore_list_new();
if (!ecore_file_mkdir("/tmp/ecdb")) if (!ecore_file_mkdir("/tmp/ecdb"))
{ {

View File

@ -34,8 +34,8 @@ struct _Ecdb_Main
{ {
char theme_path[PATH_MAX]; char theme_path[PATH_MAX];
Ecore_Evas *main_win_ee; Ecore_Evas *main_win_ee;
Ecore_List *drives; Eina_List *drives;
Ecore_List *dnd_candidates; Eina_List *dnd_candidates;
Evas_Object *drop_object; Evas_Object *drop_object;
}; };

View File

@ -6,8 +6,8 @@ struct Burn_Data
{ {
BurnDisc *disc; BurnDisc *disc;
BurnSession *session; BurnSession *session;
Ecore_List *sources; Eina_List *sources;
Ecore_List *tracks; Eina_List *tracks;
Ecdb_Project *proj; Ecdb_Project *proj;
}; };
@ -16,8 +16,8 @@ int ecdb_burn_project_init(Ecdb_Burn_Project *proj);
int ecdb_erase_project_init(Ecdb_Erase_Project *proj); int ecdb_erase_project_init(Ecdb_Erase_Project *proj);
static void ecdb_burn_progress_handler(void *data, void *buffer, static void ecdb_burn_progress_handler(void *data, void *buffer,
unsigned int nbyte); unsigned int nbyte);
void ecdb_sources_list_free(void *data); void ecdb_sources_list_free(Eina_List *list);
void ecdb_tracks_list_free(void *data); void ecdb_tracks_list_free(Eina_List *list);
Ecdb_Burn_Project * Ecdb_Burn_Project *
@ -91,10 +91,6 @@ ecdb_burn_project(Ecdb_Burn_Project *proj)
return FALSE; return FALSE;
} }
data->proj = ECDB_PROJECT(proj); data->proj = ECDB_PROJECT(proj);
data->sources = ecore_list_new();
data->tracks = ecore_list_new();
ecore_list_free_cb_set(data->sources, ecdb_sources_list_free);
ecore_list_free_cb_set(data->tracks, ecdb_tracks_list_free);
if (proj->burn_mode != BURN_AUDIO) if (proj->burn_mode != BURN_AUDIO)
padding = 300*1024; padding = 300*1024;
@ -112,8 +108,8 @@ ecdb_burn_project(Ecdb_Burn_Project *proj)
printf("Failed to add any files to burn disc!\n"); printf("Failed to add any files to burn disc!\n");
burn_session_free(data->session); burn_session_free(data->session);
burn_disc_free(data->disc); burn_disc_free(data->disc);
ecore_list_destroy(data->sources); ecdb_sources_list_free(data->sources);
ecore_list_destroy(data->tracks); ecdb_tracks_list_free(data->tracks);
FREE(data); FREE(data);
return ECDB_ERROR_IMAGE_CREATE; return ECDB_ERROR_IMAGE_CREATE;
} }
@ -123,15 +119,15 @@ ecdb_burn_project(Ecdb_Burn_Project *proj)
printf("Error: Cannot attach source object to track object!\n"); printf("Error: Cannot attach source object to track object!\n");
burn_session_free(data->session); burn_session_free(data->session);
burn_disc_free(data->disc); burn_disc_free(data->disc);
ecore_list_destroy(data->sources); ecdb_sources_list_free(data->sources);
ecore_list_destroy(data->tracks); ecdb_tracks_list_free(data->tracks);
FREE(data); FREE(data);
return ECDB_ERROR_SOURCE_ATTACH; return ECDB_ERROR_SOURCE_ATTACH;
} }
burn_session_add_track(data->session, track, BURN_POS_END); burn_session_add_track(data->session, track, BURN_POS_END);
ecore_list_append(data->sources, source); data->sources = eina_list_append(data->sources, source);
ecore_list_append(data->tracks, track); data->tracks = eina_list_append(data->tracks, track);
opts = burn_write_opts_new(ECDB_PROJECT(proj)->drive->tangible[0].drive); opts = burn_write_opts_new(ECDB_PROJECT(proj)->drive->tangible[0].drive);
burn_write_opts_set_perform_opc(opts, proj->opc); burn_write_opts_set_perform_opc(opts, proj->opc);
@ -153,8 +149,8 @@ ecdb_burn_project(Ecdb_Burn_Project *proj)
burn_session_free(data->session); burn_session_free(data->session);
burn_disc_free(data->disc); burn_disc_free(data->disc);
burn_write_opts_free(opts); burn_write_opts_free(opts);
ecore_list_destroy(data->sources); ecdb_sources_list_free(data->sources);
ecore_list_destroy(data->tracks); ecdb_tracks_list_free(data->tracks);
FREE(proj); FREE(proj);
return ECDB_ERROR_WRITE_MODE; return ECDB_ERROR_WRITE_MODE;
} }
@ -271,8 +267,8 @@ ecdb_burn_finished(void *data, int type, void *event)
proj = data; proj = data;
printf("Freeing source and tracks\n"); printf("Freeing source and tracks\n");
ecore_list_destroy(proj->sources); ecdb_sources_list_free(proj->sources);
ecore_list_destroy(proj->tracks); ecdb_tracks_list_free(proj->tracks);
printf("Freeing session and disc\n"); printf("Freeing session and disc\n");
burn_session_free(proj->session); burn_session_free(proj->session);
@ -302,13 +298,25 @@ ecdb_burn_finished(void *data, int type, void *event)
} }
void void
ecdb_sources_list_free(void *data) ecdb_sources_list_free(Eina_List *list)
{ {
burn_source_free(data); Eina_List *l;
void *data;
EINA_LIST_FOREACH(list, l, data)
burn_source_free(data);
list = eina_list_free(list);
} }
void void
ecdb_tracks_list_free(void *data) ecdb_tracks_list_free(Eina_List *list)
{ {
burn_track_free(data); Eina_List *l;
void *data;
EINA_LIST_FOREACH(list, l, data)
burn_track_free(data);
list = eina_list_free(list);
} }

View File

@ -1,8 +1,6 @@
/* vim: set sw=3 ts=3 sts=3 expandtab: */ /* vim: set sw=3 ts=3 sts=3 expandtab: */
#include "ecdb.h" #include "ecdb.h"
void ecdb_drive_info_free_cb(void *data);
int int
ecdb_aquire_drive_info(void) ecdb_aquire_drive_info(void)
{ {
@ -14,12 +12,9 @@ ecdb_aquire_drive_info(void)
ret = 0; ret = 0;
if (em->drives) if (em->drives)
{ {
ecore_list_destroy(em->drives); ecdb_drive_info_list_free(em->drives);
} }
em->drives = ecore_list_new();
ecore_list_free_cb_set(em->drives, ecdb_drive_info_free_cb);
while (!ret) while (!ret)
{ {
ret = burn_drive_scan(&drives_current, &drive_num); ret = burn_drive_scan(&drives_current, &drive_num);
@ -76,7 +71,7 @@ ecdb_aquire_drive_info(void)
} }
burn_drive_free_speedlist(&speeds); burn_drive_free_speedlist(&speeds);
ecore_list_append(em->drives, drive); em->drives = eina_list_append(em->drives, drive);
} }
burn_drive_info_free(drives_current); burn_drive_info_free(drives_current);
@ -85,30 +80,35 @@ ecdb_aquire_drive_info(void)
} }
void void
ecdb_drive_info_free_cb(void *data) ecdb_drive_info_list_free(Eina_List *list)
{ {
Ecdb_Drive_Info *info; Ecdb_Drive_Info *info;
Eina_List *l;
info = data; EINA_LIST_FOREACH(list, l, info)
{
FREE(info->read_speeds);
FREE(info->write_speeds);
FREE(info->vendor);
FREE(info->product);
FREE(info->revision);
FREE(info->location);
FREE(info->profile_name);
FREE(info);
}
FREE(info->read_speeds); list = eina_list_free(list);
FREE(info->write_speeds);
FREE(info->vendor);
FREE(info->product);
FREE(info->revision);
FREE(info->location);
FREE(info->profile_name);
FREE(info);
} }
void void
ecdb_print_drive_info(void) ecdb_print_drive_info(void)
{ {
Eina_List *l;
Ecdb_Drive_Info *drive; Ecdb_Drive_Info *drive;
int j, i, h; int j, i, h;
ecore_list_first_goto(em->drives); em->drives = eina_list_nth_list(em->drives, 0);
while ((drive = ecore_list_next(em->drives))) EINA_LIST_FOREACH(em->drives, l, drive)
{ {
printf("Vendor: %s, Product: %s, Revision: %s, " printf("Vendor: %s, Product: %s, Revision: %s, "
"Location: %s\n", "Location: %s\n",
@ -153,7 +153,7 @@ ecdb_aquire_drive(Ecdb_Project *proj, unsigned int idx)
Ecdb_Drive_Info *info; Ecdb_Drive_Info *info;
char adr[BURN_DRIVE_ADR_LEN]; char adr[BURN_DRIVE_ADR_LEN];
info = ecore_list_index_goto(em->drives, idx); info = eina_list_nth(em->drives, idx);
if (burn_drive_convert_fs_adr(info->location, adr) <= 0) if (burn_drive_convert_fs_adr(info->location, adr) <= 0)
{ {
printf("Error: Address doesn't provide cd burner!\n"); printf("Error: Address doesn't provide cd burner!\n");

View File

@ -5,5 +5,6 @@
int ecdb_aquire_drive_info(void); int ecdb_aquire_drive_info(void);
void ecdb_print_drive_info(void); void ecdb_print_drive_info(void);
int ecdb_aquire_drive(Ecdb_Project *proj, unsigned int idx); int ecdb_aquire_drive(Ecdb_Project *proj, unsigned int idx);
void ecdb_drive_info_list_free(Eina_List *list);
#endif #endif

View File

@ -109,12 +109,7 @@ ecdb_custom_filelist_directory_new(Ecdb_Source *parent)
struct stat st; struct stat st;
int nf = 0, nd = 0, i = 0; int nf = 0, nd = 0, i = 0;
Ecore_List *files, *dirs; Eina_List *files = NULL, *dirs = NULL;
files = ecore_list_new();
dirs = ecore_list_new();
ecore_list_free_cb_set(files, ECORE_FREE_CB(free_file));
ecore_list_free_cb_set(dirs, ECORE_FREE_CB(free_file));
if (!parent) if (!parent)
{ {
@ -138,13 +133,12 @@ ecdb_custom_filelist_directory_new(Ecdb_Source *parent)
if (src->dir) if (src->dir)
{ {
ecore_list_append(dirs, file); dirs = eina_list_append(dirs, file);
nd++; nd++;
} }
else else
{ {
ecore_list_append(files, file); files = eina_list_append(files, file);
nf++; nf++;
} }
@ -152,8 +146,6 @@ ecdb_custom_filelist_directory_new(Ecdb_Source *parent)
} }
dir = calloc(1, sizeof(Ewl_Filelist_Directory)); dir = calloc(1, sizeof(Ewl_Filelist_Directory));
dir->files = ecore_list_new();
dir->dirs = ecore_list_new();
dir->rfiles = files; dir->rfiles = files;
dir->rdirs = dirs; dir->rdirs = dirs;
dir->num_dirs = nd; dir->num_dirs = nd;
@ -165,55 +157,63 @@ ecdb_custom_filelist_directory_new(Ecdb_Source *parent)
} }
static void static void
free_file(Ewl_Filelist_File *file) ecdb_files_list_free(Eina_List *list)
{ {
eina_stringshare_del(file->name); Eina_List *l;
FREE(file); Ewl_Filelist_File *file;
EINA_LIST_FOREACH(list, l, file)
{
eina_stringshare_del(file->name);
FREE(file);
}
list = eina_list_free(list);
} }
static void static void
ecdb_custom_filelist_model_filter(Ewl_Filelist_Directory *dir) ecdb_custom_filelist_model_filter(Ewl_Filelist_Directory *dir)
{ {
Ewl_Filelist_File *file; Ewl_Filelist_File *file;
Eina_List *l;
int nd, nf; int nd, nf;
ecore_list_clear(dir->files); dir->files = eina_list_free(dir->files);
ecore_list_clear(dir->dirs); dir->dirs = eina_list_free(dir->dirs);
nd = nf = 0; nd = nf = 0;
if (!dir->show_dot) if (!dir->show_dot)
{ {
ecore_list_first_goto(dir->rfiles); dir->rfiles = eina_list_nth_list(dir->rfiles, 0);
while ((file = ecore_list_next(dir->rfiles))) EINA_LIST_FOREACH(dir->rfiles, l, file)
{ {
if (ecore_file_file_get(file->name)[0] != '.') if (ecore_file_file_get(file->name)[0] != '.')
{ {
ecore_list_append(dir->files, file); dir->files = eina_list_append(dir->files, file);
nf++; nf++;
} }
} }
ecore_list_first_goto(dir->rdirs); dir->rdirs = eina_list_nth_list(dir->files, 0);
while ((file = ecore_list_next(dir->rdirs))) EINA_LIST_FOREACH(dir->rdirs, l, file)
{ {
if (ecore_file_file_get(file->name)[0] != '.') if (ecore_file_file_get(file->name)[0] != '.')
{ {
ecore_list_append(dir->dirs, file); dir->dirs = eina_list_append(dir->dirs, file);
nd++; nd++;
} }
} }
} }
else else
{ {
ecore_list_first_goto(dir->rfiles); dir->rfiles = eina_list_nth_list(dir->rfiles, 0);
while ((file = ecore_list_next(dir->rfiles))) EINA_LIST_FOREACH(dir->rfiles, l, file)
{ {
ecore_list_append(dir->files, file); dir->files = eina_list_append(dir->files, file);
nf++; nf++;
} }
ecore_list_first_goto(dir->rdirs); dir->rdirs = eina_list_nth_list(dir->rdirs, 0);
while ((file = ecore_list_next(dir->rdirs))) EINA_LIST_FOREACH(dir->rdirs, l, file)
{ {
ecore_list_append(dir->dirs, file); dir->dirs = eina_list_append(dir->dirs, file);
nd++; nd++;
} }
} }
@ -228,10 +228,10 @@ ecdb_custom_filelist_model_data_unref(void *data)
Ewl_Filelist_Directory *dir; Ewl_Filelist_Directory *dir;
dir = data; dir = data;
ecore_list_destroy(dir->files); ecdb_files_list_free(dir->files);
ecore_list_destroy(dir->dirs); ecdb_files_list_free(dir->dirs);
ecore_list_destroy(dir->rfiles); ecdb_files_list_free(dir->rfiles);
ecore_list_destroy(dir->rdirs); ecdb_files_list_free(dir->rdirs);
FREE(dir); FREE(dir);
return TRUE; return TRUE;
} }
@ -250,12 +250,12 @@ ecdb_custom_filelist_model_data_fetch(void *data, unsigned int row,
/* Check if in dirs or files list */ /* Check if in dirs or files list */
if (row < fld->num_dirs) if (row < fld->num_dirs)
{ {
file = ecore_list_index_goto(fld->dirs, row); file = eina_list_nth(fld->dirs, row);
} }
else else
{ {
i = (row - fld->num_dirs); i = (row - fld->num_dirs);
file = ecore_list_index_goto(fld->files, i); file = eina_list_nth(fld->files, i);
} }
if (column == 1) ret = ewl_filelist_size_get(file->size); if (column == 1) ret = ewl_filelist_size_get(file->size);
@ -341,12 +341,12 @@ ecdb_custom_filelist_selected_file_get(Ewl_Filelist *fl)
data = EWL_SELECTION(idx)->data; data = EWL_SELECTION(idx)->data;
if (idx->row < data->num_dirs) if (idx->row < data->num_dirs)
{ {
file = ecore_list_index_goto(data->dirs, idx->row); file = eina_list_nth(data->dirs, idx->row);
} }
else else
{ {
i = (idx->row - data->num_dirs); i = (idx->row - data->num_dirs);
file = ecore_list_index_goto(data->files, i); file = eina_list_nth(data->files, i);
} }
FREE(idx); FREE(idx);

View File

@ -869,7 +869,7 @@ ecdb_burn_image_page_show(void)
} }
else if (!strcmp("ecdb/entry", wtype[i])) else if (!strcmp("ecdb/entry", wtype[i]))
{ {
ecore_list_append(em->dnd_candidates, b); em->dnd_candidates = eina_list_append(em->dnd_candidates, b);
evas_object_data_set(b, "dnd_call_func", ecdb_dnd_entry_dnd_set); evas_object_data_set(b, "dnd_call_func", ecdb_dnd_entry_dnd_set);
} }
} }

View File

@ -43,11 +43,11 @@ ecdb_shutdown(void *data, int type, void *event)
{ {
if (em->drives) if (em->drives)
{ {
ecore_list_destroy(em->drives); ecdb_drive_info_list_free(em->drives);
} }
if (em->dnd_candidates) if (em->dnd_candidates)
{ {
ecore_list_destroy(em->dnd_candidates); eina_list_free(em->dnd_candidates);
} }
FREE(em); FREE(em);
@ -181,6 +181,7 @@ ecdb_button_icon_swallow(Evas *e, Evas_Object *b, const char *iname)
int int
ecdb_dnd_position(void *data, int type, void *event) ecdb_dnd_position(void *data, int type, void *event)
{ {
Eina_List *l;
Ecore_X_Event_Xdnd_Position *ev; Ecore_X_Event_Xdnd_Position *ev;
Evas_Object *o; Evas_Object *o;
Ecore_X_Rectangle rect; Ecore_X_Rectangle rect;
@ -194,8 +195,8 @@ ecdb_dnd_position(void *data, int type, void *event)
ecore_evas_geometry_get(em->main_win_ee, &window_x, &window_y, &window_w, ecore_evas_geometry_get(em->main_win_ee, &window_x, &window_y, &window_w,
&window_h); &window_h);
ecore_list_first_goto(em->dnd_candidates); em->dnd_candidates = eina_list_nth_list(em->dnd_candidates, 0);
while ((o = ecore_list_next(em->dnd_candidates))) EINA_LIST_FOREACH(em->dnd_candidates, l, o)
{ {
if (evas_object_visible_get(o)) if (evas_object_visible_get(o))
{ {