forked from enlightenment/enlightenment
improve module config dialog load speed
SVN revision: 82820
This commit is contained in:
parent
1c4aec432d
commit
bc2cdda276
|
@ -3,6 +3,7 @@
|
||||||
* prevent windows dragged from one screen to another from being larger than the destination screen
|
* prevent windows dragged from one screen to another from being larger than the destination screen
|
||||||
* add new APIs for getting module .desktop files
|
* add new APIs for getting module .desktop files
|
||||||
* track module directories
|
* track module directories
|
||||||
|
* improve module config dialog load speed
|
||||||
|
|
||||||
2013-01-14 Brian Miculcy
|
2013-01-14 Brian Miculcy
|
||||||
|
|
||||||
|
|
1
NEWS
1
NEWS
|
@ -70,6 +70,7 @@ Improvements:
|
||||||
* compositor now applies focus/urgency state to windows on first show
|
* compositor now applies focus/urgency state to windows on first show
|
||||||
* prevent windows dragged from one screen to another from being larger than the destination screen
|
* prevent windows dragged from one screen to another from being larger than the destination screen
|
||||||
* track module directories
|
* track module directories
|
||||||
|
* improve module config dialog load speed
|
||||||
|
|
||||||
Fixes:
|
Fixes:
|
||||||
* Backlight, screenlock and screensaver don't check for fullscreen windows - we have presentation mode for that.
|
* Backlight, screenlock and screensaver don't check for fullscreen windows - we have presentation mode for that.
|
||||||
|
|
|
@ -75,7 +75,7 @@ static void _toolbar_select_cb(void *data, void *data2);
|
||||||
|
|
||||||
static CFType *_cftype_find(E_Config_Dialog_Data *cfdata, const char *key, const char *name, const char *icon);
|
static CFType *_cftype_find(E_Config_Dialog_Data *cfdata, const char *key, const char *name, const char *icon);
|
||||||
static CFType *_cftype_new(const char *key, const char *name, const char *icon);
|
static CFType *_cftype_new(const char *key, const char *name, const char *icon);
|
||||||
static void _load_modules(const char *dir, Eina_Hash *types_hash);
|
static void _load_module(E_Module_Desktop *md, Eina_Hash *types_hash);
|
||||||
static Eina_Bool _types_list_create_foreach_cb(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata);
|
static Eina_Bool _types_list_create_foreach_cb(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata);
|
||||||
static int _types_list_sort(const void *data1, const void *data2);
|
static int _types_list_sort(const void *data1, const void *data2);
|
||||||
|
|
||||||
|
@ -105,28 +105,26 @@ static void *
|
||||||
_create_data(E_Config_Dialog *cfd __UNUSED__)
|
_create_data(E_Config_Dialog *cfd __UNUSED__)
|
||||||
{
|
{
|
||||||
Eina_Hash *types_hash;
|
Eina_Hash *types_hash;
|
||||||
Eina_List *modules_paths, *l;
|
Eina_List *mods;
|
||||||
E_Path_Dir *epd;
|
E_Module_Desktop *md;
|
||||||
E_Config_Dialog_Data *cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
E_Config_Dialog_Data *cfdata;
|
||||||
|
|
||||||
|
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||||
|
|
||||||
types_hash = eina_hash_string_superfast_new(NULL);
|
types_hash = eina_hash_string_superfast_new(NULL);
|
||||||
if (!types_hash) return cfdata;
|
mods = e_module_desktop_list();
|
||||||
|
if (!mods)
|
||||||
modules_paths = e_path_dir_list_get(path_modules);
|
|
||||||
if (!modules_paths)
|
|
||||||
{
|
{
|
||||||
eina_hash_free(types_hash);
|
eina_hash_free(types_hash);
|
||||||
return cfdata;
|
return cfdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
EINA_LIST_FOREACH(modules_paths, l, epd)
|
EINA_LIST_FREE(mods, md)
|
||||||
{
|
{
|
||||||
if (ecore_file_is_dir(epd->dir))
|
_load_module(md, types_hash);
|
||||||
_load_modules(epd->dir, types_hash);
|
e_module_desktop_free(md);
|
||||||
}
|
}
|
||||||
|
|
||||||
e_path_dir_list_free(modules_paths);
|
|
||||||
|
|
||||||
eina_hash_foreach(types_hash, _types_list_create_foreach_cb, cfdata);
|
eina_hash_foreach(types_hash, _types_list_create_foreach_cb, cfdata);
|
||||||
eina_hash_free(types_hash);
|
eina_hash_free(types_hash);
|
||||||
cfdata->types = eina_list_sort(cfdata->types, -1, _types_list_sort);
|
cfdata->types = eina_list_sort(cfdata->types, -1, _types_list_sort);
|
||||||
|
@ -470,33 +468,16 @@ _cftype_new_from_key(const char *key)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_load_modules(const char *dir, Eina_Hash *types_hash)
|
_load_module(E_Module_Desktop *md, Eina_Hash *types_hash)
|
||||||
{
|
{
|
||||||
Eina_List *files;
|
|
||||||
char modpath[PATH_MAX];
|
|
||||||
char *mod;
|
|
||||||
int modpathlen;
|
|
||||||
|
|
||||||
modpathlen = snprintf(modpath, sizeof(modpath), "%s/", dir);
|
|
||||||
if (modpathlen >= (int)sizeof(modpath)) return;
|
|
||||||
|
|
||||||
files = ecore_file_ls(dir);
|
|
||||||
EINA_LIST_FREE(files, mod)
|
|
||||||
{
|
|
||||||
Efreet_Desktop *desk;
|
|
||||||
CFType *cft;
|
CFType *cft;
|
||||||
CFModule *cfm;
|
CFModule *cfm;
|
||||||
const char *type;
|
const char *type, *mod;
|
||||||
Eina_Bool new_type;
|
Eina_Bool new_type = EINA_FALSE;
|
||||||
|
|
||||||
if (!strcmp(mod, "comp")) goto end_mod;
|
mod = ecore_file_file_get(md->dir);
|
||||||
snprintf(modpath + modpathlen, sizeof(modpath) - modpathlen,
|
if (md->desktop->x)
|
||||||
"%s/module.desktop", mod);
|
type = eina_hash_find(md->desktop->x, "X-Enlightenment-ModuleType");
|
||||||
if (!ecore_file_exists(modpath)) goto end_mod;
|
|
||||||
if (!(desk = efreet_desktop_new(modpath))) goto end_mod;
|
|
||||||
|
|
||||||
if (desk->x)
|
|
||||||
type = eina_hash_find(desk->x, "X-Enlightenment-ModuleType");
|
|
||||||
else
|
else
|
||||||
type = NULL;
|
type = NULL;
|
||||||
if (!type) type = "utils"; // todo: warn?
|
if (!type) type = "utils"; // todo: warn?
|
||||||
|
@ -507,35 +488,26 @@ _load_modules(const char *dir, Eina_Hash *types_hash)
|
||||||
new_type = EINA_FALSE;
|
new_type = EINA_FALSE;
|
||||||
if ((cft->modules_hash) &&
|
if ((cft->modules_hash) &&
|
||||||
(eina_hash_find(cft->modules_hash, mod)))
|
(eina_hash_find(cft->modules_hash, mod)))
|
||||||
goto end_desktop;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cft = _cftype_new_from_key(type);
|
cft = _cftype_new_from_key(type);
|
||||||
if (cft) new_type = EINA_TRUE;
|
if (cft) new_type = EINA_TRUE;
|
||||||
else goto end_desktop;
|
else return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cfm = _module_new(mod, desk);
|
cfm = _module_new(mod, md->desktop);
|
||||||
if (!cfm)
|
if (!cfm)
|
||||||
{
|
{
|
||||||
if (new_type) _cftype_free(cft);
|
if (new_type) _cftype_free(cft);
|
||||||
goto end_desktop;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cft->modules_hash)
|
if (!cft->modules_hash)
|
||||||
cft->modules_hash = eina_hash_string_superfast_new(NULL);
|
cft->modules_hash = eina_hash_string_superfast_new(NULL);
|
||||||
if (!cft->modules_hash)
|
|
||||||
{
|
|
||||||
if (new_type) _cftype_free(cft);
|
|
||||||
_module_free(cfm);
|
|
||||||
goto end_desktop;
|
|
||||||
}
|
|
||||||
eina_hash_direct_add(cft->modules_hash, cfm->short_name, cfm);
|
eina_hash_direct_add(cft->modules_hash, cfm->short_name, cfm);
|
||||||
// TODO be paranoid about hash add failure, otherwise it will leak
|
|
||||||
|
|
||||||
cft->modules = eina_list_append(cft->modules, cfm);
|
cft->modules = eina_list_append(cft->modules, cfm);
|
||||||
// TODO be paranoid about list append failure, otherwise it will leak
|
|
||||||
cfm->module = e_module_find(mod);
|
cfm->module = e_module_find(mod);
|
||||||
if (cfm->module)
|
if (cfm->module)
|
||||||
cfm->enabled = e_module_enabled_get(cfm->module);
|
cfm->enabled = e_module_enabled_get(cfm->module);
|
||||||
|
@ -544,13 +516,6 @@ _load_modules(const char *dir, Eina_Hash *types_hash)
|
||||||
|
|
||||||
if (new_type)
|
if (new_type)
|
||||||
eina_hash_direct_add(types_hash, cft->key, cft);
|
eina_hash_direct_add(types_hash, cft->key, cft);
|
||||||
// TODO be paranoid about hash add failure, otherwise it will leak
|
|
||||||
|
|
||||||
end_desktop:
|
|
||||||
efreet_desktop_free(desk);
|
|
||||||
end_mod:
|
|
||||||
free(mod);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Reference in New Issue