#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" " " "
" "
" "" " " " _Edit" "
" " " " _Undo" " app.edit_undo" " " " " " _Redo" " app.edit_redo" " " "
" "
" " " " _Cut" " app.edit_cut" " " " " " _Copy" " app.edit_copy" " " " " " _Paste" " app.edit_paste" " " "
" "
" " " " _Find" " app.edit_find" " " "
" "
" "" " " " _Source" "
" " " " _Spell _Check" " " " _Spell _Check _Buffer" " app.source_spellcheck" " " " " " _Clear _Spelling _Errors" " app.source_spellcheck_clear" " " " " " _Go _to _Next _Spelling _Error" " app.source_spellcheck_next_error" " " " " "
" "
" " " " _Indentation" " " " _Set _Current _Buffer _Tab" " app.source_indentation_set_buffer_tab" " " " " " _Auto-Indent _Current _Buffer" " app.source_indentation_auto_indent_buffer" " " " " "
" "
" " " " _Go _to _Line" " app.source_goto_line" " " " " " _Center _Cursor" " app.source_center_cursor" " " "
" "
" " " " _Find _Documentation" " app.source_find_documentation" " " "
" "
" " " " _Go to Declaration" " app.source_goto_declaration" " " " " " _Go to Method" " app.source_goto_method" " " " " " _Rename" " app.source_rename" " " "
" "
" " " " _Go to Next Diagnostic" " app.source_goto_next_diagnostic" " " " " " _Apply Fix-Its" " app.source_apply_fix_its" " " "
" "
" "" " " " _Project" "
" " " " _Compile _and _Run" " app.compile_and_run" " " " " " _Compile" " app.compile" " " "
" "
" " " " _Run _Command" " app.run_command" " " " " " _Kill _Last _Process" " app.kill_last_running" " " " " " _Force _Kill _Last _Process" " app.force_kill_last_running" " " "
" "
" "" " " " _Window" "
" " " " _Next _Tab" " app.next_tab" " " " " " _Previous _Tab" " app.previous_tab" " " "
" "
" " " " _Close _Tab" " app.close_tab" " " "
" "
" "
" "
"; } void Menu::add_action(const std::string &name, std::function action) { auto application = builder->get_application(); actions[name]=application->add_action(name, action); } void Menu::set_keys() { auto application = builder->get_application(); for(auto &key: Singleton::Config::menu()->keys) { if(key.second.size()>0 && actions.find(key.first)!=actions.end()) application->set_accel_for_action("app."+key.first, 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(); } }