Browse Source

Update source config

merge-requests/365/head
Jørgen Lien Sellæg 10 years ago
parent
commit
c46e8ed57a
  1. 10
      src/config.cc
  2. 3
      src/source.cc
  3. 9
      src/source.h

10
src/config.cc

@ -38,19 +38,17 @@ void MainConfig::find_or_create_config_files() {
void MainConfig::GenerateSource() { void MainConfig::GenerateSource() {
auto source_cfg = Singleton::Config::source(); auto source_cfg = Singleton::Config::source();
DEBUG("Fetching source cfg");
// boost::property_tree::ptree
auto source_json = cfg.get_child("source"); auto source_json = cfg.get_child("source");
auto clang_types_json = source_json.get_child("clang_types"); auto clang_types_json = source_json.get_child("clang_types");
auto style_json = source_json.get_child("style"); auto style_json = source_json.get_child("style");
source_cfg->tab_size = source_json.get<unsigned>("tab_size"); auto gsv_json = source_json.get_child("sourceview");
for (unsigned c = 0; c < source_cfg->tab_size; c++)
source_cfg->tab+=" "; for (auto &i : gsv_json)
source_cfg->gsv[i.first] = i.second.get_value<std::string>();
for (auto &i : style_json) for (auto &i : style_json)
source_cfg->tags[i.first] = i.second.get_value<std::string>(); source_cfg->tags[i.first] = i.second.get_value<std::string>();
for (auto &i : clang_types_json) for (auto &i : clang_types_json)
source_cfg->types[i.first] = i.second.get_value<std::string>(); source_cfg->types[i.first] = i.second.get_value<std::string>();
DEBUG("Source cfg fetched");
} }
void MainConfig::GenerateDirectoryFilter() { void MainConfig::GenerateDirectoryFilter() {

3
src/source.cc

@ -65,6 +65,9 @@ Source::View::View(const std::string& file_path): file_path(file_path) {
if(scheme) { if(scheme) {
get_source_buffer()->set_style_scheme(scheme); get_source_buffer()->set_style_scheme(scheme);
} }
property_highlight_current_line() = Singleton::Config::source()->gsv["highlight_current_line"] == "true";
property_show_line_numbers() = Singleton::Config::source()->gsv["show_line_numbers"] == "true";
} }
void Source::View::search_occurrences_updated(GtkWidget* widget, GParamSpec* property, gpointer data) { void Source::View::search_occurrences_updated(GtkWidget* widget, GParamSpec* property, gpointer data) {

9
src/source.h

@ -20,12 +20,11 @@ namespace Source {
class Config { class Config {
public: public:
unsigned tab_size; unsigned tab_size = 2;
bool show_line_numbers, highlight_current_line;
std::string tab;
char tab_char = ' '; char tab_char = ' ';
std::unordered_map<std::string, std::string> tags, types; std::string tab = " ";
}; // class Config std::unordered_map<std::string, std::string> tags, types, gsv;
};
class Range { class Range {
public: public:

Loading…
Cancel
Save