dan 'dj2' sinclair
Brian 'rephorm' Mattern
-Sebastian 'englebass' Dransfeld
+Sebastian Dransfeld <sd@tango.flipp.net>
Nathan 'RbdPngn' Ingersoll
Nicholas 'Mekius' Hughart
Albin "Lutin" Tonnerre <albin.tonnerre@gmail.com>
/* TODO: We should check priority, and not just hope we search in right order */
/* TODO: We need to find out if prioritized file id has changed because of
* changed search order. */
- if (desk->type == EFREET_DESKTOP_TYPE_APPLICATION &&
+ if (!desk->hidden && desk->type == EFREET_DESKTOP_TYPE_APPLICATION &&
file_id && !eina_hash_find(file_ids, file_id))
{
int id;
return 1;
}
+static Efreet_Icon_Theme_Directory *
+icon_theme_directory_new(Efreet_Ini *ini, const char *name)
+{
+ Efreet_Icon_Theme_Directory *dir;
+ int val;
+ const char *tmp;
+
+ if (!ini) return NULL;
+
+ dir = NEW(Efreet_Icon_Theme_Directory, 1);
+ if (!dir) return NULL;
+ dir->name = eina_stringshare_add(name);
+
+ efreet_ini_section_set(ini, name);
+
+ tmp = efreet_ini_string_get(ini, "Context");
+ if (tmp)
+ {
+ if (!strcasecmp(tmp, "Actions"))
+ dir->context = EFREET_ICON_THEME_CONTEXT_ACTIONS;
+
+ else if (!strcasecmp(tmp, "Devices"))
+ dir->context = EFREET_ICON_THEME_CONTEXT_DEVICES;
+
+ else if (!strcasecmp(tmp, "FileSystems"))
+ dir->context = EFREET_ICON_THEME_CONTEXT_FILESYSTEMS;
+
+ else if (!strcasecmp(tmp, "MimeTypes"))
+ dir->context = EFREET_ICON_THEME_CONTEXT_MIMETYPES;
+ }
+
+ /* Threshold is fallback */
+ dir->type = EFREET_ICON_SIZE_TYPE_THRESHOLD;
+
+ tmp = efreet_ini_string_get(ini, "Type");
+ if (tmp)
+ {
+ if (!strcasecmp(tmp, "Fixed"))
+ dir->type = EFREET_ICON_SIZE_TYPE_FIXED;
+
+ else if (!strcasecmp(tmp, "Scalable"))
+ dir->type = EFREET_ICON_SIZE_TYPE_SCALABLE;
+ }
+
+ dir->size.normal = efreet_ini_int_get(ini, "Size");
+
+ if (dir->type == EFREET_ICON_SIZE_TYPE_THRESHOLD)
+ {
+ val = efreet_ini_int_get(ini, "Threshold");
+ if (val < 0) val = 2;
+ dir->size.max = dir->size.normal + val;
+ dir->size.min = dir->size.normal - val;
+ }
+ else if (dir->type == EFREET_ICON_SIZE_TYPE_SCALABLE)
+ {
+ val = efreet_ini_int_get(ini, "MinSize");
+ if (val < 0) dir->size.min = dir->size.normal;
+ else dir->size.min = val;
+
+ val = efreet_ini_int_get(ini, "MaxSize");
+ if (val < 0) dir->size.max = dir->size.normal;
+ else dir->size.max = val;
+ }
+
+ return dir;
+}
+
static void
icon_theme_index_read(Efreet_Icon_Theme *theme, const char *path)
{
if (p) *p = '\0';
- dir = efreet_icon_theme_directory_new(ini, s);
+ dir = icon_theme_directory_new(ini, s);
if (!dir) goto error;
theme->directories = eina_list_append(theme->directories, dir);
if (!theme)
{
- theme = efreet_icon_theme_new();
+ theme = NEW(Efreet_Icon_Theme, 1);
theme->name.internal = eina_stringshare_add(name);
eina_hash_direct_add(icon_themes,
(void *)theme->name.internal, theme);
static Eet_Data_Descriptor *icon_edd = NULL;
static Eet_File *icon_cache = NULL;
+static Eet_File *icon_theme_cache = NULL;
static const char *icon_theme_cache_file = NULL;
static void icon_cache_update_cache_job(void *data);
#endif
static void desktop_cache_update_free(void *data, void *ev);
+#ifdef ICON_CACHE
+static void icon_cache_update_free(void *data, void *ev);
+#endif
EAPI int EFREET_EVENT_ICON_CACHE_UPDATE = 0;
EAPI int EFREET_EVENT_DESKTOP_CACHE_UPDATE = 0;
theme_cache = _efreet_cache_free(theme_cache);
fallback_cache = _efreet_cache_fallback_free(fallback_cache);
- if (theme_name) eina_stringshare_del(theme_name);
- theme_name = NULL;
+ IF_RELEASE(theme_name);
icon_cache = efreet_cache_close(icon_cache);
+ icon_theme_cache = efreet_cache_close(icon_theme_cache);
#endif
desktop_cache = efreet_cache_close(desktop_cache);
EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(icon_edd, Efreet_Cache_Icon,
"icons", icons, icon_element_pointer_edd);
- EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Icon);
+ EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Icons);
icons_edd = eet_data_descriptor_file_new(&eddc);
if (!icons_edd) return NULL;
EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY_STRING(icon_fallback_edd,
Efreet_Cache_Fallback_Icon, "icons", icons);
- EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Icon);
+ EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Icons);
fallback_edd = eet_data_descriptor_file_new(&eddc);
if (!fallback_edd) return NULL;
{
/* 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);
- eina_stringshare_del(theme_name);
+ IF_RELEASE(theme_name);
theme_cache = _efreet_cache_free(theme_cache);
- theme_name = NULL;
}
if (!theme_name)
return eina_hash_find(fallback_cache->icons, icon);
}
+
+Efreet_Icon_Theme *
+efreet_cache_icon_theme_find(const char *theme)
+{
+ if (!efreet_cache_check(&icon_theme_cache, efreet_icon_theme_cache_file(), EFREET_ICON_CACHE_MAJOR)) return NULL;
+ return eet_data_read(icon_theme_cache, efreet_icon_theme_edd(), theme);
+}
+
+void
+efreet_cache_icon_theme_free(Efreet_Icon_Theme *theme)
+{
+ void *data;
+
+ if (!theme) return;
+
+ eina_list_free(theme->paths);
+ eina_list_free(theme->inherits);
+ EINA_LIST_FREE(theme->directories, data)
+ free(data);
+
+ free(theme);
+}
+
+char **
+efreet_cache_icon_theme_name_list(int *num)
+{
+ char **keys;
+ int i;
+
+ if (!efreet_cache_check(&icon_theme_cache, efreet_icon_theme_cache_file(), EFREET_ICON_CACHE_MAJOR)) return NULL;
+ keys = eet_list(icon_theme_cache, "*", num);
+ for (i = 0; i < *num; i++)
+ {
+ if (!strcmp(keys[i], EFREET_CACHE_VERSION) && (i < (*num + 1)))
+ {
+ memmove(&keys[i], &keys[i + 1], (*num - i - 1) * sizeof(char *));
+ (*num)--;
+ break;
+ }
+ }
+ return keys;
+}
+
#endif
Efreet_Desktop *
Efreet_Cache_Version *version;
if (*ef == NON_EXISTING) return EINA_FALSE;
+ if (*ef) return EINA_TRUE;
if (!*ef)
*ef = eet_open(path, EET_FILE_MODE_READ);
if (!*ef)
#ifdef ICON_CACHE
else if (!strcmp(file, "icon_data.update"))
{
+ ev = NEW(Efreet_Event_Cache_Update, 1);
+ if (!ev) goto error;
+ d = NEW(Efreet_Old_Cache, 1);
+ if (!d) goto error;
+
if (theme_cache)
{
INFO("Destorying theme cache due to cache change.");
theme_cache = _efreet_cache_free(theme_cache);
}
- if (theme_name) eina_stringshare_del(theme_name);
- theme_name = NULL;
+ IF_RELEASE(theme_name);
if (fallback_cache)
{
icon_cache = efreet_cache_close(icon_cache);
- ev = NEW(Efreet_Event_Cache_Update, 1);
- if (!ev) return;
- ecore_event_add(EFREET_EVENT_ICON_CACHE_UPDATE, ev, NULL, NULL);
+ d->hash = efreet_icon_themes;
+ d->ef = icon_theme_cache;
+
+ efreet_icon_themes = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_icon_theme_free));
+ icon_theme_cache = NULL;
+
+ ecore_event_add(EFREET_EVENT_ICON_CACHE_UPDATE, ev, icon_cache_update_free, d);
}
#endif
return;
free(ev);
}
+#ifdef ICON_CACHE
+static void
+icon_cache_update_free(void *data, void *ev)
+{
+ Efreet_Old_Cache *d;
+
+ d = data;
+ if (d->hash)
+ eina_hash_free(d->hash);
+ efreet_cache_close(d->ef);
+ free(d);
+ free(ev);
+}
+#endif
if (!efreet_desktop_dirs) return 1;
- snprintf(file, sizeof(file), "%s/.efreet/desktop_data.lock", efreet_home_dir_get());
+ snprintf(file, sizeof(file), "%s/desktop_data.lock", efreet_cache_home_get());
fd = open(file, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
if (fd < 0) return 0;
/* TODO: Retry update cache later */
static int _efreet_icon_log_dom = -1;
/* TODO: Scan efreet_extra_icon_dirs for themes */
-/* TODO: icon theme cache */
+
+Eina_Hash *efreet_icon_themes = NULL;
static const char *efreet_icon_deprecated_user_dir = NULL;
static const char *efreet_icon_user_dir = NULL;
-static Eina_Hash *efreet_icon_themes = NULL;
static Eina_List *efreet_icon_extensions = NULL;
static Eina_List *efreet_extra_icon_dirs = NULL;
#ifndef ICON_CACHE
};
static char *efreet_icon_remove_extension(const char *icon);
-static Efreet_Icon_Theme *efreet_icon_find_theme_check(const char *theme_name);
-
#ifndef ICON_CACHE
+static Efreet_Icon_Theme *efreet_icon_find_theme_check(const char *theme_name);
+
static const char *efreet_icon_find_fallback(Efreet_Icon_Theme *theme,
const char *icon,
unsigned int size);
#ifndef ICON_CACHE
static Efreet_Icon_Theme *efreet_icon_theme_new(void);
-#endif
static void efreet_icon_theme_free(Efreet_Icon_Theme *theme);
static void efreet_icon_theme_dir_scan_all(const char *theme_name);
static void efreet_icon_theme_dir_scan(const char *dir,
static void efreet_icon_theme_index_read(Efreet_Icon_Theme *theme,
const char *path);
-#ifndef ICON_CACHE
static Efreet_Icon_Theme_Directory *efreet_icon_theme_directory_new(Efreet_Ini *ini,
const char *name);
-#endif
static void efreet_icon_theme_directory_free(Efreet_Icon_Theme_Directory *dir);
-#ifndef ICON_CACHE
static void efreet_icon_theme_cache_check(Efreet_Icon_Theme *theme);
static int efreet_icon_theme_cache_check_dir(Efreet_Icon_Theme *theme,
const char *dir);
for (i = 0; default_exts[i]; i++)
efreet_icon_extensions = eina_list_append(efreet_icon_extensions, eina_stringshare_add(default_exts[i]));
- efreet_icon_themes = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_icon_theme_free));
-
- efreet_extra_icon_dirs = NULL;
#ifndef ICON_CACHE
+ efreet_icon_themes = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_icon_theme_free));
efreet_icon_cache = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_icon_cache_free));
-#endif
-
-#if ICON_CACHE
+#else
+ efreet_icon_themes = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_icon_theme_free));
efreet_icon_changes_listen();
#endif
+
+ efreet_extra_icon_dirs = NULL;
+
return 1;
}
return &efreet_extra_icon_dirs;
}
-static Eina_Bool
-_hash_keys(Eina_Hash *hash __UNUSED__, const void *key, void *list)
-{
- *(Eina_List**)list = eina_list_append(*(Eina_List**)list, key);
- return EINA_TRUE;
-}
/**
* @return Returns a list of Efreet_Icon structs for all the non-hidden icon
* themes
efreet_icon_theme_list_get(void)
{
Eina_List *list = NULL;
- Eina_List *theme_list = NULL;
- char *dir;
+#ifndef ICON_CACHE
Eina_Iterator *it;
+ Efreet_Icon_Theme *theme;
/* update the list to include all icon themes */
efreet_icon_theme_dir_scan_all(NULL);
/* create the list for the user */
- it = eina_hash_iterator_key_new(efreet_icon_themes);
- eina_iterator_foreach(it, EINA_EACH_CB(_hash_keys), &theme_list);
- eina_iterator_free(it);
-
- EINA_LIST_FREE(theme_list, dir)
+ it = eina_hash_iterator_data_new(efreet_icon_themes);
+ EINA_ITERATOR_FOREACH(it, theme)
{
- Efreet_Icon_Theme *theme;
-
- theme = eina_hash_find(efreet_icon_themes, dir);
if (theme->hidden || !theme->valid) continue;
#ifndef STRICT_SPEC
if (!theme->name.name) continue;
list = eina_list_append(list, theme);
}
+ eina_iterator_free(it);
+#else
+ char **keys;
+ int num, i;
+
+ keys = efreet_cache_icon_theme_name_list(&num);
+ if (keys)
+ {
+ for (i = 0; i < num; i++)
+ {
+ Efreet_Icon_Theme *theme;
+
+ theme = efreet_icon_theme_find(keys[i]);
+ list = eina_list_append(list, theme);
+ }
+ free(keys);
+ }
+#endif
return list;
}
theme = eina_hash_find(efreet_icon_themes, theme_name);
if (!theme)
{
+#ifndef ICON_CACHE
efreet_icon_theme_dir_scan_all(theme_name);
theme = eina_hash_find(efreet_icon_themes, theme_name);
+#else
+ theme = efreet_cache_icon_theme_find(theme_name);
+ if (theme) eina_hash_direct_add(efreet_icon_themes, theme->name.internal, theme);
+#endif
}
return theme;
return tmp;
}
+#ifndef ICON_CACHE
/**
* @internal
* @param theme_name: The icon theme to look for
return theme;
}
+#endif
/**
* @param theme_name: The icon theme to look for
const char *value = NULL;
Efreet_Icon_Theme *theme;
+#ifndef ICON_CACHE
theme = efreet_icon_find_theme_check(theme_name);
+#else
+ theme = efreet_icon_theme_find(theme_name);
+#endif
if (theme)
{
char *data;
Efreet_Icon_Theme *theme;
+#ifndef ICON_CACHE
theme = efreet_icon_find_theme_check(theme_name);
+#else
+ theme = efreet_icon_theme_find(theme_name);
+#endif
if (theme)
{
efreet_ini_free(ini);
}
+#ifndef ICON_CACHE
/**
* @internal
* @return Returns a new Efreet_Icon_Theme on success or NULL on failure
*
* Needs EAPI because of helper binaries
*/
-#ifndef ICON_CACHE
static Efreet_Icon_Theme *
-#else
-EAPI Efreet_Icon_Theme *
-#endif
efreet_icon_theme_new(void)
{
Efreet_Icon_Theme *theme;
theme->paths = eina_list_append(theme->paths, eina_stringshare_add(path));
}
-#ifndef ICON_CACHE
/**
* @internal
* @return Returns no value
return 1;
}
-#endif
/**
* @internal
*
* Needs EAPI because of helper binaries
*/
-#ifndef ICON_CACHE
static Efreet_Icon_Theme_Directory *
-#else
-EAPI Efreet_Icon_Theme_Directory *
-#endif
efreet_icon_theme_directory_new(Efreet_Ini *ini, const char *name)
{
Efreet_Icon_Theme_Directory *dir;
FREE(dir);
}
-#ifndef ICON_CACHE
static void
efreet_icon_cache_free(Efreet_Icon_Cache *value)
{
efreet_icon_changes_cb,
NULL));
}
+ eina_iterator_free(it);
}
}
#define WRN(...) EINA_LOG_DOM_WARN(EFREET_MODULE_LOG_DOM, __VA_ARGS__)
extern Eina_Hash *efreet_desktop_cache;
+#ifdef ICON_CACHE
+extern Eina_Hash *efreet_icon_themes;
+#endif
#define EFREET_DESKTOP_CACHE_MAJOR 0
#define EFREET_DESKTOP_CACHE_MINOR 1
EAPI void efreet_cache_icon_fallback_free(Efreet_Cache_Fallback_Icon *icon);
Efreet_Cache_Icon *efreet_cache_icon_find(Efreet_Icon_Theme *theme, const char *icon);
Efreet_Cache_Fallback_Icon *efreet_cache_icon_fallback_find(const char *icon);
-
-EAPI Efreet_Icon_Theme *efreet_icon_theme_new(void);
-EAPI Efreet_Icon_Theme_Directory *efreet_icon_theme_directory_new(Efreet_Ini *ini,
- const char *name);
+Efreet_Icon_Theme *efreet_cache_icon_theme_find(const char *theme);
+void efreet_cache_icon_theme_free(Efreet_Icon_Theme *theme);
+char **efreet_cache_icon_theme_name_list(int *num);
#endif
EAPI void efreet_hash_free(Eina_Hash *hash, Eina_Free_Cb free_cb);
#endif
/* TODO: move eet file handling to eet_cache.c */
+/* TODO: add no_display check, as we might want only displayable items */
#undef alloca
#ifdef HAVE_ALLOCA_H
char *env;
char **e;
- while (environment)
- {
- env = eina_list_data_get(environment);
+ EINA_LIST_FREE(environment, env)
free(env);
- environment = eina_list_remove_list(environment, environment);
- }
for (e = environ; *e; e++)
environment = eina_list_append(environment, strdup(*e));
char *e;
if (!environment) return;
- *environ = NULL;
+ clearenv();
EINA_LIST_FOREACH(environment, l, e)
putenv(e);
}
int i, passed = 0, num_tests = 0;
Eina_List *run = NULL;
double total;
+ char *env;
eina_init();
ecore_init();
}
printf("\n-----------------\n");
- while (environment)
- {
- free(eina_list_data_get(environment));
- environment = eina_list_remove_list(environment, environment);
- }
+ clearenv();
+ EINA_LIST_FREE(environment, env)
+ free(env);
printf("Passed %d of %d tests.\n", passed, num_tests);
while (run)