Browse Source

added legal file-extensions to source

merge-requests/365/head
tedjk 11 years ago
parent
commit
41b745b83d
  1. 4
      juci/api.cc
  2. 17
      juci/config.cc
  3. 7
      juci/config.json
  4. 7
      juci/directories.cc
  5. 3
      juci/notebook.cc
  6. 9
      juci/source.cc
  7. 4
      juci/source.h

4
juci/api.cc

@ -8,9 +8,12 @@ Notebook::Controller* PluginApi::notebook_;
///////////////////////////// /////////////////////////////
PluginApi::PluginApi(Menu::Controller& menu_ctl_, PluginApi::PluginApi(Menu::Controller& menu_ctl_,
Notebook::Controller& notebook_ctl_) { Notebook::Controller& notebook_ctl_) {
DEBUG("Adding pointers for the API");
menu_ = &menu_ctl_; menu_ = &menu_ctl_;
notebook_ = &notebook_ctl_; notebook_ = &notebook_ctl_;
DEBUG("Initiating plugins(from plugins.py)..");
InitPlugins(); InitPlugins();
DEBUG("Plugins initiated..");
} }
PluginApi::~PluginApi() { PluginApi::~PluginApi() {
@ -61,6 +64,7 @@ void PluginApi::InitPlugins() {
} }
void PluginApi::AddMenuElement(std::string plugin_name) { void PluginApi::AddMenuElement(std::string plugin_name) {
DEBUG("Adding menu element for "+plugin_name);
AddMenuXml(plugin_name, "PluginMenu"); AddMenuXml(plugin_name, "PluginMenu");
std::string plugin_action_name = plugin_name+"Menu"; std::string plugin_action_name = plugin_name+"Menu";
menu_->keybindings_.action_group_menu() menu_->keybindings_.action_group_menu()

17
juci/config.cc

@ -11,21 +11,26 @@ MainConfig::MainConfig() :
} }
void MainConfig::GenerateSource() { void MainConfig::GenerateSource() {
INFO("Generating source cfg"); DEBUG("Fetching source cfg");
boost::property_tree::ptree source_json = cfg_.get_child("source"); boost::property_tree::ptree source_json = cfg_.get_child("source");
boost::property_tree::ptree syntax_json = source_json.get_child("syntax"); boost::property_tree::ptree syntax_json = source_json.get_child("syntax");
boost::property_tree::ptree colors_json = source_json.get_child("colors"); boost::property_tree::ptree colors_json = source_json.get_child("colors");
boost::property_tree::ptree extensions_json = source_json.get_child("extensions");
for (auto &i : colors_json) { for (auto &i : colors_json) {
source_cfg_.InsertTag(i.first, i.second.get_value<std::string>()); source_cfg_.InsertTag(i.first, i.second.get_value<std::string>());
} }
for (auto &i : syntax_json) { for (auto &i : syntax_json) {
source_cfg_.InsertType(i.first, i.second.get_value<std::string>()); source_cfg_.InsertType(i.first, i.second.get_value<std::string>());
} }
INFO("Source cfg generated"); for (auto &i : extensions_json) {
source_cfg_.InsertExtension(i.second.get_value<std::string>());
}
DEBUG("Source cfg fetched");
} }
void MainConfig::GenerateKeybindings() { void MainConfig::GenerateKeybindings() {
INFO("Generating keybindings"); DEBUG("Fetching keybindings");
std::string line; std::string line;
std::ifstream menu_xml("menu.xml"); std::ifstream menu_xml("menu.xml");
if (menu_xml.is_open()) { if (menu_xml.is_open()) {
@ -35,10 +40,11 @@ void MainConfig::GenerateKeybindings() {
boost::property_tree::ptree keys_json = cfg_.get_child("keybindings"); boost::property_tree::ptree keys_json = cfg_.get_child("keybindings");
for (auto &i : keys_json) for (auto &i : keys_json)
keybindings_cfg_.key_map()[i.first] = i.second.get_value<std::string>(); keybindings_cfg_.key_map()[i.first] = i.second.get_value<std::string>();
INFO("Keybindings generated"); DEBUG("Keybindings fetched");
} }
void MainConfig::GenerateDirectoryFilter() { void MainConfig::GenerateDirectoryFilter() {
DEBUG("Fetching directory filter");
boost::property_tree::ptree dir_json = cfg_.get_child("directoryfilter"); boost::property_tree::ptree dir_json = cfg_.get_child("directoryfilter");
boost::property_tree::ptree ignore_json = dir_json.get_child("ignore"); boost::property_tree::ptree ignore_json = dir_json.get_child("ignore");
boost::property_tree::ptree except_json = dir_json.get_child("exceptions"); boost::property_tree::ptree except_json = dir_json.get_child("exceptions");
@ -46,6 +52,5 @@ void MainConfig::GenerateDirectoryFilter() {
dir_cfg_.AddException(i.second.get_value<std::string>()); dir_cfg_.AddException(i.second.get_value<std::string>());
for ( auto &i : ignore_json ) for ( auto &i : ignore_json )
dir_cfg_.AddIgnore(i.second.get_value<std::string>()); dir_cfg_.AddIgnore(i.second.get_value<std::string>());
DEBUG("Directory filter fetched");
} }

7
juci/config.json

@ -16,7 +16,12 @@
"702": "keyword", "702": "keyword",
"703": "own", "703": "own",
"705": "comment" "705": "comment"
} },
"extensions": [
"ext1",
"ext2",
"ext3"
]
}, },
"keybindings": { "keybindings": {
"split_window": "<control><alt>s", "split_window": "<control><alt>s",

7
juci/directories.cc

@ -29,7 +29,6 @@ open_folder(const boost::filesystem::path& dir_path) {
bool Directories::Controller::IsIgnored(std::string path) { bool Directories::Controller::IsIgnored(std::string path) {
DEBUG("Checking if file-/directory is filtered"); DEBUG("Checking if file-/directory is filtered");
std::transform(path.begin(), path.end(), path.begin(), ::tolower); std::transform(path.begin(), path.end(), path.begin(), ::tolower);
// std::cout << "ignored?: " << path << std::endl;
if (config().IsException(path)) { if (config().IsException(path)) {
return false; return false;
} }
@ -48,7 +47,7 @@ list_dirs(const boost::filesystem::path& dir_path,
unsigned file_counter = 0; unsigned file_counter = 0;
Gtk::TreeModel::Row child; Gtk::TreeModel::Row child;
Gtk::TreeModel::Row row; Gtk::TreeModel::Row row;
DEBUG_VAR(dir_path); DEBUG("");
// Fill the treeview // Fill the treeview
for ( boost::filesystem::directory_iterator itr( dir_path ); for ( boost::filesystem::directory_iterator itr( dir_path );
itr != end_itr; itr != end_itr;
@ -80,10 +79,12 @@ list_dirs(const boost::filesystem::path& dir_path,
} }
} }
} }
int Directories::Controller::count(const std::string path) { int Directories::Controller::count(const std::string path) {
int count = 0; int count = 0;
for (int i = 0; i < path.size(); i++) for (int i = 0; i < path.size(); i++)
if (path[i] == '/') count++; if (path[i] == '/')
count++;
return count; return count;
} }

3
juci/notebook.cc

@ -13,7 +13,8 @@ Notebook::View::View() : notebook_() {
view_.set_position(120); view_.set_position(120);
} }
Notebook::Controller::Controller(Gtk::Window* window, Keybindings::Controller& keybindings, Notebook::Controller::Controller(Gtk::Window* window,
Keybindings::Controller& keybindings,
Source::Config& source_cfg, Source::Config& source_cfg,
Directories::Config& dir_cfg) : Directories::Config& dir_cfg) :
source_config_(source_cfg), source_config_(source_cfg),

9
juci/source.cc

@ -70,9 +70,18 @@ const std::unordered_map<string, string>& Source::Config::typetable() const {
return typetable_; return typetable_;
} }
std::vector<string>& Source::Config::extensiontable() {
return extensiontable_;
}
void Source::Config::InsertTag(const string &key, const string &value) { void Source::Config::InsertTag(const string &key, const string &value) {
tagtable_[key] = value; tagtable_[key] = value;
} }
void Source::Config::InsertExtension(const string &ext) {
extensiontable_.push_back(ext);
}
// Source::View::Config::SetTagTable() // Source::View::Config::SetTagTable()
// sets the tagtable for the view // sets the tagtable for the view
void Source::Config:: void Source::Config::

4
juci/source.h

@ -20,16 +20,18 @@ namespace Source {
Config(); Config();
const std::unordered_map<std::string, std::string>& tagtable() const; const std::unordered_map<std::string, std::string>& tagtable() const;
const std::unordered_map<std::string, std::string>& typetable() const; const std::unordered_map<std::string, std::string>& typetable() const;
std::vector<std::string>& extensiontable();
void SetTagTable(const std::unordered_map<std::string, std::string> void SetTagTable(const std::unordered_map<std::string, std::string>
&tagtable); &tagtable);
void InsertTag(const std::string &key, const std::string &value); void InsertTag(const std::string &key, const std::string &value);
void SetTypeTable(const std::unordered_map<std::string, std::string> void SetTypeTable(const std::unordered_map<std::string, std::string>
&tagtable); &tagtable);
void InsertType(const std::string &key, const std::string &value); void InsertType(const std::string &key, const std::string &value);
void InsertExtension(const std::string &ext);
private: private:
std::unordered_map<std::string, std::string> tagtable_; std::unordered_map<std::string, std::string> tagtable_;
std::unordered_map<std::string, std::string> typetable_; std::unordered_map<std::string, std::string> typetable_;
std::vector<std::string> extensiontable_;
std::string background_; std::string background_;
}; // class Config }; // class Config

Loading…
Cancel
Save