forked from enlightenment/efl
parent
7279143b7e
commit
0b519a6f7d
|
@ -54,3 +54,7 @@
|
||||||
|
|
||||||
* Prefix internal efreet cache keys with __
|
* Prefix internal efreet cache keys with __
|
||||||
|
|
||||||
|
2011-01-XX Sebastian Dransfeld
|
||||||
|
|
||||||
|
* Create one cache file for each theme
|
||||||
|
|
||||||
|
|
|
@ -641,10 +641,12 @@ main(int argc, char **argv)
|
||||||
Eina_Iterator *it;
|
Eina_Iterator *it;
|
||||||
Efreet_Cache_Version *icon_version;
|
Efreet_Cache_Version *icon_version;
|
||||||
Efreet_Cache_Version *theme_version;
|
Efreet_Cache_Version *theme_version;
|
||||||
Efreet_Cache_Icons *cache;
|
|
||||||
Efreet_Cache_Icon_Theme *theme;
|
Efreet_Cache_Icon_Theme *theme;
|
||||||
|
Efreet_Cache_Icon *icon;
|
||||||
Eet_Data_Descriptor *theme_edd;
|
Eet_Data_Descriptor *theme_edd;
|
||||||
Eet_Data_Descriptor *edd;
|
Eet_Data_Descriptor *icon_edd;
|
||||||
|
Eet_Data_Descriptor *fallback_edd;
|
||||||
|
Eina_Hash *icons;
|
||||||
Eet_File *icon_ef;
|
Eet_File *icon_ef;
|
||||||
Eet_File *theme_ef;
|
Eet_File *theme_ef;
|
||||||
Eina_List *xdg_dirs = NULL;
|
Eina_List *xdg_dirs = NULL;
|
||||||
|
@ -690,40 +692,19 @@ main(int argc, char **argv)
|
||||||
if (lockfd == -1) return -1;
|
if (lockfd == -1) return -1;
|
||||||
|
|
||||||
/* create dir for icon cache */
|
/* create dir for icon cache */
|
||||||
dir = ecore_file_dir_get(efreet_icon_cache_file());
|
dir = ecore_file_dir_get(efreet_icon_cache_file(EFREET_CACHE_ICON_FALLBACK));
|
||||||
if (!ecore_file_mkpath(dir)) goto on_error;
|
if (!ecore_file_mkpath(dir)) goto on_error;
|
||||||
free(dir);
|
free(dir);
|
||||||
|
|
||||||
/* finish efreet init */
|
/* finish efreet init */
|
||||||
if (!efreet_init()) goto on_error;
|
if (!efreet_init()) goto on_error;
|
||||||
/* Need to init edd's, so they are like we want, not like userspace wants */
|
/* Need to init edd's, so they are like we want, not like userspace wants */
|
||||||
|
icon_edd = efreet_icon_edd();
|
||||||
|
fallback_edd = efreet_icon_fallback_edd();
|
||||||
theme_edd = efreet_icon_theme_edd(EINA_TRUE);
|
theme_edd = efreet_icon_theme_edd(EINA_TRUE);
|
||||||
|
|
||||||
icon_themes = eina_hash_string_superfast_new(EINA_FREE_CB(icon_theme_free));
|
icon_themes = eina_hash_string_superfast_new(EINA_FREE_CB(icon_theme_free));
|
||||||
|
|
||||||
/* open icon file */
|
|
||||||
icon_ef = eet_open(efreet_icon_cache_file(), EET_FILE_MODE_READ_WRITE);
|
|
||||||
if (!icon_ef) goto on_error_efreet;
|
|
||||||
icon_version = eet_data_read(icon_ef, efreet_version_edd(), EFREET_CACHE_VERSION);
|
|
||||||
if (icon_version &&
|
|
||||||
((icon_version->major != EFREET_ICON_CACHE_MAJOR) ||
|
|
||||||
(icon_version->minor != EFREET_ICON_CACHE_MINOR)))
|
|
||||||
{
|
|
||||||
// delete old cache
|
|
||||||
eet_close(icon_ef);
|
|
||||||
if (unlink(efreet_icon_cache_file()) < 0)
|
|
||||||
{
|
|
||||||
if (errno != ENOENT) goto on_error_efreet;
|
|
||||||
}
|
|
||||||
icon_ef = eet_open(efreet_icon_cache_file(), EET_FILE_MODE_READ_WRITE);
|
|
||||||
if (!icon_ef) goto on_error_efreet;
|
|
||||||
}
|
|
||||||
if (!icon_version)
|
|
||||||
icon_version = NEW(Efreet_Cache_Version, 1);
|
|
||||||
|
|
||||||
icon_version->major = EFREET_ICON_CACHE_MAJOR;
|
|
||||||
icon_version->minor = EFREET_ICON_CACHE_MINOR;
|
|
||||||
|
|
||||||
/* open theme file */
|
/* open theme file */
|
||||||
theme_ef = eet_open(efreet_icon_theme_cache_file(), EET_FILE_MODE_READ_WRITE);
|
theme_ef = eet_open(efreet_icon_theme_cache_file(), EET_FILE_MODE_READ_WRITE);
|
||||||
if (!theme_ef) goto on_error_efreet;
|
if (!theme_ef) goto on_error_efreet;
|
||||||
|
@ -781,33 +762,56 @@ main(int argc, char **argv)
|
||||||
cache_theme_scan("/usr/share/pixmaps");
|
cache_theme_scan("/usr/share/pixmaps");
|
||||||
|
|
||||||
/* scan icons */
|
/* scan icons */
|
||||||
edd = efreet_icons_edd();
|
|
||||||
it = eina_hash_iterator_data_new(icon_themes);
|
it = eina_hash_iterator_data_new(icon_themes);
|
||||||
EINA_ITERATOR_FOREACH(it, theme)
|
EINA_ITERATOR_FOREACH(it, theme)
|
||||||
{
|
{
|
||||||
Eina_Hash *themes;
|
Eina_Hash *themes;
|
||||||
|
|
||||||
if (!theme->valid || theme->hidden) continue;
|
if (!theme->valid) continue;
|
||||||
#ifndef STRICT_SPEC
|
#ifndef STRICT_SPEC
|
||||||
if (!theme->theme.name.name) continue;
|
if (!theme->theme.name.name) continue;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
changed = EINA_FALSE;
|
||||||
themes = eina_hash_string_superfast_new(NULL);
|
themes = eina_hash_string_superfast_new(NULL);
|
||||||
|
|
||||||
/* read icons from the eet file */
|
/* open icon file */
|
||||||
cache = eet_data_read(icon_ef, edd, theme->theme.name.internal);
|
icon_ef = eet_open(efreet_icon_cache_file(theme->theme.name.internal), EET_FILE_MODE_READ_WRITE);
|
||||||
|
if (!icon_ef) goto on_error_efreet;
|
||||||
/* No existing cache before, so create it */
|
icon_version = eet_data_read(icon_ef, efreet_version_edd(), EFREET_CACHE_VERSION);
|
||||||
if (!cache)
|
if (icon_version &&
|
||||||
|
((icon_version->major != EFREET_ICON_CACHE_MAJOR) ||
|
||||||
|
(icon_version->minor != EFREET_ICON_CACHE_MINOR)))
|
||||||
{
|
{
|
||||||
cache = NEW(Efreet_Cache_Icons, 1);
|
// delete old cache
|
||||||
if (!cache) goto on_error_efreet;
|
eet_close(icon_ef);
|
||||||
|
if (unlink(efreet_icon_cache_file(theme->theme.name.internal)) < 0)
|
||||||
|
{
|
||||||
|
if (errno != ENOENT) goto on_error_efreet;
|
||||||
|
}
|
||||||
|
icon_ef = eet_open(efreet_icon_cache_file(theme->theme.name.internal), EET_FILE_MODE_READ_WRITE);
|
||||||
|
if (!icon_ef) goto on_error_efreet;
|
||||||
changed = EINA_TRUE;
|
changed = EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
if (!icon_version)
|
||||||
|
icon_version = NEW(Efreet_Cache_Version, 1);
|
||||||
|
|
||||||
if (!cache->icons)
|
icon_version->major = EFREET_ICON_CACHE_MAJOR;
|
||||||
cache->icons = eina_hash_string_superfast_new(NULL);
|
icon_version->minor = EFREET_ICON_CACHE_MINOR;
|
||||||
|
|
||||||
|
/* load icons */
|
||||||
|
icons = eina_hash_string_superfast_new(NULL);
|
||||||
|
keys = eet_list(icon_ef, "*", &num);
|
||||||
|
if (keys)
|
||||||
|
{
|
||||||
|
for (i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
if (!strncmp(keys[i], "__efreet", 8)) continue;
|
||||||
|
icon = eet_data_read(icon_ef, icon_edd, keys[i]);
|
||||||
|
if (icon) eina_hash_add(icons, keys[i], icon);
|
||||||
|
}
|
||||||
|
free(keys);
|
||||||
|
}
|
||||||
|
|
||||||
changed = theme->changed = check_changed(theme);
|
changed = theme->changed = check_changed(theme);
|
||||||
if (theme->changed && theme->dirs)
|
if (theme->changed && theme->dirs)
|
||||||
|
@ -818,42 +822,76 @@ main(int argc, char **argv)
|
||||||
if (!theme->dirs)
|
if (!theme->dirs)
|
||||||
theme->dirs = eina_hash_string_superfast_new(NULL);
|
theme->dirs = eina_hash_string_superfast_new(NULL);
|
||||||
|
|
||||||
if (cache_scan(&(theme->theme), themes, cache->icons, theme->dirs, &changed))
|
if (cache_scan(&(theme->theme), themes, icons, theme->dirs, &changed))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "generated: '%s' %i (%i)\n",
|
fprintf(stderr, "generated: '%s' %i (%i)\n",
|
||||||
theme->theme.name.internal,
|
theme->theme.name.internal,
|
||||||
changed,
|
changed,
|
||||||
eina_hash_population(cache->icons));
|
eina_hash_population(icons));
|
||||||
if (changed)
|
if (changed)
|
||||||
eet_data_write(icon_ef, edd, theme->theme.name.internal, cache, 1);
|
{
|
||||||
changed = EINA_FALSE;
|
Eina_Iterator *icons_it;
|
||||||
|
Eina_Hash_Tuple *tuple;
|
||||||
|
|
||||||
|
icons_it = eina_hash_iterator_tuple_new(icons);
|
||||||
|
EINA_ITERATOR_FOREACH(icons_it, tuple)
|
||||||
|
eet_data_write(icon_ef, icon_edd, tuple->key, tuple->data, 1);
|
||||||
|
eina_iterator_free(icons_it);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
eina_hash_free(themes);
|
eina_hash_free(themes);
|
||||||
efreet_hash_free(cache->icons, EINA_FREE_CB(efreet_cache_icon_free));
|
efreet_hash_free(icons, EINA_FREE_CB(efreet_cache_icon_free));
|
||||||
free(cache);
|
|
||||||
|
|
||||||
/* TODO: Only write if changed */
|
if (theme->changed || changed)
|
||||||
|
{
|
||||||
|
if (theme->changed)
|
||||||
|
fprintf(stderr, "theme change: %s %lld\n", theme->theme.name.internal, theme->last_cache_check);
|
||||||
eet_data_write(theme_ef, theme_edd, theme->theme.name.internal, theme, 1);
|
eet_data_write(theme_ef, theme_edd, theme->theme.name.internal, theme, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eet_data_write(icon_ef, efreet_version_edd(), EFREET_CACHE_VERSION, icon_version, 1);
|
||||||
|
eet_close(icon_ef);
|
||||||
|
free(icon_version);
|
||||||
|
}
|
||||||
eina_iterator_free(it);
|
eina_iterator_free(it);
|
||||||
|
|
||||||
edd = efreet_icons_fallback_edd();
|
/* open icon file */
|
||||||
|
icon_ef = eet_open(efreet_icon_cache_file(EFREET_CACHE_ICON_FALLBACK), EET_FILE_MODE_READ_WRITE);
|
||||||
/* read fallback icons from the eet file */
|
if (!icon_ef) goto on_error_efreet;
|
||||||
cache = eet_data_read(icon_ef, edd, EFREET_CACHE_ICON_FALLBACK);
|
icon_version = eet_data_read(icon_ef, efreet_version_edd(), EFREET_CACHE_VERSION);
|
||||||
|
if (icon_version &&
|
||||||
/* No existing fallback, create it */
|
((icon_version->major != EFREET_ICON_CACHE_MAJOR) ||
|
||||||
if (!cache)
|
(icon_version->minor != EFREET_ICON_CACHE_MINOR)))
|
||||||
{
|
{
|
||||||
cache = NEW(Efreet_Cache_Icons, 1);
|
// delete old cache
|
||||||
if (!cache) goto on_error_efreet;
|
eet_close(icon_ef);
|
||||||
|
if (unlink(efreet_icon_cache_file(EFREET_CACHE_ICON_FALLBACK)) < 0)
|
||||||
|
{
|
||||||
|
if (errno != ENOENT) goto on_error_efreet;
|
||||||
|
}
|
||||||
|
icon_ef = eet_open(efreet_icon_cache_file(EFREET_CACHE_ICON_FALLBACK), EET_FILE_MODE_READ_WRITE);
|
||||||
|
if (!icon_ef) goto on_error_efreet;
|
||||||
changed = EINA_TRUE;
|
changed = EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
if (!icon_version)
|
||||||
|
icon_version = NEW(Efreet_Cache_Version, 1);
|
||||||
|
|
||||||
if (!cache->icons)
|
icon_version->major = EFREET_ICON_CACHE_MAJOR;
|
||||||
cache->icons = eina_hash_string_superfast_new(NULL);
|
icon_version->minor = EFREET_ICON_CACHE_MINOR;
|
||||||
|
|
||||||
|
icons = eina_hash_string_superfast_new(NULL);
|
||||||
|
keys = eet_list(icon_ef, "*", &num);
|
||||||
|
if (keys)
|
||||||
|
{
|
||||||
|
for (i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
if (!strncmp(keys[i], "__efreet", 8)) continue;
|
||||||
|
icon = eet_data_read(icon_ef, fallback_edd, keys[i]);
|
||||||
|
if (icon) eina_hash_add(icons, keys[i], icon);
|
||||||
|
}
|
||||||
|
free(keys);
|
||||||
|
}
|
||||||
|
|
||||||
theme = eet_data_read(theme_ef, theme_edd, EFREET_CACHE_ICON_FALLBACK);
|
theme = eet_data_read(theme_ef, theme_edd, EFREET_CACHE_ICON_FALLBACK);
|
||||||
if (!theme)
|
if (!theme)
|
||||||
|
@ -862,22 +900,32 @@ main(int argc, char **argv)
|
||||||
theme->dirs = eina_hash_string_superfast_new(NULL);
|
theme->dirs = eina_hash_string_superfast_new(NULL);
|
||||||
|
|
||||||
/* Save fallback in the right part */
|
/* Save fallback in the right part */
|
||||||
if (cache_fallback_scan(cache->icons, theme->dirs, &changed))
|
if (cache_fallback_scan(icons, theme->dirs, &changed))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "generated: fallback %i (%i)\n", changed, eina_hash_population(cache->icons));
|
fprintf(stderr, "generated: fallback %i (%i)\n", changed, eina_hash_population(icons));
|
||||||
if (changed)
|
if (changed)
|
||||||
eet_data_write(icon_ef, edd, EFREET_CACHE_ICON_FALLBACK, cache, 1);
|
{
|
||||||
|
Eina_Iterator *icons_it;
|
||||||
|
Eina_Hash_Tuple *tuple;
|
||||||
|
|
||||||
|
icons_it = eina_hash_iterator_tuple_new(icons);
|
||||||
|
EINA_ITERATOR_FOREACH(icons_it, tuple)
|
||||||
|
eet_data_write(icon_ef, fallback_edd, tuple->key, tuple->data, 1);
|
||||||
|
eina_iterator_free(icons_it);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
efreet_hash_free(cache->icons, EINA_FREE_CB(efreet_cache_icon_fallback_free));
|
efreet_hash_free(icons, EINA_FREE_CB(efreet_cache_icon_fallback_free));
|
||||||
free(cache);
|
eet_data_write(theme_ef, theme_edd, EFREET_CACHE_ICON_FALLBACK, theme, 1);
|
||||||
|
icon_theme_free(theme);
|
||||||
|
|
||||||
|
eet_data_write(icon_ef, efreet_version_edd(), EFREET_CACHE_VERSION, icon_version, 1);
|
||||||
|
eet_close(icon_ef);
|
||||||
|
free(icon_version);
|
||||||
|
|
||||||
eina_hash_free(icon_themes);
|
eina_hash_free(icon_themes);
|
||||||
|
|
||||||
/* save data */
|
/* save data */
|
||||||
eet_data_write(icon_ef, efreet_version_edd(), EFREET_CACHE_VERSION, icon_version, 1);
|
|
||||||
eet_close(icon_ef);
|
|
||||||
free(icon_version);
|
|
||||||
eet_data_write(theme_ef, efreet_version_edd(), EFREET_CACHE_VERSION, theme_version, 1);
|
eet_data_write(theme_ef, efreet_version_edd(), EFREET_CACHE_VERSION, theme_version, 1);
|
||||||
eet_close(theme_ef);
|
eet_close(theme_ef);
|
||||||
free(theme_version);
|
free(theme_version);
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* TODO: Add local hash cache for icons */
|
||||||
|
/* TODO: Pass extra icon dirs to cache process */
|
||||||
|
/* TODO: Pass icon extensions to cache process */
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -35,8 +39,6 @@ static int _efreet_cache_log_dom = -1;
|
||||||
static Eet_Data_Descriptor *directory_edd = NULL;
|
static Eet_Data_Descriptor *directory_edd = NULL;
|
||||||
static Eet_Data_Descriptor *icon_theme_edd = NULL;
|
static Eet_Data_Descriptor *icon_theme_edd = NULL;
|
||||||
static Eet_Data_Descriptor *icon_theme_directory_edd = NULL;
|
static Eet_Data_Descriptor *icon_theme_directory_edd = NULL;
|
||||||
static Eet_Data_Descriptor *icons_edd = NULL;
|
|
||||||
static Eet_Data_Descriptor *fallback_edd = NULL;
|
|
||||||
|
|
||||||
static Eet_Data_Descriptor *icon_fallback_edd = NULL;
|
static Eet_Data_Descriptor *icon_fallback_edd = NULL;
|
||||||
static Eet_Data_Descriptor *icon_element_pointer_edd = NULL;
|
static Eet_Data_Descriptor *icon_element_pointer_edd = NULL;
|
||||||
|
@ -44,13 +46,12 @@ static Eet_Data_Descriptor *icon_element_edd = NULL;
|
||||||
static Eet_Data_Descriptor *icon_edd = NULL;
|
static Eet_Data_Descriptor *icon_edd = NULL;
|
||||||
|
|
||||||
static Eet_File *icon_cache = NULL;
|
static Eet_File *icon_cache = NULL;
|
||||||
|
static Eet_File *fallback_cache = NULL;
|
||||||
static Eet_File *icon_theme_cache = NULL;
|
static Eet_File *icon_theme_cache = NULL;
|
||||||
|
|
||||||
static const char *icon_theme_cache_file = NULL;
|
static const char *icon_theme_cache_file = NULL;
|
||||||
|
|
||||||
static const char *theme_name = NULL;
|
static const char *theme_name = NULL;
|
||||||
static Efreet_Cache_Icons *theme_cache = NULL;
|
|
||||||
static Efreet_Cache_Icons *fallback_cache = NULL;
|
|
||||||
|
|
||||||
static Eet_Data_Descriptor *version_edd = NULL;
|
static Eet_Data_Descriptor *version_edd = NULL;
|
||||||
static Eet_Data_Descriptor *desktop_edd = NULL;
|
static Eet_Data_Descriptor *desktop_edd = NULL;
|
||||||
|
@ -74,8 +75,6 @@ static int desktop_cache_exe_lock = -1;
|
||||||
|
|
||||||
static Eina_List *old_desktop_caches = NULL;
|
static Eina_List *old_desktop_caches = NULL;
|
||||||
|
|
||||||
static Efreet_Cache_Icons *_efreet_cache_free(Efreet_Cache_Icons *cache);
|
|
||||||
static Efreet_Cache_Icons *_efreet_cache_fallback_free(Efreet_Cache_Icons *cache);
|
|
||||||
static void efreet_cache_edd_shutdown(void);
|
static void efreet_cache_edd_shutdown(void);
|
||||||
|
|
||||||
static Eina_Bool cache_exe_cb(void *data, int type, void *event);
|
static Eina_Bool cache_exe_cb(void *data, int type, void *event);
|
||||||
|
@ -135,9 +134,6 @@ efreet_cache_shutdown(void)
|
||||||
{
|
{
|
||||||
Efreet_Old_Cache *d;
|
Efreet_Old_Cache *d;
|
||||||
|
|
||||||
theme_cache = _efreet_cache_free(theme_cache);
|
|
||||||
fallback_cache = _efreet_cache_fallback_free(fallback_cache);
|
|
||||||
|
|
||||||
IF_RELEASE(theme_name);
|
IF_RELEASE(theme_name);
|
||||||
|
|
||||||
icon_cache = efreet_cache_close(icon_cache);
|
icon_cache = efreet_cache_close(icon_cache);
|
||||||
|
@ -184,14 +180,14 @@ efreet_cache_shutdown(void)
|
||||||
* Needs EAPI because of helper binaries
|
* Needs EAPI because of helper binaries
|
||||||
*/
|
*/
|
||||||
EAPI const char *
|
EAPI const char *
|
||||||
efreet_icon_cache_file(void)
|
efreet_icon_cache_file(const char *theme)
|
||||||
{
|
{
|
||||||
static char cache_file[PATH_MAX] = { '\0' };
|
static char cache_file[PATH_MAX] = { '\0' };
|
||||||
const char *cache;
|
const char *cache;
|
||||||
|
|
||||||
cache = efreet_cache_home_get();
|
cache = efreet_cache_home_get();
|
||||||
|
|
||||||
snprintf(cache_file, sizeof(cache_file), "%s/efreet/icons_%s.eet", cache, efreet_hostname_get());
|
snprintf(cache_file, sizeof(cache_file), "%s/efreet/icons_%s_%s.eet", cache, theme, efreet_hostname_get());
|
||||||
|
|
||||||
return cache_file;
|
return cache_file;
|
||||||
}
|
}
|
||||||
|
@ -353,10 +349,8 @@ efreet_cache_edd_shutdown(void)
|
||||||
EDD_SHUTDOWN(hash_array_string_edd);
|
EDD_SHUTDOWN(hash_array_string_edd);
|
||||||
EDD_SHUTDOWN(array_string_edd);
|
EDD_SHUTDOWN(array_string_edd);
|
||||||
EDD_SHUTDOWN(hash_string_edd);
|
EDD_SHUTDOWN(hash_string_edd);
|
||||||
EDD_SHUTDOWN(fallback_edd);
|
|
||||||
EDD_SHUTDOWN(icon_theme_edd);
|
EDD_SHUTDOWN(icon_theme_edd);
|
||||||
EDD_SHUTDOWN(icon_theme_directory_edd);
|
EDD_SHUTDOWN(icon_theme_directory_edd);
|
||||||
EDD_SHUTDOWN(icons_edd);
|
|
||||||
EDD_SHUTDOWN(directory_edd);
|
EDD_SHUTDOWN(directory_edd);
|
||||||
EDD_SHUTDOWN(icon_fallback_edd);
|
EDD_SHUTDOWN(icon_fallback_edd);
|
||||||
EDD_SHUTDOWN(icon_element_pointer_edd);
|
EDD_SHUTDOWN(icon_element_pointer_edd);
|
||||||
|
@ -378,28 +372,6 @@ efreet_cache_edd_shutdown(void)
|
||||||
"pointer", pointer, Edd_Source); \
|
"pointer", pointer, Edd_Source); \
|
||||||
}
|
}
|
||||||
|
|
||||||
static Efreet_Cache_Icons *
|
|
||||||
_efreet_cache_free(Efreet_Cache_Icons *c)
|
|
||||||
{
|
|
||||||
if (!c) return NULL;
|
|
||||||
|
|
||||||
if (c->icons) efreet_hash_free(c->icons, EINA_FREE_CB(efreet_cache_icon_free));
|
|
||||||
free(c);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Efreet_Cache_Icons *
|
|
||||||
_efreet_cache_fallback_free(Efreet_Cache_Icons *c)
|
|
||||||
{
|
|
||||||
if (!c) return NULL;
|
|
||||||
|
|
||||||
if (c->icons) efreet_hash_free(c->icons, EINA_FREE_CB(efreet_cache_icon_fallback_free));
|
|
||||||
free(c);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Eet_Data_Descriptor *
|
static Eet_Data_Descriptor *
|
||||||
efreet_icon_directory_edd(void)
|
efreet_icon_directory_edd(void)
|
||||||
{
|
{
|
||||||
|
@ -421,11 +393,11 @@ efreet_icon_directory_edd(void)
|
||||||
* Needs EAPI because of helper binaries
|
* Needs EAPI because of helper binaries
|
||||||
*/
|
*/
|
||||||
EAPI Eet_Data_Descriptor *
|
EAPI Eet_Data_Descriptor *
|
||||||
efreet_icons_edd(void)
|
efreet_icon_edd(void)
|
||||||
{
|
{
|
||||||
Eet_Data_Descriptor_Class eddc;
|
Eet_Data_Descriptor_Class eddc;
|
||||||
|
|
||||||
if (icons_edd) return icons_edd;
|
if (icon_edd) return icon_edd;
|
||||||
|
|
||||||
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Icon_Element);
|
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Icon_Element);
|
||||||
icon_element_edd = eet_data_descriptor_file_new(&eddc);
|
icon_element_edd = eet_data_descriptor_file_new(&eddc);
|
||||||
|
@ -455,14 +427,7 @@ efreet_icons_edd(void)
|
||||||
EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(icon_edd, Efreet_Cache_Icon,
|
EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(icon_edd, Efreet_Cache_Icon,
|
||||||
"icons", icons, icon_element_pointer_edd);
|
"icons", icons, icon_element_pointer_edd);
|
||||||
|
|
||||||
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Icons);
|
return icon_edd;
|
||||||
icons_edd = eet_data_descriptor_file_new(&eddc);
|
|
||||||
if (!icons_edd) return NULL;
|
|
||||||
|
|
||||||
EET_DATA_DESCRIPTOR_ADD_HASH(icons_edd, Efreet_Cache_Icons,
|
|
||||||
"icons", icons, icon_edd);
|
|
||||||
|
|
||||||
return icons_edd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -533,11 +498,11 @@ efreet_icon_theme_edd(Eina_Bool cache)
|
||||||
* Needs EAPI because of helper binaries
|
* Needs EAPI because of helper binaries
|
||||||
*/
|
*/
|
||||||
EAPI Eet_Data_Descriptor *
|
EAPI Eet_Data_Descriptor *
|
||||||
efreet_icons_fallback_edd(void)
|
efreet_icon_fallback_edd(void)
|
||||||
{
|
{
|
||||||
Eet_Data_Descriptor_Class eddc;
|
Eet_Data_Descriptor_Class eddc;
|
||||||
|
|
||||||
if (fallback_edd) return fallback_edd;
|
if (icon_fallback_edd) return icon_fallback_edd;
|
||||||
|
|
||||||
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Fallback_Icon);
|
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Fallback_Icon);
|
||||||
icon_fallback_edd = eet_data_descriptor_file_new(&eddc);
|
icon_fallback_edd = eet_data_descriptor_file_new(&eddc);
|
||||||
|
@ -546,14 +511,7 @@ efreet_icons_fallback_edd(void)
|
||||||
EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY_STRING(icon_fallback_edd,
|
EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY_STRING(icon_fallback_edd,
|
||||||
Efreet_Cache_Fallback_Icon, "icons", icons);
|
Efreet_Cache_Fallback_Icon, "icons", icons);
|
||||||
|
|
||||||
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Icons);
|
return icon_fallback_edd;
|
||||||
fallback_edd = eet_data_descriptor_file_new(&eddc);
|
|
||||||
if (!fallback_edd) return NULL;
|
|
||||||
|
|
||||||
EET_DATA_DESCRIPTOR_ADD_HASH(fallback_edd, Efreet_Cache_Icons,
|
|
||||||
"icons", icons, icon_fallback_edd);
|
|
||||||
|
|
||||||
return fallback_edd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -628,47 +586,27 @@ efreet_cache_icon_fallback_free(Efreet_Cache_Fallback_Icon *icon)
|
||||||
Efreet_Cache_Icon *
|
Efreet_Cache_Icon *
|
||||||
efreet_cache_icon_find(Efreet_Icon_Theme *theme, const char *icon)
|
efreet_cache_icon_find(Efreet_Icon_Theme *theme, const char *icon)
|
||||||
{
|
{
|
||||||
if (!efreet_cache_check(&icon_cache, efreet_icon_cache_file(), EFREET_ICON_CACHE_MAJOR)) return NULL;
|
|
||||||
|
|
||||||
if (theme_name && strcmp(theme_name, theme->name.internal))
|
if (theme_name && strcmp(theme_name, theme->name.internal))
|
||||||
{
|
{
|
||||||
/* FIXME: this is bad if people have pointer to this cache, things will go wrong */
|
/* FIXME: this is bad if people have pointer to this cache, things will go wrong */
|
||||||
INFO("theme_name change from `%s` to `%s`", theme_name, theme->name.internal);
|
INFO("theme_name change from `%s` to `%s`", theme_name, theme->name.internal);
|
||||||
IF_RELEASE(theme_name);
|
IF_RELEASE(theme_name);
|
||||||
theme_cache = _efreet_cache_free(theme_cache);
|
icon_cache = efreet_cache_close(icon_cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!efreet_cache_check(&icon_cache, efreet_icon_cache_file(theme->name.internal), EFREET_ICON_CACHE_MAJOR)) return NULL;
|
||||||
if (!theme_name)
|
if (!theme_name)
|
||||||
{
|
|
||||||
INFO("loading theme %s", theme->name.internal);
|
|
||||||
theme_cache = eet_data_read(icon_cache, efreet_icons_edd(), theme->name.internal);
|
|
||||||
if (theme_cache && !theme_cache->icons)
|
|
||||||
theme_cache->icons = eina_hash_string_superfast_new(NULL);
|
|
||||||
if (theme_cache)
|
|
||||||
theme_name = eina_stringshare_add(theme->name.internal);
|
theme_name = eina_stringshare_add(theme->name.internal);
|
||||||
}
|
|
||||||
|
|
||||||
if (!theme_cache) return NULL;
|
return eet_data_read(icon_cache, efreet_icon_edd(), icon);
|
||||||
|
|
||||||
return eina_hash_find(theme_cache->icons, icon);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Efreet_Cache_Fallback_Icon *
|
Efreet_Cache_Fallback_Icon *
|
||||||
efreet_cache_icon_fallback_find(const char *icon)
|
efreet_cache_icon_fallback_find(const char *icon)
|
||||||
{
|
{
|
||||||
if (!efreet_cache_check(&icon_cache, efreet_icon_cache_file(), EFREET_ICON_CACHE_MAJOR)) return NULL;
|
if (!efreet_cache_check(&fallback_cache, efreet_icon_cache_file(EFREET_CACHE_ICON_FALLBACK), EFREET_ICON_CACHE_MAJOR)) return NULL;
|
||||||
|
|
||||||
if (!fallback_cache)
|
return eet_data_read(fallback_cache, efreet_icon_fallback_edd(), icon);
|
||||||
{
|
|
||||||
INFO("loading fallback cache");
|
|
||||||
fallback_cache = eet_data_read(icon_cache, efreet_icons_fallback_edd(), EFREET_CACHE_ICON_FALLBACK);
|
|
||||||
if (fallback_cache && !fallback_cache->icons)
|
|
||||||
fallback_cache->icons = eina_hash_string_superfast_new(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fallback_cache) return NULL;
|
|
||||||
|
|
||||||
return eina_hash_find(fallback_cache->icons, icon);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Efreet_Icon_Theme *
|
Efreet_Icon_Theme *
|
||||||
|
@ -703,11 +641,10 @@ efreet_cache_icon_theme_name_list(int *num)
|
||||||
keys = eet_list(icon_theme_cache, "*", num);
|
keys = eet_list(icon_theme_cache, "*", num);
|
||||||
for (i = 0; i < *num; i++)
|
for (i = 0; i < *num; i++)
|
||||||
{
|
{
|
||||||
if (!strcmp(keys[i], EFREET_CACHE_VERSION) && (i < (*num + 1)))
|
if (!strncmp(keys[i], "__efreet", 8) && (i < (*num + 1)))
|
||||||
{
|
{
|
||||||
memmove(&keys[i], &keys[i + 1], (*num - i - 1) * sizeof(char *));
|
memmove(&keys[i], &keys[i + 1], (*num - i - 1) * sizeof(char *));
|
||||||
(*num)--;
|
(*num)--;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return keys;
|
return keys;
|
||||||
|
@ -881,21 +818,10 @@ cache_update_cb(void *data __UNUSED__, Ecore_File_Monitor *em __UNUSED__,
|
||||||
d = NEW(Efreet_Old_Cache, 1);
|
d = NEW(Efreet_Old_Cache, 1);
|
||||||
if (!d) goto error;
|
if (!d) goto error;
|
||||||
|
|
||||||
if (theme_cache)
|
|
||||||
{
|
|
||||||
INFO("Destorying theme cache due to cache change.");
|
|
||||||
theme_cache = _efreet_cache_free(theme_cache);
|
|
||||||
}
|
|
||||||
|
|
||||||
IF_RELEASE(theme_name);
|
IF_RELEASE(theme_name);
|
||||||
|
|
||||||
if (fallback_cache)
|
|
||||||
{
|
|
||||||
INFO("Destroying fallback cache due to cache change.");
|
|
||||||
fallback_cache = _efreet_cache_fallback_free(fallback_cache);
|
|
||||||
}
|
|
||||||
|
|
||||||
icon_cache = efreet_cache_close(icon_cache);
|
icon_cache = efreet_cache_close(icon_cache);
|
||||||
|
fallback_cache = efreet_cache_close(fallback_cache);
|
||||||
|
|
||||||
d->hash = efreet_icon_themes;
|
d->hash = efreet_icon_themes;
|
||||||
d->ef = icon_theme_cache;
|
d->ef = icon_theme_cache;
|
||||||
|
|
|
@ -13,8 +13,8 @@ EAPI Eet_Data_Descriptor *efreet_hash_array_string_edd(void);
|
||||||
EAPI Eet_Data_Descriptor *efreet_hash_string_edd(void);
|
EAPI Eet_Data_Descriptor *efreet_hash_string_edd(void);
|
||||||
EAPI Eet_Data_Descriptor *efreet_array_string_edd(void);
|
EAPI Eet_Data_Descriptor *efreet_array_string_edd(void);
|
||||||
EAPI Eet_Data_Descriptor *efreet_icon_theme_edd(Eina_Bool cache);
|
EAPI Eet_Data_Descriptor *efreet_icon_theme_edd(Eina_Bool cache);
|
||||||
EAPI Eet_Data_Descriptor *efreet_icons_edd(void);
|
EAPI Eet_Data_Descriptor *efreet_icon_edd(void);
|
||||||
EAPI Eet_Data_Descriptor *efreet_icons_fallback_edd(void);
|
EAPI Eet_Data_Descriptor *efreet_icon_fallback_edd(void);
|
||||||
|
|
||||||
typedef struct Efreet_Cache_Icon_Theme Efreet_Cache_Icon_Theme;
|
typedef struct Efreet_Cache_Icon_Theme Efreet_Cache_Icon_Theme;
|
||||||
|
|
||||||
|
|
|
@ -124,17 +124,11 @@ extern Eina_Hash *efreet_icon_themes;
|
||||||
#define EFREET_ICON_CACHE_MAJOR 0
|
#define EFREET_ICON_CACHE_MAJOR 0
|
||||||
#define EFREET_ICON_CACHE_MINOR 4
|
#define EFREET_ICON_CACHE_MINOR 4
|
||||||
|
|
||||||
typedef struct _Efreet_Cache_Icons Efreet_Cache_Icons;
|
|
||||||
typedef struct _Efreet_Cache_Directory Efreet_Cache_Directory;
|
typedef struct _Efreet_Cache_Directory Efreet_Cache_Directory;
|
||||||
typedef struct _Efreet_Cache_Icon Efreet_Cache_Icon;
|
typedef struct _Efreet_Cache_Icon Efreet_Cache_Icon;
|
||||||
typedef struct _Efreet_Cache_Icon_Element Efreet_Cache_Icon_Element;
|
typedef struct _Efreet_Cache_Icon_Element Efreet_Cache_Icon_Element;
|
||||||
typedef struct _Efreet_Cache_Fallback_Icon Efreet_Cache_Fallback_Icon;
|
typedef struct _Efreet_Cache_Fallback_Icon Efreet_Cache_Fallback_Icon;
|
||||||
|
|
||||||
struct _Efreet_Cache_Icons
|
|
||||||
{
|
|
||||||
Eina_Hash *icons;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _Efreet_Cache_Directory
|
struct _Efreet_Cache_Directory
|
||||||
{
|
{
|
||||||
long long modified_time;
|
long long modified_time;
|
||||||
|
@ -239,7 +233,7 @@ void efreet_cache_icon_update(void);
|
||||||
void efreet_cache_desktop_free(Efreet_Desktop *desktop);
|
void efreet_cache_desktop_free(Efreet_Desktop *desktop);
|
||||||
Efreet_Desktop *efreet_cache_desktop_find(const char *file);
|
Efreet_Desktop *efreet_cache_desktop_find(const char *file);
|
||||||
|
|
||||||
EAPI const char *efreet_icon_cache_file(void);
|
EAPI const char *efreet_icon_cache_file(const char *theme);
|
||||||
EAPI const char *efreet_icon_theme_cache_file(void);
|
EAPI const char *efreet_icon_theme_cache_file(void);
|
||||||
|
|
||||||
EAPI void efreet_cache_icon_free(Efreet_Cache_Icon *icon);
|
EAPI void efreet_cache_icon_free(Efreet_Cache_Icon *icon);
|
||||||
|
|
|
@ -20,56 +20,51 @@
|
||||||
#include "efreet_private.h"
|
#include "efreet_private.h"
|
||||||
#include "efreet_cache_private.h"
|
#include "efreet_cache_private.h"
|
||||||
|
|
||||||
static Eet_Data_Descriptor *edd = NULL;
|
|
||||||
|
|
||||||
int verbose = 0;
|
int verbose = 0;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dump(Efreet_Icon_Theme *theme, Eet_File *ef)
|
dump(Efreet_Icon_Theme *theme)
|
||||||
{
|
{
|
||||||
Efreet_Cache_Icons *cache;
|
Eet_File *ef;
|
||||||
Eina_Iterator *it;
|
|
||||||
const char *key;
|
|
||||||
unsigned int count = 0;
|
unsigned int count = 0;
|
||||||
double start, avg;
|
double start, avg;
|
||||||
|
char **keys;
|
||||||
|
int num, i;
|
||||||
|
|
||||||
start = ecore_time_get();
|
start = ecore_time_get();
|
||||||
|
ef = eet_open(efreet_icon_cache_file(theme->name.internal), EET_FILE_MODE_READ);
|
||||||
|
printf("open: %s %f\n", theme->name.internal, ecore_time_get() - start);
|
||||||
|
|
||||||
printf("open: %s\n", theme->name.internal);
|
start = ecore_time_get();
|
||||||
|
keys = eet_list(ef, "*", &num);
|
||||||
|
printf("list: %s %f\n", theme->name.internal, ecore_time_get() - start);
|
||||||
|
if (!keys) return;
|
||||||
|
|
||||||
cache = eet_data_read(ef, edd, theme->name.internal);
|
start = ecore_time_get();
|
||||||
|
for (i = 0; i < num; i++)
|
||||||
printf("read: %s %f\n", theme->name.internal, ecore_time_get() - start);
|
|
||||||
|
|
||||||
if (!cache || !cache->icons) return ;
|
|
||||||
|
|
||||||
it = eina_hash_iterator_key_new(cache->icons);
|
|
||||||
|
|
||||||
EINA_ITERATOR_FOREACH(it, key)
|
|
||||||
{
|
{
|
||||||
Efreet_Cache_Icon *icon;
|
Efreet_Cache_Icon *icon;
|
||||||
unsigned int i;
|
unsigned int j;
|
||||||
|
|
||||||
icon = eina_hash_find(cache->icons, key);
|
icon = eet_data_read(ef, efreet_icon_edd(), keys[i]);
|
||||||
|
if (!icon) continue;
|
||||||
|
|
||||||
for (i = 0; i < icon->icons_count; ++i)
|
for (j = 0; j < icon->icons_count; ++j)
|
||||||
count += icon->icons[i]->paths_count;
|
count += icon->icons[j]->paths_count;
|
||||||
|
efreet_cache_icon_free(icon);
|
||||||
}
|
}
|
||||||
|
free(keys);
|
||||||
eina_iterator_free(it);
|
|
||||||
|
|
||||||
efreet_hash_free(cache->icons, EINA_FREE_CB(efreet_cache_icon_free));
|
|
||||||
free(cache);
|
|
||||||
|
|
||||||
start = ecore_time_get() - start;
|
start = ecore_time_get() - start;
|
||||||
avg = start / count;
|
avg = start / count;
|
||||||
printf("read: %s - %u paths (time: %f) (avg %f)\n", theme->name.internal, count, start, avg);
|
printf("read: %s - %u paths (time: %f) (avg %f)\n", theme->name.internal, count, start, avg);
|
||||||
|
eet_close(ef);
|
||||||
|
eet_clearcache();
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
Eet_File *icons_ef;
|
|
||||||
Eet_File *theme_ef;
|
Eet_File *theme_ef;
|
||||||
Eina_List *l = NULL;
|
Eina_List *l = NULL;
|
||||||
Efreet_Icon_Theme *theme;
|
Efreet_Icon_Theme *theme;
|
||||||
|
@ -82,9 +77,6 @@ main(int argc, char **argv)
|
||||||
theme_ef = eet_open(efreet_icon_theme_cache_file(), EET_FILE_MODE_READ);
|
theme_ef = eet_open(efreet_icon_theme_cache_file(), EET_FILE_MODE_READ);
|
||||||
if (!theme_ef) return -1;
|
if (!theme_ef) return -1;
|
||||||
|
|
||||||
edd = efreet_icons_edd();
|
|
||||||
if (!edd) return -1;
|
|
||||||
|
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
{
|
{
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
|
@ -110,14 +102,11 @@ main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
icons_ef = eet_open(efreet_icon_cache_file(), EET_FILE_MODE_READ);
|
|
||||||
if (!icons_ef) return -1;
|
|
||||||
|
|
||||||
EINA_LIST_FREE(l, theme)
|
EINA_LIST_FREE(l, theme)
|
||||||
{
|
{
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
dump(theme, icons_ef);
|
dump(theme);
|
||||||
|
|
||||||
/* free theme */
|
/* free theme */
|
||||||
eina_list_free(theme->paths);
|
eina_list_free(theme->paths);
|
||||||
|
@ -127,8 +116,6 @@ main(int argc, char **argv)
|
||||||
free(theme);
|
free(theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
eet_close(icons_ef);
|
|
||||||
|
|
||||||
efreet_shutdown();
|
efreet_shutdown();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue