#include "menu.hpp" #include "config.hpp" #include #include const Glib::ustring menu_xml = R"RAW(
_Undo app.edit_undo _Redo app.edit_redo
_Paste app.edit_paste
_Toggle _Comments app.source_comments_toggle
_Go _to _Declaration app.source_goto_declaration _Go _to _Type _Declaration app.source_goto_type_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
_Undo app.edit_undo _Redo app.edit_redo
_Cut app.edit_cut _Copy app.edit_copy _Paste app.edit_paste
_Toggle _Comments app.source_comments_toggle
_About app.about
_Preferences app.preferences
_Snippets app.snippets
_Quit app.quit
_File
_New _File app.file_new_file _New _Folder app.file_new_folder _New _Project C app.file_new_project_c C++ app.file_new_project_cpp Rust app.file_new_project_rust
_Open _File app.file_open_file _Open _Folder app.file_open_folder
_Reload _File app.file_reload_file
_Save app.file_save _Save _As app.file_save_as
_Close _File app.file_close_file _Close _Folder app.file_close_folder _Close _Project app.file_close_project
_Print app.file_print
_Edit
_Undo app.edit_undo _Redo app.edit_redo
_Cut app.edit_cut _Cut _Lines app.edit_cut_lines _Copy app.edit_copy _Copy _Lines app.edit_copy_lines _Paste app.edit_paste
_Extend _Selection app.edit_extend_selection _Shrink _Selection app.edit_shrink_selection
_Show/_Hide app.edit_show_or_hide
_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 _Cursor _History _Back app.source_cursor_history_back _Forward app.source_cursor_history_forward
_Find _File app.source_find_file _Find _Symbol app.source_find_symbol _Find _Pattern app.source_find_pattern
_Comments _Toggle _Comments app.source_comments_toggle _Add _Documentation app.source_comments_add_documentation _Find _Documentation app.source_find_documentation
_Go to Declaration app.source_goto_declaration _Go to _Type _Declaration app.source_goto_type_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.project_compile_and_run _Compile app.project_compile _Recreate _Build app.project_recreate_build
_Run _Command app.project_run_command _Kill _Last _Process app.project_kill_last_running _Force _Kill _Last _Process app.project_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 _Show _Breakpoints app.debug_show_breakpoints
_Go _to _Stop app.debug_goto_stop
_Window
_Next _Tab app.window_next_tab _Previous _Tab app.window_previous_tab _Go _to _Tab app.window_goto_tab
_Toggle _Split app.window_toggle_split _Split _Source _Buffer app.window_split_source_buffer
_Toggle _Full _Screen app.window_toggle_full_screen _Toggle _Directories app.window_toggle_directories _Toggle _Terminal app.window_toggle_terminal _Toggle _Menu app.window_toggle_menu _Toggle _Tabs app.window_toggle_tabs _Toggle _Zen _Mode app.window_toggle_zen_mode
_Clear _Terminal app.window_clear_terminal
)RAW"; void Menu::add_action(const std::string &name, const 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() { try { builder = Gtk::Builder::create_from_string(menu_xml); auto object = builder->get_object("juci-menu"); juci_menu = Glib::RefPtr::cast_dynamic(object); object = builder->get_object("window-menu"); window_menu = Glib::RefPtr::cast_dynamic(object); object = builder->get_object("right-click-line-menu"); auto ptr = Glib::RefPtr::cast_dynamic(object); right_click_line_menu = std::make_unique(ptr); object = builder->get_object("right-click-selected-menu"); ptr = Glib::RefPtr::cast_dynamic(object); right_click_selected_menu = std::make_unique(ptr); } catch(const Glib::Error &ex) { std::cerr << "building menu failed: " << ex.what(); } }