kwo pushed a commit to branch master. http://git.enlightenment.org/e16/e16.git/commit/?id=cb725db9d48aca1744cd7abe9f48103150df4b84
commit cb725db9d48aca1744cd7abe9f48103150df4b84 Author: Kim Woelders <[email protected]> Date: Sat Dec 30 17:00:17 2017 +0100 Handle ".theme files" A .theme file is really the same as the usual .etheme file (i.e. a tarball of the theme files, compressed or not), except that .theme files may contain themes for multiple applications. The difference in the handling of a .theme file is only the location where it is extracted. A normal theme file, say FOO.etheme (or FOO.tar, FOO.tar.gz, FOO.blah), is (normally) extracted to ~/.e16/themes/FOO/. e16 now expects the theme files to be located in ~/.e16/themes/FOO/*.cfg or ~/.e16/themes/FOO/e16/*.cfg. A .theme file, e.g. FOO.theme, is extracted to ~/.themes/FOO/. e16 now expects the theme files to be located in ~/.themes/FOO/*.cfg or ~/.themes/FOO/e16/*.cfg (the first one should probably never be used, but it's how it works). In order to find this new theme path it is added to the default theme search path. Suggested by Don Harrop. --- src/theme.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/theme.c b/src/theme.c index 36ee426b..5e178775 100644 --- a/src/theme.c +++ b/src/theme.c @@ -24,6 +24,7 @@ #include "E.h" #include "emodule.h" #include "file.h" +#include "user.h" #include "util.h" #include "session.h" @@ -33,8 +34,9 @@ _ThemePathsUpdate(void) { char paths[FILEPATH_LEN_MAX]; - Esnprintf(paths, sizeof(paths), "%s/themes:%s/themes:%s", EDirUser(), - EDirRoot(), (Conf.theme.extra_path) ? Conf.theme.extra_path : ""); + Esnprintf(paths, sizeof(paths), "%s/themes:%s/.themes:%s/themes:%s", + EDirUser(), userhome(), EDirRoot(), + (Conf.theme.extra_path) ? Conf.theme.extra_path : ""); _EFDUP(Mode.theme.paths, paths); } @@ -202,7 +204,8 @@ _ThemeExtract(const char *path) FILE *f; unsigned char buf[262]; size_t ret; - char *name; + const char *p; + char name[128], *type; if (EDebug(EDBUG_TYPE_CONFIG)) Eprintf("%s: %s\n", __func__, path); @@ -215,9 +218,22 @@ _ThemeExtract(const char *path) memset(buf + ret, 0, sizeof(buf) - ret); fclose(f); - name = fileof(path); - Esnprintf(th, sizeof(th), "%s/themes/%s", EDirUser(), name); - Efree(name); + p = strrchr(path, '/'); + p = (p) ? p + 1 : path; + Esnprintf(name, sizeof(name), "%s", p); + type = strchr(name, '.'); + if (type) + *type++ = '\0'; + + if (type && strcmp(type, "theme") == 0) + { + Esnprintf(th, sizeof(th), "%s/.themes", userhome()); + if (!isdir(th)) + E_md(th); + Esnprintf(th, sizeof(th), "%s/.themes/%s", userhome(), name); + } + else + Esnprintf(th, sizeof(th), "%s/themes/%s", EDirUser(), name); /* check magic numbers */ if ((buf[0] == 31) && (buf[1] == 139)) --
