Avoid confusing dual use of Mode.theme.path

This commit is contained in:
Kim Woelders 2018-01-21 16:02:36 +01:00
parent cefd067f7d
commit 92cb89490b
3 changed files with 17 additions and 13 deletions

View File

@ -551,7 +551,7 @@ void StartupBackgroundsDestroy(void);
/* theme.c */
char *ThemePathFind(const char *theme);
char *ThemePathName(const char *path);
void ThemeFind(void);
void ThemeFind(const char *theme);
char **ThemesList(int *num);
/*

View File

@ -96,6 +96,7 @@ main(int argc, char **argv)
int ch, i, loop;
struct utsname ubuf;
const char *str, *dstr;
char *theme;
/* This function runs all the setup for startup, and then
* proceeds into the primary event loop at the end.
@ -146,7 +147,7 @@ main(int argc, char **argv)
* understand.
*/
Mode.theme.path = NULL;
theme = NULL;
dstr = NULL;
for (loop = 1; loop;)
@ -194,7 +195,7 @@ main(int argc, char **argv)
SetSMID(eoptarg);
break;
case 't':
Mode.theme.path = Estrdup(eoptarg);
theme = Estrdup(eoptarg);
break;
case 'V':
printf("%s %s\n", e_wm_name, e_wm_version);
@ -240,7 +241,8 @@ main(int argc, char **argv)
LangInit();
/* The theme path must now be available for config file loading. */
ThemeFind();
ThemeFind(theme);
Efree(theme);
/* Set the Environment variables */
Esetenv("EVERSION", e_wm_version);

View File

@ -337,16 +337,18 @@ ThemePathFind(const char *theme)
}
void
ThemeFind(void)
ThemeFind(const char *theme)
{
char *name, *path, *s;
char name[FILEPATH_LEN_MAX];
const char *p;
char *path, *s;
/*
* Conf.theme.name is read from the configuration.
* Mode.theme.path may be assigned on the command line.
*/
name = (Mode.theme.path) ? Mode.theme.path : Conf.theme.name;
s = (name) ? strchr(name, '=') : NULL;
name[0] = '\0';
p = (theme) ? theme : Conf.theme.name;
if (p)
snprintf(name, sizeof(name), "%s", p);
s = strchr(name, '=');
if (s)
{
*s++ = '\0';
@ -356,7 +358,7 @@ ThemeFind(void)
path = ThemePathFind(name);
if (!path && (!name || strcmp(name, "-")))
if (!path && strcmp(name, "-"))
{
Alert(_("No themes were found in the default directories:\n"
" %s\n"