#include "menu.h" #include "config.h" #include #include Menu::Menu() { ui_xml = R"RAW(
_About app.about
_Preferences app.preferences
_Quit app.quit
_File
_New _File app.new_file _New _Folder app.new_folder _New _Project C app.new_project_c C++ app.new_project_cpp
_Open _File app.open_file _Open _Folder app.open_folder
_Save app.save _Save _As app.save_as
_Print app.print
_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
_Git _Go _to _Next _Diff app.source_git_next_diff _Show _Diff app.source_git_show_diff
_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 _Symbol (Ctags) app.source_find_symbol_ctags
_Comments _Toggle _Comments app.source_comments_toggle _Add _Documentation (not yet implemented) app.source_comments_add_documentation _Find _Documentation app.source_find_documentation
_Go to Declaration app.source_goto_declaration _Go to Implementation app.source_goto_implementation _Go to Usage app.source_goto_usage _Go to Method app.source_goto_method _Rename app.source_rename _Implement _Method app.source_implement_method
_Go to Next Diagnostic app.source_goto_next_diagnostic _Apply Fix-Its app.source_apply_fix_its
_Project
_Set _Run _Arguments app.project_set_run_arguments _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
_Debug
_Set _Run _Arguments app.debug_set_run_arguments _Start/_Continue app.debug_start_continue _Stop app.debug_stop _Kill app.debug_kill
_Step _Over app.debug_step_over _Step _Into app.debug_step_into _Step _Out app.debug_step_out
_Backtrace app.debug_backtrace _Show _Variables app.debug_show_variables
_Run Command app.debug_run_command
_Toggle _Breakpoint app.debug_toggle_breakpoint
_Go _to _Stop app.debug_goto_stop
_Window
_Next _Tab app.next_tab _Previous _Tab app.previous_tab
_Close _Tab app.close_tab
_Toggle _Split app.window_toggle_split
_Clear _Console app.clear_console
)RAW"; } void Menu::add_action(const std::string &name, std::function action) { auto g_application=g_application_get_default(); auto gio_application=Glib::wrap(g_application, true); auto application=Glib::RefPtr::cast_static(gio_application); actions[name]=application->add_action(name, action); } void Menu::set_keys() { auto g_application=g_application_get_default(); auto gio_application=Glib::wrap(g_application, true); auto application=Glib::RefPtr::cast_static(gio_application); for(auto &key: Config::get().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); auto object = Menu::get().builder->get_object("juci-menu"); juci_menu = Glib::RefPtr::cast_dynamic(object); object = Menu::get().builder->get_object("window-menu"); window_menu = Glib::RefPtr::cast_dynamic(object); } catch (const Glib::Error &ex) { std::cerr << "building menu failed: " << ex.what(); } }