From a9d7a47f2efeeae2c992397da4294ca7ff739b12 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Sat, 29 Sep 2018 11:58:29 -0400 Subject: [PATCH] Removed removeDriveFromPath() and store the theme filename in settings.cfg instead of the absolute path. --- common/menu.c | 2 +- common/menu.h | 6 ------ common/theme.c | 10 ++++++++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/common/menu.c b/common/menu.c index b2fe56a..481a2c7 100644 --- a/common/menu.c +++ b/common/menu.c @@ -55,7 +55,7 @@ void launchMenuBackTask() { } void launchApplyThemeTask(menuEntry_s* arg) { - const char* themePath = removeDriveFromPath(arg->path); + const char* themePath = arg->path; SetThemePathToConfig(themePath); themeStartup(themeGlobalPreset); computeFrontGradient(themeCurrent.frontWaveColor, 280); diff --git a/common/menu.h b/common/menu.h index a155814..66a8581 100644 --- a/common/menu.h +++ b/common/menu.h @@ -112,9 +112,3 @@ static inline char* getSlash(const char* str) return (char*)p; } -static inline char* removeDriveFromPath(const char* str) { - const char* p; - for (p = str; p <= (str+strlen(str)) && *p != ':'; p++); - p++;//iterate one more time past ':' - return (char*)p; -} \ No newline at end of file diff --git a/common/theme.c b/common/theme.c index 039b956..bbcbaca 100644 --- a/common/theme.c +++ b/common/theme.c @@ -145,19 +145,22 @@ void GetThemePathFromConfig(char* themePath, size_t size) { config_t cfg = {0}; config_setting_t *settings = NULL; char tmp_path[PATH_MAX] = {0}; + char tmp_path_theme[PATH_MAX] = {0}; #ifdef __SWITCH__ tmp_path[0] = '/'; + tmp_path_theme[0] = '/'; #endif strncat(tmp_path, "config/nx-hbmenu/settings.cfg", sizeof(tmp_path)-2); + strncat(tmp_path_theme, "config/nx-hbmenu/themes/", sizeof(tmp_path_theme)-2); bool good_cfg = config_read_file(&cfg, tmp_path); if(good_cfg) { settings = config_lookup(&cfg, "settings"); if(settings != NULL) { if(config_setting_lookup_string(settings, "themePath", &tmpThemePath)) - strncpy(themePath, tmpThemePath, size-1); + snprintf(themePath, size-1, "%s%s", tmp_path_theme, tmpThemePath); } } @@ -173,6 +176,9 @@ void SetThemePathToConfig(const char* themePath) { *group = NULL, *settings = NULL; + themePath = getSlash(themePath); + if(themePath[0] == '/') themePath++; + #ifdef __SWITCH__ settingPath[0] = '/'; #endif @@ -201,4 +207,4 @@ void SetThemePathToConfig(const char* themePath) { } config_destroy(&cfg); -} \ No newline at end of file +}