From 14313e817eb7d89cbfb2f402b662ce232363e4f4 Mon Sep 17 00:00:00 2001 From: tedjk Date: Mon, 11 May 2015 14:38:04 +0200 Subject: [PATCH] created constructor to api, and added it to window --- juci/api.cc | 7 +++++++ juci/api.h | 1 + juci/config.cc | 13 +++++-------- juci/window.cc | 7 ++----- juci/window.h | 1 + 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/juci/api.cc b/juci/api.cc index 4c74620..2363e41 100644 --- a/juci/api.cc +++ b/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_ = ¬ebook_ctl_; + InitPlugins(); +} + std::string PluginApi::ProjectPath() { int MAXPATHLEN = 50; char temp[MAXPATHLEN]; diff --git a/juci/api.h b/juci/api.h index 4534487..5b09f0a 100644 --- a/juci/api.h +++ b/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(); diff --git a/juci/config.cc b/juci/config.cc index 689fd19..49de901 100644 --- a/juci/config.cc +++ b/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()); } - for ( auto &i : syntax_json ) { - source_cfg_.InsertType(i.first, i.second.get_value()); + for (auto &i : syntax_json) { + source_cfg_.InsertType(i.first, i.second.get_value()); } } @@ -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()); - for ( auto &i : ignore_json ) + for ( auto &i : ignore_json ) dir_cfg_.AddIgnore(i.second.get_value()); } diff --git a/juci/window.cc b/juci/window.cc index 94bd534..b7c0e11 100644 --- a/juci/window.cc +++ b/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_ = ¬ebook_; - PluginApi::InitPlugins(); add_accel_group(keybindings_.ui_manager_menu()->get_accel_group()); add_accel_group(keybindings_.ui_manager_hidden()->get_accel_group()); diff --git a/juci/window.h b/juci/window.h index e9c5424..a39bd23 100644 --- a/juci/window.h +++ b/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: