diff --git a/.gitignore b/.gitignore index def795e..36c3170 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,8 @@ !*/ + #Whitelist !*.cc !*.h -!*.txt +!CMakeLists.txt diff --git a/juci/CMakeLists.txt b/juci/CMakeLists.txt index 2ac0a08..17febd9 100644 --- a/juci/CMakeLists.txt +++ b/juci/CMakeLists.txt @@ -1,27 +1,79 @@ cmake_minimum_required (VERSION 2.8.4) -project (juci) +set(project_name juci) + +project (${project_name}) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") INCLUDE(FindPkgConfig) +#### Finding boost, the variables below is set ##### +#PYTHONLIBS_FOUND - True if headers and requested libraries were found +#PYTHON_INCLUDE_DIRS - Boost include directories +#PYTHON_LIBRARIES - Boost component libraries to be linked +find_package(PythonLibs 2.7) + +#If python is found +if(${PYTHONLIBS_FOUND}) + message("Python libraries found. Continuing") +else() + message("Please install python libraries. The libraries where not found.") + message("Python include dirs: ${PYTHON_INCLUDE_DIRS}") + message("Python link dirs ${PYTHON_LIBRARIES}") + message(FATAL_ERROR "The python libraries are required. Quitting.") +endif() + +#### Finding boost, the variables below is set ##### +#Boost_FOUND - True if headers and requested libraries were found +#Boost_INCLUDE_DIRS - Boost include directories +#Boost_LIBRARY_DIRS - Link directories for Boost libraries +#Boost_LIBRARIES - Boost component libraries to be linked +find_package(Boost 1.5 REQUIRED) + +#If boost is not found +if(${Boost_FOUND}) + message("Boost libraries found. Continuing") +else() + message("Please install boost libraries. The libraries where not found.") + message("Boost library dirs: ${Boost_LIBRARY_DIRS}") + message("Boost include dirs: ${Boost_INCLUDE_DIRS}") + message("Boost link dirs ${Boost_LIBRARIES}") + message(FATAL_ERROR "The boost libraries are required. Quitting.") +endif() + +#### Finding gtkmm, the variables below is set ##### +#GTKMM_FOUND - True if headers and requested libraries were found +#GTKMM_INCLUDE_DIRS - GTKMM include directories +#GTKMM_LIBRARY_DIRS - Link directories for GTKMM libraries +#GTKMM_LIBRARIES - GTKMM libraries to be linked +pkg_check_modules(GTKMM gtkmm-3.0) # The name GTKMM is set here for the variables abouve + +#If gtkmm is not found +if(${GTKMM_FOUND}) + message("Gtkmm libraries found. Continuing") +else() + message("Please install gtkmm libraries. The libraries where not found.") + message("Gtkmm library dirs ${GTKMM_LIBRARY_DIRS}") + message("Gtkmm include dirs ${GTKMM_INCLUDE_DIRS}") + message("Gtkmm link dirs ${GTKMM_LIBRARIES}") + message(FATAL_ERROR "The gtkmm libraries are required. Quitting.") +endif() + + # name of the executable on Windows will be example.exe -add_executable(juci +add_executable(${project_name} # list of every needed file to create the executable - model.h - models.cc + menu.h - view.h - views.cc - - controller.h - controllers.cc + menu.cc window.cc juci.cc ) # dependencies - pkg_check_modules(GTKMM REQUIRED gtkmm-3.0) - include_directories(${GTKMM_INCLUDE_DIRS} ) - link_directories(${GTKMM_LIBRARY_DIRS}) - target_link_libraries(juci ${GTKMM_LIBRARIES}) \ No newline at end of file + +include_directories(${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS} ${GTKMM_INCLUDE_DIRS}) +link_directories(${GTKMM_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS}) +target_link_libraries(${project_name} ${GTKMM_LIBRARIES} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES}) + diff --git a/juci/controller.h b/juci/controller.h deleted file mode 100644 index b9e79a9..0000000 --- a/juci/controller.h +++ /dev/null @@ -1,43 +0,0 @@ -/*juCi++ controller header file*/ -#ifndef CONTROLLER_H -#define CONTROLLER_H - -#include "view.h" -#include "model.h" - -/* -------------------------- HOW TO ----------------------------- */ -/* Controll classes under Controller->public */ -/* Model object under Controller::class->private name:class_model */ -/* View object under Controller::class->private name:class_view */ -/* ------------------ Remove these comments ---------------------- */ - -class Controller { -public: - class Menu { - public: - Menu(); - - virtual ~Menu(); - Gtk::Box &view(); - - Glib::RefPtr ui_manager() { - return menu_view_.ui_manager(); - }; - - private: - View::Menu menu_view_; - Model::Menu menu_model_; - /*Signal handlers*/ - void onFileNewEmptyfile(); - void onFileNewCCFile(); - void onFileNewHeaderFile(); - void onFileOpenFile(); - void onFileOpenFolder(); - void onSystemQuit(); - void onPluginAddSnippet(); - - }; -}; - - -#endif //CONTROLLER_H \ No newline at end of file diff --git a/juci/controllers.cc b/juci/controllers.cc deleted file mode 100644 index f6ab2e7..0000000 --- a/juci/controllers.cc +++ /dev/null @@ -1,80 +0,0 @@ -#include "controller.h" - -Controller::Menu::Menu() : - menu_view_(Gtk::ORIENTATION_VERTICAL), - menu_model_() { -/*Add action to menues*/ -/*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]() { - onFileNewEmptyfile(); - }); - menu_view_.action_group()->add(Gtk::Action::create("FileOpenFolder", "Open folder"), - [this]() { - onFileNewEmptyfile(); - }); - menu_view_.action_group()->add(Gtk::Action::create("FileQuit", Gtk::Stock::QUIT), - [this]() { - onSystemQuit(); - }); - menu_view_.action_group()->add(Gtk::Action::create("PluginMenu", "Plugins")); - 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(); - }); - - - menu_view_.set_ui_manager_action_group(menu_view_.action_group()); - menu_view_.set_ui_manger_string(menu_model_.ui_string()); -} - -Controller::Menu::~Menu() { - -} - -Gtk::Box &Controller::Menu::view() { - return menu_view_.view(); -} - -void Controller::Menu::onFileNewEmptyfile() { - std::cout << "New file clicked" << std::endl; -} -void Controller::Menu::onFileNewCCFile() { - std::cout << "New cc file clicked" << std::endl; -} - -void Controller::Menu::onFileNewHeaderFile() { - std::cout << "New cc file clicked" << std::endl; -} -void Controller::Menu::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 Controller::Menu::onPluginAddSnippet() { - std::cout << "Add snipper" << std::endl; //TODO(Forgi add you snippet magic code) -} diff --git a/juci/juci.h b/juci/juci.h index 7df1832..37dc1ef 100644 --- a/juci/juci.h +++ b/juci/juci.h @@ -4,9 +4,7 @@ #include #include "gtkmm.h" -#include "view.h" -#include "model.h" -#include "controller.h" +#include "menu.h" class Window : public Gtk::Window { @@ -18,7 +16,7 @@ public: Gtk::Box window_box_; private: - Controller::Menu menu; + Menu::Controller menu; /*signal handler*/ void onSystemQuit(); diff --git a/juci/menu.cc b/juci/menu.cc new file mode 100644 index 0000000..bdd00f7 --- /dev/null +++ b/juci/menu.cc @@ -0,0 +1,247 @@ +#include "menu.h" + +/***********************************/ +/* MODEL */ +/***********************************/ + + +Menu::Model::Model() { + ui_string_ = + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " "; + +} + +Menu::Model::~Model() { +} + +/***********************************/ +/* VIEW */ +/***********************************/ +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_; +} + + +Menu::View::~View() { +} + +/***********************************/ +/* CONTROLLER */ +/***********************************/ +Menu::Controller::Controller() : + menu_view_(Gtk::ORIENTATION_VERTICAL), + menu_model_() { +/* 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(); + }); +/* 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(); + }); +/* 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(); + }); +/* 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 */ +/* 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(); + }); +/* END help menu */ + + + menu_view_.set_ui_manager_action_group(menu_view_.action_group()); + menu_view_.set_ui_manger_string(menu_model_.ui_string()); +} + +Menu::Controller::~Controller() { + +} + +Gtk::Box &Menu::Controller::view() { + return menu_view_.view(); +} + +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::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::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::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::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::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::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 +} \ No newline at end of file diff --git a/juci/menu.h b/juci/menu.h new file mode 100644 index 0000000..e7d3437 --- /dev/null +++ b/juci/menu.h @@ -0,0 +1,90 @@ +#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 diff --git a/juci/model.h b/juci/model.h deleted file mode 100644 index d244cdf..0000000 --- a/juci/model.h +++ /dev/null @@ -1,28 +0,0 @@ -/*juCi++ model header file*/ -#ifndef MODEL_H -#define MODEL_H - -#include "gtkmm.h" - -/* -------------------------- HOW TO -------------------------- */ -/* Model classes under Model if possible */ -/* ------------------ Remove these comments ------------------- */ - -class Model { -public: - class Menu { - public: - Menu(); - - virtual~Menu(); - - std::string ui_string() { - return ui_string_; - }; - private: - std::string ui_string_; - }; - -}; - -#endif //MODEL_H \ No newline at end of file diff --git a/juci/models.cc b/juci/models.cc deleted file mode 100644 index 4b7f70a..0000000 --- a/juci/models.cc +++ /dev/null @@ -1,30 +0,0 @@ -#include "model.h" - -Model::Menu::Menu() { - ui_string_ = - " " - " " - " " - " " - " " - " " - " " - " " - // " " - //" " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " "; - - // TODO(oyvang) legg til under en meny Window -} - -Model::Menu::~Menu() { -} \ No newline at end of file diff --git a/juci/view.h b/juci/view.h deleted file mode 100644 index 50316c0..0000000 --- a/juci/view.h +++ /dev/null @@ -1,43 +0,0 @@ -/*juCi++ view header file*/ -#ifndef VIEW_H -#define VIEW_H - -#include "gtkmm.h" -#include "iostream" - -/* -------------------------- HOW TO -------------------------- */ -/* All view shall be under View if possible */ -/* ------------------ Remove these comments ------------------- */ - - -class View { -public: - class Menu { - public: - Menu(Gtk::Orientation orient); - - virtual ~Menu(); - - 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_; - }; - - -}; - -#endif // VIEW_H \ No newline at end of file diff --git a/juci/views.cc b/juci/views.cc deleted file mode 100644 index cfb63c3..0000000 --- a/juci/views.cc +++ /dev/null @@ -1,36 +0,0 @@ -#include "view.h" - - -/***********************************/ -/* MENU */ -/***********************************/ -View::Menu::Menu(Gtk::Orientation orientation) : - view_(orientation) { - - action_group_ = Gtk::ActionGroup::create(); - ui_manager_ = Gtk::UIManager::create(); - - -} - -void View::Menu::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 View::Menu::set_ui_manager_action_group(Glib::RefPtr action_group) { - ui_manager_->insert_action_group(action_group); -} - -Gtk::Box &View::Menu::view() { - view_.pack_start(*ui_manager_->get_widget("/MenuBar"), Gtk::PACK_SHRINK); - return view_; -} - - -View::Menu::~Menu() { -} \ No newline at end of file