1999-10-04 15:06:00 -07:00
|
|
|
/*
|
2007-01-13 11:14:29 -08:00
|
|
|
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
|
2021-01-19 10:39:11 -08:00
|
|
|
* Copyright (C) 2004-2021 Kim Woelders
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies of the Software, its documentation and marketing & publicity
|
|
|
|
* materials, and acknowledgment shall be given in the documentation, materials
|
|
|
|
* and software packages that this Software was used.
|
2000-04-05 16:22:56 -07:00
|
|
|
*
|
1999-10-04 15:06:00 -07:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
1999-08-17 15:56:46 -07:00
|
|
|
#include "E.h"
|
2005-11-27 05:11:06 -08:00
|
|
|
#include "aclass.h"
|
2005-10-24 09:05:30 -07:00
|
|
|
#include "backgrounds.h"
|
2005-12-22 10:43:15 -08:00
|
|
|
#include "borders.h"
|
2005-08-21 06:21:48 -07:00
|
|
|
#include "buttons.h"
|
1999-08-17 15:56:46 -07:00
|
|
|
#include "conf.h"
|
2009-09-29 09:02:50 -07:00
|
|
|
#include "cursors.h"
|
2006-07-24 14:10:59 -07:00
|
|
|
#include "file.h"
|
2005-11-27 05:11:06 -08:00
|
|
|
#include "iclass.h"
|
2005-09-10 11:24:20 -07:00
|
|
|
#include "menus.h"
|
2006-11-19 13:55:52 -08:00
|
|
|
#include "progress.h"
|
2006-04-19 12:13:46 -07:00
|
|
|
#include "session.h"
|
2005-11-27 05:11:06 -08:00
|
|
|
#include "tclass.h"
|
2005-08-20 06:55:51 -07:00
|
|
|
#include "tooltips.h"
|
2006-11-19 13:55:52 -08:00
|
|
|
#include "windowmatch.h"
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2008-10-26 08:35:44 -07:00
|
|
|
#define MAX_E_CFG_VERSION 2 /* Max. supported configuration version */
|
|
|
|
|
2006-02-18 00:30:09 -08:00
|
|
|
void
|
2007-07-27 09:59:50 -07:00
|
|
|
SkipTillEnd(FILE * fs)
|
2003-07-11 11:36:52 -07:00
|
|
|
{
|
|
|
|
char s[FILEPATH_LEN_MAX];
|
2010-01-29 11:45:04 -08:00
|
|
|
int i1, i2;
|
2003-07-11 11:36:52 -07:00
|
|
|
|
2007-07-27 09:59:50 -07:00
|
|
|
while (GetLine(s, sizeof(s), fs))
|
2003-07-11 11:36:52 -07:00
|
|
|
{
|
2003-09-28 12:08:27 -07:00
|
|
|
i1 = i2 = 0;
|
2010-01-29 11:45:04 -08:00
|
|
|
sscanf(s, "%i %i", &i1, &i2);
|
2003-07-11 11:36:52 -07:00
|
|
|
if (i1 == CONFIG_CLOSE)
|
|
|
|
return;
|
|
|
|
if (i2 == CONFIG_OPEN)
|
2007-07-27 09:59:50 -07:00
|
|
|
SkipTillEnd(fs);
|
2003-07-11 11:36:52 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
#define LINE_BUFFER_SIZE 1024
|
|
|
|
/*
|
|
|
|
* This function will get a single line from the file
|
|
|
|
* The string will be null terminated.
|
|
|
|
* Size must be >= 2.
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
GetLine(char *s, int size, FILE * f)
|
|
|
|
{
|
|
|
|
static char *buffer = NULL;
|
2006-08-12 03:33:47 -07:00
|
|
|
static const char *bufptr = NULL;
|
|
|
|
char *so, ch, quote, escape;
|
|
|
|
const char *si;
|
|
|
|
size_t nr;
|
|
|
|
|
2010-08-13 10:04:13 -07:00
|
|
|
if (!buffer)
|
2006-08-12 03:33:47 -07:00
|
|
|
{
|
2007-01-16 17:10:44 -08:00
|
|
|
buffer = EMALLOC(char, LINE_BUFFER_SIZE);
|
|
|
|
|
2010-08-13 10:04:13 -07:00
|
|
|
if (!buffer)
|
2006-08-12 03:33:47 -07:00
|
|
|
return NULL;
|
|
|
|
buffer[LINE_BUFFER_SIZE - 1] = '\0';
|
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
si = bufptr;
|
|
|
|
so = s;
|
|
|
|
quote = '\0';
|
|
|
|
escape = '\0';
|
|
|
|
for (;;)
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
/* Get a line from the input file */
|
2010-08-13 10:04:13 -07:00
|
|
|
if (!si)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2006-08-12 03:33:47 -07:00
|
|
|
nr = fread(buffer, 1, LINE_BUFFER_SIZE - 1, f);
|
|
|
|
if (nr == 0)
|
|
|
|
break;
|
|
|
|
buffer[nr] = '\0';
|
|
|
|
si = buffer;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/* Split on ';' or '\n', handle quoting */
|
2006-08-12 03:33:47 -07:00
|
|
|
ch = *si++;
|
|
|
|
switch (ch)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2006-08-12 03:33:47 -07:00
|
|
|
case '\0':
|
|
|
|
si = NULL;
|
|
|
|
break;
|
|
|
|
case ';': /* Line separator */
|
|
|
|
if (escape || quote)
|
|
|
|
goto case_char;
|
2010-06-06 03:05:53 -07:00
|
|
|
/* FALLTHROUGH */
|
2006-08-12 03:33:47 -07:00
|
|
|
case '\n':
|
|
|
|
if (so == s) /* Skip empty lines */
|
|
|
|
break;
|
|
|
|
*so = '\0'; /* Terminate and return */
|
|
|
|
goto done;
|
|
|
|
case '\r': /* Ignore */
|
|
|
|
break;
|
|
|
|
case '\\': /* Escape */
|
|
|
|
if (escape)
|
|
|
|
goto case_char;
|
|
|
|
escape = ch;
|
|
|
|
break;
|
|
|
|
case '"': /* Quoting */
|
2004-12-28 15:46:49 -08:00
|
|
|
/* case '\'': */
|
2006-08-12 03:33:47 -07:00
|
|
|
if (escape)
|
|
|
|
goto case_char;
|
|
|
|
if (quote == '\0')
|
|
|
|
quote = ch;
|
|
|
|
else if (quote == ch)
|
|
|
|
quote = '\0';
|
|
|
|
else
|
|
|
|
goto case_char;
|
|
|
|
break;
|
|
|
|
case ' ': /* Whitespace */
|
|
|
|
case '\t':
|
|
|
|
if (so == s) /* Skip leading whitespace */
|
|
|
|
break;
|
2017-02-11 23:11:34 -08:00
|
|
|
/* FALLTHROUGH */
|
2006-08-12 03:33:47 -07:00
|
|
|
case_char: /* Normal character */
|
|
|
|
default:
|
|
|
|
*so++ = ch;
|
|
|
|
escape = '\0';
|
|
|
|
if (--size > 1)
|
|
|
|
break;
|
|
|
|
*so = '\0';
|
|
|
|
goto done;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
done:
|
|
|
|
bufptr = si;
|
2010-08-13 10:04:13 -07:00
|
|
|
if (!si)
|
2006-08-12 03:33:47 -07:00
|
|
|
{
|
|
|
|
/* EOF */
|
2018-02-16 08:12:34 -08:00
|
|
|
EFREE_NULL(buffer);
|
2006-08-12 03:33:47 -07:00
|
|
|
if (so == s)
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-08-21 14:00:55 -07:00
|
|
|
/* Strip trailing whitespace */
|
|
|
|
si = so;
|
|
|
|
for (; so > s; so--)
|
|
|
|
{
|
|
|
|
ch = so[-1];
|
|
|
|
if (ch != ' ' && ch != '\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (so != si)
|
|
|
|
*so = '\0';
|
|
|
|
|
2006-11-19 13:55:52 -08:00
|
|
|
if (EDebug(EDBUG_TYPE_CONFIG) > 1)
|
2014-05-10 05:37:15 -07:00
|
|
|
Eprintf("%s: %s\n", __func__, s);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
return s;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2007-07-27 09:59:50 -07:00
|
|
|
int
|
|
|
|
ConfigParseline1(char *str, char *s2, char **p2, char **p3)
|
|
|
|
{
|
|
|
|
int i1, len1, len2, fields;
|
|
|
|
|
|
|
|
i1 = CONFIG_INVALID;
|
|
|
|
len1 = len2 = 0;
|
|
|
|
s2[0] = '\0';
|
|
|
|
fields = sscanf(str, "%i %n%4000s %n", &i1, &len1, s2, &len2);
|
|
|
|
if (p2)
|
|
|
|
*p2 = (len1) ? str + len1 : NULL;
|
|
|
|
if (p3)
|
|
|
|
*p3 = (len2) ? str + len2 : NULL;
|
|
|
|
|
|
|
|
if (fields <= 0)
|
|
|
|
{
|
|
|
|
i1 = CONFIG_INVALID;
|
|
|
|
}
|
|
|
|
else if (i1 == CONFIG_CLOSE || i1 == CONFIG_NEXT)
|
|
|
|
{
|
|
|
|
if (fields != 1)
|
|
|
|
{
|
2010-05-09 12:03:19 -07:00
|
|
|
Alert(_("CONFIG: ignoring extra data in \"%s\""), str);
|
2007-07-27 09:59:50 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (i1 != CONFIG_INVALID)
|
|
|
|
{
|
|
|
|
if (fields != 2)
|
|
|
|
{
|
|
|
|
i1 = CONFIG_INVALID;
|
2010-05-09 12:03:19 -07:00
|
|
|
Alert(_("CONFIG: missing required data in \"%s\""), str);
|
2007-07-27 09:59:50 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return i1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ConfigParseError(const char *where, const char *line)
|
|
|
|
{
|
|
|
|
Alert(_("Warning: unable to determine what to do with\n"
|
|
|
|
"the following text in the middle of current %s definition:\n"
|
|
|
|
"%s\nWill ignore and continue...\n"), where, line);
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
void
|
|
|
|
ConfigAlertLoad(const char *txt)
|
|
|
|
{
|
|
|
|
Alert(_("Warning: Configuration error in %s block.\n"
|
|
|
|
"Outcome is likely not good.\n"), txt);
|
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static int
|
2008-10-15 08:34:58 -07:00
|
|
|
ConfigFilePreparse(const char *src, const char *dst, const char *themepath)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2009-11-01 06:41:21 -08:00
|
|
|
const char *variant;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2006-11-19 13:55:52 -08:00
|
|
|
if (EDebug(EDBUG_TYPE_CONFIG))
|
2014-05-10 05:37:15 -07:00
|
|
|
Eprintf("%s: %s -> %s\n", __func__, src, dst);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2008-10-16 13:57:11 -07:00
|
|
|
/* When themepath is NULL it shouldn't be used, but this is consistent
|
|
|
|
* with old behavior */
|
|
|
|
if (!themepath)
|
|
|
|
themepath = Mode.theme.path;
|
2009-11-01 06:41:21 -08:00
|
|
|
variant = (Mode.theme.variant) ? Mode.theme.variant : "";
|
2008-10-16 13:57:11 -07:00
|
|
|
|
2017-12-30 10:26:42 -08:00
|
|
|
Esystem("%s/epp -P -nostdinc -undef "
|
|
|
|
"-include %s/config/definitions -I%s -I%s/config "
|
|
|
|
"-D ENLIGHTENMENT_VERSION=%s "
|
|
|
|
"-D ENLIGHTENMENT_ROOT=%s "
|
2017-12-29 08:11:34 -08:00
|
|
|
"-D ENLIGHTENMENT_BIN=%s "
|
2017-12-30 10:26:42 -08:00
|
|
|
"-D ENLIGHTENMENT_THEME=%s "
|
2017-12-30 10:32:38 -08:00
|
|
|
"-D THEME_VARIANT_%s=1 "
|
2017-12-30 10:26:42 -08:00
|
|
|
"-D ECONFDIR=%s "
|
|
|
|
"-D ECACHEDIR=%s "
|
2017-12-29 08:11:34 -08:00
|
|
|
"-D SCREEN_RESOLUTION_%ix%i=1 "
|
2017-12-30 10:26:42 -08:00
|
|
|
"-D SCREEN_WIDTH_%i=1 "
|
|
|
|
"-D SCREEN_HEIGHT_%i=1 "
|
2017-12-29 08:11:34 -08:00
|
|
|
"-D SCREEN_DEPTH_%i=1 "
|
|
|
|
"%s %s",
|
|
|
|
EDirBin(), EDirRoot(), themepath, EDirRoot(),
|
|
|
|
e_wm_version, EDirRoot(), EDirBin(), themepath, variant,
|
2021-01-19 10:39:11 -08:00
|
|
|
EDirUserConf(), EDirUserCache(),
|
2017-12-29 08:11:34 -08:00
|
|
|
WinGetW(VROOT), WinGetH(VROOT), WinGetW(VROOT), WinGetH(VROOT),
|
|
|
|
WinGetDepth(VROOT), src, dst);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2008-10-15 08:34:58 -07:00
|
|
|
return exists(dst) ? 0 : 1;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Split the process of finding the file from the process of loading it */
|
2005-03-05 04:19:48 -08:00
|
|
|
int
|
2004-12-28 15:46:49 -08:00
|
|
|
ConfigFileRead(FILE * fs)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
int err;
|
1999-08-17 15:56:46 -07:00
|
|
|
int i1, i2, fields;
|
|
|
|
char s[FILEPATH_LEN_MAX];
|
|
|
|
int e_cfg_ver = 0;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
while (GetLine(s, sizeof(s), fs))
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2003-05-22 12:15:03 -07:00
|
|
|
i1 = i2 = CONFIG_INVALID;
|
|
|
|
fields = sscanf(s, "%i %i", &i1, &i2);
|
|
|
|
|
|
|
|
if (fields < 1)
|
2007-07-27 09:59:50 -07:00
|
|
|
{
|
|
|
|
i1 = CONFIG_INVALID;
|
|
|
|
}
|
2003-05-22 12:15:03 -07:00
|
|
|
else if (i1 == CONFIG_VERSION)
|
|
|
|
{
|
|
|
|
if (fields == 2)
|
|
|
|
e_cfg_ver = i2;
|
|
|
|
}
|
|
|
|
else if (i1 == CONFIG_CLOSE)
|
|
|
|
{
|
|
|
|
if (fields != 1)
|
|
|
|
{
|
2010-05-09 12:03:19 -07:00
|
|
|
Alert(_("CONFIG: ignoring extra data in \"%s\""), s);
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (i1 != CONFIG_INVALID)
|
|
|
|
{
|
|
|
|
if (fields != 2)
|
|
|
|
{
|
2010-05-09 12:03:19 -07:00
|
|
|
Alert(_("CONFIG: missing required data in \"%s\""), s);
|
2007-07-27 09:59:50 -07:00
|
|
|
i1 = CONFIG_INVALID;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
|
|
|
}
|
2006-08-12 03:33:47 -07:00
|
|
|
|
2003-05-22 12:15:03 -07:00
|
|
|
if (i2 == CONFIG_OPEN)
|
|
|
|
{
|
2008-10-26 08:35:44 -07:00
|
|
|
if (e_cfg_ver > MAX_E_CFG_VERSION)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
AlertX(_("Theme versioning ERROR"),
|
|
|
|
_("Restart with Defaults"), " ",
|
|
|
|
_("Abort and Exit"),
|
|
|
|
_("ERROR:\n" "\n"
|
2005-03-19 03:10:12 -08:00
|
|
|
"The configuration for the theme you are running is\n"
|
|
|
|
"incompatible. It's config revision is %i.\n"
|
|
|
|
"It needs to be marked as being revision <= %i\n"
|
|
|
|
"\n"
|
|
|
|
"Please contact the theme author or maintainer and\n"
|
|
|
|
"inform them that in order for their theme to function\n"
|
|
|
|
"with this version of Enlightenment, they have to\n"
|
|
|
|
"update it to the current settings, and then match\n"
|
|
|
|
"the revision number.\n" "\n"
|
|
|
|
"If the theme revision is higher than Enlightenment's\n"
|
|
|
|
"it may be that you haven't upgraded Enlightenment for\n"
|
2004-12-28 15:46:49 -08:00
|
|
|
"a while and this theme takes advantages of new\n"
|
|
|
|
"features in Enlightenment in new versions.\n"),
|
2008-10-26 08:35:44 -07:00
|
|
|
e_cfg_ver, MAX_E_CFG_VERSION);
|
2005-01-28 23:11:59 -08:00
|
|
|
SessionExit(EEXIT_THEME, "DEFAULT");
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (i1)
|
|
|
|
{
|
|
|
|
case CONFIG_CLOSE:
|
2004-12-28 15:46:49 -08:00
|
|
|
goto done;
|
|
|
|
|
2009-09-29 09:02:50 -07:00
|
|
|
case CONFIG_CURSOR:
|
|
|
|
err = ECursorConfigLoad(fs);
|
|
|
|
if (err)
|
|
|
|
ConfigAlertLoad("Cursor");
|
|
|
|
break;
|
2003-05-22 12:15:03 -07:00
|
|
|
case CONFIG_IMAGECLASS:
|
2004-12-28 15:46:49 -08:00
|
|
|
err = ImageclassConfigLoad(fs);
|
|
|
|
if (err)
|
2006-12-09 13:32:03 -08:00
|
|
|
ConfigAlertLoad("Image class");
|
2003-05-22 12:15:03 -07:00
|
|
|
break;
|
|
|
|
case CONFIG_TOOLTIP:
|
2004-12-28 15:46:49 -08:00
|
|
|
err = TooltipConfigLoad(fs);
|
|
|
|
if (err)
|
2006-12-09 13:32:03 -08:00
|
|
|
ConfigAlertLoad("Tooltip");
|
2003-05-22 12:15:03 -07:00
|
|
|
break;
|
2004-12-28 15:46:49 -08:00
|
|
|
case CONFIG_TEXT:
|
|
|
|
err = TextclassConfigLoad(fs);
|
|
|
|
if (err)
|
2006-12-09 13:32:03 -08:00
|
|
|
ConfigAlertLoad("Text class");
|
2003-05-22 12:15:03 -07:00
|
|
|
break;
|
|
|
|
case MENU_STYLE:
|
2004-12-28 15:46:49 -08:00
|
|
|
err = MenuStyleConfigLoad(fs);
|
|
|
|
if (err)
|
2006-12-09 13:32:03 -08:00
|
|
|
ConfigAlertLoad("Menu style");
|
2003-05-22 12:15:03 -07:00
|
|
|
break;
|
2006-02-20 10:20:29 -08:00
|
|
|
case CONFIG_MENU:
|
|
|
|
err = MenuConfigLoad(fs);
|
|
|
|
if (err)
|
2006-12-09 13:32:03 -08:00
|
|
|
ConfigAlertLoad("Menu");
|
2006-02-20 10:20:29 -08:00
|
|
|
break;
|
2003-05-22 12:15:03 -07:00
|
|
|
case CONFIG_BORDER:
|
2004-12-28 15:46:49 -08:00
|
|
|
err = BorderConfigLoad(fs);
|
|
|
|
if (err)
|
2006-12-09 13:32:03 -08:00
|
|
|
ConfigAlertLoad("Border");
|
2003-05-22 12:15:03 -07:00
|
|
|
break;
|
|
|
|
case CONFIG_BUTTON:
|
2004-12-28 15:46:49 -08:00
|
|
|
err = ButtonsConfigLoad(fs);
|
|
|
|
if (err)
|
2006-12-09 13:32:03 -08:00
|
|
|
ConfigAlertLoad("Button");
|
2003-05-22 12:15:03 -07:00
|
|
|
break;
|
|
|
|
case CONFIG_DESKTOP:
|
2004-12-28 15:46:49 -08:00
|
|
|
err = BackgroundsConfigLoad(fs);
|
|
|
|
if (err)
|
2006-12-09 13:32:03 -08:00
|
|
|
ConfigAlertLoad("Background");
|
2003-05-22 12:15:03 -07:00
|
|
|
break;
|
2005-02-07 14:42:19 -08:00
|
|
|
case CONFIG_WINDOWMATCH:
|
|
|
|
err = WindowMatchConfigLoad(fs);
|
|
|
|
if (err)
|
2006-12-09 13:32:03 -08:00
|
|
|
ConfigAlertLoad("Window match");
|
2005-02-07 14:42:19 -08:00
|
|
|
break;
|
2003-05-22 12:15:03 -07:00
|
|
|
case CONFIG_COLORMOD:
|
|
|
|
break;
|
|
|
|
case CONFIG_ACTIONCLASS:
|
2004-12-28 15:46:49 -08:00
|
|
|
err = AclassConfigLoad(fs);
|
|
|
|
if (err)
|
2006-12-09 13:32:03 -08:00
|
|
|
ConfigAlertLoad("Action class");
|
2003-05-22 12:15:03 -07:00
|
|
|
break;
|
|
|
|
case CONFIG_SLIDEOUT:
|
2004-12-28 15:46:49 -08:00
|
|
|
err = SlideoutsConfigLoad(fs);
|
|
|
|
if (err)
|
2006-12-09 13:32:03 -08:00
|
|
|
ConfigAlertLoad("Slideout");
|
2003-05-22 12:15:03 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
done:
|
|
|
|
return 0;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2005-07-17 05:55:13 -07:00
|
|
|
static char *
|
2008-10-15 08:20:20 -07:00
|
|
|
FindFilePath(const char *name, const char *path)
|
2005-07-17 05:55:13 -07:00
|
|
|
{
|
|
|
|
char s[FILEPATH_LEN_MAX];
|
2008-10-15 08:20:20 -07:00
|
|
|
int len;
|
2005-07-17 05:55:13 -07:00
|
|
|
|
2010-04-02 08:27:58 -07:00
|
|
|
#if 0
|
|
|
|
Eprintf("%s: %s (%s)\n", __func__, name, path);
|
|
|
|
#endif
|
2005-07-17 05:55:13 -07:00
|
|
|
if (path)
|
|
|
|
{
|
2008-10-15 08:20:20 -07:00
|
|
|
len = Esnprintf(s, sizeof(s), "%s/%s", path, name);
|
|
|
|
name = s;
|
2005-07-17 05:55:13 -07:00
|
|
|
}
|
2008-10-15 08:20:20 -07:00
|
|
|
else
|
2005-07-17 05:55:13 -07:00
|
|
|
{
|
2008-10-15 08:20:20 -07:00
|
|
|
len = strlen(name);
|
2005-07-17 05:55:13 -07:00
|
|
|
}
|
2008-10-15 08:20:20 -07:00
|
|
|
if (len <= 0)
|
|
|
|
return NULL;
|
2005-07-17 05:55:13 -07:00
|
|
|
|
2008-10-15 08:20:20 -07:00
|
|
|
if (canread(name))
|
|
|
|
return Estrdup(name);
|
|
|
|
else
|
|
|
|
return NULL;
|
2005-07-17 05:55:13 -07:00
|
|
|
}
|
|
|
|
|
2010-04-02 08:27:58 -07:00
|
|
|
/* *INDENT-OFF* */
|
|
|
|
static const struct {
|
|
|
|
const char *where, *subdir;
|
|
|
|
} fprm[] = {
|
|
|
|
{ "utE", "config" },
|
|
|
|
{ "ute", NULL },
|
2018-12-15 09:35:12 -08:00
|
|
|
{ "UuEt", "menus" },
|
2010-08-05 14:17:25 -07:00
|
|
|
{ "UuE", "icons" }
|
2010-04-02 08:27:58 -07:00
|
|
|
};
|
|
|
|
/* *INDENT-ON* */
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
char *
|
2010-04-02 08:27:58 -07:00
|
|
|
FindFile(const char *file, const char *themepath, int type)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2010-04-02 08:27:58 -07:00
|
|
|
const char *w, *f, *path;
|
1999-08-17 15:56:46 -07:00
|
|
|
char s[FILEPATH_LEN_MAX];
|
2005-07-17 05:55:13 -07:00
|
|
|
char *p;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
|
|
|
/* if absolute path - and file exists - return it */
|
2004-02-18 14:18:41 -08:00
|
|
|
if (isabspath(file))
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2008-10-15 08:20:20 -07:00
|
|
|
p = FindFilePath(file, NULL);
|
2010-03-01 12:53:12 -08:00
|
|
|
/* Absolute path - no need to look elsewhere */
|
|
|
|
goto done;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2000-03-14 11:27:33 -08:00
|
|
|
|
2010-04-02 08:27:58 -07:00
|
|
|
p = NULL;
|
|
|
|
for (w = fprm[type].where; *w; w++)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2010-04-02 08:27:58 -07:00
|
|
|
f = file;
|
|
|
|
if (*w <= 'Z')
|
|
|
|
{
|
|
|
|
/* Look in subdir */
|
|
|
|
Esnprintf(s, sizeof(s), "%s/%s", fprm[type].subdir, file);
|
|
|
|
f = s;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (*w & 0xdf)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
case 'U': /* User config */
|
2021-01-19 10:39:11 -08:00
|
|
|
path = EDirUserConf();
|
2010-04-02 08:27:58 -07:00
|
|
|
break;
|
|
|
|
case 'E': /* e16 config */
|
|
|
|
path = EDirRoot();
|
|
|
|
break;
|
|
|
|
case 'T': /* Theme */
|
|
|
|
path = themepath;
|
|
|
|
if (!path)
|
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
p = FindFilePath(f, path);
|
2005-07-17 05:55:13 -07:00
|
|
|
if (p)
|
2010-04-02 08:27:58 -07:00
|
|
|
break;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
2000-03-14 11:27:33 -08:00
|
|
|
|
2010-03-01 12:53:12 -08:00
|
|
|
done:
|
|
|
|
#if 0
|
2010-04-02 08:27:58 -07:00
|
|
|
Eprintf("%s %d: %s (%s): %s\n", __func__, type, file, themepath, p);
|
2010-03-01 12:53:12 -08:00
|
|
|
#endif
|
|
|
|
return p;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
char *
|
2010-04-02 08:27:58 -07:00
|
|
|
ThemeFileFind(const char *file, int type)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2010-04-02 08:27:58 -07:00
|
|
|
return FindFile(file, Mode.theme.path, type);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
2010-06-06 03:05:44 -07:00
|
|
|
static char *
|
2004-12-28 15:46:49 -08:00
|
|
|
ConfigFileFind(const char *name, const char *themepath, int pp)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
|
|
|
char s[FILEPATH_LEN_MAX];
|
2004-12-28 15:46:49 -08:00
|
|
|
char *fullname, *file, *ppfile;
|
|
|
|
int i, err;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2010-04-02 08:27:58 -07:00
|
|
|
fullname = FindFile(name, themepath, FILE_TYPE_CONFIG);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!fullname)
|
2005-01-25 13:58:28 -08:00
|
|
|
return NULL;
|
2000-03-14 11:27:33 -08:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/* Quit if not preparsing */
|
|
|
|
if (!pp)
|
|
|
|
return fullname;
|
2000-03-14 11:27:33 -08:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/* The file exists. Now check the preparsed one. */
|
|
|
|
file = Estrdup(fullname);
|
|
|
|
for (i = 0; file[i]; i++)
|
|
|
|
if (file[i] == '/')
|
|
|
|
file[i] = '.';
|
2000-03-14 11:27:33 -08:00
|
|
|
|
2009-11-01 06:41:21 -08:00
|
|
|
if (Mode.theme.variant)
|
|
|
|
file = Estrdupcat2(file, "_", Mode.theme.variant);
|
2004-12-28 15:46:49 -08:00
|
|
|
Esnprintf(s, sizeof(s), "%s/cached/cfg/%s.preparsed", EDirUserCache(), file);
|
2009-11-01 06:41:21 -08:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
ppfile = Estrdup(s);
|
|
|
|
if (exists(s) && moddate(s) > moddate(fullname))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
/* No preparesd file or source is newer. Do preparsing. */
|
2008-10-15 08:34:58 -07:00
|
|
|
err = ConfigFilePreparse(fullname, ppfile, themepath);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (err)
|
|
|
|
{
|
2018-02-16 08:12:34 -08:00
|
|
|
EFREE_NULL(ppfile);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
Efree(fullname);
|
|
|
|
Efree(file);
|
|
|
|
return ppfile;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2003-07-11 11:36:52 -07:00
|
|
|
int
|
2004-12-28 15:46:49 -08:00
|
|
|
ConfigFileLoad(const char *name, const char *themepath,
|
2019-08-14 09:45:13 -07:00
|
|
|
int (*parse)(FILE * fs), int preparse)
|
2003-07-11 11:36:52 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
int err = -1;
|
|
|
|
char *file;
|
|
|
|
FILE *fs;
|
2003-07-11 11:36:52 -07:00
|
|
|
|
2006-11-19 13:55:52 -08:00
|
|
|
if (EDebug(EDBUG_TYPE_CONFIG))
|
2014-05-10 05:37:15 -07:00
|
|
|
Eprintf("%s: %s\n", __func__, name);
|
2003-07-11 11:36:52 -07:00
|
|
|
|
2005-02-16 11:48:33 -08:00
|
|
|
file = ConfigFileFind(name, themepath, preparse);
|
2003-07-11 11:36:52 -07:00
|
|
|
if (!file)
|
2004-12-28 15:46:49 -08:00
|
|
|
goto done;
|
2005-03-05 04:19:48 -08:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
fs = fopen(file, "r");
|
|
|
|
Efree(file);
|
|
|
|
if (!fs)
|
|
|
|
goto done;
|
2003-07-11 11:36:52 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
err = parse(fs);
|
2003-07-11 11:36:52 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
fclose(fs);
|
2003-07-11 11:36:52 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
done:
|
|
|
|
return err;
|
2003-07-11 11:36:52 -07:00
|
|
|
}
|
|
|
|
|
1999-10-06 09:39:17 -07:00
|
|
|
int
|
2004-12-28 15:46:49 -08:00
|
|
|
ThemeConfigLoad(void)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
static const char *const config_files[] = {
|
|
|
|
"init.cfg",
|
2009-09-29 09:02:50 -07:00
|
|
|
"cursors.cfg",
|
2004-12-28 15:46:49 -08:00
|
|
|
"textclasses.cfg",
|
|
|
|
"imageclasses.cfg",
|
|
|
|
"desktops.cfg",
|
|
|
|
"actionclasses.cfg",
|
|
|
|
"buttons.cfg",
|
|
|
|
"slideouts.cfg",
|
|
|
|
"borders.cfg",
|
2005-02-07 14:42:19 -08:00
|
|
|
"windowmatches.cfg",
|
2004-12-28 15:46:49 -08:00
|
|
|
"tooltips.cfg",
|
|
|
|
"menustyles.cfg",
|
|
|
|
};
|
|
|
|
Progressbar *p = NULL;
|
2021-03-17 22:17:47 -07:00
|
|
|
unsigned int i;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2007-07-28 06:58:20 -07:00
|
|
|
/* Font mappings */
|
|
|
|
FontConfigLoad();
|
|
|
|
|
2021-03-17 22:17:47 -07:00
|
|
|
for (i = 0; i < E_ARRAY_SIZE(config_files); i++)
|
2004-02-11 07:27:54 -08:00
|
|
|
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2008-09-29 09:29:15 -07:00
|
|
|
if (!Mode.wm.restart && Conf.startup.animate)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
|
|
|
if (i == 2)
|
2005-02-27 06:42:41 -08:00
|
|
|
StartupWindowsCreate();
|
2004-02-18 14:18:41 -08:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
if ((i > 1) && (!p))
|
|
|
|
{
|
|
|
|
p = ProgressbarCreate(_("Enlightenment Starting..."), 400,
|
|
|
|
16);
|
|
|
|
if (p)
|
|
|
|
ProgressbarShow(p);
|
|
|
|
}
|
|
|
|
}
|
2004-07-25 02:34:43 -07:00
|
|
|
|
2005-02-16 11:48:33 -08:00
|
|
|
ConfigFileLoad(config_files[i], Mode.theme.path, ConfigFileRead, 1);
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
if (p)
|
2021-03-17 22:17:47 -07:00
|
|
|
ProgressbarSet(p, (i * 100) / E_ARRAY_SIZE(config_files));
|
2012-04-22 10:39:53 -07:00
|
|
|
|
|
|
|
/* Hack - We are not running in the event loop here */
|
|
|
|
EobjsRepaint();
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
if (p)
|
|
|
|
ProgressbarDestroy(p);
|
2004-02-13 10:36:52 -08:00
|
|
|
|
2005-03-05 04:19:48 -08:00
|
|
|
/* Font mappings no longer needed */
|
2004-12-28 15:46:49 -08:00
|
|
|
FontConfigUnload();
|
2004-02-13 10:36:52 -08:00
|
|
|
|
2005-01-25 13:58:28 -08:00
|
|
|
return 0;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|