forked from e16/e16
1
0
Fork 0

config: Introduce method to invalidate theme cache

This will cause the theme configuration to be re-parsed on the next run
and whenever E_CFG_VER_CACHE is changed.
This commit is contained in:
Kim Woelders 2023-10-23 17:41:06 +02:00
parent ffaf268e62
commit dccc8cb55b
3 changed files with 14 additions and 3 deletions

View File

@ -3,7 +3,7 @@
/*****************************************************************************/
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2022 Kim Woelders
* Copyright (C) 2004-2023 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -33,6 +33,7 @@
#include "util.h"
#include "xtypes.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
@ -283,6 +284,7 @@ typedef struct {
char animate;
} startup;
struct {
int cache_ver;
char use_theme_font_cfg;
char use_alt_font_cfg;
char *name;
@ -399,6 +401,7 @@ typedef struct {
char ext_pmap_valid;
} root;
struct {
bool cache_rebuild;
char *paths;
char *path;
char *variant;

View File

@ -38,6 +38,7 @@
#include "windowmatch.h"
#define E_CFG_VER_MAX 2 /* Max. supported theme config version */
#define E_CFG_VER_CACHE 1 /* Cache version (bump to invalidate cache) */
void
SkipTillEnd(FILE * fs)
@ -529,7 +530,7 @@ ConfigFileFind(const char *name, const char *themepath, int pp)
Esnprintf(s, sizeof(s), "%s/cached/cfg/%s.preparsed", EDirUserCache(), file);
ppfile = Estrdup(s);
if (exists(s) && moddate(s) > moddate(fullname))
if (!Mode.theme.cache_rebuild && exists(s) && moddate(s) > moddate(fullname))
goto done;
/* No preparesd file or source is newer. Do preparsing. */
@ -593,6 +594,12 @@ ThemeConfigLoad(void)
Progressbar *p = NULL;
unsigned int i, delay_ms;
if (Conf.theme.cache_ver != E_CFG_VER_CACHE)
{
Mode.theme.cache_rebuild = true;
Conf.theme.cache_ver = E_CFG_VER_CACHE;
}
/* Font mappings */
FontConfigLoad();

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2004-2021 Kim Woelders
* Copyright (C) 2004-2023 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@ -509,6 +509,7 @@ static const IpcItem ThemeIpcArray[] = {
};
static const CfgItem ThemeCfgItems[] = {
CFG_ITEM_INT(Conf.theme, cache_ver, 0),
CFG_ITEM_STR(Conf.theme, name),
CFG_ITEM_STR(Conf.theme, extra_path),
CFG_ITEM_BOOL(Conf.theme, use_theme_font_cfg, 0),