Stick with efreet formatting
efreet has it's own formatting, something like "set ts=4 sw=4 sts=4 expandtab cino=(0W1st0". Please keep it like this, or do the job to convert the whole lib to efl style. SVN revision: 55036
This commit is contained in:
parent
66e52e2829
commit
0c8c2d3c9f
|
@ -44,14 +44,14 @@ term_handler(int sig __UNUSED__, siginfo_t * info __UNUSED__, void *data __UNUSE
|
||||||
static void
|
static void
|
||||||
catch_sigterm(void)
|
catch_sigterm(void)
|
||||||
{
|
{
|
||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
|
|
||||||
act.sa_sigaction = term_handler;
|
act.sa_sigaction = term_handler;
|
||||||
act.sa_flags = SA_RESTART | SA_SIGINFO;
|
act.sa_flags = SA_RESTART | SA_SIGINFO;
|
||||||
sigemptyset(&act.sa_mask);
|
sigemptyset(&act.sa_mask);
|
||||||
|
|
||||||
if (sigaction(SIGTERM, &act, NULL) < 0)
|
if (sigaction(SIGTERM, &act, NULL) < 0)
|
||||||
perror("sigaction"); /* It's bad if we can't deal with SIGTERM, but not dramatic */
|
perror("sigaction"); /* It's bad if we can't deal with SIGTERM, but not dramatic */
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -68,8 +68,8 @@ cache_add(const char *path, const char *file_id, int priority __UNUSED__, int *c
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
printf("FOUND: %s\n", path);
|
printf("FOUND: %s\n", path);
|
||||||
if (file_id) printf(" (id): %s\n", file_id);
|
if (file_id) printf(" (id): %s\n", file_id);
|
||||||
}
|
}
|
||||||
ext = strrchr(path, '.');
|
ext = strrchr(path, '.');
|
||||||
if (!ext || (strcmp(ext, ".desktop") && strcmp(ext, ".directory"))) return 1;
|
if (!ext || (strcmp(ext, ".desktop") && strcmp(ext, ".directory"))) return 1;
|
||||||
|
|
|
@ -26,12 +26,12 @@ static int verbose = 0;
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_cache_extention_lookup(const char *ext)
|
_cache_extention_lookup(const char *ext)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; exts[i]; ++i)
|
for (i = 0; exts[i]; ++i)
|
||||||
if (!strcmp(exts[i], ext))
|
if (!strcmp(exts[i], ext))
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
|
@ -47,47 +47,47 @@ cache_fallback_scan_dir(Eina_Hash *icons, Eina_Hash *dirs, const char *dir, Eina
|
||||||
if (!it) return 1;
|
if (!it) return 1;
|
||||||
|
|
||||||
EINA_ITERATOR_FOREACH(it, entry)
|
EINA_ITERATOR_FOREACH(it, entry)
|
||||||
{
|
{
|
||||||
Efreet_Cache_Fallback_Icon *icon;
|
Efreet_Cache_Fallback_Icon *icon;
|
||||||
char *name;
|
char *name;
|
||||||
char *ext;
|
char *ext;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (entry->type == EINA_FILE_DIR)
|
if (entry->type == EINA_FILE_DIR)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ext = strrchr(entry->path + entry->name_start, '.');
|
ext = strrchr(entry->path + entry->name_start, '.');
|
||||||
if (!ext || !_cache_extention_lookup(ext))
|
if (!ext || !_cache_extention_lookup(ext))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* icon with known extension */
|
/* icon with known extension */
|
||||||
name = entry->path + entry->name_start;
|
name = entry->path + entry->name_start;
|
||||||
*ext = '\0';
|
*ext = '\0';
|
||||||
|
|
||||||
icon = eina_hash_find(icons, name);
|
icon = eina_hash_find(icons, name);
|
||||||
if (!icon)
|
if (!icon)
|
||||||
{
|
{
|
||||||
icon = NEW(Efreet_Cache_Fallback_Icon, 1);
|
icon = NEW(Efreet_Cache_Fallback_Icon, 1);
|
||||||
icon->free = 1;
|
icon->free = 1;
|
||||||
icon->theme = NULL;
|
icon->theme = NULL;
|
||||||
eina_hash_add(icons, name, icon);
|
eina_hash_add(icons, name, icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
*ext = '.';
|
*ext = '.';
|
||||||
|
|
||||||
for (i = 0; i < icon->icons_count; ++i)
|
for (i = 0; i < icon->icons_count; ++i)
|
||||||
if (!strcmp(icon->icons[i], entry->path))
|
if (!strcmp(icon->icons[i], entry->path))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (i != icon->icons_count)
|
if (i != icon->icons_count)
|
||||||
continue ;
|
continue ;
|
||||||
|
|
||||||
/* we don't really track path deat here, so we will leak... */
|
/* we don't really track path deat here, so we will leak... */
|
||||||
icon->icons = realloc(icon->icons, sizeof (char *) * (icon->icons_count + 1));
|
icon->icons = realloc(icon->icons, sizeof (char *) * (icon->icons_count + 1));
|
||||||
icon->icons[icon->icons_count++] = eina_stringshare_add(entry->path);
|
icon->icons[icon->icons_count++] = eina_stringshare_add(entry->path);
|
||||||
|
|
||||||
*changed = EINA_TRUE;
|
*changed = EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
eina_iterator_free(it);
|
eina_iterator_free(it);
|
||||||
|
|
||||||
|
@ -145,82 +145,82 @@ cache_scan_path_dir(Efreet_Icon_Theme *theme,
|
||||||
if (!it) return 1;
|
if (!it) return 1;
|
||||||
|
|
||||||
EINA_ITERATOR_FOREACH(it, entry)
|
EINA_ITERATOR_FOREACH(it, entry)
|
||||||
{
|
{
|
||||||
Efreet_Cache_Icon *icon;
|
Efreet_Cache_Icon *icon;
|
||||||
char *name;
|
char *name;
|
||||||
char *ext;
|
char *ext;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (entry->type == EINA_FILE_DIR)
|
if (entry->type == EINA_FILE_DIR)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ext = strrchr(entry->path + entry->name_start, '.');
|
ext = strrchr(entry->path + entry->name_start, '.');
|
||||||
if (!ext || !_cache_extention_lookup(ext))
|
if (!ext || !_cache_extention_lookup(ext))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* icon with known extension */
|
/* icon with known extension */
|
||||||
name = entry->path + entry->name_start;
|
name = entry->path + entry->name_start;
|
||||||
*ext = '\0';
|
*ext = '\0';
|
||||||
|
|
||||||
icon = eina_hash_find(icons, name);
|
icon = eina_hash_find(icons, name);
|
||||||
if (!icon)
|
if (!icon)
|
||||||
{
|
{
|
||||||
icon = NEW(Efreet_Cache_Icon, 1);
|
icon = NEW(Efreet_Cache_Icon, 1);
|
||||||
icon->free = 1;
|
icon->free = 1;
|
||||||
icon->theme = eina_stringshare_add(theme->name.internal);
|
icon->theme = eina_stringshare_add(theme->name.internal);
|
||||||
eina_hash_add(icons, name, icon);
|
eina_hash_add(icons, name, icon);
|
||||||
}
|
}
|
||||||
else if (icon->theme && strcmp(icon->theme, theme->name.internal))
|
else if (icon->theme && strcmp(icon->theme, theme->name.internal))
|
||||||
{
|
{
|
||||||
/* We got this icon from a parent theme */
|
/* We got this icon from a parent theme */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* find if we have the same icon in another type */
|
/* find if we have the same icon in another type */
|
||||||
for (i = 0; i < icon->icons_count; ++i)
|
for (i = 0; i < icon->icons_count; ++i)
|
||||||
{
|
{
|
||||||
if ((icon->icons[i]->type == dir->type) &&
|
if ((icon->icons[i]->type == dir->type) &&
|
||||||
(icon->icons[i]->normal == dir->size.normal) &&
|
(icon->icons[i]->normal == dir->size.normal) &&
|
||||||
(icon->icons[i]->max == dir->size.max) &&
|
(icon->icons[i]->max == dir->size.max) &&
|
||||||
(icon->icons[i]->min == dir->size.min))
|
(icon->icons[i]->min == dir->size.min))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ext = '.';
|
*ext = '.';
|
||||||
|
|
||||||
if (i != icon->icons_count)
|
if (i != icon->icons_count)
|
||||||
{
|
{
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
|
|
||||||
/* check if the path already exist */
|
/* check if the path already exist */
|
||||||
for (j = 0; j < icon->icons[i]->paths_count; ++j)
|
for (j = 0; j < icon->icons[i]->paths_count; ++j)
|
||||||
if (!strcmp(icon->icons[i]->paths[j], entry->path))
|
if (!strcmp(icon->icons[i]->paths[j], entry->path))
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
if (j != icon->icons[i]->paths_count)
|
if (j != icon->icons[i]->paths_count)
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
/* no icon match so add a new one */
|
/* no icon match so add a new one */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
icon->icons = realloc(icon->icons,
|
icon->icons = realloc(icon->icons,
|
||||||
sizeof (Efreet_Cache_Icon_Element*) * (++icon->icons_count));
|
sizeof (Efreet_Cache_Icon_Element*) * (++icon->icons_count));
|
||||||
icon->icons[i] = NEW(Efreet_Cache_Icon_Element, 1);
|
icon->icons[i] = NEW(Efreet_Cache_Icon_Element, 1);
|
||||||
icon->icons[i]->type = dir->type;
|
icon->icons[i]->type = dir->type;
|
||||||
icon->icons[i]->normal = dir->size.normal;
|
icon->icons[i]->normal = dir->size.normal;
|
||||||
icon->icons[i]->min = dir->size.min;
|
icon->icons[i]->min = dir->size.min;
|
||||||
icon->icons[i]->max = dir->size.max;
|
icon->icons[i]->max = dir->size.max;
|
||||||
icon->icons[i]->paths = NULL;
|
icon->icons[i]->paths = NULL;
|
||||||
icon->icons[i]->paths_count = 0;
|
icon->icons[i]->paths_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and finally store the path */
|
/* and finally store the path */
|
||||||
icon->icons[i]->paths = realloc(icon->icons[i]->paths,
|
icon->icons[i]->paths = realloc(icon->icons[i]->paths,
|
||||||
sizeof (char*) * (icon->icons[i]->paths_count + 1));
|
sizeof (char*) * (icon->icons[i]->paths_count + 1));
|
||||||
icon->icons[i]->paths[icon->icons[i]->paths_count++] = eina_stringshare_add(entry->path);
|
icon->icons[i]->paths[icon->icons[i]->paths_count++] = eina_stringshare_add(entry->path);
|
||||||
|
|
||||||
*changed = EINA_TRUE;
|
*changed = EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
eina_iterator_free(it);
|
eina_iterator_free(it);
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ cache_scan_path(Efreet_Icon_Theme *theme, Eina_Hash *icons, const char *path, Ei
|
||||||
Efreet_Icon_Theme_Directory *dir;
|
Efreet_Icon_Theme_Directory *dir;
|
||||||
|
|
||||||
EINA_LIST_FOREACH(theme->directories, l, dir)
|
EINA_LIST_FOREACH(theme->directories, l, dir)
|
||||||
if (!cache_scan_path_dir(theme, path, dir, icons, changed)) return 0;
|
if (!cache_scan_path_dir(theme, path, dir, icons, changed)) return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -252,26 +252,26 @@ cache_scan(Efreet_Icon_Theme *theme, Eina_Hash *themes, Eina_Hash *icons, Eina_B
|
||||||
|
|
||||||
/* scan theme */
|
/* scan theme */
|
||||||
EINA_LIST_FOREACH(theme->paths, l, path)
|
EINA_LIST_FOREACH(theme->paths, l, path)
|
||||||
if (!cache_scan_path(theme, icons, path, changed)) return 0;
|
if (!cache_scan_path(theme, icons, path, changed)) return 0;
|
||||||
|
|
||||||
/* scan inherits */
|
/* scan inherits */
|
||||||
if (theme->inherits)
|
if (theme->inherits)
|
||||||
{
|
{
|
||||||
EINA_LIST_FOREACH(theme->inherits, l, name)
|
EINA_LIST_FOREACH(theme->inherits, l, name)
|
||||||
{
|
{
|
||||||
Efreet_Icon_Theme *inherit;
|
Efreet_Icon_Theme *inherit;
|
||||||
|
|
||||||
inherit = efreet_icon_theme_find(name);
|
inherit = efreet_icon_theme_find(name);
|
||||||
if (!inherit) fprintf(stderr, "Theme `%s` not found for `%s`.\n",
|
if (!inherit) fprintf(stderr, "Theme `%s` not found for `%s`.\n",
|
||||||
name, theme->name.internal);
|
name, theme->name.internal);
|
||||||
if (!cache_scan(inherit, themes, icons, changed)) return 0;
|
if (!cache_scan(inherit, themes, icons, changed)) return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (strcmp(theme->name.internal, "hicolor"))
|
else if (strcmp(theme->name.internal, "hicolor"))
|
||||||
{
|
{
|
||||||
theme = efreet_icon_theme_find("hicolor");
|
theme = efreet_icon_theme_find("hicolor");
|
||||||
if (!cache_scan(theme, themes, icons, changed)) return 0;
|
if (!cache_scan(theme, themes, icons, changed)) return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -279,25 +279,25 @@ cache_scan(Efreet_Icon_Theme *theme, Eina_Hash *themes, Eina_Hash *icons, Eina_B
|
||||||
static int
|
static int
|
||||||
cache_lock_file(void)
|
cache_lock_file(void)
|
||||||
{
|
{
|
||||||
char file[PATH_MAX];
|
char file[PATH_MAX];
|
||||||
struct flock fl;
|
struct flock fl;
|
||||||
int lockfd;
|
int lockfd;
|
||||||
|
|
||||||
snprintf(file, sizeof(file), "%s/.efreet/icon_data.lock", efreet_home_dir_get());
|
snprintf(file, sizeof(file), "%s/.efreet/icon_data.lock", efreet_home_dir_get());
|
||||||
lockfd = open(file, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
|
lockfd = open(file, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
|
||||||
if (lockfd < 0) return -1;
|
if (lockfd < 0) return -1;
|
||||||
|
|
||||||
memset(&fl, 0, sizeof(struct flock));
|
memset(&fl, 0, sizeof(struct flock));
|
||||||
fl.l_type = F_WRLCK;
|
fl.l_type = F_WRLCK;
|
||||||
fl.l_whence = SEEK_SET;
|
fl.l_whence = SEEK_SET;
|
||||||
if (fcntl(lockfd, F_SETLK, &fl) < 0)
|
if (fcntl(lockfd, F_SETLK, &fl) < 0)
|
||||||
{
|
{
|
||||||
if (verbose) printf("LOCKED! You may want to delete %s if this persists\n", file);
|
if (verbose) printf("LOCKED! You may want to delete %s if this persists\n", file);
|
||||||
close(lockfd);
|
close(lockfd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return lockfd;
|
return lockfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -309,14 +309,14 @@ term_handler(int sig __UNUSED__, siginfo_t * info __UNUSED__, void *data __UNUSE
|
||||||
static void
|
static void
|
||||||
catch_sigterm(void)
|
catch_sigterm(void)
|
||||||
{
|
{
|
||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
|
|
||||||
act.sa_sigaction = term_handler;
|
act.sa_sigaction = term_handler;
|
||||||
act.sa_flags = SA_RESTART | SA_SIGINFO;
|
act.sa_flags = SA_RESTART | SA_SIGINFO;
|
||||||
sigemptyset(&act.sa_mask);
|
sigemptyset(&act.sa_mask);
|
||||||
|
|
||||||
if (sigaction(SIGTERM, &act, NULL) < 0)
|
if (sigaction(SIGTERM, &act, NULL) < 0)
|
||||||
perror("sigaction"); /* It's bad if we can't deal with SIGTERM, but not dramatic */
|
perror("sigaction"); /* It's bad if we can't deal with SIGTERM, but not dramatic */
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -329,35 +329,35 @@ main(int argc, char **argv)
|
||||||
* - pass extra dirs to binary, and read them
|
* - pass extra dirs to binary, and read them
|
||||||
* - make sure programs with different extra dirs all work together
|
* - make sure programs with different extra dirs all work together
|
||||||
*/
|
*/
|
||||||
Efreet_Cache_Theme *cache;
|
Efreet_Cache_Theme *cache;
|
||||||
Efreet_Icon_Theme *theme;
|
Efreet_Icon_Theme *theme;
|
||||||
Eet_Data_Descriptor *edd;
|
Eet_Data_Descriptor *edd;
|
||||||
Eet_File *ef;
|
Eet_File *ef;
|
||||||
Eina_List *l = NULL;
|
Eina_List *l = NULL;
|
||||||
char file[PATH_MAX];
|
char file[PATH_MAX];
|
||||||
char *dir = NULL;
|
char *dir = NULL;
|
||||||
Eina_Bool changed = EINA_FALSE;
|
Eina_Bool changed = EINA_FALSE;
|
||||||
int lockfd = -1;
|
int lockfd = -1;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
if (!strcmp(argv[i], "-v")) verbose = 1;
|
if (!strcmp(argv[i], "-v")) verbose = 1;
|
||||||
else if ((!strcmp(argv[i], "-h")) ||
|
else if ((!strcmp(argv[i], "-h")) ||
|
||||||
(!strcmp(argv[i], "-help")) ||
|
(!strcmp(argv[i], "-help")) ||
|
||||||
(!strcmp(argv[i], "--h")) ||
|
(!strcmp(argv[i], "--h")) ||
|
||||||
(!strcmp(argv[i], "--help")))
|
(!strcmp(argv[i], "--help")))
|
||||||
{
|
{
|
||||||
printf("Options:\n");
|
printf("Options:\n");
|
||||||
printf(" -v Verbose mode\n");
|
printf(" -v Verbose mode\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* init external subsystems */
|
/* init external subsystems */
|
||||||
if (!eina_init()) return -1;
|
if (!eina_init()) return -1;
|
||||||
if (!eet_init()) return -1;
|
if (!eet_init()) return -1;
|
||||||
if (!ecore_init()) return -1;
|
if (!ecore_init()) return -1;
|
||||||
|
|
||||||
efreet_cache_update = 0;
|
efreet_cache_update = 0;
|
||||||
|
|
||||||
|
@ -381,13 +381,13 @@ main(int argc, char **argv)
|
||||||
if (!efreet_init()) goto on_error;
|
if (!efreet_init()) goto on_error;
|
||||||
|
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
{
|
{
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
theme = efreet_icon_theme_find(argv[i]);
|
theme = efreet_icon_theme_find(argv[i]);
|
||||||
if (theme) l = eina_list_append(l, theme);
|
if (theme) l = eina_list_append(l, theme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!l) l = efreet_icon_theme_list_get();
|
if (!l) l = efreet_icon_theme_list_get();
|
||||||
|
|
||||||
|
@ -397,52 +397,52 @@ main(int argc, char **argv)
|
||||||
edd = efreet_icon_theme_edd();
|
edd = efreet_icon_theme_edd();
|
||||||
|
|
||||||
EINA_LIST_FREE(l, theme)
|
EINA_LIST_FREE(l, theme)
|
||||||
{
|
{
|
||||||
Eina_Hash *themes;
|
Eina_Hash *themes;
|
||||||
|
|
||||||
themes = eina_hash_string_superfast_new(NULL);
|
themes = eina_hash_string_superfast_new(NULL);
|
||||||
|
|
||||||
/* read icons from the eet file */
|
/* read icons from the eet file */
|
||||||
cache = eet_data_read(ef, edd, theme->name.internal);
|
cache = eet_data_read(ef, edd, theme->name.internal);
|
||||||
|
|
||||||
/* Wype out in case of version change */
|
/* Wype out in case of version change */
|
||||||
if (cache
|
if (cache
|
||||||
&& cache->version.major != EFREET_CACHE_MAJOR
|
&& cache->version.major != EFREET_CACHE_MAJOR
|
||||||
&& cache->version.minor != EFREET_CACHE_MINOR)
|
&& cache->version.minor != EFREET_CACHE_MINOR)
|
||||||
{
|
{
|
||||||
eina_hash_free(cache->icons);
|
eina_hash_free(cache->icons);
|
||||||
free(cache);
|
free(cache);
|
||||||
cache = NULL;
|
cache = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No existing cache before, so create it */
|
/* No existing cache before, so create it */
|
||||||
if (!cache)
|
if (!cache)
|
||||||
{
|
{
|
||||||
cache = malloc(sizeof (Efreet_Cache_Theme));
|
cache = malloc(sizeof (Efreet_Cache_Theme));
|
||||||
if (!cache) goto on_error_efreet;
|
if (!cache) goto on_error_efreet;
|
||||||
|
|
||||||
cache->version.major = EFREET_CACHE_MAJOR;
|
cache->version.major = EFREET_CACHE_MAJOR;
|
||||||
cache->version.minor = EFREET_CACHE_MINOR;
|
cache->version.minor = EFREET_CACHE_MINOR;
|
||||||
|
|
||||||
cache->icons = eina_hash_string_superfast_new((Eina_Free_Cb) efreet_cache_icon_free);
|
cache->icons = eina_hash_string_superfast_new((Eina_Free_Cb) efreet_cache_icon_free);
|
||||||
|
|
||||||
changed = EINA_TRUE;
|
changed = EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cache_scan(theme, themes, cache->icons, &changed))
|
if (cache_scan(theme, themes, cache->icons, &changed))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "generated: '%s' %i (%i)\n",
|
fprintf(stderr, "generated: '%s' %i (%i)\n",
|
||||||
theme->name.internal,
|
theme->name.internal,
|
||||||
changed,
|
changed,
|
||||||
eina_hash_population(cache->icons));
|
eina_hash_population(cache->icons));
|
||||||
if (changed)
|
if (changed)
|
||||||
eet_data_write(ef, edd, theme->name.internal, cache, 1);
|
eet_data_write(ef, edd, theme->name.internal, cache, 1);
|
||||||
changed = EINA_FALSE;
|
changed = EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
eina_hash_free(themes);
|
eina_hash_free(themes);
|
||||||
eina_hash_free(cache->icons);
|
eina_hash_free(cache->icons);
|
||||||
free(cache);
|
free(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
edd = efreet_icon_fallback_edd();
|
edd = efreet_icon_fallback_edd();
|
||||||
|
@ -450,33 +450,33 @@ main(int argc, char **argv)
|
||||||
/* read fallback icons from the eet file */
|
/* read fallback icons from the eet file */
|
||||||
cache = eet_data_read(ef, edd, "efreet/fallback");
|
cache = eet_data_read(ef, edd, "efreet/fallback");
|
||||||
if (cache && cache->version.major != EFREET_CACHE_MAJOR)
|
if (cache && cache->version.major != EFREET_CACHE_MAJOR)
|
||||||
{
|
{
|
||||||
eina_hash_free(cache->icons);
|
eina_hash_free(cache->icons);
|
||||||
free(cache);
|
free(cache);
|
||||||
cache = NULL;
|
cache = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No existing fallback, create it */
|
/* No existing fallback, create it */
|
||||||
if (!cache)
|
if (!cache)
|
||||||
{
|
{
|
||||||
cache = malloc(sizeof (Efreet_Cache_Theme));
|
cache = malloc(sizeof (Efreet_Cache_Theme));
|
||||||
if (!cache) goto on_error_efreet;
|
if (!cache) goto on_error_efreet;
|
||||||
|
|
||||||
cache->version.major = EFREET_CACHE_MAJOR;
|
cache->version.major = EFREET_CACHE_MAJOR;
|
||||||
cache->version.minor = EFREET_CACHE_MINOR;
|
cache->version.minor = EFREET_CACHE_MINOR;
|
||||||
|
|
||||||
cache->icons = eina_hash_string_superfast_new((Eina_Free_Cb) efreet_cache_icon_fallback_free);
|
cache->icons = eina_hash_string_superfast_new((Eina_Free_Cb) efreet_cache_icon_fallback_free);
|
||||||
|
|
||||||
changed = EINA_TRUE;
|
changed = EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save fallback in the right part */
|
/* Save fallback in the right part */
|
||||||
if (cache_fallback_scan(cache->icons, &changed))
|
if (cache_fallback_scan(cache->icons, &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(cache->icons));
|
||||||
if (changed)
|
if (changed)
|
||||||
eet_data_write(ef, edd, "efreet/fallback", cache, 1);
|
eet_data_write(ef, edd, "efreet/fallback", cache, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
eina_hash_free(cache->icons);
|
eina_hash_free(cache->icons);
|
||||||
free(cache);
|
free(cache);
|
||||||
|
@ -484,10 +484,10 @@ main(int argc, char **argv)
|
||||||
/* save data */
|
/* save data */
|
||||||
eet_close(ef);
|
eet_close(ef);
|
||||||
|
|
||||||
on_error_efreet:
|
on_error_efreet:
|
||||||
efreet_shutdown();
|
efreet_shutdown();
|
||||||
|
|
||||||
on_error:
|
on_error:
|
||||||
close(lockfd);
|
close(lockfd);
|
||||||
|
|
||||||
ecore_shutdown();
|
ecore_shutdown();
|
||||||
|
|
|
@ -26,77 +26,77 @@ int verbose = 0;
|
||||||
static void
|
static void
|
||||||
dump(Efreet_Icon_Theme *theme, Eet_File *ef)
|
dump(Efreet_Icon_Theme *theme, Eet_File *ef)
|
||||||
{
|
{
|
||||||
Efreet_Cache_Theme *cache;
|
Efreet_Cache_Theme *cache;
|
||||||
Eina_Iterator *it;
|
Eina_Iterator *it;
|
||||||
const char *key;
|
const char *key;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
double start, avg;
|
double start, avg;
|
||||||
|
|
||||||
start = ecore_time_get();
|
start = ecore_time_get();
|
||||||
|
|
||||||
printf("open: %s\n", theme->name.internal);
|
printf("open: %s\n", theme->name.internal);
|
||||||
|
|
||||||
cache = eet_data_read(ef, edd, theme->name.internal);
|
cache = eet_data_read(ef, edd, theme->name.internal);
|
||||||
|
|
||||||
printf("read: %s %f\n", theme->name.internal, ecore_time_get() - start);
|
printf("read: %s %f\n", theme->name.internal, ecore_time_get() - start);
|
||||||
|
|
||||||
if (!cache || !cache->icons) return ;
|
if (!cache || !cache->icons) return ;
|
||||||
|
|
||||||
it = eina_hash_iterator_key_new(cache->icons);
|
it = eina_hash_iterator_key_new(cache->icons);
|
||||||
|
|
||||||
EINA_ITERATOR_FOREACH(it, key)
|
EINA_ITERATOR_FOREACH(it, key)
|
||||||
{
|
{
|
||||||
Efreet_Cache_Icon *icon;
|
Efreet_Cache_Icon *icon;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
icon = eina_hash_find(cache->icons, key);
|
icon = eina_hash_find(cache->icons, key);
|
||||||
|
|
||||||
for (i = 0; i < icon->icons_count; ++i)
|
for (i = 0; i < icon->icons_count; ++i)
|
||||||
count += icon->icons[i]->paths_count;
|
count += icon->icons[i]->paths_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
eina_iterator_free(it);
|
eina_iterator_free(it);
|
||||||
|
|
||||||
eina_hash_free(cache->icons);
|
eina_hash_free(cache->icons);
|
||||||
free(cache);
|
free(cache);
|
||||||
|
|
||||||
start = ecore_time_get() - start;
|
start = ecore_time_get() - start;
|
||||||
avg = start / count;
|
avg = start / count;
|
||||||
printf("read: %s - %i paths (time: %f) (avg %f)\n", theme->name.internal, count, start, avg);
|
printf("read: %s - %i paths (time: %f) (avg %f)\n", theme->name.internal, count, start, avg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
Eet_File *ef;
|
Eet_File *ef;
|
||||||
Eina_List *l = NULL;
|
Eina_List *l = NULL;
|
||||||
Efreet_Icon_Theme *theme;
|
Efreet_Icon_Theme *theme;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
efreet_cache_update = 0;
|
efreet_cache_update = 0;
|
||||||
|
|
||||||
if (!efreet_init()) return -1;
|
if (!efreet_init()) return -1;
|
||||||
|
|
||||||
edd = efreet_icon_theme_edd();
|
edd = efreet_icon_theme_edd();
|
||||||
if (!edd) return -1;
|
if (!edd) return -1;
|
||||||
|
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
theme = efreet_icon_theme_find(argv[i]);
|
theme = efreet_icon_theme_find(argv[i]);
|
||||||
if (theme) l = eina_list_append(l, theme);
|
if (theme) l = eina_list_append(l, theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!l) l = efreet_icon_theme_list_get();
|
if (!l) l = efreet_icon_theme_list_get();
|
||||||
|
|
||||||
ef = eet_open(efreet_icon_cache_file(), EET_FILE_MODE_READ);
|
ef = eet_open(efreet_icon_cache_file(), EET_FILE_MODE_READ);
|
||||||
if (!ef) return -1;
|
if (!ef) return -1;
|
||||||
|
|
||||||
EINA_LIST_FREE(l, theme)
|
EINA_LIST_FREE(l, theme)
|
||||||
dump(theme, ef);
|
dump(theme, ef);
|
||||||
|
|
||||||
eet_close(ef);
|
eet_close(ef);
|
||||||
|
|
||||||
efreet_shutdown();
|
efreet_shutdown();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue