Pass extensions and directories to cache process.
SVN revision: 56666
This commit is contained in:
parent
c1bf3a7d32
commit
83e7cba435
|
@ -20,7 +20,14 @@
|
|||
#include "efreet_private.h"
|
||||
#include "efreet_cache_private.h"
|
||||
|
||||
static const char *exts[] = { ".png", ".xpm", ".svg", ".edj", NULL };
|
||||
/* TODO:
|
||||
* - Need to cache all exts searched and extra_dirs, so we know if we
|
||||
* need to rescan dirs. Then re-enable cache_directory_find().
|
||||
* - Need to check if files has disappeared, as we only add new.
|
||||
*/
|
||||
|
||||
static Eina_Array *exts = NULL;
|
||||
static Eina_Array *extra_dirs = NULL;
|
||||
static Eina_Array *strs = NULL;
|
||||
static Eina_Hash *icon_themes = NULL;
|
||||
static int verbose = 0;
|
||||
|
@ -28,6 +35,8 @@ static int verbose = 0;
|
|||
static Eina_Bool
|
||||
cache_directory_find(Eina_Hash *dirs, const char *dir)
|
||||
{
|
||||
return EINA_TRUE;
|
||||
#if 0
|
||||
Efreet_Cache_Directory *dcache;
|
||||
struct stat st;
|
||||
|
||||
|
@ -47,15 +56,16 @@ cache_directory_find(Eina_Hash *dirs, const char *dir)
|
|||
dcache->modified_time = st.st_mtime;
|
||||
|
||||
return EINA_TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_cache_extension_lookup(const char *ext)
|
||||
cache_extension_lookup(const char *ext)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; exts[i]; ++i)
|
||||
if (!strcmp(exts[i], ext))
|
||||
for (i = 0; i < exts->count; ++i)
|
||||
if (!strcmp(exts->data[i], ext))
|
||||
return EINA_TRUE;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
@ -82,7 +92,7 @@ cache_fallback_scan_dir(Eina_Hash *icons, Eina_Hash *dirs, const char *dir, Eina
|
|||
continue;
|
||||
|
||||
ext = strrchr(entry->path + entry->name_start, '.');
|
||||
if (!ext || !_cache_extension_lookup(ext))
|
||||
if (!ext || !cache_extension_lookup(ext))
|
||||
continue;
|
||||
|
||||
/* icon with known extension */
|
||||
|
@ -122,10 +132,14 @@ cache_fallback_scan_dir(Eina_Hash *icons, Eina_Hash *dirs, const char *dir, Eina
|
|||
static Eina_Bool
|
||||
cache_fallback_scan(Eina_Hash *icons, Eina_Hash *dirs, Eina_Bool *changed)
|
||||
{
|
||||
unsigned int i;
|
||||
Eina_List *xdg_dirs, *l;
|
||||
const char *dir;
|
||||
char path[PATH_MAX];
|
||||
|
||||
for (i = 0; i < extra_dirs->count; i++)
|
||||
cache_fallback_scan_dir(icons, dirs, extra_dirs->data[i], changed);
|
||||
|
||||
cache_fallback_scan_dir(icons, dirs, efreet_icon_deprecated_user_dir_get(), changed);
|
||||
cache_fallback_scan_dir(icons, dirs, efreet_icon_user_dir_get(), changed);
|
||||
|
||||
|
@ -180,7 +194,7 @@ cache_scan_path_dir(Efreet_Icon_Theme *theme,
|
|||
continue;
|
||||
|
||||
ext = strrchr(entry->path + entry->name_start, '.');
|
||||
if (!ext || !_cache_extension_lookup(ext))
|
||||
if (!ext || !cache_extension_lookup(ext))
|
||||
continue;
|
||||
|
||||
/* icon with known extension */
|
||||
|
@ -660,6 +674,12 @@ main(int argc, char **argv)
|
|||
char **keys;
|
||||
int num, i;
|
||||
|
||||
/* init external subsystems */
|
||||
if (!eina_init()) return -1;
|
||||
|
||||
exts = eina_array_new(10);
|
||||
extra_dirs = eina_array_new(10);
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if (!strcmp(argv[i], "-v")) verbose = 1;
|
||||
|
@ -669,13 +689,28 @@ main(int argc, char **argv)
|
|||
(!strcmp(argv[i], "--help")))
|
||||
{
|
||||
printf("Options:\n");
|
||||
printf(" -v Verbose mode\n");
|
||||
printf(" -v Verbose mode\n");
|
||||
printf(" -e .ext1 .ext2 Extensions\n");
|
||||
printf(" -d dir1 dir2 Extra dirs\n");
|
||||
exit(0);
|
||||
}
|
||||
else if (!strcmp(argv[i], "-e"))
|
||||
{
|
||||
while ((i < (argc - 1)) && (argv[(i + 1)][0] != '-'))
|
||||
eina_array_push(exts, argv[++i]);
|
||||
}
|
||||
else if (!strcmp(argv[i], "-d"))
|
||||
{
|
||||
while ((i < (argc - 1)) && (argv[(i + 1)][0] != '-'))
|
||||
eina_array_push(extra_dirs, argv[++i]);
|
||||
}
|
||||
}
|
||||
if (exts->count == 0)
|
||||
{
|
||||
printf("Error: Need to pass extensions to icon cache create process\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* init external subsystems */
|
||||
if (!eina_init()) return -1;
|
||||
if (!eet_init()) return -1;
|
||||
if (!ecore_init()) return -1;
|
||||
|
||||
|
@ -892,6 +927,12 @@ main(int argc, char **argv)
|
|||
free(keys);
|
||||
}
|
||||
|
||||
theme->changed = changed;
|
||||
if (theme->changed && theme->dirs)
|
||||
{
|
||||
efreet_hash_free(theme->dirs, free);
|
||||
theme->dirs = NULL;
|
||||
}
|
||||
theme = eet_data_read(theme_ef, theme_edd, EFREET_CACHE_ICON_FALLBACK);
|
||||
if (!theme)
|
||||
theme = NEW(Efreet_Cache_Icon_Theme, 1);
|
||||
|
@ -947,6 +988,8 @@ on_error:
|
|||
while ((path = eina_array_pop(strs)))
|
||||
eina_stringshare_del(path);
|
||||
eina_array_free(strs);
|
||||
eina_array_free(exts);
|
||||
eina_array_free(extra_dirs);
|
||||
|
||||
ecore_shutdown();
|
||||
eet_shutdown();
|
||||
|
|
|
@ -924,6 +924,7 @@ icon_cache_update_cache_job(void *data __UNUSED__)
|
|||
char file[PATH_MAX];
|
||||
struct flock fl;
|
||||
int prio;
|
||||
Eina_List **l, *l2;
|
||||
|
||||
icon_cache_job = NULL;
|
||||
|
||||
|
@ -940,7 +941,34 @@ icon_cache_update_cache_job(void *data __UNUSED__)
|
|||
if (fcntl(icon_cache_exe_lock, F_SETLK, &fl) < 0) goto error;
|
||||
prio = ecore_exe_run_priority_get();
|
||||
ecore_exe_run_priority_set(19);
|
||||
icon_cache_exe = ecore_exe_run(PACKAGE_LIB_DIR "/efreet/efreet_icon_cache_create", NULL);
|
||||
eina_strlcpy(file, PACKAGE_LIB_DIR "/efreet/efreet_icon_cache_create", sizeof(file));
|
||||
l = efreet_icon_extra_list_get();
|
||||
if (l && eina_list_count(*l) > 0)
|
||||
{
|
||||
Eina_List *ll;
|
||||
char *p;
|
||||
|
||||
eina_strlcat(file, " -d", sizeof(file));
|
||||
EINA_LIST_FOREACH(*l, ll, p)
|
||||
{
|
||||
eina_strlcat(file, " ", sizeof(file));
|
||||
eina_strlcat(file, p, sizeof(file));
|
||||
}
|
||||
}
|
||||
l2 = efreet_icon_extensions_list_get();
|
||||
if (eina_list_count(l2) > 0)
|
||||
{
|
||||
Eina_List *ll;
|
||||
char *p;
|
||||
|
||||
eina_strlcat(file, " -e", sizeof(file));
|
||||
EINA_LIST_FOREACH(l2, ll, p)
|
||||
{
|
||||
eina_strlcat(file, " ", sizeof(file));
|
||||
eina_strlcat(file, p, sizeof(file));
|
||||
}
|
||||
}
|
||||
icon_cache_exe = ecore_exe_run(file, NULL);
|
||||
ecore_exe_run_priority_set(prio);
|
||||
if (!icon_cache_exe) goto error;
|
||||
|
||||
|
|
|
@ -208,6 +208,16 @@ efreet_icon_extra_list_get(void)
|
|||
return &efreet_extra_icon_dirs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns a list of strings that are icon extensions to look for
|
||||
* @brief Gets the list of all icon extensions to look for
|
||||
*/
|
||||
EAPI Eina_List *
|
||||
efreet_icon_extensions_list_get(void)
|
||||
{
|
||||
return efreet_icon_extensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns a list of Efreet_Icon structs for all the non-hidden icon
|
||||
* themes
|
||||
|
@ -850,13 +860,11 @@ efreet_cache_icon_fallback_lookup_path(Efreet_Cache_Fallback_Icon *icon)
|
|||
path = efreet_cache_icon_fallback_lookup_path_path(icon, efreet_icon_user_dir_get());
|
||||
if (path) return path;
|
||||
|
||||
#if 0
|
||||
EINA_LIST_FOREACH(efreet_extra_icon_dirs, l, dir)
|
||||
{
|
||||
path = efreet_cache_icon_lookup_path_path(elem, dir);
|
||||
path = efreet_cache_icon_fallback_lookup_path_path(icon, dir);
|
||||
if (path) return path;
|
||||
}
|
||||
#endif
|
||||
|
||||
xdg_dirs = efreet_data_dirs_get();
|
||||
|
||||
|
|
|
@ -144,6 +144,7 @@ EAPI const char *efreet_icon_deprecated_user_dir_get(void);
|
|||
EAPI void efreet_icon_extension_add(const char *ext);
|
||||
|
||||
EAPI Eina_List **efreet_icon_extra_list_get(void);
|
||||
EAPI Eina_List *efreet_icon_extensions_list_get(void);
|
||||
EAPI Eina_List *efreet_icon_theme_list_get(void);
|
||||
EAPI Efreet_Icon_Theme *efreet_icon_theme_find(const char *theme_name);
|
||||
EAPI Efreet_Icon *efreet_icon_find(const char *theme_name,
|
||||
|
|
Loading…
Reference in New Issue