Change font configuration search scheme.

Preparing for theme font configuration files.
Attempting not to break existing user configurations.

SVN revision: 39792
This commit is contained in:
Kim Woelders 2009-03-29 14:56:45 +00:00
parent e5aa7658ad
commit 4c79684eae
6 changed files with 37 additions and 11 deletions

View File

@ -5,7 +5,7 @@ config_DATA = \
definitions \
actionclasses.cfg bindings.cfg matches.cfg menus.cfg \
e16keyedit.db \
fonts.cfg.xft fonts.cfg.pango
fonts.xft.cfg fonts.pango.cfg
menudir = $(pkgdatadir)/config/menus
menu_DATA = \

View File

@ -261,6 +261,7 @@ typedef struct {
char animate;
} startup;
struct {
char use_theme_font_cfg;
char use_alt_font_cfg;
char *name;
char *extra_path;

View File

@ -112,21 +112,45 @@ _FontConfigLoad(FILE * fs)
return err;
}
static int
_FontConfigLoad1(const char *cfg, int look_in_theme_too)
{
const char *path;
path = (look_in_theme_too) ? Mode.theme.path : NULL;
return ConfigFileLoad(cfg, path, _FontConfigLoad, 0);
}
void
FontConfigLoad(void)
{
int err;
if (Conf.theme.use_alt_font_cfg)
/* First check explicitly specified configuration (not in theme dir) */
if (Conf.theme.use_alt_font_cfg && Conf.theme.font_cfg)
{
if (!Conf.theme.font_cfg)
Conf.theme.font_cfg = Estrdup("fonts.cfg.xft");
err = ConfigFileLoad(Conf.theme.font_cfg, Mode.theme.path,
_FontConfigLoad, 0);
if (!err)
if (!_FontConfigLoad1(Conf.theme.font_cfg, 0))
return;
}
ConfigFileLoad("fonts.cfg", Mode.theme.path, _FontConfigLoad, 0);
/* If using theme font is specified look for that */
if (Conf.theme.use_theme_font_cfg)
{
if (!_FontConfigLoad1("fonts.theme.cfg", 1))
return;
}
/* Look in user config dir (not in theme dir) */
_FontConfigLoad1("fonts.cfg", 0);
#if USE_PANGO
if (!_FontConfigLoad1("fonts.pango.cfg", 1))
return;
#endif
#if USE_XFT
if (!_FontConfigLoad1("fonts.xft.cfg", 1))
return;
#endif
_FontConfigLoad1("fonts.cfg", 1);
}
void

View File

@ -414,7 +414,8 @@ static const IpcItem ThemeIpcArray[] = {
static const CfgItem ThemeCfgItems[] = {
CFG_ITEM_STR(Conf.theme, name),
CFG_ITEM_STR(Conf.theme, extra_path),
CFG_ITEM_BOOL(Conf.theme, use_alt_font_cfg, 1),
CFG_ITEM_BOOL(Conf.theme, use_theme_font_cfg, 0),
CFG_ITEM_BOOL(Conf.theme, use_alt_font_cfg, 0),
CFG_ITEM_STR(Conf.theme, font_cfg),
};
#define N_CFG_ITEMS (sizeof(ThemeCfgItems)/sizeof(CfgItem))