Browse Source

Merge branch 'master' of https://github.com/Joshua-Wright/jucipp

merge-requests/365/head
eidheim 9 years ago
parent
commit
89003d27ce
  1. 8
      src/menu.cc
  2. 68
      src/window.cc

8
src/menu.cc

@ -262,6 +262,10 @@ const Glib::ustring menu_xml= R"RAW(<interface>
</submenu> </submenu>
</section> </section>
<section> <section>
<item>
<attribute name='label' translatable='yes'>_Find _File</attribute>
<attribute name='action'>app.source_find_file</attribute>
</item>
<item> <item>
<attribute name='label' translatable='yes'>_Find _Symbol (Ctags)</attribute> <attribute name='label' translatable='yes'>_Find _Symbol (Ctags)</attribute>
<attribute name='action'>app.source_find_symbol_ctags</attribute> <attribute name='action'>app.source_find_symbol_ctags</attribute>
@ -469,7 +473,7 @@ void Menu::add_action(const std::string &name, std::function<void()> action) {
auto g_application=g_application_get_default(); auto g_application=g_application_get_default();
auto gio_application=Glib::wrap(g_application, true); auto gio_application=Glib::wrap(g_application, true);
auto application=Glib::RefPtr<Gtk::Application>::cast_static(gio_application); auto application=Glib::RefPtr<Gtk::Application>::cast_static(gio_application);
actions[name]=application->add_action(name, action); actions[name]=application->add_action(name, action);
} }
@ -477,7 +481,7 @@ void Menu::set_keys() {
auto g_application=g_application_get_default(); auto g_application=g_application_get_default();
auto gio_application=Glib::wrap(g_application, true); auto gio_application=Glib::wrap(g_application, true);
auto application=Glib::RefPtr<Gtk::Application>::cast_static(gio_application); auto application=Glib::RefPtr<Gtk::Application>::cast_static(gio_application);
for(auto &key: Config::get().menu.keys) { for(auto &key: Config::get().menu.keys) {
if(key.second.size()>0 && actions.find(key.first)!=actions.end()) if(key.second.size()>0 && actions.find(key.first)!=actions.end())
application->set_accel_for_action("app."+key.first, key.second); application->set_accel_for_action("app."+key.first, key.second);

68
src/window.cc

@ -656,6 +656,74 @@ void Window::set_menu_actions() {
SelectionDialog::get()->show(); SelectionDialog::get()->show();
}); });
menu.add_action("source_find_file", [this]() {
auto view = Notebook::get().get_current_view();
boost::filesystem::path project_path;
if(!Directories::get().path.empty())
project_path=Directories::get().path;
else {
boost::system::error_code ec;
project_path=boost::filesystem::current_path(ec);
if(ec) {
Terminal::get().print("Error: could not find current path\n", true);
return;
}
}
if(view) {
auto dialog_iter=view->get_iter_for_dialog();
SelectionDialog::create(view, view->get_buffer()->create_mark(dialog_iter), true, true);
}
else {
SelectionDialog::create(true, true);
}
boost::filesystem::path build_default_path, build_debug_path;
auto build = Project::Build::create(project_path);
if(!project_path.empty()) {
if (is_directory(build->get_default_path())) {
build_default_path = build->get_default_path();
}
if (is_directory(build->get_debug_path())) {
build_debug_path = build->get_debug_path();
}
}
// populate with all files in project
for (boost::filesystem::recursive_directory_iterator iter(project_path), end; iter != end; iter++) {
auto path = iter->path();
// ignore folders, but not everything in them
if (!boost::filesystem::is_regular_file(path)) {
continue;
}
// ignore build directory, and everything in it
if ((filesystem::file_in_path(path, build_default_path) && build_default_path != "") ||
(filesystem::file_in_path(path, build_debug_path) && build_debug_path != "")) {
iter.pop();
continue;
}
// remove project base path (and separating slash)
auto path_str = filesystem::get_relative_path(path, project_path).string();
// SelectionDialog::get()->add_row(path_str.substr(project_path.string().length()+1));
SelectionDialog::get()->add_row(path_str);
}
SelectionDialog::get()->on_select=[this, project_path](const std::string &selected, bool hide_window) {
auto full_path = boost::filesystem::canonical(selected);
Notebook::get().open(full_path);
if (auto view=Notebook::get().get_current_view())
view->hide_tooltips();
};
if(view)
view->hide_tooltips();
SelectionDialog::get()->show();
});
menu.add_action("source_comments_toggle", [this]() { menu.add_action("source_comments_toggle", [this]() {
if(auto view=Notebook::get().get_current_view()) { if(auto view=Notebook::get().get_current_view()) {
if(view->toggle_comments) { if(view->toggle_comments) {

Loading…
Cancel
Save