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 */ /* theme.c */
char *ThemePathFind(const char *theme); char *ThemePathFind(const char *theme);
char *ThemePathName(const char *path); char *ThemePathName(const char *path);
void ThemeFind(void); void ThemeFind(const char *theme);
char **ThemesList(int *num); char **ThemesList(int *num);
/* /*

View File

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

View File

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