1999-10-04 15:06:00 -07:00
|
|
|
/*
|
2005-03-19 08:40:18 -08:00
|
|
|
* Copyright (C) 2000-2005 Carsten Haitzler, Geoff Harrison and various contributors
|
|
|
|
* Copyright (C) 2004-2005 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"
|
|
|
|
#include "conf.h"
|
2005-08-20 06:55:51 -07:00
|
|
|
#include "tooltips.h"
|
2003-11-09 15:17:15 -08:00
|
|
|
#include <ctype.h>
|
1999-08-17 15:56:46 -07:00
|
|
|
|
1999-08-29 14:55:48 -07:00
|
|
|
#define SKIP_If_EXISTS(name, type) \
|
2004-12-28 15:46:49 -08:00
|
|
|
if (ConfigSkipIfExists(ConfigFile, name, type)) return
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2003-07-11 11:36:52 -07:00
|
|
|
static void
|
|
|
|
SkipTillEnd(FILE * ConfigFile)
|
|
|
|
{
|
|
|
|
char s[FILEPATH_LEN_MAX];
|
|
|
|
int i1, i2, fields;
|
|
|
|
|
|
|
|
while (GetLine(s, sizeof(s), ConfigFile))
|
|
|
|
{
|
2003-09-28 12:08:27 -07:00
|
|
|
i1 = i2 = 0;
|
2003-07-11 11:36:52 -07:00
|
|
|
fields = sscanf(s, "%i %i", &i1, &i2);
|
|
|
|
if (i1 == CONFIG_CLOSE)
|
|
|
|
return;
|
|
|
|
if (i2 == CONFIG_OPEN)
|
|
|
|
SkipTillEnd(ConfigFile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
int
|
|
|
|
ConfigSkipIfExists(FILE * ConfigFile, const char *name, int type)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
if (FindItem(name, 0, LIST_FINDBY_NAME, type))
|
2003-07-11 11:36:52 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
SkipTillEnd(ConfigFile);
|
|
|
|
return 1;
|
2003-07-11 11:36:52 -07:00
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
return 0;
|
2003-07-11 11:36:52 -07:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
static int
|
|
|
|
IsWhitespace(const char *s)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
int i = 0;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
while (s[i])
|
|
|
|
{
|
|
|
|
if ((s[i] != ' ') && (s[i] != '\n') && (s[i] != '\t'))
|
|
|
|
return 0;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
1999-08-17 15:56:46 -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)
|
|
|
|
{
|
|
|
|
char *si, *so, ch, quote, escape;
|
|
|
|
static char *buffer = NULL;
|
|
|
|
static char *bufptr = NULL;
|
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
|
|
|
if (buffer == NULL)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
buffer = Emalloc(LINE_BUFFER_SIZE);
|
|
|
|
if (buffer == NULL)
|
|
|
|
return NULL;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
/* Get a line from the input file */
|
|
|
|
if (si == NULL)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
si = fgets(buffer, LINE_BUFFER_SIZE - 1, f);
|
|
|
|
buffer[LINE_BUFFER_SIZE - 1] = '\0';
|
|
|
|
if (si == NULL)
|
2003-05-22 12:15:03 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
/* EOF */
|
|
|
|
Efree(buffer);
|
|
|
|
buffer = bufptr = NULL;
|
|
|
|
return NULL;
|
2003-05-22 12:15:03 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/* Split on ';' or '\n', handle quoting */
|
|
|
|
for (; si;)
|
|
|
|
{
|
|
|
|
ch = *si++;
|
|
|
|
switch (ch)
|
|
|
|
{
|
|
|
|
case '\0':
|
|
|
|
si = NULL;
|
|
|
|
if (so == s) /* Skip empty lines */
|
|
|
|
break;
|
|
|
|
goto case_eol;
|
|
|
|
case ';': /* Line separator */
|
|
|
|
if (escape || quote)
|
|
|
|
goto case_char;
|
|
|
|
case '\n':
|
|
|
|
if (so == s) /* Skip empty lines */
|
|
|
|
break;
|
|
|
|
case_eol:
|
|
|
|
*so++ = '\0'; /* Terminate and return */
|
|
|
|
goto done;
|
|
|
|
case '\r': /* Ignore */
|
|
|
|
break;
|
|
|
|
case '\\': /* Escape */
|
|
|
|
if (escape)
|
|
|
|
goto case_char;
|
|
|
|
escape = ch;
|
|
|
|
break;
|
|
|
|
case '"': /* Quoting */
|
|
|
|
/* case '\'': */
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
|
|
|
|
if (EventDebug(EDBUG_TYPE_CONFIG))
|
|
|
|
Eprintf("GetLine %s\n", s);
|
|
|
|
|
|
|
|
return s;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
void
|
|
|
|
ConfigAlertLoad(const char *txt)
|
|
|
|
{
|
|
|
|
RecoverUserConfig();
|
|
|
|
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
|
|
|
|
ConfigFilePreparse(const char *path, const char *dest)
|
1999-08-17 15:56:46 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
static char have_epp = 0;
|
1999-08-17 15:56:46 -07:00
|
|
|
char execline[FILEPATH_LEN_MAX];
|
2004-03-20 17:39:40 -08:00
|
|
|
const char *epp_path = ENLIGHTENMENT_BIN "/epp";
|
2004-12-28 15:46:49 -08:00
|
|
|
char *def_home, *def_user, *def_shell;
|
|
|
|
|
|
|
|
if (EventDebug(EDBUG_TYPE_CONFIG))
|
|
|
|
Eprintf("ConfigFilePreparse %s->%s\n", path, dest);
|
|
|
|
|
|
|
|
if ((!have_epp) && (!(isfile(epp_path)) && (canexec(epp_path))))
|
|
|
|
{
|
|
|
|
Alert(_("Help! Cannot find epp!\n"
|
|
|
|
"Enlightenment is looking for epp here:\n" "%s\n"
|
|
|
|
"This is a FATAL ERROR.\n"
|
|
|
|
"This is probably due to either the program not existing or\n"
|
|
|
|
"it not being able to be executed by you.\n"), epp_path);
|
2005-01-28 23:11:59 -08:00
|
|
|
SessionExit(EEXIT_ERROR, NULL);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
have_epp = 1;
|
|
|
|
|
|
|
|
def_home = homedir(getuid());
|
|
|
|
def_user = username(getuid());
|
|
|
|
def_shell = usershell(getuid());
|
|
|
|
|
|
|
|
Esnprintf(execline, sizeof(execline), "%s " "-P " "-nostdinc " "-undef "
|
|
|
|
"-include %s/config/definitions " "-I%s " "-I%s/config "
|
|
|
|
"-D ENLIGHTENMENT_VERSION=%s " "-D ENLIGHTENMENT_ROOT=%s "
|
|
|
|
"-D ENLIGHTENMENT_BIN=%s "
|
|
|
|
"-D ENLIGHTENMENT_THEME=%s " "-D ECONFDIR=%s "
|
|
|
|
"-D ECACHEDIR=%s " "-D SCREEN_RESOLUTION_%ix%i=1 "
|
|
|
|
"-D SCREEN_WIDTH_%i=1 " "-D SCREEN_HEIGHT_%i=1 "
|
|
|
|
"-D SCREEN_DEPTH_%i=1 " "-D USER_NAME=%s " "-D HOME_DIR=%s "
|
|
|
|
"-D USER_SHELL=%s " "-D ENLIGHTENMENT_VERSION_015=1 "
|
|
|
|
"%s %s",
|
|
|
|
epp_path, EDirRoot(), Mode.theme.path, EDirRoot(),
|
|
|
|
ENLIGHTENMENT_VERSION, EDirRoot(), EDirBin(),
|
|
|
|
Mode.theme.path, EDirUser(), EDirUserCache(), VRoot.w,
|
|
|
|
VRoot.h, VRoot.w, VRoot.h, VRoot.depth, def_user, def_home,
|
|
|
|
def_shell, path, dest);
|
|
|
|
system(execline);
|
|
|
|
|
|
|
|
if (def_user)
|
|
|
|
Efree(def_user);
|
|
|
|
if (def_shell)
|
|
|
|
Efree(def_shell);
|
|
|
|
if (def_home)
|
|
|
|
Efree(def_home);
|
|
|
|
|
|
|
|
return exists(dest) ? 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;
|
2005-03-19 03:10:12 -08:00
|
|
|
int max_e_cfg_ver = 1;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
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
|
|
|
if (IsWhitespace(s))
|
|
|
|
continue;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2003-05-22 12:15:03 -07:00
|
|
|
i1 = i2 = CONFIG_INVALID;
|
|
|
|
fields = sscanf(s, "%i %i", &i1, &i2);
|
|
|
|
|
|
|
|
if (fields < 1)
|
|
|
|
i1 = CONFIG_INVALID;
|
|
|
|
else if (i1 == CONFIG_VERSION)
|
|
|
|
{
|
|
|
|
if (fields == 2)
|
|
|
|
e_cfg_ver = i2;
|
|
|
|
}
|
|
|
|
else if (i1 == CONFIG_CLOSE)
|
|
|
|
{
|
|
|
|
if (fields != 1)
|
|
|
|
{
|
|
|
|
RecoverUserConfig();
|
|
|
|
Alert(_("CONFIG: ignoring extra data in \"%s\"\n"), s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (i1 != CONFIG_INVALID)
|
|
|
|
{
|
|
|
|
if (fields != 2)
|
|
|
|
{
|
|
|
|
RecoverUserConfig();
|
|
|
|
Alert(_("CONFIG: missing required data in \"%s\"\n"), s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i2 == CONFIG_OPEN)
|
|
|
|
{
|
2005-03-19 03:10:12 -08:00
|
|
|
if (e_cfg_ver > max_e_cfg_ver)
|
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"),
|
2005-03-19 03:10:12 -08:00
|
|
|
e_cfg_ver, max_e_cfg_ver);
|
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;
|
|
|
|
|
2003-05-22 12:15:03 -07:00
|
|
|
case CONFIG_IMAGECLASS:
|
2004-12-28 15:46:49 -08:00
|
|
|
err = ImageclassConfigLoad(fs);
|
|
|
|
if (err)
|
|
|
|
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)
|
|
|
|
ConfigAlertLoad(_("Tooltip"));
|
2003-05-22 12:15:03 -07:00
|
|
|
break;
|
2004-12-28 15:46:49 -08:00
|
|
|
case CONFIG_FONTS:
|
|
|
|
err = FontConfigLoad(fs);
|
|
|
|
if (err)
|
|
|
|
ConfigAlertLoad(_("Font"));
|
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)
|
|
|
|
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)
|
|
|
|
ConfigAlertLoad(_("Menu style"));
|
2003-05-22 12:15:03 -07:00
|
|
|
break;
|
|
|
|
case CONFIG_BORDER:
|
2004-12-28 15:46:49 -08:00
|
|
|
err = BorderConfigLoad(fs);
|
|
|
|
if (err)
|
|
|
|
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)
|
|
|
|
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)
|
|
|
|
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)
|
|
|
|
ConfigAlertLoad(_("Window match"));
|
|
|
|
break;
|
2003-05-22 12:15:03 -07:00
|
|
|
case CONFIG_COLORMOD:
|
2005-04-15 16:59:59 -07:00
|
|
|
#if ENABLE_COLOR_MODIFIERS
|
2004-12-28 15:46:49 -08:00
|
|
|
Config_ColorModifier(fs);
|
|
|
|
#endif
|
2003-05-22 12:15:03 -07:00
|
|
|
break;
|
|
|
|
case CONFIG_ACTIONCLASS:
|
2004-12-28 15:46:49 -08:00
|
|
|
err = AclassConfigLoad(fs);
|
|
|
|
if (err)
|
|
|
|
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)
|
|
|
|
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 *
|
|
|
|
FindFileLocalized(const char *name, const char *path, int localized)
|
|
|
|
{
|
|
|
|
char s[FILEPATH_LEN_MAX];
|
|
|
|
const char *lang;
|
|
|
|
char *p[4];
|
|
|
|
int i, len;
|
|
|
|
|
|
|
|
if (path)
|
|
|
|
len = Esnprintf(s, sizeof(s), "%s/%s", path, name);
|
|
|
|
else
|
|
|
|
len = Esnprintf(s, sizeof(s), "%s", name);
|
|
|
|
if (len <= 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
lang = Mode.locale.lang;
|
|
|
|
if (!localized || !lang)
|
|
|
|
{
|
|
|
|
if (isfile(s))
|
|
|
|
return Estrdup(s);
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (len + 1 + strlen(lang) >= sizeof(s))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
s[len] = '.';
|
|
|
|
strcpy(s + len + 1, lang);
|
|
|
|
|
|
|
|
p[0] = s + len + 1 + strlen(lang); /* .da_DK.UTF-8 */
|
|
|
|
p[1] = strchr(s + len + 1, '.'); /* .da_DK */
|
|
|
|
p[2] = strchr(s + len + 1, '_'); /* .da */
|
|
|
|
p[3] = s + len;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
if (p[i] == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
*p[i] = '\0';
|
|
|
|
if (isfile(s))
|
|
|
|
return Estrdup(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
char *
|
2005-07-17 05:55:13 -07:00
|
|
|
FindFile(const char *file, const char *themepath, int localized)
|
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
|
|
|
{
|
2005-07-17 05:55:13 -07:00
|
|
|
p = FindFileLocalized(file, NULL, localized);
|
|
|
|
if (p)
|
|
|
|
return p;
|
2000-07-26 11:00:47 -07:00
|
|
|
}
|
2000-03-14 11:27:33 -08:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/* look in ~/.e16 first */
|
2005-07-17 05:55:13 -07:00
|
|
|
p = FindFileLocalized(file, EDirUser(), localized);
|
|
|
|
if (p)
|
|
|
|
return p;
|
2000-03-14 11:27:33 -08:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
if (themepath)
|
|
|
|
{
|
|
|
|
/* look in theme dir */
|
2005-07-17 05:55:13 -07:00
|
|
|
p = FindFileLocalized(file, themepath, localized);
|
|
|
|
if (p)
|
|
|
|
return p;
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
2000-03-14 11:27:33 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
/* look in system config dir */
|
2005-07-17 05:55:13 -07:00
|
|
|
Esnprintf(s, sizeof(s), "%s/config", EDirRoot());
|
|
|
|
p = FindFileLocalized(file, s, localized);
|
|
|
|
if (p)
|
|
|
|
return p;
|
2000-03-14 11:27:33 -08:00
|
|
|
|
1999-08-17 15:56:46 -07:00
|
|
|
/* not found.... NULL */
|
2005-01-25 13:58:28 -08:00
|
|
|
return NULL;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
char *
|
2005-07-17 05:55:13 -07:00
|
|
|
ThemeFileFind(const char *file, int localized)
|
2004-12-28 15:46:49 -08:00
|
|
|
{
|
2005-07-17 05:55:13 -07:00
|
|
|
return FindFile(file, Mode.theme.path, localized);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
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
|
|
|
|
2005-07-17 05:55:13 -07:00
|
|
|
fullname = FindFile(name, themepath, 1);
|
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
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
Esnprintf(s, sizeof(s), "%s/cached/cfg/%s.preparsed", EDirUserCache(), file);
|
|
|
|
ppfile = Estrdup(s);
|
|
|
|
if (exists(s) && moddate(s) > moddate(fullname))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
/* No preparesd file or source is newer. Do preparsing. */
|
|
|
|
err = ConfigFilePreparse(fullname, ppfile);
|
|
|
|
if (err)
|
|
|
|
{
|
|
|
|
Efree(ppfile);
|
|
|
|
ppfile = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
2005-02-16 11:48:33 -08: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
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
if (EventDebug(EDBUG_TYPE_CONFIG))
|
|
|
|
Eprintf("ConfigFileLoad %s\n", 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[] = {
|
|
|
|
"fonts.cfg",
|
|
|
|
"init.cfg",
|
|
|
|
"textclasses.cfg",
|
|
|
|
"backup-textclasses.cfg",
|
2005-04-17 07:08:42 -07:00
|
|
|
#if ENABLE_COLOR_MODIFIERS
|
2004-12-28 15:46:49 -08:00
|
|
|
"colormodifiers.cfg",
|
|
|
|
"backup-colormodifiers.cfg",
|
2005-04-17 07:08:42 -07:00
|
|
|
#endif
|
2004-12-28 15:46:49 -08:00
|
|
|
"imageclasses.cfg",
|
|
|
|
"backup-imageclasses.cfg",
|
|
|
|
"desktops.cfg",
|
|
|
|
"actionclasses.cfg",
|
|
|
|
"backup-cursors.cfg",
|
|
|
|
"buttons.cfg",
|
|
|
|
"slideouts.cfg",
|
|
|
|
"borders.cfg",
|
|
|
|
"backup-borders.cfg",
|
2005-02-07 14:42:19 -08:00
|
|
|
"windowmatches.cfg",
|
2004-12-28 15:46:49 -08:00
|
|
|
"tooltips.cfg",
|
|
|
|
"backup-tooltips.cfg",
|
|
|
|
"menustyles.cfg",
|
|
|
|
};
|
|
|
|
char s[FILEPATH_LEN_MAX];
|
|
|
|
Progressbar *p = NULL;
|
|
|
|
int i;
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
Esnprintf(s, sizeof(s), "%s/", Mode.theme.path);
|
2004-07-25 02:34:43 -07:00
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
for (i = 0; i < (int)(sizeof(config_files) / sizeof(char *)); i++)
|
2004-02-11 07:27:54 -08:00
|
|
|
|
2000-07-26 11:00:47 -07:00
|
|
|
{
|
2004-12-28 15:46:49 -08:00
|
|
|
if (!Mode.wm.restart)
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
ProgressbarSet(p, (i * 100) /
|
|
|
|
(int)(sizeof(config_files) / sizeof(char *)));
|
|
|
|
}
|
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
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/* Loose ends... */
|
|
|
|
BordersSetupFallback();
|
1999-08-17 15:56:46 -07:00
|
|
|
|
2005-01-25 13:58:28 -08:00
|
|
|
return 0;
|
1999-08-17 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
void
|
1999-09-23 14:12:27 -07:00
|
|
|
RecoverUserConfig(void)
|
|
|
|
{
|
2004-06-19 14:31:40 -07:00
|
|
|
int save;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
/* Don't save settings if we restart or quit */
|
|
|
|
save = Conf.autosave;
|
|
|
|
Conf.autosave = 0;
|
|
|
|
|
|
|
|
AlertX(_("Recover system config?"), _("Yes, Attempt recovery"),
|
|
|
|
_("Restart and try again"), _("Quit and give up"),
|
|
|
|
_
|
|
|
|
("Enlightenment has encountered parsing errors in your autosaved\n"
|
|
|
|
"configuration.\n" "\n"
|
|
|
|
"This may be due to filing system errors, Minor bugs or "
|
|
|
|
"unforeseen\n" "system shutdowns.\n" "\n"
|
|
|
|
"Do you wish Enlightenment to recover its original system\n"
|
|
|
|
"configuration and try again?\n"));
|
|
|
|
|
|
|
|
/* Allow settings to be saved if we continue */
|
|
|
|
Conf.autosave = save;
|
1999-09-23 14:12:27 -07:00
|
|
|
}
|