From: Enlightenment S. <no-...@en...> - 2010-11-11 21:28:14
|
Log: enlil : add a method to retrieve the first photo of a library Author: watchwolf Date: 2010-11-11 13:28:07 -0800 (Thu, 11 Nov 2010) New Revision: 54480 Modified: trunk/enlil/src/enlil/Enlil.h trunk/enlil/src/enlil/root.c Modified: trunk/enlil/src/enlil/Enlil.h =================================================================== --- trunk/enlil/src/enlil/Enlil.h 2010-11-11 20:34:35 UTC (rev 54479) +++ trunk/enlil/src/enlil/Enlil.h 2010-11-11 21:28:07 UTC (rev 54480) @@ -157,6 +157,7 @@ EAPI void enlil_root_monitor_start(Enlil_Root *root); EAPI void enlil_root_monitor_stop(Enlil_Root *root); EAPI void enlil_root_albums_sort(Enlil_Root *root); +EAPI Enlil_Photo * enlil_root_first_photo_get(const char *library_path); EAPI const Eina_List * enlil_root_collections_get(const Enlil_Root *root); EAPI void enlil_root_collection_del(Enlil_Root *root, Enlil_Collection *col); Modified: trunk/enlil/src/enlil/root.c =================================================================== --- trunk/enlil/src/enlil/root.c 2010-11-11 20:34:35 UTC (rev 54479) +++ trunk/enlil/src/enlil/root.c 2010-11-11 21:28:07 UTC (rev 54480) @@ -991,7 +991,6 @@ ASSERT_RETURN(root!=NULL); - printf("%s/\n", enlil_root_path_get(root)); snprintf(path,PATH_MAX,"%s/"EET_FILE,enlil_root_path_get(root)); f = enlil_file_manager_open(path); ASSERT_RETURN(f!=NULL); @@ -1247,4 +1246,40 @@ return root->conf; } +Enlil_Photo * enlil_root_first_photo_get(const char *library_path) +{ + char buf[PATH_MAX]; + Eina_Bool found = EINA_TRUE, found2 = EINA_TRUE; + Enlil_Photo *photo = NULL; + char *folder, *file; + Eina_List *folders = ecore_file_ls(library_path); + EINA_LIST_FREE(folders, folder) + { + if(found) + { + snprintf(buf, PATH_MAX, "%s/%s", library_path, folder); + Eina_List *files = ecore_file_ls(buf); + + EINA_LIST_FREE(files, file) + { + + if(found2) + { + if( enlil_photo_is(file) ) + { + photo = enlil_photo_new(); + enlil_photo_path_set(photo, buf); + enlil_photo_file_name_set(photo, file); + found2 = EINA_FALSE; + found = EINA_FALSE; + } + } + FREE(file); + } + } + FREE(folder); + } + + return photo; +} |