This commit is huge. I did test it a lot on my computer, and it run fine here.
But is so big i fear i could have broken some piece of code. So report any wrong behaviour to me (cedric on #edevelop). So moving e17 and efreet to eina_hash. With a little efreet API break so they must come together. SVN revision: 38185
This commit is contained in:
parent
e33474c92f
commit
35540b3a3b
|
@ -12,11 +12,12 @@
|
|||
#define THEME "Tango"
|
||||
#define FREE(x) do { free(x); x = NULL; } while (0);
|
||||
|
||||
static Eina_Bool _hash_keys(Eina_Hash *hash, const char *key, void *list);
|
||||
static void ef_icon_theme_themes_find(const char *search_dir,
|
||||
Ecore_Hash *themes);
|
||||
Eina_Hash *themes);
|
||||
static void ef_icons_find(Efreet_Icon_Theme *theme, Ecore_List *themes,
|
||||
Ecore_Hash *icons);
|
||||
static void ef_read_dir(const char *dir, Ecore_Hash *icons);
|
||||
Eina_Hash *icons);
|
||||
static void ef_read_dir(const char *dir, Eina_Hash *icons);
|
||||
|
||||
int
|
||||
ef_cb_efreet_icon_theme(void)
|
||||
|
@ -52,19 +53,27 @@ ef_cb_efreet_icon_theme(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_hash_keys(Eina_Hash *hash, const char *key, void *list)
|
||||
{
|
||||
ecore_list_append(list, key);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
ef_cb_efreet_icon_theme_list(void)
|
||||
{
|
||||
int ret = 1;
|
||||
Ecore_List *themes;
|
||||
Ecore_Hash *dirs;
|
||||
Eina_Hash *dirs;
|
||||
Eina_Iterator *it;
|
||||
Efreet_Icon_Theme *theme;
|
||||
Ecore_List *icon_dirs;
|
||||
const char *dir;
|
||||
char buf[PATH_MAX];
|
||||
void *value;
|
||||
|
||||
dirs = ecore_hash_new(ecore_str_hash, ecore_str_compare);
|
||||
ecore_hash_free_key_cb_set(dirs, free);
|
||||
dirs = eina_hash_string_superfast_new(free);
|
||||
|
||||
icon_dirs = efreet_data_dirs_get();
|
||||
ecore_list_first_goto(icon_dirs);
|
||||
|
@ -81,8 +90,8 @@ ef_cb_efreet_icon_theme_list(void)
|
|||
ecore_list_first_goto(themes);
|
||||
while ((theme = ecore_list_next(themes)))
|
||||
{
|
||||
if (ecore_hash_get(dirs, theme->name.internal))
|
||||
ecore_hash_remove(dirs, theme->name.internal);
|
||||
if ((eina_hash_find(dirs, theme->name.internal)))
|
||||
eina_hash_del(dirs, theme->name.internal, NULL);
|
||||
else
|
||||
{
|
||||
printf("efreet_icon_theme_list_get() returned %s which we didn't "
|
||||
|
@ -92,7 +101,11 @@ ef_cb_efreet_icon_theme_list(void)
|
|||
}
|
||||
ecore_list_destroy(themes);
|
||||
|
||||
themes = ecore_hash_keys(dirs);
|
||||
themes = ecore_list_new();
|
||||
it = eina_hash_iterator_key_new(dirs);
|
||||
eina_iterator_foreach(it, EINA_EACH(_hash_keys), themes);
|
||||
eina_iterator_free(it);
|
||||
|
||||
if (ecore_list_count(themes) > 0)
|
||||
{
|
||||
char *dir;
|
||||
|
@ -106,13 +119,13 @@ ef_cb_efreet_icon_theme_list(void)
|
|||
ret = 0;
|
||||
}
|
||||
ecore_list_destroy(themes);
|
||||
ecore_hash_destroy(dirs);
|
||||
eina_hash_free(dirs);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
ef_icon_theme_themes_find(const char *search_dir, Ecore_Hash *themes)
|
||||
ef_icon_theme_themes_find(const char *search_dir, Eina_Hash *themes)
|
||||
{
|
||||
Ecore_List *dirs;
|
||||
char *dir;
|
||||
|
@ -127,7 +140,7 @@ ef_icon_theme_themes_find(const char *search_dir, Ecore_Hash *themes)
|
|||
char p[PATH_MAX];
|
||||
|
||||
/* if we've already added the theme we're done */
|
||||
if (ecore_hash_get(themes, dir))
|
||||
if (eina_hash_find(themes, dir))
|
||||
{
|
||||
free(dir);
|
||||
continue;
|
||||
|
@ -152,7 +165,7 @@ ef_icon_theme_themes_find(const char *search_dir, Ecore_Hash *themes)
|
|||
if (!skip)
|
||||
{
|
||||
d = strdup(dir);
|
||||
ecore_hash_set(themes, d, d);
|
||||
eina_hash_add(themes, dir, d);
|
||||
}
|
||||
}
|
||||
free(dir);
|
||||
|
@ -425,7 +438,7 @@ int
|
|||
ef_cb_efreet_icon_match(void)
|
||||
{
|
||||
int i, ret = 1;
|
||||
Ecore_Hash *icon_hash;
|
||||
Eina_Hash *icon_hash;
|
||||
Efreet_Icon_Theme *theme;
|
||||
Ecore_List *themes;
|
||||
|
||||
|
@ -444,9 +457,7 @@ ef_cb_efreet_icon_match(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
icon_hash = ecore_hash_new(ecore_str_hash, ecore_str_compare);
|
||||
ecore_hash_free_key_cb_set(icon_hash, free);
|
||||
ecore_hash_free_value_cb_set(icon_hash, free);
|
||||
icon_hash = eina_hash_string_superfast_new(free);
|
||||
|
||||
ef_icons_find(theme, themes, icon_hash);
|
||||
ecore_list_destroy(themes);
|
||||
|
@ -461,7 +472,7 @@ ef_cb_efreet_icon_match(void)
|
|||
if (!path)
|
||||
{
|
||||
#if 1
|
||||
if (ecore_hash_get(icon_hash, icons[i]))
|
||||
if (eina_hash_find(icon_hash, icons[i]))
|
||||
{
|
||||
printf("NOT FOUND %s\n", icons[i]);
|
||||
ret = 0;
|
||||
|
@ -469,7 +480,7 @@ ef_cb_efreet_icon_match(void)
|
|||
#endif
|
||||
continue;
|
||||
}
|
||||
else if (!ecore_hash_get(icon_hash, icons[i]))
|
||||
else if (!eina_hash_find(icon_hash, icons[i]))
|
||||
{
|
||||
printf("Found icon not in hash: %s\n", icons[i]);
|
||||
}
|
||||
|
@ -487,7 +498,7 @@ ef_cb_efreet_icon_match(void)
|
|||
free(path);
|
||||
}
|
||||
printf("Time: %f\n", (ecore_time_get() - start));
|
||||
ecore_hash_destroy(icon_hash);
|
||||
eina_hash_free(icon_hash);
|
||||
|
||||
start = ecore_time_get();
|
||||
for (i = 0; icons[i] != NULL; i++)
|
||||
|
@ -516,7 +527,7 @@ ef_cb_efreet_icon_match(void)
|
|||
}
|
||||
|
||||
static void
|
||||
ef_icons_find(Efreet_Icon_Theme *theme, Ecore_List *themes, Ecore_Hash *icons)
|
||||
ef_icons_find(Efreet_Icon_Theme *theme, Ecore_List *themes, Eina_Hash *icons)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
|
||||
|
@ -599,7 +610,7 @@ ef_icons_find(Efreet_Icon_Theme *theme, Ecore_List *themes, Ecore_Hash *icons)
|
|||
}
|
||||
|
||||
static void
|
||||
ef_read_dir(const char *dir, Ecore_Hash *icons)
|
||||
ef_read_dir(const char *dir, Eina_Hash *icons)
|
||||
{
|
||||
Ecore_List *files;
|
||||
char *file;
|
||||
|
@ -624,7 +635,7 @@ ef_read_dir(const char *dir, Ecore_Hash *icons)
|
|||
{
|
||||
*p = '\0';
|
||||
|
||||
ecore_hash_set(icons, strdup(file), strdup(file));
|
||||
eina_hash_add(icons, file, strdup(file));
|
||||
}
|
||||
|
||||
FREE(file);
|
||||
|
|
|
@ -13,7 +13,7 @@ static const char *desktop_environment = NULL;
|
|||
* A cache of all loaded desktops, hashed by file name.
|
||||
* Values are Efreet_Desktop structures
|
||||
*/
|
||||
static Ecore_Hash *efreet_desktop_cache = NULL;
|
||||
static Eina_Hash *efreet_desktop_cache = NULL;
|
||||
|
||||
/**
|
||||
* A list of the desktop types available
|
||||
|
@ -61,10 +61,14 @@ static int efreet_desktop_generic_fields_parse(Efreet_Desktop *desktop,
|
|||
Efreet_Ini *ini);
|
||||
static void efreet_desktop_generic_fields_save(Efreet_Desktop *desktop,
|
||||
Efreet_Ini *ini);
|
||||
static void efreet_desktop_x_fields_parse(Ecore_Hash_Node *node,
|
||||
Efreet_Desktop *desktop);
|
||||
static void efreet_desktop_x_fields_save(Ecore_Hash_Node *node,
|
||||
Efreet_Ini *ini);
|
||||
static Eina_Bool efreet_desktop_x_fields_parse(const Eina_Hash *hash,
|
||||
const void *key,
|
||||
void *data,
|
||||
void *fdata);
|
||||
static Eina_Bool efreet_desktop_x_fields_save(const Eina_Hash *hash,
|
||||
const void *key,
|
||||
void *value,
|
||||
void *fdata);
|
||||
static int efreet_desktop_environment_check(Efreet_Ini *ini);
|
||||
static char *efreet_string_append(char *dest, int *size,
|
||||
int *len, const char *src);
|
||||
|
@ -116,8 +120,7 @@ efreet_desktop_init(void)
|
|||
if (!eina_stringshare_init()) return --init;
|
||||
if (!ecore_file_init()) return --init;
|
||||
|
||||
efreet_desktop_cache = ecore_hash_new(ecore_str_hash, ecore_str_compare);
|
||||
ecore_hash_free_key_cb_set(efreet_desktop_cache, ECORE_FREE_CB(free));
|
||||
efreet_desktop_cache = eina_hash_string_superfast_new(NULL);
|
||||
|
||||
efreet_desktop_types = ecore_list_new();
|
||||
ecore_list_free_cb_set(efreet_desktop_types,
|
||||
|
@ -188,7 +191,7 @@ efreet_desktop_get(const char *file)
|
|||
|
||||
if (efreet_desktop_cache)
|
||||
{
|
||||
desktop = ecore_hash_get(efreet_desktop_cache, file);
|
||||
desktop = eina_hash_find(efreet_desktop_cache, file);
|
||||
if (desktop)
|
||||
{
|
||||
if (efreet_desktop_cache_check(desktop))
|
||||
|
@ -206,14 +209,14 @@ efreet_desktop_get(const char *file)
|
|||
}
|
||||
|
||||
desktop->cached = 0;
|
||||
ecore_hash_remove(efreet_desktop_cache, file);
|
||||
eina_hash_del(efreet_desktop_cache, file, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
desktop = efreet_desktop_new(file);
|
||||
if (!desktop) return NULL;
|
||||
|
||||
ecore_hash_set(efreet_desktop_cache, strdup(file), desktop);
|
||||
eina_hash_add(efreet_desktop_cache, file, desktop);
|
||||
desktop->cached = 1;
|
||||
return desktop;
|
||||
}
|
||||
|
@ -330,8 +333,7 @@ efreet_desktop_read(Efreet_Desktop *desktop)
|
|||
if (!error && !efreet_desktop_environment_check(ini)) error = 1;
|
||||
if (!error && !efreet_desktop_generic_fields_parse(desktop, ini)) error = 1;
|
||||
if (!error)
|
||||
ecore_hash_for_each_node(ini->section,
|
||||
ECORE_FOR_EACH(efreet_desktop_x_fields_parse), desktop);
|
||||
eina_hash_foreach(ini->section, efreet_desktop_x_fields_parse, desktop);
|
||||
|
||||
efreet_ini_free(ini);
|
||||
|
||||
|
@ -428,11 +430,12 @@ efreet_desktop_save(Efreet_Desktop *desktop)
|
|||
if (!efreet_ini_save(ini, desktop->orig_path)) ok = 0;
|
||||
else
|
||||
{
|
||||
if (desktop != ecore_hash_get(efreet_desktop_cache, desktop->orig_path))
|
||||
if (desktop != eina_hash_find(efreet_desktop_cache, desktop->orig_path))
|
||||
{
|
||||
desktop->cached = 1;
|
||||
ecore_hash_set(efreet_desktop_cache,
|
||||
strdup(desktop->orig_path), desktop);
|
||||
eina_hash_del(efreet_desktop_cache, desktop->orig_path, NULL);
|
||||
eina_hash_add(efreet_desktop_cache, desktop->orig_path,
|
||||
desktop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -449,10 +452,10 @@ efreet_desktop_save(Efreet_Desktop *desktop)
|
|||
EAPI int
|
||||
efreet_desktop_save_as(Efreet_Desktop *desktop, const char *file)
|
||||
{
|
||||
if (desktop == ecore_hash_get(efreet_desktop_cache, desktop->orig_path))
|
||||
if (desktop == eina_hash_find(efreet_desktop_cache, desktop->orig_path))
|
||||
{
|
||||
desktop->cached = 0;
|
||||
ecore_hash_remove(efreet_desktop_cache, desktop->orig_path);
|
||||
eina_hash_del(efreet_desktop_cache, desktop->orig_path, NULL);
|
||||
}
|
||||
FREE(desktop->orig_path);
|
||||
desktop->orig_path = strdup(file);
|
||||
|
@ -474,7 +477,7 @@ efreet_desktop_free(Efreet_Desktop *desktop)
|
|||
if (desktop->ref > 0) return;
|
||||
|
||||
if (desktop->cached && efreet_desktop_cache)
|
||||
ecore_hash_remove(efreet_desktop_cache, desktop->orig_path);
|
||||
eina_hash_del(efreet_desktop_cache, desktop->orig_path, NULL);
|
||||
|
||||
IF_FREE(desktop->orig_path);
|
||||
|
||||
|
@ -985,9 +988,8 @@ efreet_desktop_generic_fields_save(Efreet_Desktop *desktop, Efreet_Ini *ini)
|
|||
efreet_ini_boolean_set(ini, "NoDisplay", desktop->no_display);
|
||||
efreet_ini_boolean_set(ini, "Hidden", desktop->hidden);
|
||||
|
||||
if (desktop->x) ecore_hash_for_each_node(desktop->x,
|
||||
ECORE_FOR_EACH(efreet_desktop_x_fields_save),
|
||||
ini);
|
||||
if (desktop->x) eina_hash_foreach(desktop->x, efreet_desktop_x_fields_save,
|
||||
ini);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -997,21 +999,19 @@ efreet_desktop_generic_fields_save(Efreet_Desktop *desktop, Efreet_Ini *ini)
|
|||
* @return Returns no value
|
||||
* @brief Parses out an X- key from @a node and stores in @a desktop
|
||||
*/
|
||||
static void
|
||||
efreet_desktop_x_fields_parse(Ecore_Hash_Node *node, Efreet_Desktop *desktop)
|
||||
static Eina_Bool
|
||||
efreet_desktop_x_fields_parse(const Eina_Hash *hash, const void *key, void *value, void *fdata)
|
||||
{
|
||||
if (strncmp(node->key, "X-", 2)) return;
|
||||
Efreet_Desktop * desktop = fdata;
|
||||
|
||||
if (!desktop->x)
|
||||
{
|
||||
desktop->x = ecore_hash_new(ecore_str_hash, ecore_str_compare);
|
||||
ecore_hash_free_key_cb_set(desktop->x,
|
||||
ECORE_FREE_CB(eina_stringshare_del));
|
||||
ecore_hash_free_value_cb_set(desktop->x,
|
||||
ECORE_FREE_CB(eina_stringshare_del));
|
||||
}
|
||||
ecore_hash_set(desktop->x, (void *)eina_stringshare_add(node->key),
|
||||
(void *)eina_stringshare_add(node->value));
|
||||
if (strncmp(key, "X-", 2)) return EINA_TRUE;
|
||||
|
||||
if (desktop && !desktop->x)
|
||||
desktop->x = eina_hash_string_superfast_new(EINA_FREE_CB(eina_stringshare_del));
|
||||
eina_hash_del(desktop->x, key, NULL);
|
||||
eina_hash_add(desktop->x, key, (void *)eina_stringshare_add(value));
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1021,10 +1021,13 @@ efreet_desktop_x_fields_parse(Ecore_Hash_Node *node, Efreet_Desktop *desktop)
|
|||
* @return Returns no value
|
||||
* @brief Stores an X- key from @a node and stores in @a ini
|
||||
*/
|
||||
static void
|
||||
efreet_desktop_x_fields_save(Ecore_Hash_Node *node, Efreet_Ini *ini)
|
||||
static Eina_Bool
|
||||
efreet_desktop_x_fields_save(const Eina_Hash *hash, const void *key, void *value, void *fdata)
|
||||
{
|
||||
efreet_ini_string_set(ini, node->key, node->value);
|
||||
Efreet_Ini *ini = fdata;
|
||||
efreet_ini_string_set(ini, key, value);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ struct Efreet_Desktop
|
|||
unsigned char startup_notify:1; /**< The starup notify settings of the app */
|
||||
unsigned char cached:1; /**< The desktop file is cached by Efreet */
|
||||
|
||||
Ecore_Hash *x; /**< Keep track of all user extensions, keys that begin with X- */
|
||||
Eina_Hash *x; /**< Keep track of all user extensions, keys that begin with X- */
|
||||
void *type_data; /**< Type specific data for custom types */
|
||||
};
|
||||
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
static char *efreet_icon_deprecated_user_dir = NULL;
|
||||
static char *efreet_icon_user_dir = NULL;
|
||||
static Ecore_Hash *efreet_icon_themes = NULL;
|
||||
static Eina_Hash *efreet_icon_themes = NULL;
|
||||
static Ecore_List *efreet_icon_extensions = NULL;
|
||||
static Ecore_List *efreet_extra_icon_dirs = NULL;
|
||||
static Ecore_Hash *efreet_icon_cache = NULL;
|
||||
static Eina_Hash *efreet_icon_cache = NULL;
|
||||
|
||||
static int efreet_icon_init_count = 0;
|
||||
|
||||
|
@ -110,13 +110,10 @@ efreet_icon_init(void)
|
|||
for (i = 0; default_exts[i] != NULL; i++)
|
||||
ecore_list_append(efreet_icon_extensions, strdup(default_exts[i]));
|
||||
|
||||
efreet_icon_themes = ecore_hash_new(NULL, NULL);
|
||||
ecore_hash_free_value_cb_set(efreet_icon_themes,
|
||||
ECORE_FREE_CB(efreet_icon_theme_free));
|
||||
efreet_icon_themes = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_icon_theme_free));
|
||||
efreet_extra_icon_dirs = ecore_list_new();
|
||||
|
||||
efreet_icon_cache = ecore_hash_new(ecore_direct_hash, ecore_direct_compare);
|
||||
ecore_hash_free_value_cb_set(efreet_icon_cache, ECORE_FREE_CB(ecore_list_destroy));
|
||||
efreet_icon_cache = eina_hash_pointer_new(EINA_FREE_CB(ecore_list_destroy));
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -207,6 +204,12 @@ efreet_icon_extra_list_get(void)
|
|||
return efreet_extra_icon_dirs;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_hash_keys(Eina_Hash *hash, const void *key, void *list)
|
||||
{
|
||||
ecore_list_append(list, key);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
/**
|
||||
* @return Returns a list of Efreet_Icon structs for all the non-hidden icon
|
||||
* themes
|
||||
|
@ -218,6 +221,7 @@ efreet_icon_theme_list_get(void)
|
|||
{
|
||||
Ecore_List *list, *theme_list;
|
||||
char *dir;
|
||||
Eina_Iterator *it;
|
||||
|
||||
/* update the list to include all icon themes */
|
||||
efreet_icon_theme_dir_scan_all(NULL);
|
||||
|
@ -225,13 +229,16 @@ efreet_icon_theme_list_get(void)
|
|||
|
||||
/* create the list for the user */
|
||||
list = ecore_list_new();
|
||||
theme_list = ecore_hash_keys(efreet_icon_themes);
|
||||
theme_list = ecore_list_new();
|
||||
it = eina_hash_iterator_key_new(efreet_icon_themes);
|
||||
eina_iterator_foreach(it, EINA_EACH(_hash_keys), theme_list);
|
||||
eina_iterator_free(it);
|
||||
ecore_list_first_goto(theme_list);
|
||||
while ((dir = ecore_list_next(theme_list)))
|
||||
{
|
||||
Efreet_Icon_Theme *theme;
|
||||
|
||||
theme = ecore_hash_get(efreet_icon_themes, dir);
|
||||
theme = eina_hash_find(efreet_icon_themes, dir);
|
||||
if (theme->hidden || theme->fake) continue;
|
||||
#ifndef STRICT_SPEC
|
||||
if (!theme->name.name) continue;
|
||||
|
@ -257,11 +264,11 @@ efreet_icon_theme_find(const char *theme_name)
|
|||
Efreet_Icon_Theme *theme;
|
||||
|
||||
key = eina_stringshare_add(theme_name);
|
||||
theme = ecore_hash_get(efreet_icon_themes, key);
|
||||
theme = eina_hash_find(efreet_icon_themes, key);
|
||||
if (!theme)
|
||||
{
|
||||
efreet_icon_theme_dir_scan_all(theme_name);
|
||||
theme = ecore_hash_get(efreet_icon_themes, key);
|
||||
theme = eina_hash_find(efreet_icon_themes, key);
|
||||
}
|
||||
eina_stringshare_del(key);
|
||||
|
||||
|
@ -319,7 +326,8 @@ efreet_icon_find_theme_check(const char *theme_name)
|
|||
theme = efreet_icon_theme_new();
|
||||
theme->fake = 1;
|
||||
theme->name.internal = eina_stringshare_add(theme_name);
|
||||
ecore_hash_set(efreet_icon_themes, (void *)theme->name.internal, theme);
|
||||
eina_hash_del(efreet_icon_themes, (void *)theme->name.internal, NULL);
|
||||
eina_hash_add(efreet_icon_themes, (void *)theme->name.internal, theme);
|
||||
}
|
||||
|
||||
return theme;
|
||||
|
@ -1217,7 +1225,7 @@ efreet_icon_theme_cache_check_dir(Efreet_Icon_Theme *theme, const char *dir)
|
|||
/* have we modified this directory since our last cache check? */
|
||||
if (stat(dir, &buf) || (buf.st_mtime > theme->last_cache_check))
|
||||
{
|
||||
ecore_hash_remove(efreet_icon_cache, theme);
|
||||
eina_hash_del(efreet_icon_cache, &theme, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1289,14 +1297,14 @@ efreet_icon_theme_dir_scan(const char *search_dir, const char *theme_name)
|
|||
continue;
|
||||
|
||||
key = eina_stringshare_add(dir->d_name);
|
||||
theme = ecore_hash_get(efreet_icon_themes, key);
|
||||
theme = eina_hash_find(efreet_icon_themes, key);
|
||||
|
||||
if (!theme)
|
||||
{
|
||||
theme = efreet_icon_theme_new();
|
||||
theme->name.internal = key;
|
||||
ecore_hash_set(efreet_icon_themes,
|
||||
(void *)theme->name.internal, theme);
|
||||
eina_hash_add(efreet_icon_themes,
|
||||
(void *)theme->name.internal, theme);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1323,12 +1331,9 @@ efreet_icon_theme_dir_scan(const char *search_dir, const char *theme_name)
|
|||
{
|
||||
Efreet_Icon_Theme *theme;
|
||||
|
||||
theme = ecore_hash_get(efreet_icon_themes, theme_name);
|
||||
theme = eina_hash_find(efreet_icon_themes, theme_name);
|
||||
if (theme && !theme->valid && !theme->fake)
|
||||
{
|
||||
ecore_hash_remove(efreet_icon_themes, theme_name);
|
||||
efreet_icon_theme_free(theme);
|
||||
}
|
||||
eina_hash_del(efreet_icon_themes, theme_name, theme);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1441,19 +1446,20 @@ efreet_icon_theme_dir_validity_check(void)
|
|||
{
|
||||
Ecore_List *keys;
|
||||
const char *name;
|
||||
Eina_Iterator *it;
|
||||
|
||||
keys = ecore_hash_keys(efreet_icon_themes);
|
||||
keys = ecore_list_new();
|
||||
it = eina_hash_iterator_key_new(efreet_icon_themes);
|
||||
eina_iterator_foreach(it, EINA_EACH(_hash_keys), keys);
|
||||
eina_iterator_free(it);
|
||||
ecore_list_first_goto(keys);
|
||||
while ((name = ecore_list_next(keys)))
|
||||
{
|
||||
Efreet_Icon_Theme *theme;
|
||||
|
||||
theme = ecore_hash_get(efreet_icon_themes, name);
|
||||
if (!theme->valid && !theme->fake)
|
||||
{
|
||||
ecore_hash_remove(efreet_icon_themes, name);
|
||||
efreet_icon_theme_free(theme);
|
||||
}
|
||||
theme = eina_hash_find(efreet_icon_themes, name);
|
||||
if (theme && !theme->valid && !theme->fake)
|
||||
eina_hash_del(efreet_icon_themes, name, theme);
|
||||
}
|
||||
ecore_list_destroy(keys);
|
||||
}
|
||||
|
@ -1583,12 +1589,12 @@ efreet_icon_cache_check(Efreet_Icon_Theme *theme, const char *icon, unsigned int
|
|||
char key[4096];
|
||||
struct stat st;
|
||||
|
||||
list = ecore_hash_get(efreet_icon_cache, theme);
|
||||
list = eina_hash_find(efreet_icon_cache, &theme);
|
||||
if (!list)
|
||||
{
|
||||
list = ecore_list_new();
|
||||
ecore_list_free_cb_set(list, ECORE_FREE_CB(efreet_icon_cache_free));
|
||||
ecore_hash_set(efreet_icon_cache, theme, list);
|
||||
eina_hash_add(efreet_icon_cache, &theme, list);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1620,12 +1626,12 @@ efreet_icon_cache_add(Efreet_Icon_Theme *theme, const char *icon, unsigned int s
|
|||
char key[4096];
|
||||
struct stat st;
|
||||
|
||||
list = ecore_hash_get(efreet_icon_cache, theme);
|
||||
list = eina_hash_find(efreet_icon_cache, &theme);
|
||||
if (!list)
|
||||
{
|
||||
list = ecore_list_new();
|
||||
ecore_list_free_cb_set(list, ECORE_FREE_CB(efreet_icon_cache_free));
|
||||
ecore_hash_set(efreet_icon_cache, theme, list);
|
||||
eina_hash_add(efreet_icon_cache, &theme, list);
|
||||
}
|
||||
|
||||
snprintf(key, sizeof(key), "%s %d", icon, size);
|
||||
|
|
|
@ -2,11 +2,13 @@
|
|||
#include "Efreet.h"
|
||||
#include "efreet_private.h"
|
||||
|
||||
static Ecore_Hash *efreet_ini_parse(const char *file);
|
||||
static Eina_Hash *efreet_ini_parse(const char *file);
|
||||
static char *efreet_ini_unescape(const char *str);
|
||||
|
||||
static void efreet_ini_section_save(Ecore_Hash_Node *node, FILE *f);
|
||||
static void efreet_ini_value_save(Ecore_Hash_Node *node, FILE *f);
|
||||
static Eina_Bool
|
||||
efreet_ini_section_save(const Eina_Hash *hash, const void *key, void *data, void *fdata);
|
||||
static Eina_Bool
|
||||
efreet_ini_value_save(const Eina_Hash *hash, const void *key, void *data, void *fdata);
|
||||
|
||||
/**
|
||||
* The number of times the Ini subsytem has been initialized
|
||||
|
@ -65,16 +67,16 @@ efreet_ini_new(const char *file)
|
|||
/**
|
||||
* @internal
|
||||
* @param file The file to parse
|
||||
* @return Returns an Ecore_Hash with the contents of @a file, or NULL if the
|
||||
* @return Returns an Eina_Hash with the contents of @a file, or NULL if the
|
||||
* file fails to parse or if the file doesn't exist
|
||||
* @brief Parses the ini file @a file into an Ecore_Hash
|
||||
* @brief Parses the ini file @a file into an Eina_Hash
|
||||
*/
|
||||
static Ecore_Hash *
|
||||
static Eina_Hash *
|
||||
efreet_ini_parse(const char *file)
|
||||
{
|
||||
const char *buffer, *line_start;
|
||||
FILE *f;
|
||||
Ecore_Hash *data, *section = NULL;
|
||||
Eina_Hash *data, *section = NULL;
|
||||
struct stat file_stat;
|
||||
int line_length, left;
|
||||
|
||||
|
@ -100,9 +102,7 @@ efreet_ini_parse(const char *file)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
data = ecore_hash_new(ecore_str_hash, ecore_str_compare);
|
||||
ecore_hash_free_key_cb_set(data, ECORE_FREE_CB(eina_stringshare_del));
|
||||
ecore_hash_free_value_cb_set(data, ECORE_FREE_CB(ecore_hash_destroy));
|
||||
data = eina_hash_string_small_new(EINA_FREE_CB(eina_hash_free));
|
||||
|
||||
line_start = buffer;
|
||||
while (left > 0)
|
||||
|
@ -141,7 +141,7 @@ efreet_ini_parse(const char *file)
|
|||
|
||||
if (line_start[header_length] == ']')
|
||||
{
|
||||
Ecore_Hash *old;
|
||||
Eina_Hash *old;
|
||||
const char *header;
|
||||
|
||||
header = alloca(header_length * sizeof(unsigned char));
|
||||
|
@ -150,18 +150,13 @@ efreet_ini_parse(const char *file)
|
|||
memcpy((char*)header, line_start + 1, header_length - 1);
|
||||
((char*)header)[header_length - 1] = '\0';
|
||||
|
||||
section = ecore_hash_new(ecore_str_hash, ecore_str_compare);
|
||||
ecore_hash_free_key_cb_set(section,
|
||||
ECORE_FREE_CB(eina_stringshare_del));
|
||||
ecore_hash_free_value_cb_set(section, ECORE_FREE_CB(free));
|
||||
section = eina_hash_string_small_new(free);
|
||||
|
||||
old = ecore_hash_remove(data, header);
|
||||
eina_hash_del(data, header, NULL);
|
||||
// if (old) printf("[efreet] Warning: duplicate section '%s' "
|
||||
// "in file '%s'\n", header, file);
|
||||
|
||||
IF_FREE_HASH(old);
|
||||
ecore_hash_set(data, (void *)eina_stringshare_add(header),
|
||||
section);
|
||||
eina_hash_add(data, header, section);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -197,15 +192,15 @@ efreet_ini_parse(const char *file)
|
|||
|
||||
/* trim whitespace from start of value */
|
||||
for (value_start = sep + 1;
|
||||
(value_start < line_length) &&
|
||||
isspace(line_start[value_start]); ++value_start)
|
||||
(value_start < line_length) &&
|
||||
isspace(line_start[value_start]); ++value_start)
|
||||
;
|
||||
|
||||
/* trim \n off of end of value */
|
||||
for (value_end = line_length;
|
||||
(value_end > value_start) &&
|
||||
((line_start[value_end] == '\n') ||
|
||||
(line_start[value_end] == '\r')); --value_end)
|
||||
(value_end > value_start) &&
|
||||
((line_start[value_end] == '\n') ||
|
||||
(line_start[value_end] == '\r')); --value_end)
|
||||
;
|
||||
|
||||
if (line_start[value_end] != '\n'
|
||||
|
@ -233,11 +228,8 @@ efreet_ini_parse(const char *file)
|
|||
value_end - value_start);
|
||||
((char*)value)[value_end - value_start] = '\0';
|
||||
|
||||
old = ecore_hash_remove(section, key);
|
||||
IF_FREE(old);
|
||||
|
||||
ecore_hash_set(section, (void *)eina_stringshare_add(key),
|
||||
efreet_ini_unescape(value));
|
||||
eina_hash_del(section, key, NULL);
|
||||
eina_hash_add(section, key, efreet_ini_unescape(value));
|
||||
}
|
||||
// else
|
||||
// {
|
||||
|
@ -283,7 +275,7 @@ efreet_ini_save(Efreet_Ini *ini, const char *file)
|
|||
|
||||
f = fopen(file, "wb");
|
||||
if (!f) return 0;
|
||||
ecore_hash_for_each_node(ini->data, ECORE_FOR_EACH(efreet_ini_section_save), f);
|
||||
eina_hash_foreach(ini->data, efreet_ini_section_save, f);
|
||||
fclose(f);
|
||||
|
||||
return 1;
|
||||
|
@ -300,7 +292,7 @@ efreet_ini_section_set(Efreet_Ini *ini, const char *section)
|
|||
{
|
||||
if (!ini || !ini->data || !section) return 0;
|
||||
|
||||
ini->section = ecore_hash_get(ini->data, section);
|
||||
ini->section = eina_hash_find(ini->data, section);
|
||||
return (ini->section ? 1 : 0);
|
||||
}
|
||||
|
||||
|
@ -313,22 +305,16 @@ efreet_ini_section_set(Efreet_Ini *ini, const char *section)
|
|||
EAPI void
|
||||
efreet_ini_section_add(Efreet_Ini *ini, const char *section)
|
||||
{
|
||||
Ecore_Hash *hash;
|
||||
Eina_Hash *hash;
|
||||
|
||||
if (!ini || !section) return;
|
||||
|
||||
if (!ini->data)
|
||||
{
|
||||
ini->data = ecore_hash_new(ecore_str_hash, ecore_str_compare);
|
||||
ecore_hash_free_key_cb_set(ini->data, ECORE_FREE_CB(eina_stringshare_del));
|
||||
ecore_hash_free_value_cb_set(ini->data, ECORE_FREE_CB(ecore_hash_destroy));
|
||||
}
|
||||
if (ecore_hash_get(ini->data, section)) return;
|
||||
ini->data = eina_hash_string_small_new(EINA_FREE_CB(eina_hash_free));
|
||||
if (eina_hash_find(ini->data, section)) return;
|
||||
|
||||
hash = ecore_hash_new(ecore_str_hash, ecore_str_compare);
|
||||
ecore_hash_free_key_cb_set(hash, ECORE_FREE_CB(eina_stringshare_del));
|
||||
ecore_hash_free_value_cb_set(hash, ECORE_FREE_CB(free));
|
||||
ecore_hash_set(ini->data, (void *)eina_stringshare_add(section), hash);
|
||||
hash = eina_hash_string_small_new(free);
|
||||
eina_hash_add(ini->data, section, hash);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -343,7 +329,7 @@ efreet_ini_string_get(Efreet_Ini *ini, const char *key)
|
|||
{
|
||||
if (!ini || !key || !ini->section) return NULL;
|
||||
|
||||
return ecore_hash_get(ini->section, key);
|
||||
return eina_hash_find(ini->section, key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -358,7 +344,8 @@ efreet_ini_string_set(Efreet_Ini *ini, const char *key, const char *value)
|
|||
{
|
||||
if (!ini || !key || !ini->section) return;
|
||||
|
||||
ecore_hash_set(ini->section, (void *)eina_stringshare_add(key), strdup(value));
|
||||
eina_hash_del(ini->section, key, NULL);
|
||||
eina_hash_add(ini->section, key, strdup(value));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -637,15 +624,21 @@ efreet_ini_unescape(const char *str)
|
|||
return buf;
|
||||
}
|
||||
|
||||
static void
|
||||
efreet_ini_section_save(Ecore_Hash_Node *node, FILE *f)
|
||||
static Eina_Bool
|
||||
efreet_ini_section_save(const Eina_Hash *hash, const void *key, void *value, void *fdata)
|
||||
{
|
||||
fprintf(f, "[%s]\n", (char *)node->key);
|
||||
ecore_hash_for_each_node(node->value, ECORE_FOR_EACH(efreet_ini_value_save), f);
|
||||
FILE *f = fdata;
|
||||
|
||||
fprintf(f, "[%s]\n", (char *)key);
|
||||
eina_hash_foreach(value, efreet_ini_value_save, f);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
efreet_ini_value_save(Ecore_Hash_Node *node, FILE *f)
|
||||
static Eina_Bool
|
||||
efreet_ini_value_save(const Eina_Hash *hash, const void *key, void *value, void *fdata)
|
||||
{
|
||||
fprintf(f, "%s=%s\n", (char *)node->key, (char *)node->value);
|
||||
FILE *f = fdata;
|
||||
|
||||
fprintf(f, "%s=%s\n", (char *)key, (char *)value);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@ typedef struct Efreet_Ini Efreet_Ini;
|
|||
*/
|
||||
struct Efreet_Ini
|
||||
{
|
||||
Ecore_Hash *data; /**< Hash of string => (Hash of string => string) */
|
||||
Ecore_Hash *section; /**< currently selected section */
|
||||
Eina_Hash *data; /**< Hash of string => (Hash of string => string) */
|
||||
Eina_Hash *section; /**< currently selected section */
|
||||
};
|
||||
|
||||
EAPI Efreet_Ini *efreet_ini_new(const char *file);
|
||||
|
|
|
@ -51,7 +51,7 @@ struct Efreet_Menu_Internal
|
|||
Ecore_List *applications; /**< applications in this menu */
|
||||
|
||||
Ecore_DList *directory_dirs; /**< .directory file directories */
|
||||
Ecore_Hash *directory_cache; /**< .directory dirs */
|
||||
Eina_Hash *directory_cache; /**< .directory dirs */
|
||||
|
||||
Ecore_List *moves; /**< List of moves to be handled by the menu */
|
||||
Ecore_List *filters; /**< Include and Exclude filters */
|
||||
|
@ -212,13 +212,13 @@ Ecore_List *efreet_menu_kde_legacy_dirs = NULL; /**< The directories to use for
|
|||
static const char *efreet_tag_menu = NULL;
|
||||
static char *efreet_menu_file = NULL; /**< A menu file set explicityl as default */
|
||||
|
||||
static Ecore_Hash *efreet_merged_menus = NULL;
|
||||
static Ecore_Hash *efreet_merged_dirs = NULL;
|
||||
static Eina_Hash *efreet_merged_menus = NULL;
|
||||
static Eina_Hash *efreet_merged_dirs = NULL;
|
||||
|
||||
static Ecore_Hash *efreet_menu_handle_cbs = NULL;
|
||||
static Ecore_Hash *efreet_menu_filter_cbs = NULL;
|
||||
static Ecore_Hash *efreet_menu_move_cbs = NULL;
|
||||
static Ecore_Hash *efreet_menu_layout_cbs = NULL;
|
||||
static Eina_Hash *efreet_menu_handle_cbs = NULL;
|
||||
static Eina_Hash *efreet_menu_filter_cbs = NULL;
|
||||
static Eina_Hash *efreet_menu_move_cbs = NULL;
|
||||
static Eina_Hash *efreet_menu_layout_cbs = NULL;
|
||||
|
||||
static const char *efreet_menu_prefix_get(void);
|
||||
|
||||
|
@ -242,14 +242,14 @@ static int efreet_menu_app_dir_scan(Efreet_Menu_Internal *internal,
|
|||
int legacy);
|
||||
static int efreet_menu_directory_dirs_process(Efreet_Menu_Internal *internal);
|
||||
static int efreet_menu_directory_dir_scan(const char *path,
|
||||
const char *relative_path,
|
||||
Ecore_Hash *cache);
|
||||
const char *relative_path,
|
||||
Eina_Hash *cache);
|
||||
static Efreet_Desktop *efreet_menu_directory_get(Efreet_Menu_Internal *internal,
|
||||
const char *path);
|
||||
static void efreet_menu_process_filters(Efreet_Menu_Internal *internal,
|
||||
unsigned int only_unallocated);
|
||||
static void efreet_menu_process_app_pool(Ecore_List *pool, Ecore_List *applications,
|
||||
Ecore_Hash *matches,
|
||||
Eina_Hash *matches,
|
||||
Efreet_Menu_Filter *filter,
|
||||
unsigned int only_unallocated);
|
||||
static int efreet_menu_filter_matches(Efreet_Menu_Filter_Op *op,
|
||||
|
@ -439,47 +439,54 @@ efreet_menu_init(void)
|
|||
if (!eina_stringshare_init()) return 0;
|
||||
if (!efreet_xml_init()) return 0;
|
||||
|
||||
efreet_menu_handle_cbs = ecore_hash_new(NULL, NULL);
|
||||
efreet_menu_filter_cbs = ecore_hash_new(NULL, NULL);
|
||||
efreet_menu_move_cbs = ecore_hash_new(NULL, NULL);
|
||||
efreet_menu_layout_cbs = ecore_hash_new(NULL, NULL);
|
||||
efreet_menu_handle_cbs = eina_hash_string_superfast_new(NULL);
|
||||
efreet_menu_filter_cbs = eina_hash_string_superfast_new(NULL);
|
||||
efreet_menu_move_cbs = eina_hash_string_superfast_new(NULL);
|
||||
efreet_menu_layout_cbs = eina_hash_string_superfast_new(NULL);
|
||||
if (!efreet_menu_handle_cbs || !efreet_menu_filter_cbs
|
||||
|| !efreet_menu_move_cbs || !efreet_menu_layout_cbs)
|
||||
return 0;
|
||||
|
||||
ecore_hash_free_key_cb_set(efreet_menu_handle_cbs,
|
||||
ECORE_FREE_CB(eina_stringshare_del));
|
||||
ecore_hash_free_key_cb_set(efreet_menu_filter_cbs,
|
||||
ECORE_FREE_CB(eina_stringshare_del));
|
||||
ecore_hash_free_key_cb_set(efreet_menu_move_cbs,
|
||||
ECORE_FREE_CB(eina_stringshare_del));
|
||||
ecore_hash_free_key_cb_set(efreet_menu_layout_cbs,
|
||||
ECORE_FREE_CB(eina_stringshare_del));
|
||||
|
||||
/* set Menu into it's own so we can check the XML is valid before trying
|
||||
* to handle it */
|
||||
efreet_tag_menu = eina_stringshare_add(menu_cbs[0].key);
|
||||
|
||||
for (i = 0; menu_cbs[i].key != NULL; i++)
|
||||
ecore_hash_set(efreet_menu_handle_cbs,
|
||||
(void *)eina_stringshare_add(menu_cbs[i].key),
|
||||
menu_cbs[i].cb);
|
||||
|
||||
{
|
||||
eina_hash_del(efreet_menu_handle_cbs,
|
||||
menu_cbs[i].key,
|
||||
NULL);
|
||||
eina_hash_add(efreet_menu_handle_cbs,
|
||||
menu_cbs[i].key,
|
||||
menu_cbs[i].cb);
|
||||
}
|
||||
for (i = 0; filter_cbs[i].key != NULL; i++)
|
||||
ecore_hash_set(efreet_menu_filter_cbs,
|
||||
(void *)eina_stringshare_add(filter_cbs[i].key),
|
||||
filter_cbs[i].cb);
|
||||
|
||||
{
|
||||
eina_hash_del(efreet_menu_filter_cbs,
|
||||
filter_cbs[i].key,
|
||||
NULL);
|
||||
eina_hash_add(efreet_menu_filter_cbs,
|
||||
filter_cbs[i].key,
|
||||
filter_cbs[i].cb);
|
||||
}
|
||||
for (i = 0; move_cbs[i].key != NULL; i++)
|
||||
ecore_hash_set(efreet_menu_move_cbs,
|
||||
(void *)eina_stringshare_add(move_cbs[i].key),
|
||||
move_cbs[i].cb);
|
||||
|
||||
{
|
||||
eina_hash_del(efreet_menu_move_cbs,
|
||||
move_cbs[i].key,
|
||||
NULL);
|
||||
eina_hash_add(efreet_menu_move_cbs,
|
||||
move_cbs[i].key,
|
||||
move_cbs[i].cb);
|
||||
}
|
||||
for (i = 0; layout_cbs[i].key != NULL; i++)
|
||||
ecore_hash_set(efreet_menu_layout_cbs,
|
||||
(void *)eina_stringshare_add(layout_cbs[i].key),
|
||||
layout_cbs[i].cb);
|
||||
|
||||
{
|
||||
eina_hash_del(efreet_menu_layout_cbs,
|
||||
layout_cbs[i].key,
|
||||
NULL);
|
||||
eina_hash_add(efreet_menu_layout_cbs,
|
||||
layout_cbs[i].key,
|
||||
layout_cbs[i].cb);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -651,12 +658,10 @@ efreet_menu_parse(const char *path)
|
|||
}
|
||||
|
||||
IF_FREE_HASH(efreet_merged_menus);
|
||||
efreet_merged_menus = ecore_hash_new(ecore_str_hash, ecore_str_compare);
|
||||
ecore_hash_free_key_cb_set(efreet_merged_menus, ECORE_FREE_CB(free));
|
||||
efreet_merged_menus = eina_hash_string_superfast_new(NULL);
|
||||
|
||||
IF_FREE_HASH(efreet_merged_dirs);
|
||||
efreet_merged_dirs = ecore_hash_new(ecore_str_hash, ecore_str_compare);
|
||||
ecore_hash_free_key_cb_set(efreet_merged_dirs, ECORE_FREE_CB(free));
|
||||
efreet_merged_dirs = eina_hash_string_superfast_new(NULL);
|
||||
|
||||
/* split appart the filename and the path */
|
||||
internal = efreet_menu_internal_new();
|
||||
|
@ -1065,7 +1070,7 @@ efreet_menu_handle_menu(Efreet_Menu_Internal *internal, Efreet_Xml *xml)
|
|||
ecore_list_last_goto(xml->children);
|
||||
while ((child = ecore_dlist_previous(xml->children)))
|
||||
{
|
||||
cb = ecore_hash_get(efreet_menu_handle_cbs, child->tag);
|
||||
cb = eina_hash_find(efreet_menu_handle_cbs, child->tag);
|
||||
if (cb)
|
||||
{
|
||||
if (!cb(internal, child))
|
||||
|
@ -1649,10 +1654,10 @@ efreet_menu_merge(Efreet_Menu_Internal *parent, Efreet_Xml *xml, const char *pat
|
|||
}
|
||||
|
||||
/* don't merge the same path twice */
|
||||
if (ecore_hash_get(efreet_merged_menus, realpath))
|
||||
if (eina_hash_find(efreet_merged_menus, realpath))
|
||||
return 1;
|
||||
|
||||
ecore_hash_set(efreet_merged_menus, strdup(realpath), (void *)1);
|
||||
eina_hash_add(efreet_merged_menus, realpath, (void *)1);
|
||||
|
||||
merge_xml = efreet_xml_new(realpath);
|
||||
FREE(realpath);
|
||||
|
@ -1723,8 +1728,8 @@ efreet_menu_merge_dir(Efreet_Menu_Internal *parent, Efreet_Xml *xml, const char
|
|||
if (!parent || !xml || !path) return 0;
|
||||
|
||||
/* check to see if we've merged this directory already */
|
||||
if (ecore_hash_get(efreet_merged_dirs, path)) return 1;
|
||||
ecore_hash_set(efreet_merged_dirs, strdup(path), (void *)1);
|
||||
if (eina_hash_find(efreet_merged_dirs, path)) return 1;
|
||||
eina_hash_add(efreet_merged_dirs, path, (void *)1);
|
||||
|
||||
files = opendir(path);
|
||||
if (!files) return 1;
|
||||
|
@ -2025,7 +2030,7 @@ efreet_menu_handle_move(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
|
|||
{
|
||||
int (*cb)(Efreet_Menu_Internal *parent, Efreet_Xml *xml);
|
||||
|
||||
cb = ecore_hash_get(efreet_menu_move_cbs, child->tag);
|
||||
cb = eina_hash_find(efreet_menu_move_cbs, child->tag);
|
||||
if (cb)
|
||||
{
|
||||
if (!cb(parent, child))
|
||||
|
@ -2130,7 +2135,7 @@ efreet_menu_handle_layout(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
|
|||
{
|
||||
int (*cb)(Efreet_Menu_Internal *parent, Efreet_Xml *xml, int def);
|
||||
|
||||
cb = ecore_hash_get(efreet_menu_layout_cbs, child->tag);
|
||||
cb = eina_hash_find(efreet_menu_layout_cbs, child->tag);
|
||||
if (cb)
|
||||
{
|
||||
if (!cb(parent, child, 0))
|
||||
|
@ -2187,7 +2192,7 @@ efreet_menu_handle_default_layout(Efreet_Menu_Internal *parent, Efreet_Xml *xml)
|
|||
{
|
||||
int (*cb)(Efreet_Menu_Internal *parent, Efreet_Xml *xml, int def);
|
||||
|
||||
cb = ecore_hash_get(efreet_menu_layout_cbs, child->tag);
|
||||
cb = eina_hash_find(efreet_menu_layout_cbs, child->tag);
|
||||
if (cb)
|
||||
{
|
||||
if (!cb(parent, child, 1))
|
||||
|
@ -2366,7 +2371,7 @@ efreet_menu_handle_filter_op(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml)
|
|||
{
|
||||
int (*cb)(Efreet_Menu_Filter_Op *op, Efreet_Xml *xml);
|
||||
|
||||
cb = ecore_hash_get(efreet_menu_filter_cbs, child->tag);
|
||||
cb = eina_hash_find(efreet_menu_filter_cbs, child->tag);
|
||||
if (cb)
|
||||
{
|
||||
if (!cb(op, child))
|
||||
|
@ -2683,9 +2688,9 @@ efreet_menu_process_filters(Efreet_Menu_Internal *internal, unsigned int only_un
|
|||
|
||||
if (filter->type == EFREET_MENU_FILTER_INCLUDE)
|
||||
{
|
||||
Ecore_Hash *matches;
|
||||
Eina_Hash *matches;
|
||||
|
||||
matches = ecore_hash_new(ecore_str_hash, ecore_str_compare);
|
||||
matches = eina_hash_string_superfast_new(NULL);
|
||||
efreet_menu_process_app_pool(internal->app_pool, internal->applications,
|
||||
matches, filter, internal->only_unallocated);
|
||||
if (internal->parent)
|
||||
|
@ -2699,7 +2704,7 @@ efreet_menu_process_filters(Efreet_Menu_Internal *internal, unsigned int only_un
|
|||
internal->only_unallocated);
|
||||
} while ((parent = parent->parent));
|
||||
}
|
||||
ecore_hash_destroy(matches);
|
||||
eina_hash_free(matches);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2762,9 +2767,9 @@ efreet_menu_process_filters(Efreet_Menu_Internal *internal, unsigned int only_un
|
|||
*/
|
||||
static
|
||||
void efreet_menu_process_app_pool(Ecore_List *pool, Ecore_List *applications,
|
||||
Ecore_Hash *matches,
|
||||
Efreet_Menu_Filter *filter,
|
||||
unsigned int only_unallocated)
|
||||
Eina_Hash *matches,
|
||||
Efreet_Menu_Filter *filter,
|
||||
unsigned int only_unallocated)
|
||||
{
|
||||
Efreet_Menu_Desktop *md;
|
||||
|
||||
|
@ -2773,12 +2778,12 @@ void efreet_menu_process_app_pool(Ecore_List *pool, Ecore_List *applications,
|
|||
ecore_list_first_goto(pool);
|
||||
while ((md = ecore_list_next(pool)))
|
||||
{
|
||||
if (ecore_hash_get(matches, md->id)) continue;
|
||||
if (eina_hash_find(matches, md->id)) continue;
|
||||
if (only_unallocated && md->allocated) continue;
|
||||
if (efreet_menu_filter_matches(filter->op, md))
|
||||
{
|
||||
ecore_list_append(applications, md);
|
||||
ecore_hash_set(matches, (void *)md->id, md);
|
||||
eina_hash_add(matches, (void *)md->id, md);
|
||||
md->allocated = 1;
|
||||
}
|
||||
}
|
||||
|
@ -3459,9 +3464,8 @@ efreet_menu_directory_dirs_process(Efreet_Menu_Internal *internal)
|
|||
|
||||
if (internal->directory_dirs)
|
||||
{
|
||||
internal->directory_cache = ecore_hash_new(ecore_str_hash, ecore_str_compare);
|
||||
ecore_hash_free_key_cb_set(internal->directory_cache, ECORE_FREE_CB(free));
|
||||
ecore_hash_free_value_cb_set(internal->directory_cache, ECORE_FREE_CB(efreet_desktop_free));
|
||||
internal->directory_cache =
|
||||
eina_hash_string_superfast_new(EINA_FREE_CB(efreet_desktop_free));
|
||||
|
||||
ecore_dlist_last_goto(internal->directory_dirs);
|
||||
while ((path = ecore_dlist_previous(internal->directory_dirs)))
|
||||
|
@ -3496,7 +3500,7 @@ efreet_menu_directory_dirs_process(Efreet_Menu_Internal *internal)
|
|||
*/
|
||||
static int
|
||||
efreet_menu_directory_dir_scan(const char *path, const char *relative_path,
|
||||
Ecore_Hash *cache)
|
||||
Eina_Hash *cache)
|
||||
{
|
||||
Efreet_Desktop *desktop;
|
||||
DIR *files;
|
||||
|
@ -3531,7 +3535,8 @@ efreet_menu_directory_dir_scan(const char *path, const char *relative_path,
|
|||
continue;
|
||||
}
|
||||
|
||||
ecore_hash_set(cache, (void *)strdup(buf2), desktop);
|
||||
eina_hash_del(cache, buf2, NULL);
|
||||
eina_hash_add(cache, buf2, desktop);
|
||||
}
|
||||
}
|
||||
closedir(files);
|
||||
|
@ -3553,7 +3558,7 @@ efreet_menu_directory_get(Efreet_Menu_Internal *internal, const char *path)
|
|||
|
||||
if (internal->directory_cache)
|
||||
{
|
||||
dir = ecore_hash_get(internal->directory_cache, path);
|
||||
dir = eina_hash_find(internal->directory_cache, path);
|
||||
if (dir) return dir;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
static Ecore_List *globs = NULL; /* contains Efreet_Mime_Glob structs */
|
||||
static Ecore_List *magics = NULL; /* contains Efreet_Mime_Magic structs */
|
||||
static Ecore_Hash *wild = NULL; /* contains *.ext and mime.types globs*/
|
||||
static Ecore_Hash *monitors = NULL; /* contains file monitors */
|
||||
static Eina_Hash *wild = NULL; /* contains *.ext and mime.types globs*/
|
||||
static Eina_Hash *monitors = NULL; /* contains file monitors */
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
@ -111,10 +111,7 @@ efreet_mime_init(void)
|
|||
|
||||
efreet_mime_endianess = efreet_mime_endian_check();
|
||||
|
||||
monitors = ecore_hash_new(ecore_str_hash, ecore_str_compare);
|
||||
ecore_hash_free_key_cb_set(monitors, ECORE_FREE_CB(free));
|
||||
ecore_hash_free_value_cb_set(monitors,
|
||||
ECORE_FREE_CB(ecore_file_monitor_del));
|
||||
monitors = eina_hash_string_superfast_new(EINA_FREE_CB(ecore_file_monitor_del));
|
||||
|
||||
if (!efreet_mime_init_files())
|
||||
return 0;
|
||||
|
@ -269,7 +266,7 @@ efreet_mime_globs_type_get(const char *file)
|
|||
while (p)
|
||||
{
|
||||
p++;
|
||||
if (p && (mime = ecore_hash_get(wild, p))) return mime;
|
||||
if (p && (mime = eina_hash_find(wild, p))) return mime;
|
||||
p = strchr(p, '.');
|
||||
}
|
||||
}
|
||||
|
@ -342,11 +339,14 @@ efreet_mime_monitor_add(const char *file)
|
|||
|
||||
/* if this is already in our hash then we're already monitoring so no
|
||||
* reason to re-monitor */
|
||||
if (ecore_hash_get(monitors, file))
|
||||
if (eina_hash_find(monitors, file))
|
||||
return;
|
||||
|
||||
if ((fm = ecore_file_monitor_add(file, efreet_mime_cb_update_file, NULL)))
|
||||
ecore_hash_set(monitors, strdup(file), fm);
|
||||
{
|
||||
eina_hash_del(monitors, file, NULL);
|
||||
eina_hash_add(monitors, file, fm);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -364,10 +364,7 @@ efreet_mime_load_globs(Ecore_List *datadirs, const char *datahome)
|
|||
const char *datadir = NULL;
|
||||
|
||||
IF_FREE_HASH(wild);
|
||||
wild = ecore_hash_new(ecore_str_hash, ecore_str_compare);
|
||||
ecore_hash_free_key_cb_set(wild, ECORE_FREE_CB(eina_stringshare_del));
|
||||
ecore_hash_free_value_cb_set(wild,
|
||||
ECORE_FREE_CB(eina_stringshare_del));
|
||||
wild = eina_hash_string_superfast_new(EINA_FREE_CB(eina_stringshare_del));
|
||||
IF_FREE_LIST(globs);
|
||||
globs = ecore_list_new();
|
||||
ecore_list_free_cb_set(globs, efreet_mime_glob_free);
|
||||
|
@ -688,8 +685,8 @@ efreet_mime_mime_types_load(const char *file)
|
|||
strncpy(ext, pp, (p - pp));
|
||||
ext[p - pp] = 0;
|
||||
|
||||
ecore_hash_set(wild, (void*)eina_stringshare_add(ext),
|
||||
(void*)eina_stringshare_add(mimetype));
|
||||
eina_hash_del(wild, ext, NULL);
|
||||
eina_hash_add(wild, ext, (void*)eina_stringshare_add(mimetype));
|
||||
}
|
||||
while ((*p != '\n') && (*p != 0));
|
||||
}
|
||||
|
@ -746,8 +743,9 @@ efreet_mime_shared_mimeinfo_globs_load(const char *file)
|
|||
|
||||
if (ext[0] == '*' && ext[1] == '.')
|
||||
{
|
||||
ecore_hash_set(wild, (void*)eina_stringshare_add(&(ext[2])),
|
||||
(void*)eina_stringshare_add(mimetype));
|
||||
eina_hash_del(wild, &(ext[2]), NULL);
|
||||
eina_hash_add(wild, &(ext[2]),
|
||||
(void*)eina_stringshare_add(mimetype));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
*/
|
||||
#define IF_FREE_HASH(x) do { \
|
||||
if (x) { \
|
||||
Ecore_Hash *__tmp; __tmp = (x); (x) = NULL; ecore_hash_destroy(__tmp); \
|
||||
Eina_Hash *__tmp; __tmp = (x); (x) = NULL; eina_hash_free(__tmp); \
|
||||
} \
|
||||
(x) = NULL; \
|
||||
} while (0)
|
||||
|
|
|
@ -25,6 +25,7 @@ struct Efreet_Cache_Fill_Dir
|
|||
|
||||
struct Efreet_Cache_Search
|
||||
{
|
||||
Efreet_Util_Desktop *result;
|
||||
const char *what1;
|
||||
const char *what2;
|
||||
};
|
||||
|
@ -56,16 +57,16 @@ static void efreet_util_cache_remove(const char *path, const char *file_id, int
|
|||
static void efreet_util_cache_reload(const char *path, const char *file_id, int priority);
|
||||
static void efreet_util_cache_dir_free(void *data);
|
||||
|
||||
static void efreet_util_cache_search_mime(void *value, void *data);
|
||||
static int efreet_util_cache_search_wm_class(const void *value, const void *data);
|
||||
static int efreet_util_cache_search_exec(const void *value, const void *data);
|
||||
static int efreet_util_cache_search_name(const void *value, const void *data);
|
||||
static int efreet_util_cache_search_generic_name(const void *value, const void *data);
|
||||
static Eina_Bool efreet_util_cache_search_mime(const Eina_Hash *hash, void *value, void *fdata);
|
||||
static Eina_Bool efreet_util_cache_search_wm_class(const Eina_Hash *hash, void *value, void *fdata);
|
||||
static Eina_Bool efreet_util_cache_search_exec(const Eina_Hash *hash, void *value, void *fdata);
|
||||
static Eina_Bool efreet_util_cache_search_name(const Eina_Hash *hash, void *value, void *fdata);
|
||||
static Eina_Bool efreet_util_cache_search_generic_name(const Eina_Hash *hash, void *value, void *fdata);
|
||||
|
||||
static void efreet_util_cache_search_name_glob(void *value, void *data);
|
||||
static void efreet_util_cache_search_exec_glob(void *value, void *data);
|
||||
static void efreet_util_cache_search_generic_name_glob(void *value, void *data);
|
||||
static void efreet_util_cache_search_comment_glob(void *value, void *data);
|
||||
static Eina_Bool efreet_util_cache_search_name_glob(const Eina_Hash *hash, void *value, void *fdata);
|
||||
static Eina_Bool efreet_util_cache_search_exec_glob(const Eina_Hash *hash, void *value, void *fdata);
|
||||
static Eina_Bool efreet_util_cache_search_generic_name_glob(const Eina_Hash *hash, void *value, void *fdata);
|
||||
static Eina_Bool efreet_util_cache_search_comment_glob(const Eina_Hash *hash, void *value, void *fdata);
|
||||
|
||||
static int efreet_util_glob_match(const char *str, const char *glob);
|
||||
|
||||
|
@ -81,9 +82,9 @@ static void efreet_util_desktops_by_category_remove(Efreet_Desktop *desktop);
|
|||
static void efreet_util_desktop_free(Efreet_Util_Desktop *ud);
|
||||
static void efreet_event_desktop_change_free(void *data, void *ev);
|
||||
|
||||
static Ecore_Hash *desktop_by_file_id = NULL;
|
||||
static Ecore_Hash *file_id_by_desktop_path = NULL;
|
||||
static Ecore_Hash *desktops_by_category = NULL;
|
||||
static Eina_Hash *desktop_by_file_id = NULL;
|
||||
static Eina_Hash *file_id_by_desktop_path = NULL;
|
||||
static Eina_Hash *desktops_by_category = NULL;
|
||||
|
||||
static Ecore_Idler *idler = NULL;
|
||||
static Efreet_Cache_Fill *fill = NULL;
|
||||
|
@ -106,17 +107,9 @@ efreet_util_init(void)
|
|||
EFREET_EVENT_DESKTOP_LIST_CHANGE = ecore_event_type_new();
|
||||
if (!EFREET_EVENT_DESKTOP_CHANGE)
|
||||
EFREET_EVENT_DESKTOP_CHANGE = ecore_event_type_new();
|
||||
desktop_by_file_id = ecore_hash_new(ecore_str_hash, ecore_str_compare);
|
||||
ecore_hash_free_key_cb_set(desktop_by_file_id, ECORE_FREE_CB(eina_stringshare_del));
|
||||
ecore_hash_free_value_cb_set(desktop_by_file_id, ECORE_FREE_CB(efreet_util_desktop_free));
|
||||
|
||||
file_id_by_desktop_path = ecore_hash_new(ecore_str_hash, ecore_str_compare);
|
||||
ecore_hash_free_key_cb_set(file_id_by_desktop_path, ECORE_FREE_CB(eina_stringshare_del));
|
||||
ecore_hash_free_value_cb_set(file_id_by_desktop_path, ECORE_FREE_CB(eina_stringshare_del));
|
||||
|
||||
desktops_by_category = ecore_hash_new(ecore_str_hash, ecore_str_compare);
|
||||
ecore_hash_free_key_cb_set(desktops_by_category, ECORE_FREE_CB(eina_stringshare_del));
|
||||
ecore_hash_free_value_cb_set(desktops_by_category, ECORE_FREE_CB(ecore_list_destroy));
|
||||
desktop_by_file_id = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_util_desktop_free));
|
||||
file_id_by_desktop_path = eina_hash_string_superfast_new(EINA_FREE_CB(eina_stringshare_del));
|
||||
desktops_by_category = eina_hash_string_superfast_new(EINA_FREE_CB(ecore_list_destroy));
|
||||
|
||||
monitors = ecore_list_new();
|
||||
ecore_list_free_cb_set(monitors, efreet_util_monitor_free);
|
||||
|
@ -206,7 +199,7 @@ efreet_util_path_to_file_id(const char *path)
|
|||
const char *file_id = NULL;
|
||||
|
||||
if (!path) return NULL;
|
||||
file_id = ecore_hash_get(file_id_by_desktop_path, path);
|
||||
file_id = eina_hash_find(file_id_by_desktop_path, path);
|
||||
if (file_id) return file_id;
|
||||
|
||||
base = efreet_util_path_in_default("applications", path);
|
||||
|
@ -234,8 +227,8 @@ efreet_util_path_to_file_id(const char *path)
|
|||
free(base);
|
||||
file_id = eina_stringshare_add(tmp);
|
||||
free(tmp);
|
||||
ecore_hash_set(file_id_by_desktop_path, (void *)eina_stringshare_add(path),
|
||||
(void *)file_id);
|
||||
eina_hash_del(file_id_by_desktop_path, path, NULL);
|
||||
eina_hash_add(file_id_by_desktop_path, path, (void *)file_id);
|
||||
return file_id;
|
||||
}
|
||||
|
||||
|
@ -243,11 +236,15 @@ EAPI Ecore_List *
|
|||
efreet_util_desktop_mime_list(const char *mime)
|
||||
{
|
||||
Efreet_Cache_Search_List search;
|
||||
Eina_Iterator *it;
|
||||
|
||||
search.list = ecore_list_new();
|
||||
search.what = eina_stringshare_add(mime);
|
||||
|
||||
ecore_hash_for_each_node(desktop_by_file_id, efreet_util_cache_search_mime, &search);
|
||||
it = eina_hash_iterator_data_new(desktop_by_file_id);
|
||||
eina_iterator_foreach(it, EINA_EACH(efreet_util_cache_search_mime), &search);
|
||||
eina_iterator_free(it);
|
||||
|
||||
eina_stringshare_del(search.what);
|
||||
|
||||
if (ecore_list_empty_is(search.list)) IF_FREE_LIST(search.list);
|
||||
|
@ -259,11 +256,18 @@ efreet_util_desktop_wm_class_find(const char *wmname, const char *wmclass)
|
|||
{
|
||||
Efreet_Cache_Search search;
|
||||
Efreet_Util_Desktop *ud;
|
||||
Eina_Iterator *it;
|
||||
|
||||
if ((!wmname) && (!wmclass)) return NULL;
|
||||
search.what1 = wmname;
|
||||
search.what2 = wmclass;
|
||||
ud = ecore_hash_find(desktop_by_file_id, efreet_util_cache_search_wm_class, &search);
|
||||
search.result = NULL;
|
||||
|
||||
it = eina_hash_iterator_data_new(desktop_by_file_id);
|
||||
eina_iterator_foreach(it, EINA_EACH(efreet_util_cache_search_wm_class), &search);
|
||||
eina_iterator_free(it);
|
||||
ud = search.result;
|
||||
|
||||
if (ud) return ud->desktop;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -278,7 +282,7 @@ efreet_util_desktop_file_id_find(const char *file_id)
|
|||
int priority = 0;
|
||||
|
||||
if (!file_id) return NULL;
|
||||
ud = ecore_hash_get(desktop_by_file_id, file_id);
|
||||
ud = eina_hash_find(desktop_by_file_id, file_id);
|
||||
if (ud) return ud->desktop;
|
||||
|
||||
dirs = efreet_default_dirs_get(efreet_data_home_get(), efreet_data_dirs_get(),
|
||||
|
@ -315,7 +319,8 @@ efreet_util_desktop_file_id_find(const char *file_id)
|
|||
ud->priority = priority;
|
||||
ud->desktop = desktop;
|
||||
|
||||
ecore_hash_set(desktop_by_file_id, (void *)eina_stringshare_add(file_id), ud);
|
||||
eina_hash_del(desktop_by_file_id, file_id, NULL);
|
||||
eina_hash_add(desktop_by_file_id, file_id, ud);
|
||||
efreet_util_desktops_by_category_add(desktop);
|
||||
|
||||
ev = NEW(Efreet_Event_Desktop_Change, 1);
|
||||
|
@ -331,13 +336,18 @@ EAPI Efreet_Desktop *
|
|||
efreet_util_desktop_exec_find(const char *exec)
|
||||
{
|
||||
Efreet_Cache_Search search;
|
||||
Efreet_Util_Desktop *ud;
|
||||
Eina_Iterator *it;
|
||||
|
||||
if (!exec) return NULL;
|
||||
search.what1 = exec;
|
||||
search.what2 = NULL;
|
||||
ud = ecore_hash_find(desktop_by_file_id, efreet_util_cache_search_exec, &search);
|
||||
if (ud) return ud->desktop;
|
||||
search.result = NULL;
|
||||
|
||||
it = eina_hash_iterator_data_new(desktop_by_file_id);
|
||||
eina_iterator_foreach(it, EINA_EACH(efreet_util_cache_search_exec), &search);
|
||||
eina_iterator_free(it);
|
||||
|
||||
if (search.result) return search.result->desktop;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -345,13 +355,18 @@ EAPI Efreet_Desktop *
|
|||
efreet_util_desktop_name_find(const char *name)
|
||||
{
|
||||
Efreet_Cache_Search search;
|
||||
Efreet_Util_Desktop *ud;
|
||||
Eina_Iterator *it;
|
||||
|
||||
if (!name) return NULL;
|
||||
search.what1 = name;
|
||||
search.what2 = NULL;
|
||||
ud = ecore_hash_find(desktop_by_file_id, efreet_util_cache_search_name, &search);
|
||||
if (ud) return ud->desktop;
|
||||
search.result = NULL;
|
||||
|
||||
it = eina_hash_iterator_data_new(desktop_by_file_id);
|
||||
eina_iterator_foreach(it, EINA_EACH(efreet_util_cache_search_name), &search);
|
||||
eina_iterator_free(it);
|
||||
|
||||
if (search.result) return search.result->desktop;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -359,13 +374,18 @@ EAPI Efreet_Desktop *
|
|||
efreet_util_desktop_generic_name_find(const char *generic_name)
|
||||
{
|
||||
Efreet_Cache_Search search;
|
||||
Efreet_Util_Desktop *ud;
|
||||
Eina_Iterator *it;
|
||||
|
||||
if (!generic_name) return NULL;
|
||||
search.what1 = generic_name;
|
||||
search.what2 = NULL;
|
||||
ud = ecore_hash_find(desktop_by_file_id, efreet_util_cache_search_generic_name, &search);
|
||||
if (ud) return ud->desktop;
|
||||
search.result = NULL;
|
||||
|
||||
it = eina_hash_iterator_data_new(desktop_by_file_id);
|
||||
eina_iterator_foreach(it, EINA_EACH(efreet_util_cache_search_generic_name), &search);
|
||||
eina_iterator_free(it);
|
||||
|
||||
if (search.result) return search.result->desktop;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -373,11 +393,14 @@ EAPI Ecore_List *
|
|||
efreet_util_desktop_name_glob_list(const char *glob)
|
||||
{
|
||||
Efreet_Cache_Search_List search;
|
||||
Eina_Iterator *it;
|
||||
|
||||
search.list = ecore_list_new();
|
||||
search.what = glob;
|
||||
|
||||
ecore_hash_for_each_node(desktop_by_file_id, efreet_util_cache_search_name_glob, &search);
|
||||
it = eina_hash_iterator_data_new(desktop_by_file_id);
|
||||
eina_iterator_foreach(it, EINA_EACH(efreet_util_cache_search_name_glob), &search);
|
||||
eina_iterator_free(it);
|
||||
|
||||
if (ecore_list_empty_is(search.list)) IF_FREE_LIST(search.list);
|
||||
return search.list;
|
||||
|
@ -387,11 +410,14 @@ EAPI Ecore_List *
|
|||
efreet_util_desktop_exec_glob_list(const char *glob)
|
||||
{
|
||||
Efreet_Cache_Search_List search;
|
||||
Eina_Iterator *it;
|
||||
|
||||
search.list = ecore_list_new();
|
||||
search.what = glob;
|
||||
|
||||
ecore_hash_for_each_node(desktop_by_file_id, efreet_util_cache_search_exec_glob, &search);
|
||||
it = eina_hash_iterator_data_new(desktop_by_file_id);
|
||||
eina_iterator_foreach(it, EINA_EACH(efreet_util_cache_search_exec_glob), &search);
|
||||
eina_iterator_free(it);
|
||||
|
||||
if (ecore_list_empty_is(search.list)) IF_FREE_LIST(search.list);
|
||||
return search.list;
|
||||
|
@ -401,11 +427,14 @@ EAPI Ecore_List *
|
|||
efreet_util_desktop_generic_name_glob_list(const char *glob)
|
||||
{
|
||||
Efreet_Cache_Search_List search;
|
||||
Eina_Iterator *it;
|
||||
|
||||
search.list = ecore_list_new();
|
||||
search.what = glob;
|
||||
|
||||
ecore_hash_for_each_node(desktop_by_file_id, efreet_util_cache_search_generic_name_glob, &search);
|
||||
it = eina_hash_iterator_data_new(desktop_by_file_id);
|
||||
eina_iterator_foreach(it, EINA_EACH(efreet_util_cache_search_generic_name_glob), &search);
|
||||
eina_iterator_free(it);
|
||||
|
||||
if (ecore_list_empty_is(search.list)) IF_FREE_LIST(search.list);
|
||||
return search.list;
|
||||
|
@ -415,11 +444,14 @@ EAPI Ecore_List *
|
|||
efreet_util_desktop_comment_glob_list(const char *glob)
|
||||
{
|
||||
Efreet_Cache_Search_List search;
|
||||
Eina_Iterator *it;
|
||||
|
||||
search.list = ecore_list_new();
|
||||
search.what = glob;
|
||||
|
||||
ecore_hash_for_each_node(desktop_by_file_id, efreet_util_cache_search_comment_glob, &search);
|
||||
it = eina_hash_iterator_data_new(desktop_by_file_id);
|
||||
eina_iterator_foreach(it, EINA_EACH(efreet_util_cache_search_comment_glob), &search);
|
||||
eina_iterator_free(it);
|
||||
|
||||
if (ecore_list_empty_is(search.list)) IF_FREE_LIST(search.list);
|
||||
return search.list;
|
||||
|
@ -434,7 +466,18 @@ efreet_util_desktop_comment_glob_list(const char *glob)
|
|||
EAPI Ecore_List *
|
||||
efreet_util_desktop_categories_list(void)
|
||||
{
|
||||
return ecore_hash_keys(desktops_by_category);
|
||||
Eina_Iterator *it;
|
||||
Ecore_List *list;
|
||||
|
||||
list = ecore_list_new();
|
||||
if (list)
|
||||
{
|
||||
it = eina_hash_iterator_key_new(desktops_by_category);
|
||||
eina_iterator_foreach(it, EINA_EACH(desktops_by_category), list);
|
||||
eina_iterator_free(it);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -448,21 +491,19 @@ efreet_util_desktop_categories_list(void)
|
|||
EAPI Ecore_List *
|
||||
efreet_util_desktop_category_list(const char *category)
|
||||
{
|
||||
return ecore_hash_get(desktops_by_category, category);
|
||||
return eina_hash_find(desktops_by_category, category);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
dump(void *value, void *data __UNUSED__)
|
||||
static Eina_Bool
|
||||
dump(Eina_Hash *hash, const char *key, void *value, __UNUSED__ void *data)
|
||||
{
|
||||
Ecore_Hash_Node *node;
|
||||
node = value;
|
||||
printf("%s -> %p\n", (char *)node->key, node->value);
|
||||
printf("%s -> %p\n", (char *)key, value);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
efreet_util_cache_fill(void *data __UNUSED__)
|
||||
efreet_util_cache_fill(__UNUSED__ void *data)
|
||||
{
|
||||
struct dirent *file = NULL;
|
||||
double start;
|
||||
|
@ -487,9 +528,9 @@ efreet_util_cache_fill(void *data __UNUSED__)
|
|||
idler = NULL;
|
||||
fill = NULL;
|
||||
#if 0
|
||||
ecore_hash_for_each_node(desktop_by_file_id, dump, NULL);
|
||||
ecore_hash_for_each_node(file_id_by_desktop_path, dump, NULL);
|
||||
printf("%d\n", ecore_hash_count(desktop_by_file_id));
|
||||
eina_hash_foreach(desktop_by_file_id, dump, NULL);
|
||||
eina_hash_foreach(file_id_by_desktop_path, dump, NULL);
|
||||
printf("%d\n", eina_hash_population(desktop_by_file_id));
|
||||
#endif
|
||||
ecore_event_add(EFREET_EVENT_DESKTOP_LIST_CHANGE, NULL, NULL, NULL);
|
||||
|
||||
|
@ -567,19 +608,22 @@ efreet_util_cache_add(const char *path, const char *file_id, int priority, int e
|
|||
return;
|
||||
}
|
||||
|
||||
if (!ecore_hash_get(file_id_by_desktop_path, desktop->orig_path))
|
||||
ecore_hash_set(file_id_by_desktop_path,
|
||||
(void *)eina_stringshare_add(desktop->orig_path),
|
||||
(void *)eina_stringshare_add(file_id));
|
||||
if (!eina_hash_find(file_id_by_desktop_path, desktop->orig_path))
|
||||
{
|
||||
eina_hash_add(file_id_by_desktop_path,
|
||||
desktop->orig_path,
|
||||
(void *)eina_stringshare_add(file_id));
|
||||
|
||||
ud = ecore_hash_get(desktop_by_file_id, file_id);
|
||||
}
|
||||
|
||||
ud = eina_hash_find(desktop_by_file_id, file_id);
|
||||
if (!ud)
|
||||
{
|
||||
ud = NEW(Efreet_Util_Desktop, 1);
|
||||
ud->priority = priority;
|
||||
ud->desktop = desktop;
|
||||
|
||||
ecore_hash_set(desktop_by_file_id, (void *)eina_stringshare_add(file_id), ud);
|
||||
eina_hash_add(desktop_by_file_id, file_id, ud);
|
||||
efreet_util_desktops_by_category_add(desktop);
|
||||
|
||||
if (event)
|
||||
|
@ -630,12 +674,11 @@ efreet_util_cache_remove(const char *path, const char *file_id, int priority)
|
|||
|
||||
ext = strrchr(path, '.');
|
||||
if (!ext || strcmp(ext, ".desktop")) return;
|
||||
ud = ecore_hash_get(desktop_by_file_id, file_id);
|
||||
ud = eina_hash_find(desktop_by_file_id, file_id);
|
||||
if (ud && (ud->priority >= priority))
|
||||
{
|
||||
Efreet_Event_Desktop_Change *ev;
|
||||
|
||||
ecore_hash_remove(desktop_by_file_id, file_id);
|
||||
efreet_util_desktops_by_category_remove(ud->desktop);
|
||||
|
||||
ev = NEW(Efreet_Event_Desktop_Change, 1);
|
||||
|
@ -644,13 +687,13 @@ efreet_util_cache_remove(const char *path, const char *file_id, int priority)
|
|||
ev->change = EFREET_DESKTOP_CHANGE_REMOVE;
|
||||
ecore_event_add(EFREET_EVENT_DESKTOP_CHANGE, ev, efreet_event_desktop_change_free, NULL);
|
||||
|
||||
efreet_util_desktop_free(ud);
|
||||
eina_hash_del(desktop_by_file_id, file_id, ud);
|
||||
|
||||
/* This call will search application dirs and add the file to cache if it
|
||||
* exists. */
|
||||
efreet_util_desktop_file_id_find(file_id);
|
||||
}
|
||||
ecore_hash_remove(file_id_by_desktop_path, path);
|
||||
eina_hash_del(file_id_by_desktop_path, path, eina_hash_find(file_id_by_desktop_path, path));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -670,7 +713,7 @@ efreet_util_cache_reload(const char *path, const char *file_id, int priority)
|
|||
return;
|
||||
}
|
||||
|
||||
ud = ecore_hash_get(desktop_by_file_id, file_id);
|
||||
ud = eina_hash_find(desktop_by_file_id, file_id);
|
||||
if (ud)
|
||||
{
|
||||
Efreet_Event_Desktop_Change *ev;
|
||||
|
@ -703,7 +746,7 @@ efreet_util_cache_reload(const char *path, const char *file_id, int priority)
|
|||
ud->priority = priority;
|
||||
ud->desktop = desktop;
|
||||
|
||||
ecore_hash_set(desktop_by_file_id, (void *)eina_stringshare_add(file_id), ud);
|
||||
eina_hash_add(desktop_by_file_id, file_id, ud);
|
||||
efreet_util_desktops_by_category_remove(ud->desktop);
|
||||
efreet_util_desktops_by_category_add(desktop);
|
||||
|
||||
|
@ -726,19 +769,17 @@ efreet_util_cache_dir_free(void *data)
|
|||
free(dir);
|
||||
}
|
||||
|
||||
static void
|
||||
efreet_util_cache_search_mime(void *value, void *data)
|
||||
static Eina_Bool
|
||||
efreet_util_cache_search_mime(__UNUSED__ const Eina_Hash *hash, void *value, void *fdata)
|
||||
{
|
||||
Ecore_Hash_Node *node;
|
||||
Efreet_Cache_Search_List *search;
|
||||
Efreet_Util_Desktop *ud;
|
||||
const char *mime;
|
||||
|
||||
node = value;
|
||||
search = data;
|
||||
ud = node->value;
|
||||
search = fdata;
|
||||
ud = value;
|
||||
|
||||
if (!ud->desktop->mime_types) return;
|
||||
if (!ud->desktop->mime_types) return EINA_FALSE;
|
||||
ecore_list_first_goto(ud->desktop->mime_types);
|
||||
while ((mime = ecore_list_next(ud->desktop->mime_types)))
|
||||
{
|
||||
|
@ -748,109 +789,125 @@ efreet_util_cache_search_mime(void *value, void *data)
|
|||
break;
|
||||
}
|
||||
}
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
efreet_util_cache_search_wm_class(const void *value, const void *data)
|
||||
static Eina_Bool
|
||||
efreet_util_cache_search_wm_class(__UNUSED__ const Eina_Hash *hash, void *value, void *fdata)
|
||||
{
|
||||
const Efreet_Cache_Search *search;
|
||||
const Efreet_Util_Desktop *ud;
|
||||
Efreet_Cache_Search *search;
|
||||
Efreet_Util_Desktop *ud;
|
||||
|
||||
ud = value;
|
||||
search = data;
|
||||
search = fdata;
|
||||
|
||||
if (!ud->desktop->startup_wm_class) return 1;
|
||||
if (!ud->desktop->startup_wm_class) return EINA_TRUE;
|
||||
if ((search->what2) && (!strcmp(ud->desktop->startup_wm_class, search->what2)))
|
||||
return 0;
|
||||
{
|
||||
search->result = ud;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
else if ((search->what1) && (!strcmp(ud->desktop->startup_wm_class, search->what1)))
|
||||
return 0;
|
||||
return 1;
|
||||
{
|
||||
search->result = ud;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
efreet_util_cache_search_exec(const void *value, const void *data)
|
||||
static Eina_Bool
|
||||
efreet_util_cache_search_exec(__UNUSED__ const Eina_Hash *hash, void *value, void *fdata)
|
||||
{
|
||||
const Efreet_Cache_Search *search;
|
||||
const Efreet_Util_Desktop *ud;
|
||||
Efreet_Cache_Search *search;
|
||||
Efreet_Util_Desktop *ud;
|
||||
char *exec;
|
||||
const char *file;
|
||||
|
||||
ud = value;
|
||||
search = data;
|
||||
search = fdata;
|
||||
|
||||
if (!ud->desktop->exec) return 1;
|
||||
if (!ud->desktop->exec) return EINA_TRUE;
|
||||
exec = ecore_file_app_exe_get(ud->desktop->exec);
|
||||
if (!exec) return 1;
|
||||
if (!exec) return EINA_TRUE;
|
||||
if (!strcmp(exec, search->what1))
|
||||
{
|
||||
free(exec);
|
||||
return 0;
|
||||
search->result = ud;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
file = ecore_file_file_get(exec);
|
||||
if (file && !strcmp(file, search->what1))
|
||||
{
|
||||
free(exec);
|
||||
return 0;
|
||||
search->result = ud;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
free(exec);
|
||||
return 1;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
efreet_util_cache_search_name(const void *value, const void *data)
|
||||
static Eina_Bool
|
||||
efreet_util_cache_search_name(__UNUSED__ const Eina_Hash *hash, void *value, void *fdata)
|
||||
{
|
||||
const Efreet_Cache_Search *search;
|
||||
const Efreet_Util_Desktop *ud;
|
||||
Efreet_Cache_Search *search;
|
||||
Efreet_Util_Desktop *ud;
|
||||
|
||||
ud = value;
|
||||
search = data;
|
||||
search = fdata;
|
||||
|
||||
if (!ud->desktop->name) return 1;
|
||||
return strcmp(ud->desktop->name, search->what1);
|
||||
if (!ud->desktop->name) return EINA_TRUE;
|
||||
if (!strcmp(ud->desktop->name, search->what1))
|
||||
{
|
||||
search->result = ud;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
efreet_util_cache_search_generic_name(const void *value, const void *data)
|
||||
static Eina_Bool
|
||||
efreet_util_cache_search_generic_name(__UNUSED__ const Eina_Hash *hash, void *value, void *fdata)
|
||||
{
|
||||
const Efreet_Cache_Search *search;
|
||||
const Efreet_Util_Desktop *ud;
|
||||
Efreet_Cache_Search *search;
|
||||
Efreet_Util_Desktop *ud;
|
||||
|
||||
ud = value;
|
||||
search = data;
|
||||
search = fdata;
|
||||
|
||||
if (!ud->desktop->generic_name) return 1;
|
||||
return strcmp(ud->desktop->generic_name, search->what1);
|
||||
if (!ud->desktop->generic_name) return EINA_TRUE;
|
||||
if (!strcmp(ud->desktop->generic_name, search->what1))
|
||||
{
|
||||
search->result = ud;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
efreet_util_cache_search_name_glob(void *value, void *data)
|
||||
static Eina_Bool
|
||||
efreet_util_cache_search_name_glob(__UNUSED__ const Eina_Hash *hash, void *value, void *fdata)
|
||||
{
|
||||
Ecore_Hash_Node *node;
|
||||
Efreet_Cache_Search_List *search;
|
||||
Efreet_Util_Desktop *ud;
|
||||
|
||||
node = value;
|
||||
search = data;
|
||||
ud = node->value;
|
||||
search = fdata;
|
||||
ud = value;
|
||||
|
||||
if (efreet_util_glob_match(ud->desktop->name, search->what))
|
||||
ecore_list_append(search->list, ud->desktop);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
efreet_util_cache_search_exec_glob(void *value, void *data)
|
||||
static Eina_Bool
|
||||
efreet_util_cache_search_exec_glob(__UNUSED__ const Eina_Hash *hash, void *value, void *fdata)
|
||||
{
|
||||
Ecore_Hash_Node *node;
|
||||
Efreet_Cache_Search_List *search;
|
||||
Efreet_Util_Desktop *ud;
|
||||
char *exec;
|
||||
|
||||
node = value;
|
||||
search = data;
|
||||
ud = node->value;
|
||||
search = fdata;
|
||||
ud = value;
|
||||
|
||||
if (!ud->desktop->exec) return;
|
||||
if (!ud->desktop->exec) return EINA_FALSE;
|
||||
exec = ecore_file_app_exe_get(ud->desktop->exec);
|
||||
if (exec)
|
||||
{
|
||||
|
@ -858,36 +915,35 @@ efreet_util_cache_search_exec_glob(void *value, void *data)
|
|||
ecore_list_append(search->list, ud->desktop);
|
||||
free(exec);
|
||||
}
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
efreet_util_cache_search_generic_name_glob(void *value, void *data)
|
||||
static Eina_Bool
|
||||
efreet_util_cache_search_generic_name_glob(__UNUSED__ const Eina_Hash *hash, void *value, void *fdata)
|
||||
{
|
||||
Ecore_Hash_Node *node;
|
||||
Efreet_Cache_Search_List *search;
|
||||
Efreet_Util_Desktop *ud;
|
||||
|
||||
node = value;
|
||||
search = data;
|
||||
ud = node->value;
|
||||
search = fdata;
|
||||
ud = value;
|
||||
|
||||
if (efreet_util_glob_match(ud->desktop->generic_name, search->what))
|
||||
ecore_list_append(search->list, ud->desktop);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
efreet_util_cache_search_comment_glob(void *value, void *data)
|
||||
static Eina_Bool
|
||||
efreet_util_cache_search_comment_glob(__UNUSED__ const Eina_Hash *hash, void *value, void *fdata)
|
||||
{
|
||||
Ecore_Hash_Node *node;
|
||||
Efreet_Cache_Search_List *search;
|
||||
Efreet_Util_Desktop *ud;
|
||||
|
||||
node = value;
|
||||
search = data;
|
||||
ud = node->value;
|
||||
search = fdata;
|
||||
ud = value;
|
||||
|
||||
if (efreet_util_glob_match(ud->desktop->comment, search->what))
|
||||
ecore_list_append(search->list, ud->desktop);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1044,12 +1100,11 @@ efreet_util_desktops_by_category_add(Efreet_Desktop *desktop)
|
|||
while ((category = ecore_list_next(desktop->categories)))
|
||||
{
|
||||
Ecore_List *list;
|
||||
list = ecore_hash_get(desktops_by_category, category);
|
||||
list = eina_hash_find(desktops_by_category, category);
|
||||
if (!list)
|
||||
{
|
||||
list = ecore_list_new();
|
||||
ecore_hash_set(desktops_by_category,
|
||||
(void *)eina_stringshare_add(category), list);
|
||||
eina_hash_add(desktops_by_category, category, list);
|
||||
}
|
||||
if (!ecore_list_goto(list, desktop))
|
||||
ecore_list_append(list, desktop);
|
||||
|
@ -1067,15 +1122,12 @@ efreet_util_desktops_by_category_remove(Efreet_Desktop *desktop)
|
|||
while ((category = ecore_list_next(desktop->categories)))
|
||||
{
|
||||
Ecore_List *list;
|
||||
list = ecore_hash_get(desktops_by_category, category);
|
||||
list = eina_hash_find(desktops_by_category, category);
|
||||
if (!list) continue;
|
||||
if (ecore_list_goto(list, desktop))
|
||||
ecore_list_remove(list);
|
||||
if (ecore_list_empty_is(list))
|
||||
{
|
||||
ecore_hash_remove(desktops_by_category, category);
|
||||
ecore_list_destroy(list);
|
||||
}
|
||||
eina_hash_del(desktops_by_category, category, list);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue