efreet: Improve language reset

efreet.c: Reset parsed locale, and force a reparse of LANG env
efreet_cache.c: Close desktop cache so we reopen cache with correct
language

SVN revision: 72817
This commit is contained in:
Sebastian Dransfeld 2012-06-25 17:12:35 +00:00
parent e7f6b58537
commit 314d42ea42
7 changed files with 73 additions and 52 deletions

View File

@ -147,5 +147,6 @@ src/tests/efreet_test
/po/quot.sed
/po/remove-potcdate.sed
/po/remove-potcdate.sin
/po/*.gmo
/po/stamp-po
/stamp-h1

View File

@ -93,6 +93,13 @@ EAPI int efreet_init(void);
*/
EAPI int efreet_shutdown(void);
/**
* @brief Resets language dependent variables and resets language dependent
* caches This must be called whenever the locale is changed.
* @since 1.3
*/
EAPI void efreet_lang_reset(void);
#ifdef __cplusplus
}
#endif

View File

@ -166,6 +166,18 @@ efreet_shutdown(void)
return _efreet_init_count;
}
EAPI void
efreet_lang_reset(void)
{
IF_RELEASE(efreet_lang);
IF_RELEASE(efreet_lang_country);
IF_RELEASE(efreet_lang_modifier);
efreet_parsed_locale = 0; /* reset this in case they init efreet again */
efreet_dirs_reset();
efreet_cache_desktop_reset();
}
/**
* @internal
* @return Returns the current users language setting or NULL if none set
@ -220,13 +232,13 @@ efreet_parse_locale(void)
{
efreet_parsed_locale = 1;
if (efreet_parse_locale_setting("LANG"))
return;
if (efreet_parse_locale_setting("LC_ALL"))
return;
if (efreet_parse_locale_setting("LC_MESSAGES"))
return;
efreet_parse_locale_setting("LANG");
efreet_parse_locale_setting("LC_MESSAGES");
}
/**

View File

@ -187,20 +187,10 @@ efreet_hostname_get(void)
return hostname;
}
EAPI void
void
efreet_dirs_reset(void)
{
const char *s;
eina_stringshare_replace(&hostname, NULL);
eina_stringshare_replace(&xdg_desktop_dir, NULL);
eina_stringshare_replace(&xdg_cache_home, NULL);
eina_stringshare_replace(&xdg_config_home, NULL);
eina_stringshare_replace(&xdg_data_home, NULL);
eina_stringshare_replace(&efreet_home_dir, NULL);
EINA_LIST_FREE(xdg_data_dirs, s)
eina_stringshare_del(s);
EINA_LIST_FREE(xdg_config_dirs, s)
eina_stringshare_del(s);
}
/**

View File

@ -65,13 +65,6 @@ EAPI const char *efreet_cache_home_get(void);
*/
EAPI const char *efreet_hostname_get(void);
/**
* @brief Resets all the stored env variables. This must be called whenever the
* locale is changed.
* @since 1.3
*/
EAPI void efreet_dirs_reset(void);
/**
* Efreet_Event_Cache_Update
*/

View File

@ -941,6 +941,49 @@ efreet_cache_desktop_dirs(void)
return eet_data_read(desktop_cache, efreet_array_string_edd(), EFREET_CACHE_DESKTOP_DIRS);
}
void
efreet_cache_desktop_reset(void)
{
Eina_List *l = NULL;
Efreet_Event_Cache_Update *ev = NULL;
Efreet_Old_Cache *d = NULL;
IF_RELEASE(util_cache_names_key);
IF_RELEASE(util_cache_hash_key);
if ((desktop_cache) && (desktop_cache != NON_EXISTING))
{
d = NEW(Efreet_Old_Cache, 1);
if (!d) goto error;
d->hash = desktops;
d->ef = desktop_cache;
old_desktop_caches = eina_list_append(old_desktop_caches, d);
desktops = eina_hash_string_superfast_new(NULL);
}
desktop_cache = NULL;
efreet_cache_array_string_free(util_cache_names);
util_cache_names = NULL;
if (util_cache_hash)
{
eina_hash_free(util_cache_hash->hash);
free(util_cache_hash);
util_cache_hash = NULL;
}
util_cache = efreet_cache_close(util_cache);
ecore_event_add(EFREET_EVENT_DESKTOP_CACHE_UPDATE, ev, desktop_cache_update_free, d);
return;
error:
IF_FREE(ev);
IF_FREE(d);
EINA_LIST_FREE(l, d)
free(d);
}
void
efreet_cache_desktop_update(void)
{
@ -1117,34 +1160,7 @@ cache_update_cb(void *data __UNUSED__, Ecore_File_Monitor *em __UNUSED__,
if (!ev) goto error;
if (cache_check_change(path))
{
IF_RELEASE(util_cache_names_key);
IF_RELEASE(util_cache_hash_key);
if ((desktop_cache) && (desktop_cache != NON_EXISTING))
{
d = NEW(Efreet_Old_Cache, 1);
if (!d) goto error;
d->hash = desktops;
d->ef = desktop_cache;
old_desktop_caches = eina_list_append(old_desktop_caches, d);
desktops = eina_hash_string_superfast_new(NULL);
}
desktop_cache = NULL;
efreet_cache_array_string_free(util_cache_names);
util_cache_names = NULL;
if (util_cache_hash)
{
eina_hash_free(util_cache_hash->hash);
free(util_cache_hash);
util_cache_hash = NULL;
}
util_cache = efreet_cache_close(util_cache);
ecore_event_add(EFREET_EVENT_DESKTOP_CACHE_UPDATE, ev, desktop_cache_update_free, d);
efreet_cache_desktop_reset();
}
ecore_event_add(EFREET_EVENT_DESKTOP_CACHE_BUILD, NULL, NULL, NULL);
/* TODO: Check if desktop_dirs_add exists, and rebuild cache if */

View File

@ -186,6 +186,7 @@ int efreet_util_init(void);
int efreet_util_shutdown(void);
const char *efreet_home_dir_get(void);
void efreet_dirs_reset(void);
const char *efreet_lang_get(void);
const char *efreet_lang_country_get(void);
@ -202,6 +203,7 @@ Efreet_Desktop *efreet_cache_desktop_find(const char *file);
void efreet_cache_desktop_free(Efreet_Desktop *desktop);
void efreet_cache_desktop_add(Efreet_Desktop *desktop);
Efreet_Cache_Array_String *efreet_cache_desktop_dirs(void);
void efreet_cache_desktop_reset(void);
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);