Removed removeDriveFromPath() and store the theme filename in settings.cfg instead of the absolute path.
This commit is contained in:
parent
5b35642de7
commit
a9d7a47f2e
@ -55,7 +55,7 @@ void launchMenuBackTask() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void launchApplyThemeTask(menuEntry_s* arg) {
|
void launchApplyThemeTask(menuEntry_s* arg) {
|
||||||
const char* themePath = removeDriveFromPath(arg->path);
|
const char* themePath = arg->path;
|
||||||
SetThemePathToConfig(themePath);
|
SetThemePathToConfig(themePath);
|
||||||
themeStartup(themeGlobalPreset);
|
themeStartup(themeGlobalPreset);
|
||||||
computeFrontGradient(themeCurrent.frontWaveColor, 280);
|
computeFrontGradient(themeCurrent.frontWaveColor, 280);
|
||||||
|
@ -112,9 +112,3 @@ static inline char* getSlash(const char* str)
|
|||||||
return (char*)p;
|
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;
|
|
||||||
}
|
|
@ -145,19 +145,22 @@ void GetThemePathFromConfig(char* themePath, size_t size) {
|
|||||||
config_t cfg = {0};
|
config_t cfg = {0};
|
||||||
config_setting_t *settings = NULL;
|
config_setting_t *settings = NULL;
|
||||||
char tmp_path[PATH_MAX] = {0};
|
char tmp_path[PATH_MAX] = {0};
|
||||||
|
char tmp_path_theme[PATH_MAX] = {0};
|
||||||
|
|
||||||
#ifdef __SWITCH__
|
#ifdef __SWITCH__
|
||||||
tmp_path[0] = '/';
|
tmp_path[0] = '/';
|
||||||
|
tmp_path_theme[0] = '/';
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
strncat(tmp_path, "config/nx-hbmenu/settings.cfg", sizeof(tmp_path)-2);
|
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);
|
bool good_cfg = config_read_file(&cfg, tmp_path);
|
||||||
|
|
||||||
if(good_cfg) {
|
if(good_cfg) {
|
||||||
settings = config_lookup(&cfg, "settings");
|
settings = config_lookup(&cfg, "settings");
|
||||||
if(settings != NULL) {
|
if(settings != NULL) {
|
||||||
if(config_setting_lookup_string(settings, "themePath", &tmpThemePath))
|
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,
|
*group = NULL,
|
||||||
*settings = NULL;
|
*settings = NULL;
|
||||||
|
|
||||||
|
themePath = getSlash(themePath);
|
||||||
|
if(themePath[0] == '/') themePath++;
|
||||||
|
|
||||||
#ifdef __SWITCH__
|
#ifdef __SWITCH__
|
||||||
settingPath[0] = '/';
|
settingPath[0] = '/';
|
||||||
#endif
|
#endif
|
||||||
@ -201,4 +207,4 @@ void SetThemePathToConfig(const char* themePath) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
config_destroy(&cfg);
|
config_destroy(&cfg);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user