raster pushed a commit to branch master. http://git.enlightenment.org/core/elementary.git/commit/?id=9f51ad064259a0184fa7eee3db8abedd92e32230
commit 9f51ad064259a0184fa7eee3db8abedd92e32230 Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com> Date: Thu Dec 31 15:38:20 2015 +0900 elm config - allow the ability to save out to another hidden profile support the ability to have hidden profiles that begin with a dot (.) char like all hidden files/dirs. to do this we need to also be able to create profiles with a given name (a hidden name) without switching to them, so add the ability to save out to a specific profile name without switching to it. of course this means to list profiles we need to list them or list ALL includiing hidden profiles. @feature --- src/lib/elm_config.c | 82 ++++++++++++++++++++++++++++++---------------------- src/lib/elm_config.h | 30 +++++++++++++++++++ src/lib/elm_priv.h | 4 +-- 3 files changed, 80 insertions(+), 36 deletions(-) diff --git a/src/lib/elm_config.c b/src/lib/elm_config.c index 88595dc..e15e8fe 100644 --- a/src/lib/elm_config.c +++ b/src/lib/elm_config.c @@ -1053,7 +1053,7 @@ _elm_config_colors_free(const char *palette_name) } Eina_List * -_elm_config_profiles_list(void) +_elm_config_profiles_list(Eina_Bool hide_profiles) { Eina_File_Direct_Info *info; Eina_List *flist = NULL; @@ -1065,8 +1065,7 @@ _elm_config_profiles_list(void) len = _elm_config_user_dir_snprintf(buf, sizeof(buf), "config"); file_it = eina_file_stat_ls(buf); - if (!file_it) - goto sys; + if (!file_it) goto sys; buf[len] = '/'; len++; @@ -1075,15 +1074,15 @@ _elm_config_profiles_list(void) EINA_ITERATOR_FOREACH(file_it, info) { - if (info->name_length >= len) - continue; + if (info->name_length >= len) continue; + if ((hide_profiles) && (info->path[info->name_start] == '.')) continue; if (info->type == EINA_FILE_DIR) { flist = eina_list_sorted_insert(flist, _sort_files_cb, - eina_stringshare_add(info->path + - info->name_start)); + eina_stringshare_add + (info->path + info->name_start)); } } @@ -1095,8 +1094,7 @@ sys: sizeof("config") - 1); file_it = eina_file_stat_ls(buf); - if (!file_it) - goto list_free; + if (!file_it) goto list_free; buf[len] = '/'; len++; @@ -1104,26 +1102,26 @@ sys: len = sizeof(buf) - len; EINA_ITERATOR_FOREACH(file_it, info) { - if (info->name_length >= len) - continue; + if (info->name_length >= len) continue; + if ((hide_profiles) && (info->path[info->name_start] == '.')) continue; switch (info->type) { case EINA_FILE_DIR: - { - const Eina_List *l; - const char *tmp; - - EINA_LIST_FOREACH(flist, l, tmp) - if (!strcmp(info->path + info->name_start, tmp)) - break; + { + const Eina_List *l; + const char *tmp; - if (!l) - flist = - eina_list_sorted_insert(flist, _sort_files_cb, - eina_stringshare_add(info->path + - info->name_start)); - } + EINA_LIST_FOREACH(flist, l, tmp) + { + if (!strcmp(info->path + info->name_start, tmp)) break; + } + if (!l) + flist = eina_list_sorted_insert(flist, _sort_files_cb, + eina_stringshare_add + (info->path + + info->name_start)); + } break; default: @@ -1134,9 +1132,7 @@ sys: return flist; list_free: - EINA_LIST_FREE(flist, dir) - eina_stringshare_del(dir); - + EINA_LIST_FREE(flist, dir) eina_stringshare_del(dir); return NULL; } @@ -1700,7 +1696,7 @@ err: } Eina_Bool -_elm_config_save(void) +_elm_config_save(const char *profile) { char buf[4096], buf2[4096]; int ok = 0, ret; @@ -1721,7 +1717,7 @@ _elm_config_save(void) } len = _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/%s", - _elm_profile); + profile ? profile : _elm_profile); if (len + 1 >= sizeof(buf)) return EINA_FALSE; @@ -1733,8 +1729,11 @@ _elm_config_save(void) return EINA_FALSE; } - if (!_elm_config_profile_save()) - return EINA_FALSE; + if (!profile) + { + if (!_elm_config_profile_save()) + return EINA_FALSE; + } buf[len] = '/'; len++; @@ -1889,7 +1888,7 @@ _config_update(void) _elm_config->config_version = ELM_CONFIG_VERSION; /* after updating user config, we must save */ _config_free(tcfg); - _elm_config_save(); + _elm_config_save(NULL); } static void @@ -2387,7 +2386,7 @@ elm_config_password_show_last_timeout_set(double password_show_last_timeout) EAPI Eina_Bool elm_config_save(void) { - return _elm_config_save(); + return _elm_config_save(NULL); } EAPI void @@ -2418,7 +2417,13 @@ elm_config_profile_dir_free(const char *p_dir) EAPI Eina_List * elm_config_profile_list_get(void) { - return _elm_config_profiles_list(); + return _elm_config_profiles_list(EINA_TRUE); +} + +EAPI Eina_List * +elm_config_profile_list_full_get(void) +{ + return _elm_config_profiles_list(EINA_FALSE); } EAPI void @@ -2437,6 +2442,14 @@ elm_config_profile_set(const char *profile) _elm_config_profile_set(profile); } +EAPI void +elm_config_profile_save(const char *profile) +{ + EINA_SAFETY_ON_NULL_RETURN(profile); + _elm_config_save(profile); +} + + EAPI const char * elm_config_engine_get(void) { @@ -3368,6 +3381,7 @@ elm_config_all_flush(void) } ecore_file_unlink(buf2); + elm_config_save(); return; err: diff --git a/src/lib/elm_config.h b/src/lib/elm_config.h index e7bece0..12c2ff4 100644 --- a/src/lib/elm_config.h +++ b/src/lib/elm_config.h @@ -116,6 +116,22 @@ EAPI void elm_config_profile_dir_free(const char *p_dir); EAPI Eina_List *elm_config_profile_list_get(void); /** + * Get Elementary's list of available profiles including hidden ones. + * + * This gets a full list of profiles even with hidden names that should not + * be user-visible. + * + * @return The profiles list. List node data are the profile name + * strings. + * @ingroup Profile + * + * @note One must free this list, after usage, with the function + * elm_config_profile_list_free(). + * @since 1.17 + */ +EAPI Eina_List *elm_config_profile_list_full_get(void); + +/** * Free Elementary's list of available profiles. * * @param l The profiles list, as returned by elm_config_profile_list_get(). @@ -138,6 +154,20 @@ EAPI void elm_config_profile_list_free(Eina_List *l); EAPI void elm_config_profile_set(const char *profile); /** + * Take the current config and write it out to the named profile + * + * This will take the current in-memory config and write it out to the named + * profile specified by @p profile. This will not change profile for the + * application or make other processes switch profile. + * + * @param profile The profile's name + * @ingroup Profile + * + * @since 1.17 + */ +EAPI void elm_config_profile_save(const char *profile); + +/** * @} */ diff --git a/src/lib/elm_priv.h b/src/lib/elm_priv.h index f0dfd01..f5f1cde 100644 --- a/src/lib/elm_priv.h +++ b/src/lib/elm_priv.h @@ -433,7 +433,7 @@ void _elm_config_init(void); void _elm_config_sub_init(void); void _elm_config_shutdown(void); void _elm_config_sub_shutdown(void); -Eina_Bool _elm_config_save(void); +Eina_Bool _elm_config_save(const char *profile); void _elm_config_reload(void); size_t _elm_config_user_dir_snprintf(char *dst, size_t size, const char *fmt, ...) @@ -445,7 +445,7 @@ void _elm_recache(void); const char *_elm_config_current_profile_get(void); const char *_elm_config_profile_dir_get(const char *prof, Eina_Bool is_user); -Eina_List *_elm_config_profiles_list(void); +Eina_List *_elm_config_profiles_list(Eina_Bool hide_profiles); void _elm_config_all_update(void); void _elm_config_profile_set(const char *profile); --