|
|
|
@ -53,131 +53,115 @@ Menu::Model::~Model() { |
|
|
|
Menu::View::View(Gtk::Orientation orientation) : |
|
|
|
Menu::View::View(Gtk::Orientation orientation) : |
|
|
|
view_(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<Gtk::ActionGroup> action_group) { |
|
|
|
|
|
|
|
ui_manager_->insert_action_group(action_group); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Gtk::Box &Menu::View::view() { |
|
|
|
Gtk::Box &Menu::View::view(Glib::RefPtr<Gtk::UIManager> ui_manager) { |
|
|
|
view_.pack_start(*ui_manager_->get_widget("/MenuBar"), Gtk::PACK_SHRINK); |
|
|
|
view_.pack_start(*ui_manager->get_widget("/MenuBar"), Gtk::PACK_SHRINK); |
|
|
|
return view_; |
|
|
|
return view_; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Menu::View::~View() { |
|
|
|
Menu::View::~View() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/***********************************/ |
|
|
|
/***********************************/ |
|
|
|
/* CONTROLLER */ |
|
|
|
/* CONTROLLER */ |
|
|
|
/***********************************/ |
|
|
|
/***********************************/ |
|
|
|
Menu::Controller::Controller() : |
|
|
|
Menu::Controller::Controller(Keybindings::Controller keybindings) : |
|
|
|
menu_view_(Gtk::ORIENTATION_VERTICAL), |
|
|
|
menu_view_(Gtk::ORIENTATION_VERTICAL), |
|
|
|
menu_model_() { |
|
|
|
menu_model_(), |
|
|
|
|
|
|
|
keybindings_(keybindings){ |
|
|
|
/* Add action to menues */ |
|
|
|
/* Add action to menues */ |
|
|
|
/* START file menu */ |
|
|
|
/* START file menu */ |
|
|
|
menu_view_.action_group()->add(Gtk::Action::create("FileMenu", Gtk::Stock::FILE)); |
|
|
|
keybindings_.action_group()->add(Gtk::Action::create("FileMenu", Gtk::Stock::FILE)); |
|
|
|
/* File->New files */ |
|
|
|
/* File->New files */ |
|
|
|
menu_view_.action_group()->add(Gtk::Action::create("FileNew", "New")); |
|
|
|
keybindings_.action_group()->add(Gtk::Action::create("FileNew", "New")); |
|
|
|
|
|
|
|
keybindings_.action_group()->add(Gtk::Action::create("FileNewStandard", |
|
|
|
menu_view_.action_group()->add(Gtk::Action::create("FileNewStandard", |
|
|
|
|
|
|
|
Gtk::Stock::NEW, "New empty file", "Create a new file"), |
|
|
|
Gtk::Stock::NEW, "New empty file", "Create a new file"), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
onFileNewEmptyfile(); |
|
|
|
OnFileNewEmptyfile(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
menu_view_.action_group()->add(Gtk::Action::create("FileNewCC", |
|
|
|
keybindings_.action_group()->add(Gtk::Action::create("FileNewCC", |
|
|
|
Gtk::Stock::NEW, "New cc file", "Create a new cc file"), |
|
|
|
Gtk::Stock::NEW, "New cc file", "Create a new cc file"), |
|
|
|
Gtk::AccelKey("<control><alt>c"), |
|
|
|
Gtk::AccelKey("<control><alt>c"), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
onFileNewCCFile(); |
|
|
|
OnFileNewCCFile(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
menu_view_.action_group()->add(Gtk::Action::create("FileNewH", |
|
|
|
keybindings_.action_group()->add(Gtk::Action::create("FileNewH", |
|
|
|
Gtk::Stock::NEW, "New h file", "Create a new h file"), |
|
|
|
Gtk::Stock::NEW, "New h file", "Create a new h file"), |
|
|
|
Gtk::AccelKey("<control><alt>h"), |
|
|
|
Gtk::AccelKey("<control><alt>h"), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
onFileNewHeaderFile(); |
|
|
|
OnFileNewHeaderFile(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
/* File-> New files end */ |
|
|
|
/* File-> New files end */ |
|
|
|
menu_view_.action_group()->add(Gtk::Action::create("FileOpenFile", Gtk::Stock::OPEN), |
|
|
|
keybindings_.action_group()->add(Gtk::Action::create("FileOpenFile", Gtk::Stock::OPEN), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
onFileOpenFile(); |
|
|
|
OnFileOpenFile(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
menu_view_.action_group()->add(Gtk::Action::create("FileOpenFolder", "Open folder"), |
|
|
|
keybindings_.action_group()->add(Gtk::Action::create("FileOpenFolder", "Open folder"), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
onFileOpenFolder(); |
|
|
|
OnFileOpenFolder(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
menu_view_.action_group()->add(Gtk::Action::create("FileQuit", Gtk::Stock::QUIT), |
|
|
|
keybindings_.action_group()->add(Gtk::Action::create("FileQuit", Gtk::Stock::QUIT), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
onSystemQuit(); |
|
|
|
OnSystemQuit(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
/* END file menu */ |
|
|
|
/* END file menu */ |
|
|
|
/* START edit menu */ |
|
|
|
/* START edit menu */ |
|
|
|
menu_view_.action_group()->add(Gtk::Action::create("EditMenu", Gtk::Stock::EDIT)); |
|
|
|
keybindings_.action_group()->add(Gtk::Action::create("EditMenu", Gtk::Stock::EDIT)); |
|
|
|
menu_view_.action_group()->add(Gtk::Action::create("EditCopy", Gtk::Stock::COPY), |
|
|
|
keybindings_.action_group()->add(Gtk::Action::create("EditCopy", Gtk::Stock::COPY), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
onEditCopy(); |
|
|
|
OnEditCopy(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
menu_view_.action_group()->add(Gtk::Action::create("EditCut", Gtk::Stock::CUT), |
|
|
|
keybindings_.action_group()->add(Gtk::Action::create("EditCut", Gtk::Stock::CUT), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
onEditCut(); |
|
|
|
OnEditCut(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
menu_view_.action_group()->add(Gtk::Action::create("EditPaste", Gtk::Stock::PASTE), |
|
|
|
keybindings_.action_group()->add(Gtk::Action::create("EditPaste", Gtk::Stock::PASTE), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
onEditPaste(); |
|
|
|
OnEditPaste(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
menu_view_.action_group()->add(Gtk::Action::create("EditFind", Gtk::Stock::FIND), |
|
|
|
keybindings_.action_group()->add(Gtk::Action::create("EditFind", Gtk::Stock::FIND), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
onEditFind(); |
|
|
|
OnEditFind(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
/* END edit menu */ |
|
|
|
/* END edit menu */ |
|
|
|
/* START window menu */ |
|
|
|
/* START window menu */ |
|
|
|
menu_view_.action_group()->add(Gtk::Action::create("WindowMenu", "_Window")); |
|
|
|
keybindings_.action_group()->add(Gtk::Action::create("WindowMenu", "_Window")); |
|
|
|
menu_view_.action_group()->add(Gtk::Action::create("WindowCloseTab", "Close tab"), |
|
|
|
keybindings_.action_group()->add(Gtk::Action::create("WindowCloseTab", "Close tab"), |
|
|
|
Gtk::AccelKey("<control>w"), |
|
|
|
Gtk::AccelKey("<control>w"), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
onWindowCloseTab(); |
|
|
|
OnWindowCloseTab(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
menu_view_.action_group()->add(Gtk::Action::create("WindowSplitWindow", "Split window"), |
|
|
|
keybindings_.action_group()->add(Gtk::Action::create("WindowSplitWindow", "Split window"), |
|
|
|
Gtk::AccelKey("<control><alt>S"), |
|
|
|
Gtk::AccelKey("<control><alt>S"), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
onWindowSplitWindow(); |
|
|
|
OnWindowSplitWindow(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
/* END window menu */ |
|
|
|
/* END window menu */ |
|
|
|
/* START Plugin menu */ |
|
|
|
/* START Plugin menu */ |
|
|
|
menu_view_.action_group()->add(Gtk::Action::create("PluginMenu", "_Plugins")); |
|
|
|
keybindings_.action_group()->add(Gtk::Action::create("PluginMenu", "_Plugins")); |
|
|
|
/*Plugin->snippet*/ |
|
|
|
/*Plugin->snippet*/ |
|
|
|
menu_view_.action_group()->add(Gtk::Action::create("PluginSnippet", "Snippet")); |
|
|
|
keybindings_.action_group()->add(Gtk::Action::create("PluginSnippet", "Snippet")); |
|
|
|
menu_view_.action_group()->add(Gtk::Action::create("PluginAddSnippet", "Add snippet"), |
|
|
|
keybindings_.action_group()->add(Gtk::Action::create("PluginAddSnippet", "Add snippet"), |
|
|
|
Gtk::AccelKey("<alt>space"), |
|
|
|
Gtk::AccelKey("<alt>space"), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
onPluginAddSnippet(); |
|
|
|
OnPluginAddSnippet(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
/* End snippet */ |
|
|
|
/* End snippet */ |
|
|
|
/* END plugin menu */ |
|
|
|
/* END plugin menu */ |
|
|
|
/* START help menu */ |
|
|
|
/* START help menu */ |
|
|
|
menu_view_.action_group()->add(Gtk::Action::create("HelpMenu", Gtk::Stock::HELP)); |
|
|
|
keybindings_.action_group()->add(Gtk::Action::create("HelpMenu", Gtk::Stock::HELP)); |
|
|
|
menu_view_.action_group()->add(Gtk::Action::create("HelpAbout", Gtk::Stock::ABOUT), |
|
|
|
keybindings_.action_group()->add(Gtk::Action::create("HelpAbout", Gtk::Stock::ABOUT), |
|
|
|
[this]() { |
|
|
|
[this]() { |
|
|
|
onHelpAbout(); |
|
|
|
OnHelpAbout(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* END help menu */ |
|
|
|
/* END help menu */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
menu_view_.set_ui_manager_action_group(menu_view_.action_group()); |
|
|
|
keybindings_.ui_manager()->add_ui_from_string(menu_model_.ui_string()); |
|
|
|
menu_view_.set_ui_manger_string(menu_model_.ui_string()); |
|
|
|
keybindings_.ui_manager()->insert_action_group(keybindings_.action_group()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Menu::Controller::~Controller() { |
|
|
|
Menu::Controller::~Controller() { |
|
|
|
@ -185,63 +169,75 @@ Menu::Controller::~Controller() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Gtk::Box &Menu::Controller::view() { |
|
|
|
Gtk::Box &Menu::Controller::view() { |
|
|
|
return menu_view_.view(); |
|
|
|
return menu_view_.view(keybindings_.ui_manager()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Menu::Controller::onFileNewEmptyfile() { |
|
|
|
void Menu::Controller::OnFileNewEmptyfile() { |
|
|
|
std::cout << "New file clicked" << std::endl; |
|
|
|
std::cout << "New file clicked" << std::endl; |
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
} |
|
|
|
} |
|
|
|
void Menu::Controller::onFileNewCCFile() { |
|
|
|
|
|
|
|
|
|
|
|
void Menu::Controller::OnFileNewCCFile() { |
|
|
|
std::cout << "New cc file clicked" << std::endl; |
|
|
|
std::cout << "New cc file clicked" << std::endl; |
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Menu::Controller::onFileNewHeaderFile() { |
|
|
|
void Menu::Controller::OnFileNewHeaderFile() { |
|
|
|
std::cout << "New cc file clicked" << std::endl; |
|
|
|
std::cout << "New cc file clicked" << std::endl; |
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
} |
|
|
|
} |
|
|
|
void Menu::Controller::onSystemQuit(){ |
|
|
|
|
|
|
|
|
|
|
|
void Menu::Controller::OnSystemQuit() { |
|
|
|
//TODO(Oyvang, Zalox, Forgie) Add everything that needs to be done before quiting
|
|
|
|
//TODO(Oyvang, Zalox, Forgie) Add everything that needs to be done before quiting
|
|
|
|
/*Quit the system*/ |
|
|
|
/*Quit the system*/ |
|
|
|
Gtk::Main::quit(); //TODO(Oyvang, Zalox, Forgie) methode is depricated, find a better solution.
|
|
|
|
Gtk::Main::quit(); //TODO(Oyvang, Zalox, Forgie) methode is depricated, find a better solution.
|
|
|
|
} |
|
|
|
} |
|
|
|
void Menu::Controller::onPluginAddSnippet() { |
|
|
|
|
|
|
|
|
|
|
|
void Menu::Controller::OnPluginAddSnippet() { |
|
|
|
std::cout << "Add snipper" << std::endl; //TODO(Forgi add you snippet magic code)
|
|
|
|
std::cout << "Add snipper" << std::endl; //TODO(Forgi add you snippet magic code)
|
|
|
|
} |
|
|
|
} |
|
|
|
void Menu::Controller::onFileOpenFile() { |
|
|
|
|
|
|
|
|
|
|
|
void Menu::Controller::OnFileOpenFile() { |
|
|
|
std::cout << "Open file clicked" << std::endl; |
|
|
|
std::cout << "Open file clicked" << std::endl; |
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
} |
|
|
|
} |
|
|
|
void Menu::Controller::onFileOpenFolder() { |
|
|
|
|
|
|
|
|
|
|
|
void Menu::Controller::OnFileOpenFolder() { |
|
|
|
std::cout << "Open folder clicked" << std::endl; |
|
|
|
std::cout << "Open folder clicked" << std::endl; |
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
} |
|
|
|
} |
|
|
|
void Menu::Controller::onWindowCloseTab() { |
|
|
|
|
|
|
|
|
|
|
|
void Menu::Controller::OnWindowCloseTab() { |
|
|
|
std::cout << "Closing tab clicked" << std::endl; |
|
|
|
std::cout << "Closing tab clicked" << std::endl; |
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
} |
|
|
|
} |
|
|
|
void Menu::Controller::onEditCopy() { |
|
|
|
|
|
|
|
|
|
|
|
void Menu::Controller::OnEditCopy() { |
|
|
|
std::cout << "Clicked copy" << std::endl; |
|
|
|
std::cout << "Clicked copy" << std::endl; |
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
} |
|
|
|
} |
|
|
|
void Menu::Controller::onEditCut() { |
|
|
|
|
|
|
|
|
|
|
|
void Menu::Controller::OnEditCut() { |
|
|
|
std::cout << "Clicked cut" << std::endl; |
|
|
|
std::cout << "Clicked cut" << std::endl; |
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
} |
|
|
|
} |
|
|
|
void Menu::Controller::onEditPaste() { |
|
|
|
|
|
|
|
|
|
|
|
void Menu::Controller::OnEditPaste() { |
|
|
|
std::cout << "Clicked paste" << std::endl; |
|
|
|
std::cout << "Clicked paste" << std::endl; |
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
} |
|
|
|
} |
|
|
|
void Menu::Controller::onEditFind() { |
|
|
|
|
|
|
|
|
|
|
|
void Menu::Controller::OnEditFind() { |
|
|
|
std::cout << "Clicked find" << std::endl; |
|
|
|
std::cout << "Clicked find" << std::endl; |
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
} |
|
|
|
} |
|
|
|
void Menu::Controller::onWindowSplitWindow() { |
|
|
|
|
|
|
|
|
|
|
|
void Menu::Controller::OnWindowSplitWindow() { |
|
|
|
std::cout << "Clicked split window" << std::endl; |
|
|
|
std::cout << "Clicked split window" << std::endl; |
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
} |
|
|
|
} |
|
|
|
void Menu::Controller::onHelpAbout() { |
|
|
|
|
|
|
|
|
|
|
|
void Menu::Controller::OnHelpAbout() { |
|
|
|
std::cout << "Clicked about" << std::endl; |
|
|
|
std::cout << "Clicked about" << std::endl; |
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
//TODO(Oyvang) Legg til funksjon
|
|
|
|
} |
|
|
|
} |