Enlightenment CVS committal Author : rephorm Project : e17 Module : libs/efreet
Dir : e17/libs/efreet/src/lib Modified Files: efreet_icon.c Log Message: cache at actual icon size when doing directory scan. additionally cache at search size (if different) when doing an icon lookup this fixes a bug where an icon other than the closest size was getting returned if the exact size didn't exist =================================================================== RCS file: /cvs/e/e17/libs/efreet/src/lib/efreet_icon.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- efreet_icon.c 26 Mar 2007 16:17:40 -0000 1.4 +++ efreet_icon.c 26 Mar 2007 22:28:28 -0000 1.5 @@ -23,8 +23,7 @@ static Efreet_Icon *efreet_icon_lookup_directory( Efreet_Icon_Theme *theme, Efreet_Icon_Theme_Directory *dir, - const char *icon_name, - unsigned int size); + const char *icon_name); static int efreet_icon_directory_size_distance(Efreet_Icon_Theme_Directory *dir, unsigned int size); static int efreet_icon_directory_size_match(Efreet_Icon_Theme_Directory *dir, @@ -43,8 +42,7 @@ const char *key, void *value); static void efreet_icon_directory_cache(Efreet_Icon_Theme *theme, Efreet_Icon_Theme_Directory *dir, - const char *path, - unsigned int size); + const char *path); static Efreet_Icon_Theme *efreet_icon_theme_new(void); static void efreet_icon_theme_free(Efreet_Icon_Theme *theme); @@ -356,8 +354,8 @@ while ((dir = ecore_list_next(theme->directories))) { if (!efreet_icon_directory_size_match(dir, real_size)) continue; - icon = efreet_icon_lookup_directory(theme, dir, - icon_name, real_size); + icon = efreet_icon_lookup_directory(theme, dir, + icon_name); if (icon) return icon; } @@ -371,14 +369,28 @@ if (distance >= minimal_size) continue; tmp = efreet_icon_lookup_directory(theme, dir, - icon_name, - real_size); + icon_name); if (tmp) { icon = tmp; minimal_size = distance; } } + + if (icon) + { + char cache_key[PATH_MAX]; + const char *key; + Efreet_Icon *value; + + snprintf(cache_key, sizeof(cache_key), "[EMAIL PROTECTED]", icon_name, real_size, real_size); + key = ecore_string_instance(cache_key); + + if (!efreet_icon_cache_get(theme, key)) + efreet_icon_cache_set(theme, key, icon); + else + ecore_string_release(cache_key); + } return icon; } @@ -397,10 +409,10 @@ static Efreet_Icon * efreet_icon_lookup_directory(Efreet_Icon_Theme *theme, Efreet_Icon_Theme_Directory *dir, - const char *icon_name, unsigned int size) + const char *icon_name) { if (theme->paths.count == 1) - efreet_icon_directory_cache(theme, dir, theme->paths.path, size); + efreet_icon_directory_cache(theme, dir, theme->paths.path); else { @@ -408,10 +420,10 @@ ecore_list_goto_first(theme->paths.path); while ((path = ecore_list_next(theme->paths.path))) - efreet_icon_directory_cache(theme, dir, path, size); + efreet_icon_directory_cache(theme, dir, path); } - return efreet_icon_cache_check(theme, icon_name, size); + return efreet_icon_cache_check(theme, icon_name, dir->size.normal); } /** @@ -563,15 +575,13 @@ * @param theme: The theme to work with * @param dir: The theme directory to work with * @param path: The partial path to use - * @param size: The size to look for * @return Returns no value * @brief Caches the icons in the given theme directory path at the given * size */ static void efreet_icon_directory_cache(Efreet_Icon_Theme *theme, - Efreet_Icon_Theme_Directory *dir, const char *path, - unsigned int size) + Efreet_Icon_Theme_Directory *dir, const char *path) { char file_path[PATH_MAX], size_str[10]; const char *dir_key, *path_strs[] = { path, "/", dir->name, NULL }; @@ -590,11 +600,11 @@ /* if we've already cached this directory don't do it again */ dir_key = ecore_string_instance(file_path); - if (ecore_hash_get(efreet_icon_dirs_cached, dir_key)) - return; + if (ecore_hash_get(efreet_icon_dirs_cached, dir_key)) return; + ecore_hash_set(efreet_icon_dirs_cached, (void *)dir_key, (void *)1); - snprintf(size_str, sizeof(size_str), "%d", size); + snprintf(size_str, sizeof(size_str), "%d", dir->size.normal); dirp = opendir(file_path); if (dirp) { @@ -636,14 +646,15 @@ /* No icon present, build a full path and generate icon */ efreet_array_cat(file_path, sizeof(file_path), icon_path); value = efreet_icon_new(file_path); - } - /* Add icon to cache */ - if (value) - { - value->ref_count ++; - ecore_hash_set(theme->icon_cache, (void *)key, value); + /* Add icon to cache */ + if (value) + { + value->ref_count++; + ecore_hash_set(theme->icon_cache, (void *)key, value); + } } + } closedir(dirp); } ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs