24 const char *error = NULL;
26 const char *d = strrchr(FileName,
'/');
29 const char *n = strchr(FileName,
'-');
32 if (!strchr(++n,
'-')) {
33 const char *e = strchr(n,
'.');
34 if (e && strcmp(e,
".theme") == 0) {
41 error =
"missing theme name";
44 error =
"invalid extension";
47 error =
"too many '-'";
50 error =
"missing skin name";
53 error =
"missing '-'";
58 esyslog(
"ERROR: invalid theme file name (%s): '%s'", error, FileName);
75 if (!OnlyDescriptions)
76 isyslog(
"loading %s", FileName);
77 FILE *f = fopen(FileName,
"r");
82 const char *error = NULL;
85 while ((s = ReadLine.
Read(f)) != NULL) {
87 char *p = strchr(s,
'#');
93 char *v = strchr(s,
'=');
98 if (strstr(n,
"Description") == n) {
100 char *l = strchr(n,
'.');
108 error =
"invalid language code";
110 else if (!OnlyDescriptions) {
116 tColor c = strtoul(v, &p, 16);
120 error =
"invalid color value";
125 error =
"unknown color name";
132 error =
"missing value";
140 esyslog(
"ERROR: error in %s, line %d%s%s", FileName, line, error ?
": " :
"", error ? error :
"");
216 while ((e = d.
Next()) != NULL) {
217 if (strstr(e->d_name, SkinName) == e->d_name && e->d_name[strlen(SkinName)] ==
'-') {
225 for (
int i = 0; i < Data.
Size(); i++) {
227 char *t = strchr(s,
'\t');
230 esyslog(
"ERROR: duplicate themes '%s' in skin '%s'", s, SkinName);
235 names.Append(strdup(s));
struct dirent * Next(void)
void Sort(bool IgnoreCase=false)
static cString sprintf(const char *fmt,...) __attribute__((format(printf
const char * Description(void)
Returns a user visible, single line description of this theme.
bool Save(const char *FileName)
Saves the theme data to the given file.
bool FileNameOk(const char *FileName, bool SetName=false)
int AddColor(const char *Name, tColor Color)
Adds a color with the given Name to this theme, initializes it with Color and returns an index into t...
tColor Color(int Subject)
Returns the color for the given Subject.
cTheme(void)
Creates a new theme class.
cVector< tColor > colorValues
bool Load(const char *FileName, bool OnlyDescriptions=false)
Loads the theme data from the given file.
static void SetThemesDirectory(const char *ThemesDirectory)
static cString themesDirectory
int GetThemeIndex(const char *Description)
bool Load(const char *SkinName)
static void Save(const char *SkinName, cTheme *Theme)
const char * FileName(int Index)
virtual void Append(T Data)
const cStringList * I18nLanguages(void)
Returns the list of available languages.
int I18nLanguageIndex(const char *Code)
Returns the index of the language with the given three letter language Code.
int I18nCurrentLanguage(void)
Returns the index of the current language.
const char * I18nLanguageCode(int Language)
Returns the three letter language code of the given Language (which is an index as returned by I18nCu...