From 6249f25238ddc6abfadfb977077d1ce0b61d0e09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Wed, 11 Feb 2015 10:55:36 +0100 Subject: [PATCH 1/3] fix return in source --- juci/source.cc | 41 +++++++++++++++++++---------------------- juci/source.h | 8 ++++++-- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/juci/source.cc b/juci/source.cc index 8070f7e..48c5a19 100644 --- a/juci/source.cc +++ b/juci/source.cc @@ -1,47 +1,44 @@ #include "source.h" #include -using namespace std; - - ////////////// //// View //// ////////////// Source::View::View() { - cout << "View construktor run" << endl; + std::cout << "View constructor run" << std::endl; } void Source::View::UpdateLine(Glib::RefPtr mark) { - cout << "Update line called. linum: " << mark->get_iter().get_line() << endl; + std::cout << "Update line called. linum: "; + std::cout << mark->get_iter().get_line() << std::endl; } /////////////// //// Model //// /////////////// -Source::Model::Model(){ - cout << "Model construktor run" << endl; +Source::Model::Model() { + std::cout << "Model constructor run" << std::endl; } //////////////////// //// Controller //// //////////////////// -/** - * - */ +// Source::Controller::Controller() +// Constructor for Controller Source::Controller::Controller() { - cout << "Controller construktor run" << endl; + std::cout << "Controller constructor run" << std::endl; } -/** - * - */ -std::shared_ptr Source::Controller::sourceview() { - sourceview(); - return std::shared_ptr(&sourceview_); +// Source::Controller::view() +// return shared_ptr to the view +std::shared_ptr Source::Controller::view() { + return std::shared_ptr(&view_); } -/** - * - */ -void Source::Controller::OnLineEdit(Glib::RefPtr mark){ - +// Source::Controller::model() +// return shared_ptr to the model() +std::shared_ptr Source::Controller::model() { + return std::shared_ptr(&model_); } +// Source::Controller::OnLineEdit() +// fired when a line in the buffer is edited +void Source::Controller::OnLineEdit(Glib::RefPtr mark) {} diff --git a/juci/source.h b/juci/source.h index 773b15e..8d5d9a6 100644 --- a/juci/source.h +++ b/juci/source.h @@ -21,11 +21,15 @@ namespace Source { class Controller { public: Controller(); - std::shared_ptr sourceview(); + std::shared_ptr view(); + std::shared_ptr model(); + private: void OnLineEdit(Glib::RefPtr mark); + protected: - View sourceview_; + View view_; + Model model_; }; // class Controller } // namespace Source #endif // JUCI_SOURCE_H_ From 19311982e01dc8bbb5f20b2df76094a2666d44e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Wed, 11 Feb 2015 11:39:58 +0100 Subject: [PATCH 2/3] Fix pointer settings --- juci/CMakeLists.txt | 3 ++- juci/juci.h | 4 ++-- juci/source.cc | 8 ++++---- juci/source.h | 4 ++-- juci/window.cc | 7 +++---- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/juci/CMakeLists.txt b/juci/CMakeLists.txt index 9d13438..5581401 100644 --- a/juci/CMakeLists.txt +++ b/juci/CMakeLists.txt @@ -67,11 +67,12 @@ endif() # name of the executable on Windows will be example.exe add_executable(${project_name} #list of every needed file to create the executable + juci.h + juci.cc keybindings menu source window - juci api #there is no need for extentions ) diff --git a/juci/juci.h b/juci/juci.h index 6eb5018..ab439b8 100644 --- a/juci/juci.h +++ b/juci/juci.h @@ -1,4 +1,4 @@ -/*juCi++ main header file*/ +//juCi++ main header file #ifndef JUCI_JUCI_H_ #define JUCI_JUCI_H_ @@ -12,7 +12,7 @@ public: Window(); virtual ~Window() {} Gtk::Box window_box_; - std::shared_ptr source(); + Source::Controller& source(); private: Keybindings::Controller keybindings_; Menu::Controller menu_; diff --git a/juci/source.cc b/juci/source.cc index 48c5a19..9fb3b05 100644 --- a/juci/source.cc +++ b/juci/source.cc @@ -31,13 +31,13 @@ Source::Controller::Controller() { } // Source::Controller::view() // return shared_ptr to the view -std::shared_ptr Source::Controller::view() { - return std::shared_ptr(&view_); +Source::View& Source::Controller::view() { + return view_; } // Source::Controller::model() // return shared_ptr to the model() -std::shared_ptr Source::Controller::model() { - return std::shared_ptr(&model_); +Source::Model& Source::Controller::model() { + return model_; } // Source::Controller::OnLineEdit() // fired when a line in the buffer is edited diff --git a/juci/source.h b/juci/source.h index 8d5d9a6..4c901f4 100644 --- a/juci/source.h +++ b/juci/source.h @@ -21,8 +21,8 @@ namespace Source { class Controller { public: Controller(); - std::shared_ptr view(); - std::shared_ptr model(); + View& view(); + Model& model(); private: void OnLineEdit(Glib::RefPtr mark); diff --git a/juci/window.cc b/juci/window.cc index 4e27b3b..977fc1a 100644 --- a/juci/window.cc +++ b/juci/window.cc @@ -5,14 +5,13 @@ Window::Window() : menu_(keybindings_) { set_title("example juCi++"); set_default_size(600, 600); - // window_box_.add(*source_.sourceview()); + window_box_.add(source().view()); add(window_box_); add_accel_group(keybindings_.ui_manager()->get_accel_group()); window_box_.pack_start(menu_.view()); show_all_children(); - } -std::shared_ptr Window::source() { - return std::shared_ptr(&source_); +Source::Controller& Window::source() { + return source_; } From 1144ce805a8192fb8bee51c76e0f28d642cb804f Mon Sep 17 00:00:00 2001 From: oyvang Date: Wed, 11 Feb 2015 12:32:32 +0100 Subject: [PATCH 3/3] fixed quit_system bug --- juci/juci.cc | 5 +++ juci/juci.h | 11 +++-- juci/keybindings.h | 4 +- juci/menu.cc | 25 +++-------- juci/menu.h | 109 +++++++++++++++++++++++++++------------------ juci/window.cc | 44 ++++++++++-------- 6 files changed, 114 insertions(+), 84 deletions(-) diff --git a/juci/juci.cc b/juci/juci.cc index c7726db..5b206f6 100644 --- a/juci/juci.cc +++ b/juci/juci.cc @@ -1,9 +1,14 @@ #include "juci.h" + + + int main(int argc, char *argv[]) { Glib::RefPtr app = Gtk::Application::create( argc, argv, "no.sout.juci"); + // app->set_flags(Gio::APPLICATION_NON_UNIQUE); + Window window; return app->run(window); } diff --git a/juci/juci.h b/juci/juci.h index 6eb5018..b5d2b25 100644 --- a/juci/juci.h +++ b/juci/juci.h @@ -10,15 +10,20 @@ class Window : public Gtk::Window { public: Window(); - virtual ~Window() {} - Gtk::Box window_box_; + + virtual ~Window() { + } + std::shared_ptr source(); + private: Keybindings::Controller keybindings_; Menu::Controller menu_; Source::Controller source_; + Gtk::Box window_box_; + /*signal handler*/ - void onSystemQuit(); + void OnSystemQuit(); }; #endif // JUCI_JUCI_H_ diff --git a/juci/keybindings.h b/juci/keybindings.h index 440d1f0..c15a50c 100644 --- a/juci/keybindings.h +++ b/juci/keybindings.h @@ -2,10 +2,10 @@ #include "gtkmm.h" namespace Keybindings { - class Controller { public: Controller(); + virtual ~Controller(); Glib::RefPtr action_group() { @@ -15,11 +15,11 @@ namespace Keybindings { 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_; diff --git a/juci/menu.cc b/juci/menu.cc index 9d028f2..2fcd916 100644 --- a/juci/menu.cc +++ b/juci/menu.cc @@ -7,7 +7,7 @@ Menu::Model::Model() { ui_string_ = - " " + " " " " " " " " @@ -52,11 +52,11 @@ Menu::Model::~Model() { Menu::View::View(Gtk::Orientation orientation) : view_(orientation) { - + } -Gtk::Box& Menu::View::view( - Glib::RefPtr ui_manager) { +Gtk::Box &Menu::View::view( + Glib::RefPtr ui_manager) { view_.pack_start(*ui_manager->get_widget("/MenuBar"), Gtk::PACK_SHRINK); return view_; } @@ -70,7 +70,7 @@ Menu::View::~View() { Menu::Controller::Controller(Keybindings::Controller keybindings) : menu_view_(Gtk::ORIENTATION_VERTICAL), menu_model_(), - keybindings_(keybindings){ + keybindings_(keybindings) { /* Add action to menues */ /* START file menu */ keybindings_.action_group()->add(Gtk::Action::create("FileMenu", Gtk::Stock::FILE)); @@ -79,7 +79,7 @@ Menu::Controller::Controller(Keybindings::Controller keybindings) : keybindings_.action_group()->add(Gtk::Action::create("FileNewStandard", Gtk::Stock::NEW, "New empty file", "Create a new file"), [this]() { - OnFileNewEmptyfile(); + OnFileNewEmptyfile(); }); keybindings_.action_group()->add(Gtk::Action::create("FileNewCC", Gtk::Stock::NEW, "New cc file", "Create a new cc file"), @@ -87,7 +87,6 @@ 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"), @@ -103,10 +102,6 @@ Menu::Controller::Controller(Keybindings::Controller keybindings) : [this]() { OnFileOpenFolder(); }); - keybindings_.action_group()->add(Gtk::Action::create("FileQuit", Gtk::Stock::QUIT), - [this]() { - OnSystemQuit(); - }); /* END file menu */ /* START edit menu */ keybindings_.action_group()->add(Gtk::Action::create("EditMenu", Gtk::Stock::EDIT)); @@ -169,7 +164,7 @@ Menu::Controller::Controller(Keybindings::Controller keybindings) : Menu::Controller::~Controller() { } -Gtk::Box& Menu::Controller::view() { +Gtk::Box &Menu::Controller::view() { return menu_view_.view(keybindings_.ui_manager()); } @@ -188,12 +183,6 @@ void Menu::Controller::OnFileNewHeaderFile() { //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*/ - -} - void Menu::Controller::OnPluginAddSnippet() { std::cout << "Add snipper" << std::endl; //TODO(Forgi add you snippet magic code) } diff --git a/juci/menu.h b/juci/menu.h index caa9e98..1eea96e 100644 --- a/juci/menu.h +++ b/juci/menu.h @@ -6,48 +6,71 @@ #include "keybindings.h" namespace Menu { - 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(); - Gtk::Box& view(Glib::RefPtr ui_manager); - - protected: - Gtk::Box view_; - }; // class View - // controller - class Controller { - public: - explicit Controller(Keybindings::Controller keybindings); - virtual ~Controller(); - Gtk::Box& view(); - private: - Keybindings::Controller keybindings_; - 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 + 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(); + + Gtk::Box &view(Glib::RefPtr ui_manager); + + protected: + Gtk::Box view_; + }; // class View + // controller + class Controller { + public: + explicit Controller(Keybindings::Controller keybindings); + + virtual ~Controller(); + + Gtk::Box &view(); + + private: + Keybindings::Controller keybindings_; + View menu_view_; + Model menu_model_; + + void OnFileNewEmptyfile(); + + /*Signal handlers*/ + void OnFileNewCCFile(); + + void OnFileNewHeaderFile(); + + void OnFileOpenFile(); + + void OnFileOpenFolder(); + + 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/window.cc b/juci/window.cc index 4e27b3b..7d7857c 100644 --- a/juci/window.cc +++ b/juci/window.cc @@ -1,18 +1,26 @@ -#include "juci.h" - -Window::Window() : - window_box_(Gtk::ORIENTATION_HORIZONTAL), - menu_(keybindings_) { - set_title("example juCi++"); - set_default_size(600, 600); - // window_box_.add(*source_.sourceview()); - add(window_box_); - add_accel_group(keybindings_.ui_manager()->get_accel_group()); - window_box_.pack_start(menu_.view()); - show_all_children(); - -} - -std::shared_ptr Window::source() { - return std::shared_ptr(&source_); -} +#include "juci.h" +Window::Window() : + window_box_(Gtk::ORIENTATION_HORIZONTAL), + menu_(keybindings_) { + set_title("juCi++"); + set_default_size(600, 600); + // window_box_.add(*source_.sourceview()); + add(window_box_); + keybindings_.action_group()->add(Gtk::Action::create("FileQuit", + Gtk::Stock::QUIT), + [this]() { + OnSystemQuit(); + }); + add_accel_group(keybindings_.ui_manager()->get_accel_group()); + //Add views under here + window_box_.pack_start(menu_.view()); + show_all_children(); +} + +std::shared_ptr Window::source() { + return std::shared_ptr(&source_); +} + +void Window::OnSystemQuit() { + hide(); +} \ No newline at end of file