From b8e8507fc6cc1179baae997aa2cc36ca8f7a91a0 Mon Sep 17 00:00:00 2001 From: oyvang Date: Mon, 9 Feb 2015 15:43:19 +0100 Subject: [PATCH 1/2] keybindings changes --- juci/CMakeLists.txt | 4 +- juci/juci.cc | 8 +- juci/juci.h | 5 +- juci/keybindings.cc | 21 +++ juci/keybindings.h | 28 ++++ juci/menu.cc | 354 ++++++++++++++++++++++---------------------- juci/menu.h | 87 +++++------ juci/window.cc | 23 +-- 8 files changed, 274 insertions(+), 256 deletions(-) create mode 100644 juci/keybindings.cc create mode 100644 juci/keybindings.h diff --git a/juci/CMakeLists.txt b/juci/CMakeLists.txt index 17febd9..a973386 100644 --- a/juci/CMakeLists.txt +++ b/juci/CMakeLists.txt @@ -63,10 +63,10 @@ endif() # name of the executable on Windows will be example.exe add_executable(${project_name} # list of every needed file to create the executable + keybindings.h menu.h - + keybindings.cc menu.cc - window.cc juci.cc ) diff --git a/juci/juci.cc b/juci/juci.cc index 6b86603..7868202 100644 --- a/juci/juci.cc +++ b/juci/juci.cc @@ -1,9 +1,7 @@ #include "juci.h" int main(int argc, char *argv[]) { - - Glib::RefPtr app = Gtk::Application::create(argc, argv, "no.sout.juci"); - Window window; - - return app->run(window);; + Glib::RefPtr app = Gtk::Application::create(argc, argv, "no.sout.juci"); + Window window; + return app->run(window);; } diff --git a/juci/juci.h b/juci/juci.h index 37dc1ef..8c3ead1 100644 --- a/juci/juci.h +++ b/juci/juci.h @@ -10,16 +10,19 @@ class Window : public Gtk::Window { public: Window(); - virtual ~Window(); Gtk::Box window_box_; private: + Keybindings::Controller keybindings; Menu::Controller menu; + /*signal handler*/ void onSystemQuit(); }; + + #endif // JUCI_H diff --git a/juci/keybindings.cc b/juci/keybindings.cc new file mode 100644 index 0000000..c112c0a --- /dev/null +++ b/juci/keybindings.cc @@ -0,0 +1,21 @@ +#include "keybindings.h" + + + Keybindings::Controller::Controller() { + action_group_ = Gtk::ActionGroup::create(); + ui_manager_ = Gtk::UIManager::create(); + } +Keybindings::Controller::~Controller(){ + +} +void Keybindings::Controller::set_ui_manager_action_group(Glib::RefPtr action_group) { + ui_manager_->insert_action_group(action_group); +} +void Keybindings::Controller::set_ui_manger_string(std::string ui_string) { + try { + ui_manager_->add_ui_from_string(ui_string); + } + catch (const Glib::Error &ex) { + std::cerr << "building menus failed: " << ex.what(); + } +} diff --git a/juci/keybindings.h b/juci/keybindings.h new file mode 100644 index 0000000..440d1f0 --- /dev/null +++ b/juci/keybindings.h @@ -0,0 +1,28 @@ +#include "iostream" +#include "gtkmm.h" + +namespace Keybindings { + + class Controller { + public: + Controller(); + virtual ~Controller(); + + Glib::RefPtr action_group() { + return action_group_; + }; + + Glib::RefPtr ui_manager() { + return ui_manager_; + }; + void set_ui_manger_string(std::string ui_string); + + void set_ui_manager_action_group(Glib::RefPtr action_group); + + + protected: + Glib::RefPtr ui_manager_; + Glib::RefPtr action_group_; + }; + +} \ No newline at end of file diff --git a/juci/menu.cc b/juci/menu.cc index bdd00f7..e71d574 100644 --- a/juci/menu.cc +++ b/juci/menu.cc @@ -6,41 +6,41 @@ Menu::Model::Model() { - ui_string_ = - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " "; + ui_string_ = + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " "; } @@ -53,131 +53,115 @@ Menu::Model::~Model() { Menu::View::View(Gtk::Orientation orientation) : view_(orientation) { - action_group_ = Gtk::ActionGroup::create(); - ui_manager_ = Gtk::UIManager::create(); - - -} - -void Menu::View::set_ui_manger_string(std::string ui_string) { - try { - ui_manager_->add_ui_from_string(ui_string); - } - catch (const Glib::Error &ex) { - std::cerr << "building menus failed: " << ex.what(); - } -} - -void Menu::View::set_ui_manager_action_group(Glib::RefPtr action_group) { - ui_manager_->insert_action_group(action_group); } -Gtk::Box &Menu::View::view() { - view_.pack_start(*ui_manager_->get_widget("/MenuBar"), Gtk::PACK_SHRINK); - return view_; +Gtk::Box &Menu::View::view(Glib::RefPtr ui_manager) { + view_.pack_start(*ui_manager->get_widget("/MenuBar"), Gtk::PACK_SHRINK); + return view_; } - Menu::View::~View() { } /***********************************/ /* CONTROLLER */ /***********************************/ -Menu::Controller::Controller() : +Menu::Controller::Controller(Keybindings::Controller keybindings) : menu_view_(Gtk::ORIENTATION_VERTICAL), - menu_model_() { + menu_model_(), + keybindings_(keybindings){ /* Add action to menues */ /* START file menu */ - menu_view_.action_group()->add(Gtk::Action::create("FileMenu", Gtk::Stock::FILE)); - /* File->New files */ - menu_view_.action_group()->add(Gtk::Action::create("FileNew", "New")); - - menu_view_.action_group()->add(Gtk::Action::create("FileNewStandard", - Gtk::Stock::NEW, "New empty file", "Create a new file"), - [this]() { - onFileNewEmptyfile(); - }); - menu_view_.action_group()->add(Gtk::Action::create("FileNewCC", - Gtk::Stock::NEW, "New cc file", "Create a new cc file"), - Gtk::AccelKey("c"), - [this]() { - onFileNewCCFile(); - }); - menu_view_.action_group()->add(Gtk::Action::create("FileNewH", - Gtk::Stock::NEW, "New h file", "Create a new h file"), - Gtk::AccelKey("h"), - [this]() { - onFileNewHeaderFile(); - }); - /* File-> New files end */ - menu_view_.action_group()->add(Gtk::Action::create("FileOpenFile", Gtk::Stock::OPEN), - [this]() { - onFileOpenFile(); - }); - menu_view_.action_group()->add(Gtk::Action::create("FileOpenFolder", "Open folder"), - [this]() { - onFileOpenFolder(); - }); - menu_view_.action_group()->add(Gtk::Action::create("FileQuit", Gtk::Stock::QUIT), - [this]() { - onSystemQuit(); - }); + keybindings_.action_group()->add(Gtk::Action::create("FileMenu", Gtk::Stock::FILE)); + /* File->New files */ + keybindings_.action_group()->add(Gtk::Action::create("FileNew", "New")); + keybindings_.action_group()->add(Gtk::Action::create("FileNewStandard", + Gtk::Stock::NEW, "New empty file", "Create a new file"), + [this]() { + OnFileNewEmptyfile(); + }); + keybindings_.action_group()->add(Gtk::Action::create("FileNewCC", + Gtk::Stock::NEW, "New cc file", "Create a new cc file"), + Gtk::AccelKey("c"), + [this]() { + OnFileNewCCFile(); + }); + keybindings_.action_group()->add(Gtk::Action::create("FileNewH", + Gtk::Stock::NEW, "New h file", "Create a new h file"), + Gtk::AccelKey("h"), + [this]() { + OnFileNewHeaderFile(); + }); + /* File-> New files end */ + keybindings_.action_group()->add(Gtk::Action::create("FileOpenFile", Gtk::Stock::OPEN), + [this]() { + OnFileOpenFile(); + }); + keybindings_.action_group()->add(Gtk::Action::create("FileOpenFolder", "Open folder"), + [this]() { + OnFileOpenFolder(); + }); + keybindings_.action_group()->add(Gtk::Action::create("FileQuit", Gtk::Stock::QUIT), + [this]() { + OnSystemQuit(); + }); /* END file menu */ /* START edit menu */ - menu_view_.action_group()->add(Gtk::Action::create("EditMenu", Gtk::Stock::EDIT)); - menu_view_.action_group()->add(Gtk::Action::create("EditCopy", Gtk::Stock::COPY), - [this]() { - onEditCopy(); - }); - menu_view_.action_group()->add(Gtk::Action::create("EditCut", Gtk::Stock::CUT), - [this]() { - onEditCut(); - }); - menu_view_.action_group()->add(Gtk::Action::create("EditPaste", Gtk::Stock::PASTE), - [this]() { - onEditPaste(); - }); - menu_view_.action_group()->add(Gtk::Action::create("EditFind", Gtk::Stock::FIND), - [this]() { - onEditFind(); - }); + keybindings_.action_group()->add(Gtk::Action::create("EditMenu", Gtk::Stock::EDIT)); + keybindings_.action_group()->add(Gtk::Action::create("EditCopy", Gtk::Stock::COPY), + [this]() { + OnEditCopy(); + }); + keybindings_.action_group()->add(Gtk::Action::create("EditCut", Gtk::Stock::CUT), + [this]() { + OnEditCut(); + }); + keybindings_.action_group()->add(Gtk::Action::create("EditPaste", Gtk::Stock::PASTE), + [this]() { + OnEditPaste(); + }); + keybindings_.action_group()->add(Gtk::Action::create("EditFind", Gtk::Stock::FIND), + [this]() { + OnEditFind(); + }); /* END edit menu */ /* START window menu */ - menu_view_.action_group()->add(Gtk::Action::create("WindowMenu", "_Window")); - menu_view_.action_group()->add(Gtk::Action::create("WindowCloseTab", "Close tab"), - Gtk::AccelKey("w"), - [this]() { - onWindowCloseTab(); - }); - menu_view_.action_group()->add(Gtk::Action::create("WindowSplitWindow", "Split window"), - Gtk::AccelKey("S"), - [this]() { - onWindowSplitWindow(); - }); + keybindings_.action_group()->add(Gtk::Action::create("WindowMenu", "_Window")); + keybindings_.action_group()->add(Gtk::Action::create("WindowCloseTab", "Close tab"), + Gtk::AccelKey("w"), + [this]() { + OnWindowCloseTab(); + }); + keybindings_.action_group()->add(Gtk::Action::create("WindowSplitWindow", "Split window"), + Gtk::AccelKey("S"), + [this]() { + OnWindowSplitWindow(); + }); /* END window menu */ /* START Plugin menu */ - menu_view_.action_group()->add(Gtk::Action::create("PluginMenu", "_Plugins")); - /*Plugin->snippet*/ - menu_view_.action_group()->add(Gtk::Action::create("PluginSnippet", "Snippet")); - menu_view_.action_group()->add(Gtk::Action::create("PluginAddSnippet", "Add snippet"), - Gtk::AccelKey("space"), - [this]() { - onPluginAddSnippet(); - }); - /* End snippet */ + keybindings_.action_group()->add(Gtk::Action::create("PluginMenu", "_Plugins")); + /*Plugin->snippet*/ + keybindings_.action_group()->add(Gtk::Action::create("PluginSnippet", "Snippet")); + keybindings_.action_group()->add(Gtk::Action::create("PluginAddSnippet", "Add snippet"), + Gtk::AccelKey("space"), + [this]() { + OnPluginAddSnippet(); + }); + /* End snippet */ /* END plugin menu */ /* START help menu */ - menu_view_.action_group()->add(Gtk::Action::create("HelpMenu", Gtk::Stock::HELP)); - menu_view_.action_group()->add(Gtk::Action::create("HelpAbout", Gtk::Stock::ABOUT), - [this]() { - onHelpAbout(); - }); + keybindings_.action_group()->add(Gtk::Action::create("HelpMenu", Gtk::Stock::HELP)); + keybindings_.action_group()->add(Gtk::Action::create("HelpAbout", Gtk::Stock::ABOUT), + [this]() { + OnHelpAbout(); + }); + + /* END help menu */ - menu_view_.set_ui_manager_action_group(menu_view_.action_group()); - menu_view_.set_ui_manger_string(menu_model_.ui_string()); + keybindings_.ui_manager()->add_ui_from_string(menu_model_.ui_string()); + keybindings_.ui_manager()->insert_action_group(keybindings_.action_group()); } Menu::Controller::~Controller() { @@ -185,63 +169,75 @@ Menu::Controller::~Controller() { } Gtk::Box &Menu::Controller::view() { - return menu_view_.view(); + return menu_view_.view(keybindings_.ui_manager()); } -void Menu::Controller::onFileNewEmptyfile() { - std::cout << "New file clicked" << std::endl; - //TODO(Oyvang) Legg til funksjon +void Menu::Controller::OnFileNewEmptyfile() { + std::cout << "New file clicked" << std::endl; + //TODO(Oyvang) Legg til funksjon } -void Menu::Controller::onFileNewCCFile() { - std::cout << "New cc file clicked" << std::endl; - //TODO(Oyvang) Legg til funksjon + +void Menu::Controller::OnFileNewCCFile() { + std::cout << "New cc file clicked" << std::endl; + //TODO(Oyvang) Legg til funksjon } -void Menu::Controller::onFileNewHeaderFile() { - std::cout << "New cc file clicked" << std::endl; - //TODO(Oyvang) Legg til funksjon +void Menu::Controller::OnFileNewHeaderFile() { + std::cout << "New cc 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::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() { - std::cout << "Add snipper" << std::endl; //TODO(Forgi add you snippet magic code) + +void Menu::Controller::OnPluginAddSnippet() { + std::cout << "Add snipper" << std::endl; //TODO(Forgi add you snippet magic code) } -void Menu::Controller::onFileOpenFile() { - std::cout << "Open file clicked" << std::endl; - //TODO(Oyvang) Legg til funksjon + +void Menu::Controller::OnFileOpenFile() { + std::cout << "Open file clicked" << std::endl; + //TODO(Oyvang) Legg til funksjon } -void Menu::Controller::onFileOpenFolder() { - std::cout << "Open folder clicked" << std::endl; - //TODO(Oyvang) Legg til funksjon + +void Menu::Controller::OnFileOpenFolder() { + std::cout << "Open folder clicked" << std::endl; + //TODO(Oyvang) Legg til funksjon } -void Menu::Controller::onWindowCloseTab() { - std::cout << "Closing tab clicked" << std::endl; - //TODO(Oyvang) Legg til funksjon + +void Menu::Controller::OnWindowCloseTab() { + std::cout << "Closing tab clicked" << std::endl; + //TODO(Oyvang) Legg til funksjon } -void Menu::Controller::onEditCopy() { - std::cout << "Clicked copy" << std::endl; - //TODO(Oyvang) Legg til funksjon + +void Menu::Controller::OnEditCopy() { + std::cout << "Clicked copy" << std::endl; + //TODO(Oyvang) Legg til funksjon } -void Menu::Controller::onEditCut() { - std::cout << "Clicked cut" << std::endl; - //TODO(Oyvang) Legg til funksjon + +void Menu::Controller::OnEditCut() { + std::cout << "Clicked cut" << std::endl; + //TODO(Oyvang) Legg til funksjon } -void Menu::Controller::onEditPaste() { - std::cout << "Clicked paste" << std::endl; - //TODO(Oyvang) Legg til funksjon + +void Menu::Controller::OnEditPaste() { + std::cout << "Clicked paste" << std::endl; + //TODO(Oyvang) Legg til funksjon } -void Menu::Controller::onEditFind() { - std::cout << "Clicked find" << std::endl; - //TODO(Oyvang) Legg til funksjon + +void Menu::Controller::OnEditFind() { + std::cout << "Clicked find" << std::endl; + //TODO(Oyvang) Legg til funksjon } -void Menu::Controller::onWindowSplitWindow() { - std::cout << "Clicked split window" << std::endl; - //TODO(Oyvang) Legg til funksjon + +void Menu::Controller::OnWindowSplitWindow() { + std::cout << "Clicked split window" << std::endl; + //TODO(Oyvang) Legg til funksjon } -void Menu::Controller::onHelpAbout() { - std::cout << "Clicked about" << std::endl; - //TODO(Oyvang) Legg til funksjon + +void Menu::Controller::OnHelpAbout() { + std::cout << "Clicked about" << std::endl; + //TODO(Oyvang) Legg til funksjon } \ No newline at end of file diff --git a/juci/menu.h b/juci/menu.h index e7d3437..0316337 100644 --- a/juci/menu.h +++ b/juci/menu.h @@ -1,90 +1,69 @@ #include #include "gtkmm.h" +#include "keybindings.h" namespace Menu { class Model { public: - Model(); + Model(); - virtual~Model(); + virtual~Model(); - std::string ui_string() { - return ui_string_; - }; + std::string ui_string() { + return ui_string_; + }; private: - std::string ui_string_; + std::string ui_string_; }; - class View { public: - View(Gtk::Orientation orient); - - virtual ~View(); - - Gtk::Box &view(); - - Glib::RefPtr action_group() { - return action_group_; - }; - - Glib::RefPtr ui_manager() { - return ui_manager_; - }; - - void set_ui_manger_string(std::string ui_string); - - void set_ui_manager_action_group(Glib::RefPtr action_group); + View(Gtk::Orientation orient); + virtual ~View(); + Gtk::Box &view(Glib::RefPtr ui_manager); protected: - Gtk::Box view_; - Glib::RefPtr ui_manager_; - Glib::RefPtr action_group_; + Gtk::Box view_; + }; class Controller { public: - Controller(); - - virtual ~Controller(); - - Gtk::Box &view(); - - Glib::RefPtr ui_manager() { - return menu_view_.ui_manager(); - }; - + Controller(Keybindings::Controller keybindings); + virtual ~Controller(); + Gtk::Box &view(); private: - Menu::View menu_view_; - Menu::Model menu_model_; + Keybindings::Controller keybindings_; + Menu::View menu_view_; + Menu::Model menu_model_; - /*Signal handlers*/ - void onFileNewEmptyfile(); + /*Signal handlers*/ + void OnFileNewEmptyfile(); - void onFileNewCCFile(); + void OnFileNewCCFile(); - void onFileNewHeaderFile(); + void OnFileNewHeaderFile(); - void onFileOpenFile(); + void OnFileOpenFile(); - void onFileOpenFolder(); + void OnFileOpenFolder(); - void onSystemQuit(); + void OnSystemQuit(); - void onPluginAddSnippet(); + void OnPluginAddSnippet(); - void onWindowCloseTab(); + void OnWindowCloseTab(); - void onEditCopy(); + void OnEditCopy(); - void onEditCut(); + void OnEditCut(); - void onEditPaste(); + void OnEditPaste(); - void onEditFind(); + void OnEditFind(); - void onWindowSplitWindow(); + void OnWindowSplitWindow(); - void onHelpAbout(); + void OnHelpAbout(); }; } \ No newline at end of file diff --git a/juci/window.cc b/juci/window.cc index 7c25a9d..02dc462 100644 --- a/juci/window.cc +++ b/juci/window.cc @@ -2,23 +2,16 @@ Window::Window() : window_box_(Gtk::ORIENTATION_HORIZONTAL), - menu() { - - - set_title("example juCi++"); - set_default_size(600, 600); - - add(window_box_); - - add_accel_group(menu.ui_manager()->get_accel_group()); - - window_box_.pack_start(menu.view()); - - - show_all_children(); + keybindings(), + menu(keybindings) { + set_title("example juCi++"); + set_default_size(600, 600); + add(window_box_); + window_box_.pack_start(menu.view()); + add_accel_group(keybindings.ui_manager()->get_accel_group()); + show_all_children(); }; - Window::~Window() { } From 8caba58f660e2943c6ce7c2a34159ab3f0746b70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Tue, 10 Feb 2015 21:21:42 +0100 Subject: [PATCH 2/2] Fix semantic errors --- juci/CMakeLists.txt | 4 +- juci/juci.cc | 17 +++-- juci/juci.h | 26 ++++---- juci/menu.cc | 15 ++--- juci/menu.h | 149 ++++++++++++++++++-------------------------- juci/source.cc | 47 ++++++++++++++ juci/source.h | 31 +++++++++ juci/window.cc | 30 +++------ 8 files changed, 185 insertions(+), 134 deletions(-) create mode 100644 juci/source.cc create mode 100644 juci/source.h diff --git a/juci/CMakeLists.txt b/juci/CMakeLists.txt index 3e4cf3b..8398b7c 100644 --- a/juci/CMakeLists.txt +++ b/juci/CMakeLists.txt @@ -64,9 +64,9 @@ endif() add_executable(${project_name} # list of every needed file to create the executable menu.h - menu.cc - + source.h + source.cc window.cc juci.cc ) diff --git a/juci/juci.cc b/juci/juci.cc index 6b86603..4b6f121 100644 --- a/juci/juci.cc +++ b/juci/juci.cc @@ -1,9 +1,18 @@ #include "juci.h" - int main(int argc, char *argv[]) { + Glib::RefPtr app = Gtk::Application::create( + argc, + argv, + "no.sout.juci" + ); + Window window; + return app->run(window);; - Glib::RefPtr app = Gtk::Application::create(argc, argv, "no.sout.juci"); - Window window; +} - return app->run(window);; +//////////////// +//// Window //// +//////////////// +std::shared_ptr Window::source() { + return std::shared_ptr(&source_); } diff --git a/juci/juci.h b/juci/juci.h index 37dc1ef..91e7937 100644 --- a/juci/juci.h +++ b/juci/juci.h @@ -1,25 +1,23 @@ /*juCi++ main header file*/ -#ifndef JUCI_H -#define JUCI_H +#ifndef JUCI_JUCI_H_ +#define JUCI_JUCI_H_ #include #include "gtkmm.h" #include "menu.h" - +#include "source.h" class Window : public Gtk::Window { public: - Window(); - - virtual ~Window(); - - Gtk::Box window_box_; - + Window(); + virtual ~Window(){}; + Gtk::Box window_box_; + std::shared_ptr source(); private: - Menu::Controller menu; - /*signal handler*/ - void onSystemQuit(); - + Menu::Controller menu; + Source::Controller source_; + /*signal handler*/ + void onSystemQuit(); }; -#endif // JUCI_H +#endif // JUCI_JUCI_H_ diff --git a/juci/menu.cc b/juci/menu.cc index bdd00f7..ac6d9ee 100644 --- a/juci/menu.cc +++ b/juci/menu.cc @@ -68,13 +68,14 @@ void Menu::View::set_ui_manger_string(std::string ui_string) { } } -void Menu::View::set_ui_manager_action_group(Glib::RefPtr action_group) { +void Menu::View::set_ui_manager_action_group(Glib::RefPtr + action_group) { ui_manager_->insert_action_group(action_group); } -Gtk::Box &Menu::View::view() { +Glib::RefPtr Menu::View::view() { view_.pack_start(*ui_manager_->get_widget("/MenuBar"), Gtk::PACK_SHRINK); - return view_; + return Glib::RefPtr(&view_); } @@ -184,8 +185,8 @@ Menu::Controller::~Controller() { } -Gtk::Box &Menu::Controller::view() { - return menu_view_.view(); +Glib::RefPtr Menu::Controller::view() { + return menu_view_.view(); } void Menu::Controller::onFileNewEmptyfile() { @@ -204,7 +205,7 @@ void Menu::Controller::onFileNewHeaderFile() { 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() { std::cout << "Add snipper" << std::endl; //TODO(Forgi add you snippet magic code) @@ -244,4 +245,4 @@ void Menu::Controller::onWindowSplitWindow() { void Menu::Controller::onHelpAbout() { std::cout << "Clicked about" << std::endl; //TODO(Oyvang) Legg til funksjon -} \ No newline at end of file +} diff --git a/juci/menu.h b/juci/menu.h index e7d3437..1fe345e 100644 --- a/juci/menu.h +++ b/juci/menu.h @@ -1,90 +1,65 @@ +#ifndef JUCI_MENU_H_ +#define JUCI_MENU_H_ + #include #include "gtkmm.h" namespace Menu { - class Model { - public: - Model(); - - virtual~Model(); - - std::string ui_string() { - return ui_string_; - }; - private: - std::string ui_string_; - }; - - - class View { - public: - View(Gtk::Orientation orient); - - virtual ~View(); - - Gtk::Box &view(); - - Glib::RefPtr action_group() { - return action_group_; - }; - - Glib::RefPtr ui_manager() { - return ui_manager_; - }; - - void set_ui_manger_string(std::string ui_string); - - void set_ui_manager_action_group(Glib::RefPtr action_group); - - protected: - Gtk::Box view_; - Glib::RefPtr ui_manager_; - Glib::RefPtr action_group_; - }; - - class Controller { - public: - Controller(); - - virtual ~Controller(); - - Gtk::Box &view(); - - Glib::RefPtr ui_manager() { - return menu_view_.ui_manager(); - }; - - private: - Menu::View menu_view_; - Menu::Model menu_model_; - - /*Signal handlers*/ - void onFileNewEmptyfile(); - - void onFileNewCCFile(); - - void onFileNewHeaderFile(); - - void onFileOpenFile(); - - void onFileOpenFolder(); - - void onSystemQuit(); - - void onPluginAddSnippet(); - - void onWindowCloseTab(); - - void onEditCopy(); - - void onEditCut(); - - void onEditPaste(); - - void onEditFind(); - - void onWindowSplitWindow(); - - void onHelpAbout(); - - }; -} \ No newline at end of file + class Model { + public: + Model(); + virtual~Model(); + std::string ui_string() { return ui_string_; } + private: + std::string ui_string_; + }; // class Model + + class View { + public: + explicit View(Gtk::Orientation orient); + virtual ~View(); + Glib::RefPtr view(); + Glib::RefPtr action_group() { + return action_group_; + } + Glib::RefPtr ui_manager() { + return ui_manager_; + } + void set_ui_manger_string(std::string ui_string); + void set_ui_manager_action_group( + Glib::RefPtr action_group); + + protected: + Gtk::Box view_; + Glib::RefPtr ui_manager_; + Glib::RefPtr action_group_; + }; // class View + // controller + class Controller { + public: + Controller(); + virtual ~Controller(); + Glib::RefPtr view(); + Glib::RefPtr ui_manager() { + return menu_view_.ui_manager(); + } + + private: + View menu_view_; + Model menu_model_; + void onFileNewEmptyfile(); /*Signal handlers*/ + void onFileNewCCFile(); + void onFileNewHeaderFile(); + void onFileOpenFile(); + void onFileOpenFolder(); + void onSystemQuit(); + void onPluginAddSnippet(); + void onWindowCloseTab(); + void onEditCopy(); + void onEditCut(); + void onEditPaste(); + void onEditFind(); + void onWindowSplitWindow(); + void onHelpAbout(); + }; // class Controller +} // namespace Menu +#endif // JUCI_MENU_H_ diff --git a/juci/source.cc b/juci/source.cc new file mode 100644 index 0000000..8070f7e --- /dev/null +++ b/juci/source.cc @@ -0,0 +1,47 @@ +#include "source.h" +#include + +using namespace std; + + +////////////// +//// View //// +////////////// +Source::View::View() { + cout << "View construktor run" << endl; +} + +void Source::View::UpdateLine(Glib::RefPtr mark) { + cout << "Update line called. linum: " << mark->get_iter().get_line() << endl; +} + +/////////////// +//// Model //// +/////////////// +Source::Model::Model(){ + cout << "Model construktor run" << endl; +} + +//////////////////// +//// Controller //// +//////////////////// + +/** + * + */ +Source::Controller::Controller() { + cout << "Controller construktor run" << endl; +} +/** + * + */ +std::shared_ptr Source::Controller::sourceview() { + sourceview(); + return std::shared_ptr(&sourceview_); +} +/** + * + */ +void Source::Controller::OnLineEdit(Glib::RefPtr mark){ + +} diff --git a/juci/source.h b/juci/source.h new file mode 100644 index 0000000..773b15e --- /dev/null +++ b/juci/source.h @@ -0,0 +1,31 @@ +#ifndef JUCI_SOURCE_H_ +#define JUCI_SOURCE_H_ + +#include +#include "gtkmm.h" + +namespace Source { + class View : public Gtk::TextView { + public: + View(); + void UpdateLine(Glib::RefPtr mark); + private: + void UpdateSyntaxHighlighting(int line_number); + }; + + class Model{ + public: + Model(); + }; + + class Controller { + public: + Controller(); + std::shared_ptr sourceview(); + private: + void OnLineEdit(Glib::RefPtr mark); + protected: + View sourceview_; + }; // class Controller +} // namespace Source +#endif // JUCI_SOURCE_H_ diff --git a/juci/window.cc b/juci/window.cc index 7c25a9d..5675c4a 100644 --- a/juci/window.cc +++ b/juci/window.cc @@ -1,26 +1,16 @@ #include "juci.h" Window::Window() : - window_box_(Gtk::ORIENTATION_HORIZONTAL), - menu() { - - - set_title("example juCi++"); - set_default_size(600, 600); - - add(window_box_); - - add_accel_group(menu.ui_manager()->get_accel_group()); - - window_box_.pack_start(menu.view()); - - - show_all_children(); -}; - - -Window::~Window() { - + window_box_(Gtk::ORIENTATION_HORIZONTAL), + menu(), + source_() { + 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()); + show_all_children(); }