#include "menu.h" #include "singletons.h" #include #include using namespace std; //TODO: remove Menu::Menu() { ui_xml = "" " " "
" " " " _About" " app.about" " " "
" "
" " " " _Preferences" " app.preferences" " " "
" "
" " " " _Quit" " app.quit" " " "
" "
" "" " " " " " _File" "
" " " " _New _File" " app.new_file" " " " " " _New _Directory" " app.new_folder" " " " " " _New _Project" " " " C++" " app.new_project_cpp" " " " " "
" "
" " " " _Open _File" " app.open_file" " " " " " _Open _Folder" " app.open_folder" " " "
" "
" " " " _Save" " app.save" " " " " " _Save _As" " app.save_as" " " "
" "
" "
" "
"; } void Menu::add_action(const std::string &name, std::function action) { auto application = builder->get_application(); actions[name]=application->add_action(name, action); auto key=Singleton::Config::menu()->keys.find(name); if(key!=Singleton::Config::menu()->keys.end()) application->set_accel_for_action("app."+name, key->second); } void Menu::build() { builder = Gtk::Builder::create(); try { builder->add_from_string(ui_xml); } catch (const Glib::Error &ex) { std::cerr << "building menu failed: " << ex.what(); } }