From a012f0c17bf2793cf8508474de7af986ac08679c Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 18 Feb 2012 23:39:46 +0100 Subject: [PATCH] Support a theme.config.local. --- bigscreen/.gitignore | 1 + bigscreen/theme.cpp | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 bigscreen/.gitignore diff --git a/bigscreen/.gitignore b/bigscreen/.gitignore new file mode 100644 index 0000000..b3cc2b6 --- /dev/null +++ b/bigscreen/.gitignore @@ -0,0 +1 @@ +theme.config.local diff --git a/bigscreen/theme.cpp b/bigscreen/theme.cpp index 03a26c1..eb5d549 100644 --- a/bigscreen/theme.cpp +++ b/bigscreen/theme.cpp @@ -7,11 +7,11 @@ std::map config; -void init_theme() +void read_config(const char *filename) { - FILE *fp = fopen("theme.config", "rb"); + FILE *fp = fopen(filename, "r"); if (fp == NULL) - throw std::runtime_error("Couldn't open theme.config."); + throw std::runtime_error("Couldn't open theme file."); while (!feof(fp)) { char buf[1024]; @@ -46,11 +46,22 @@ void init_theme() continue; } - config.insert(std::make_pair(key, value)); + fprintf(stderr, "%s = %s\n", key, value); + config[key] = value; } fclose(fp); } +void init_theme() +{ + read_config("theme.config"); + try { + read_config("theme.config.local"); + } catch (...) { + // Ignore. + } +} + std::string get_theme_config(const std::string &key, const std::string subkey) { if (config.count(key + "." + subkey)) { -- 2.39.2