allow style options in the rc file to override those found in the style

This commit is contained in:
Dana Jansens 2002-07-07 21:16:35 +00:00
parent 32c1369752
commit 137a0c4e59
3 changed files with 18 additions and 22 deletions

View file

@ -35,21 +35,21 @@ using std::string;
bool Configuration::m_initialized = False; bool Configuration::m_initialized = False;
Configuration::Configuration(const string &file) { Configuration::Configuration(const string &file, bool autosave) {
setFile(file); setFile(file);
m_modified = False; m_modified = False;
m_database = NULL; m_database = NULL;
m_autosave = True; m_autosave = autosave;
if (! m_initialized) { if (! m_initialized) {
XrmInitialize(); XrmInitialize();
m_initialized = True; m_initialized = True;
} }
} }
Configuration::Configuration() { Configuration::Configuration(bool autosave) {
m_modified = False; m_modified = False;
m_database = NULL; m_database = NULL;
m_autosave = True; m_autosave = autosave;
if (! m_initialized) { if (! m_initialized) {
XrmInitialize(); XrmInitialize();
m_initialized = True; m_initialized = True;
@ -84,6 +84,15 @@ bool Configuration::load() {
return True; return True;
} }
bool Configuration::merge(const string &file, bool overwrite) {
if (XrmCombineFileDatabase(file.c_str(), &m_database, overwrite) == 0)
return False;
m_modified = True;
if (m_autosave)
save();
return True;
}
void Configuration::create() { void Configuration::create() {
if (m_database != NULL) if (m_database != NULL)
XrmDestroyDatabase(m_database); XrmDestroyDatabase(m_database);

View file

@ -37,8 +37,8 @@
*/ */
class Configuration { class Configuration {
public: public:
explicit Configuration(const std::string &file); explicit Configuration(const std::string &file, bool autosave = True);
Configuration(); Configuration(bool autosave = True);
virtual ~Configuration(); virtual ~Configuration();
inline const std::string &file() const { inline const std::string &file() const {
@ -58,6 +58,7 @@ public:
void save(); void save();
bool load(); bool load();
bool merge(const std::string &file, bool overwrite = False);
void create(); void create();
void setValue(const std::string &rname, bool value); void setValue(const std::string &rname, bool value);

View file

@ -739,24 +739,10 @@ void BScreen::LoadStyle(void) {
} }
} }
string s;
if (config->getValue("rootCommand", s))
printf("config.rootCommand: %s\n", s.c_str());
if (style.getValue("rootCommand", s))
printf("style.rootCommand: %s\n", s.c_str());
// merge in the rc file // merge in the rc file
style.merge(config, True); style.merge(config->file(), True);
printf("merged databases\n"); string s;
if (style.getValue("rootCommand", s))
printf("style.rootCommand: %s\n", s.c_str());
if (style.getValue("session.cacheMax", s))
printf("session.cacheMax: %s\n", s.c_str());
// load fonts/fontsets // load fonts/fontsets
if (resource.wstyle.font) if (resource.wstyle.font)