diff --git a/juci/juci.h b/juci/juci.h index 715d466..6eb5018 100644 --- a/juci/juci.h +++ b/juci/juci.h @@ -14,7 +14,8 @@ public: Gtk::Box window_box_; std::shared_ptr source(); private: - Menu::Controller menu; + Keybindings::Controller keybindings_; + Menu::Controller menu_; Source::Controller source_; /*signal handler*/ void onSystemQuit(); diff --git a/juci/menu.cc b/juci/menu.cc index c298010..9d028f2 100644 --- a/juci/menu.cc +++ b/juci/menu.cc @@ -7,7 +7,7 @@ Menu::Model::Model() { ui_string_ = - " " + " " " " " " " " @@ -47,18 +47,18 @@ Menu::Model::Model() { Menu::Model::~Model() { } -/***********************************/ -/* VIEW */ -/***********************************/ + +// VIEW + Menu::View::View(Gtk::Orientation orientation) : view_(orientation) { } -Glib::RefPtr Menu::View::view( +Gtk::Box& Menu::View::view( Glib::RefPtr ui_manager) { view_.pack_start(*ui_manager->get_widget("/MenuBar"), Gtk::PACK_SHRINK); - return Glib::RefPtr(&view_); + return view_; } Menu::View::~View() { @@ -87,6 +87,7 @@ Menu::Controller::Controller(Keybindings::Controller keybindings) : [this]() { OnFileNewCCFile(); }); + keybindings_.action_group()->add(Gtk::Action::create("FileNewH", Gtk::Stock::NEW, "New h file", "Create a new h file"), Gtk::AccelKey("h"), @@ -168,6 +169,10 @@ Menu::Controller::Controller(Keybindings::Controller keybindings) : Menu::Controller::~Controller() { } +Gtk::Box& Menu::Controller::view() { + return menu_view_.view(keybindings_.ui_manager()); +} + void Menu::Controller::OnFileNewEmptyfile() { std::cout << "New file clicked" << std::endl; //TODO(Oyvang) Legg til funksjon @@ -179,14 +184,14 @@ void Menu::Controller::OnFileNewCCFile() { } void Menu::Controller::OnFileNewHeaderFile() { - std::cout << "New cc file clicked" << std::endl; + std::cout << "New header file clicked" << std::endl; //TODO(Oyvang) Legg til funksjon } void Menu::Controller::OnSystemQuit() { //TODO(Oyvang, Zalox, Forgie) Add everything that needs to be done before quiting /*Quit the system*/ - Gtk::Main::quit(); //TODO(Oyvang, Zalox, Forgie) methode is depricated, find a better solution. + } void Menu::Controller::OnPluginAddSnippet() { diff --git a/juci/menu.h b/juci/menu.h index 9c5be84..caa9e98 100644 --- a/juci/menu.h +++ b/juci/menu.h @@ -19,7 +19,7 @@ namespace Menu { public: explicit View(Gtk::Orientation orient); virtual ~View(); - Glib::RefPtr view(Glib::RefPtr ui_manager); + Gtk::Box& view(Glib::RefPtr ui_manager); protected: Gtk::Box view_; @@ -29,7 +29,7 @@ namespace Menu { public: explicit Controller(Keybindings::Controller keybindings); virtual ~Controller(); - + Gtk::Box& view(); private: Keybindings::Controller keybindings_; View menu_view_; diff --git a/juci/window.cc b/juci/window.cc index 2fb07c7..4e27b3b 100644 --- a/juci/window.cc +++ b/juci/window.cc @@ -2,14 +2,15 @@ Window::Window() : window_box_(Gtk::ORIENTATION_HORIZONTAL), - menu() { + menu_(keybindings_) { set_title("example juCi++"); set_default_size(600, 600); // window_box_.add(*source_.sourceview()); add(window_box_); - add_accel_group(menu.ui_manager()->get_accel_group()); - window_box_.pack_start(menu.view()); + add_accel_group(keybindings_.ui_manager()->get_accel_group()); + window_box_.pack_start(menu_.view()); show_all_children(); + } std::shared_ptr Window::source() {