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;
theme_name = NULL;
icon_cache = efreet_cache_close(icon_cache);
+ icon_theme_cache = efreet_cache_close(icon_theme_cache);
#endif
desktop_cache = efreet_cache_close(desktop_cache);
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 *
}
icon_cache = efreet_cache_close(icon_cache);
+ icon_theme_cache = efreet_cache_close(icon_theme_cache);
ev = NEW(Efreet_Event_Cache_Update, 1);
if (!ev) return;
static int _efreet_icon_log_dom = -1;
/* TODO: Scan efreet_extra_icon_dirs for themes */
-/* TODO: icon theme cache */
static const char *efreet_icon_deprecated_user_dir = NULL;
static const char *efreet_icon_user_dir = NULL;
};
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;
}
efreet_icon_theme_list_get(void)
{
Eina_List *list = NULL;
+#ifndef ICON_CACHE
Eina_Iterator *it;
Efreet_Icon_Theme *theme;
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)
{
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);