Browse Source

created constructor to api, and added it to window

merge-requests/365/head
tedjk 11 years ago
parent
commit
14313e817e
  1. 7
      juci/api.cc
  2. 1
      juci/api.h
  3. 13
      juci/config.cc
  4. 7
      juci/window.cc
  5. 1
      juci/window.h

7
juci/api.cc

@ -5,6 +5,13 @@ Notebook::Controller* PluginApi::notebook_;
/////////////////////////////
//// API ServiceProvider ////
/////////////////////////////
PluginApi::PluginApi(Menu::Controller& menu_ctl_,
Notebook::Controller& notebook_ctl_) {
menu_ = &menu_ctl_;
notebook_ = &notebook_ctl_;
InitPlugins();
}
std::string PluginApi::ProjectPath() {
int MAXPATHLEN = 50;
char temp[MAXPATHLEN];

1
juci/api.h

@ -12,6 +12,7 @@
////////////////////
class PluginApi {
public:
PluginApi(Menu::Controller&, Notebook::Controller&);
static Menu::Controller* menu_;
static Notebook::Controller* notebook_;
static void InitPlugins();

13
juci/config.cc

@ -6,20 +6,17 @@ MainConfig::MainConfig() :
GenerateSource();
GenerateKeybindings();
GenerateDirectoryFilter();
// keybindings_cfg_ = cfg_.get_child("keybindings");
// notebook_cfg_ = cfg_.get_child("notebook");
// menu_cfg_ = cfg_.get_child("menu");
}
void MainConfig::GenerateSource() {
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 colors_json = source_json.get_child("colors");
for ( auto &i : colors_json ) {
for (auto &i : colors_json) {
source_cfg_.InsertTag(i.first, i.second.get_value<std::string>());
}
for ( auto &i : syntax_json ) {
source_cfg_.InsertType(i.first, i.second.get_value<std::string>());
for (auto &i : syntax_json) {
source_cfg_.InsertType(i.first, i.second.get_value<std::string>());
}
}
@ -40,9 +37,9 @@ void MainConfig::GenerateDirectoryFilter() {
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 except_json = dir_json.get_child("exceptions");
for ( auto &i : except_json )
for ( auto &i : except_json )
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>());
}

7
juci/window.cc

@ -5,7 +5,8 @@ Window::Window() :
main_config_(),
keybindings_(main_config_.keybindings_cfg()),
notebook_(this,keybindings(), main_config_.source_cfg(), main_config_.dir_cfg()),
menu_(keybindings()) {
menu_(keybindings()),
api_(menu_, notebook_) {
set_title("juCi++");
set_default_size(600, 400);
add(window_box_);
@ -77,10 +78,6 @@ Window::Window() :
connect(sigc::mem_fun(*this,&Window::OnMouseRelease),false);
terminal_.Terminal().signal_button_release_event().
connect(sigc::mem_fun(*this,&Window::OnMouseRelease),false);
PluginApi::menu_ = &menu_;
PluginApi::notebook_ = &notebook_;
PluginApi::InitPlugins();
add_accel_group(keybindings_.ui_manager_menu()->get_accel_group());
add_accel_group(keybindings_.ui_manager_hidden()->get_accel_group());

1
juci/window.h

@ -22,6 +22,7 @@ public:
Menu::Controller menu_;
Notebook::Controller notebook_;
Terminal::Controller terminal_;
PluginApi api_;
Keybindings::Controller& keybindings() { return keybindings_; }
private:

Loading…
Cancel
Save